feat: accounting

This commit is contained in:
2026-08-02 22:32:08 +03:30
parent dd5b6d4616
commit ba7147ff59
2 changed files with 88 additions and 30 deletions
+10
View File
@@ -35,6 +35,16 @@ export const parseStoreRate = (value: string | number): number => {
return Math.min(100, Math.max(0, n));
};
// Parse a non-negative integer input (e.g. transaction fee in Rial).
export const parseFee = (value: string | number): number => {
if (value === null || value === undefined || value === '') return 0;
const str = String(value).replace(/[^\d]/g, '');
if (!str) return 0;
const n = parseInt(str, 10);
if (Number.isNaN(n)) return 0;
return Math.max(0, n);
};
export const formatDate = (dateString: string | null): string => {
if (!dateString) return 'نامشخص';