mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
Merge pull request #1423 from Gadha2311/roundoff-account
fix: correct round-off account source allocation
This commit is contained in:
@@ -461,7 +461,10 @@ export class Payment extends Transactional {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const previousOutstandingAmount = referenceDoc.outstandingAmount as Money;
|
const previousOutstandingAmount = referenceDoc.outstandingAmount as Money;
|
||||||
const outstandingAmount = previousOutstandingAmount.sub(row.amount!);
|
const isReturnInvoice = (referenceDoc as Invoice).isReturn;
|
||||||
|
const outstandingAmount = isReturnInvoice
|
||||||
|
? previousOutstandingAmount.add(row.amount!)
|
||||||
|
: previousOutstandingAmount.sub(row.amount!);
|
||||||
await referenceDoc.setAndSync({ outstandingAmount });
|
await referenceDoc.setAndSync({ outstandingAmount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,11 +508,10 @@ export class Payment extends Transactional {
|
|||||||
ref.referenceType!,
|
ref.referenceType!,
|
||||||
ref.referenceName
|
ref.referenceName
|
||||||
);
|
);
|
||||||
|
const isReturnInvoice = (refDoc as Invoice).isReturn;
|
||||||
const outstandingAmount = (refDoc.outstandingAmount as Money).add(
|
const outstandingAmount = isReturnInvoice
|
||||||
ref.amount!
|
? (refDoc.outstandingAmount as Money).sub(ref.amount!)
|
||||||
);
|
: (refDoc.outstandingAmount as Money).add(ref.amount!);
|
||||||
|
|
||||||
await refDoc.setAndSync({ outstandingAmount });
|
await refDoc.setAndSync({ outstandingAmount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ export class SalesInvoice extends Invoice {
|
|||||||
this.loyaltyProgram
|
this.loyaltyProgram
|
||||||
)) as LoyaltyProgram;
|
)) as LoyaltyProgram;
|
||||||
|
|
||||||
let totalAmount;
|
let loyaltyAmount;
|
||||||
|
|
||||||
if (this.isReturn) {
|
if (this.isReturn) {
|
||||||
totalAmount = this.fyo.pesa(await getReturnLoyaltyPoints(this));
|
loyaltyAmount = this.fyo.pesa(await getReturnLoyaltyPoints(this));
|
||||||
} else {
|
} else {
|
||||||
totalAmount = await getAddedLPWithGrandTotal(
|
loyaltyAmount = await getAddedLPWithGrandTotal(
|
||||||
this.fyo,
|
this.fyo,
|
||||||
this.loyaltyProgram as string,
|
this.loyaltyProgram as string,
|
||||||
this.loyaltyPoints as number
|
this.loyaltyPoints as number
|
||||||
@@ -57,10 +57,8 @@ export class SalesInvoice extends Invoice {
|
|||||||
|
|
||||||
await posting.debit(
|
await posting.debit(
|
||||||
loyaltyProgramDoc.expenseAccount as string,
|
loyaltyProgramDoc.expenseAccount as string,
|
||||||
totalAmount
|
loyaltyAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
await posting.credit(this.account!, totalAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.taxes) {
|
if (this.taxes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user