سامانه صدور فاکتور و حسابداری
test: normalize Persian and Arabic dates in autopost fixture
davoodmehraban89 committed
Nov 17, 2026 at 21:40 UTC
5f949e915ea383e501c71664e9e6282a7df5ac6c
1 file changed
+3
-1
scripts/accounting-document-workflow.spec.js
+3
-1
@@ -53,7 +53,9 @@ async function installHarness(page,server){
53
const sourceRow=server.records.get(sourceKey);
54
if(!sourceRow)return {data:null,error:{message:'FINORA_SOURCE_NOT_COMMITTED_IN_ORG',code:'23503'}};
55
const kind=args.p_header.sourceType;
56
- if(args.p_header.voucherType!==kind||args.p_header.date!==sourceRow.data.date)return {data:null,error:{message:'FINORA_SOURCE_HEADER_MISMATCH',code:'23514'}};
56
+ const digitMap={'۰':'0','۱':'1','۲':'2','۳':'3','۴':'4','۵':'5','۶':'6','۷':'7','۸':'8','۹':'9','٠':'0','١':'1','٢':'2','٣':'3','٤':'4','٥':'5','٦':'6','٧':'7','٨':'8','٩':'9'};
57
+ const normalizeDate=value=>String(value||'').replace(/[۰-۹٠-٩]/g,digit=>digitMap[digit]||digit);
58
+ if(args.p_header.voucherType!==kind||normalizeDate(args.p_header.date)!==normalizeDate(sourceRow.data.date))return {data:null,error:{message:'FINORA_SOURCE_HEADER_MISMATCH',code:'23514'}};
59
const prior=[...server.records.values()].find(row=>row.collection==='journalVouchers'&&row.data.sourceType===kind&&row.data.sourceId===args.p_source_id&&['posted','reversed'].includes(row.data.status));
60
if(prior)return {data:{voucher:{...copy(prior.data),id:prior.id,version:Number(prior.version)||1},replayed:true},error:null};
61
const amount=Number(sourceRow.data.grandTotal||0);