mirror of
https://github.com/frappe/books.git
synced 2026-09-28 01:46:20 -04:00
Merge pull request #1223 from suhailanzar/fix-PaymentType
fix: payment type fix while return and returnIssue status added
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user