Merge pull request #1223 from suhailanzar/fix-PaymentType

fix: payment type fix while return and returnIssue status added
This commit is contained in:
Able k Saju
2025-05-29 12:58:15 +05:30
committed by GitHub
2 changed files with 19 additions and 2 deletions
+1
View File
@@ -202,6 +202,7 @@ export abstract class Invoice extends Transactional {
await super.afterSubmit();
if (this.isReturn) {
await this._removeLoyaltyPointEntry();
await this._updateIsItemsReturned();
this.reduceUsedCountOfCoupons();
return;
+18 -2
View File
@@ -630,6 +630,14 @@ export class Payment extends Transactional {
return;
}
const reference = this?.for?.[0];
if (!reference) {
return null;
}
const refDoc = (await reference.loadAndGetLink(
'referenceName'
)) as Invoice | null;
const partyDoc = (await this.loadAndGetLink('party')) as Party;
const outstanding = partyDoc.outstandingAmount as Money;
@@ -641,9 +649,17 @@ export class Payment extends Transactional {
}
if (partyDoc.role === 'Supplier') {
return 'Pay';
if (refDoc?.isReturn) {
return 'Receive';
} else {
return 'Pay';
}
} else if (partyDoc.role === 'Customer') {
return 'Receive';
if (refDoc?.isSales && refDoc.isReturn) {
return 'Pay';
} else {
return 'Receive';
}
}
if (outstanding?.isZero() ?? true) {