feat: accounting
This commit is contained in:
@@ -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 'نامشخص';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user