mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
fix: refactor the code
This commit is contained in:
@@ -59,26 +59,6 @@ export class SalesInvoice extends Invoice {
|
||||
loyaltyProgramDoc.expenseAccount as string,
|
||||
loyaltyAmount
|
||||
);
|
||||
|
||||
await posting.credit(this.account!, loyaltyAmount);
|
||||
|
||||
const { debit, credit } = posting._getTotalDebitAndCredit();
|
||||
const difference = debit.sub(credit);
|
||||
const absoluteValue = difference.abs();
|
||||
|
||||
if (!absoluteValue.eq(0)) {
|
||||
if (difference.gt(0)) {
|
||||
await posting.credit(
|
||||
loyaltyProgramDoc.expenseAccount as string,
|
||||
absoluteValue
|
||||
);
|
||||
} else {
|
||||
await posting.debit(
|
||||
loyaltyProgramDoc.expenseAccount as string,
|
||||
absoluteValue
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.taxes) {
|
||||
|
||||
Reference in New Issue
Block a user