سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 20:45 UTC
test(ui): preserve partial-reversal display in linked journal status fix
davoodmehraban89 committed
Nov 22, 2026 at 16:45 UTC
9259160087d03982355dd2e4b844932d7c6408b1
3 files changed
+19
-5
js/invoices.js
+1
-1
@@ -373,7 +373,7 @@ function invoiceDocumentStatus(inv){
373
// Contradictory source statuses require review instead of a false draft label.
374
if(linkedStatus==='draft')
375
return inv.accountingStatus==='posted'||inv.documentStatus==='posted'?'legacy_review':'draft';
376
- if(linkedStatus==='posted')return 'posted';
376
+ if(linkedStatus==='posted'||linkedStatus==='partially_reversed')return 'posted';
377
if(inv.journalVoucherId)return 'legacy_review'; // unresolved/missing linked voucher
378
if(inv.accountingStatus==='posted'||inv.documentStatus==='posted')return 'posted';
379
if(inv.documentStatus==='draft'||inv.accountingStatus==='draft')return 'draft';
js/purchases.js
+1
-1
@@ -66,7 +66,7 @@
66
const linked=typeof jeSourceVoucher==='function'?jeSourceVoucher(p):null;
67
const linkedStatus=linked?(typeof jeRpcEffectiveStatus==='function'?jeRpcEffectiveStatus(linked):linked.status):'';
68
if(linkedStatus==='reversed'||p.accountingStatus==='reversed')return 'reversed';
69
- if(linkedStatus==='posted')return 'posted';
69
+ if(linkedStatus==='posted'||linkedStatus==='partially_reversed')return 'posted';
70
if(linkedStatus==='draft')
71
return p.accountingStatus==='posted'||p.documentStatus==='posted'?'legacy_review':'draft';
72
if(p.journalVoucherId)return 'legacy_review'; // missing or unresolved linked voucher
scripts/accounting-document-workflow.spec.js
+17
-3
@@ -1006,8 +1006,12 @@ test('P0 #229 linked journal draft stays draft for both sales and purchases',asy
1006
journalVoucherId:'QA_PUR_JV_CONFLICT',documentStatus:'posted'};
1007
const danglingSale={...sale,id:'QA_SALE_LINK_DANGLING',journalVoucherId:'QA_NOT_FOUND_SALE'};
1008
const danglingPurchase={...purchase,id:'QA_PUR_LINK_DANGLING',journalVoucherId:'QA_NOT_FOUND_PUR'};
1009
- datastore.invoices.push(sale,conflictingSale,danglingSale);
1010
- datastore.purchases.push(purchase,conflictingPurchase,danglingPurchase);
1009
+ const partiallyReversedSale={...sale,id:'QA_SALE_PARTIAL',journalVoucherId:'QA_SALE_JV_PARTIAL',
1010
+ accountingStatus:'posted',documentStatus:'posted'};
1011
+ const partiallyReversedPurchase={...purchase,id:'QA_PUR_PARTIAL',journalVoucherId:'QA_PUR_JV_PARTIAL',
1012
+ accountingStatus:'posted',documentStatus:'posted'};
1013
+ datastore.invoices.push(sale,conflictingSale,danglingSale,partiallyReversedSale);
1014
+ datastore.purchases.push(purchase,conflictingPurchase,danglingPurchase,partiallyReversedPurchase);
1015
datastore.journalVouchers.push(
1016
{id:'QA_SALE_JV_DRAFT',ownerUserId,companyId,status:'draft',
1017
sourceType:'sale',sourceId:sale.id},
@@ -1016,8 +1020,15 @@ test('P0 #229 linked journal draft stays draft for both sales and purchases',asy
1020
{id:'QA_SALE_JV_CONFLICT',ownerUserId,companyId,status:'draft',
1021
sourceType:'sale',sourceId:conflictingSale.id},
1022
{id:'QA_PUR_JV_CONFLICT',ownerUserId,companyId,status:'draft',
1019
- sourceType:'purchase',sourceId:conflictingPurchase.id}
1023
+ sourceType:'purchase',sourceId:conflictingPurchase.id},
1024
+ {id:'QA_SALE_JV_PARTIAL',ownerUserId,companyId,status:'posted',
1025
+ sourceType:'sale',sourceId:partiallyReversedSale.id},
1026
+ {id:'QA_PUR_JV_PARTIAL',ownerUserId,companyId,status:'posted',
1027
+ sourceType:'purchase',sourceId:partiallyReversedPurchase.id}
1028
);
1029
+ // Effective status can be partial while the immutable original remains posted.
1030
+ jeRpcEffectiveStatuses.set('QA_SALE_JV_PARTIAL','partially_reversed');
1031
+ jeRpcEffectiveStatuses.set('QA_PUR_JV_PARTIAL','partially_reversed');
1032
return {
1033
sale:invoiceDocumentStatus(sale),
1034
purchase:purchaseDocumentStatus(purchase),
@@ -1025,6 +1036,8 @@ test('P0 #229 linked journal draft stays draft for both sales and purchases',asy
1036
conflictingPurchase:purchaseDocumentStatus(conflictingPurchase),
1037
danglingSale:invoiceDocumentStatus(danglingSale),
1038
danglingPurchase:purchaseDocumentStatus(danglingPurchase),
1039
+ partiallyReversedSale:invoiceDocumentStatus(partiallyReversedSale),
1040
+ partiallyReversedPurchase:purchaseDocumentStatus(partiallyReversedPurchase),
1041
voucherStates:getMyJournalVouchers().filter(v=>v.id.endsWith('_JV_DRAFT')).map(v=>v.status)
1042
};
1043
});
@@ -1032,6 +1045,7 @@ test('P0 #229 linked journal draft stays draft for both sales and purchases',asy
1045
sale:'draft',purchase:'draft',
1046
conflictingSale:'legacy_review',conflictingPurchase:'legacy_review',
1047
danglingSale:'legacy_review',danglingPurchase:'legacy_review',
1048
+ partiallyReversedSale:'posted',partiallyReversedPurchase:'posted',
1049
voucherStates:['draft','draft']
1050
});
1051
});