fix: correct debit and credit calculations for local adjustments in BillGLEntries

This commit is contained in:
Ahmed Bouhuolia
2024-12-09 00:44:50 +02:00
parent 477da0e7c0
commit 1d54947764

View File

@@ -110,6 +110,7 @@ export class BillGLEntries {
return {
debit: 0,
credit: 0,
currencyCode: bill.currencyCode,
exchangeRate: bill.exchangeRate || 1,
@@ -281,11 +282,12 @@ export class BillGLEntries {
otherExpensesAccountId: number
) => {
const commonEntry = this.getBillCommonEntry(bill);
const adjustmentAmount = Math.abs(bill.adjustmentLocal);
return {
...commonEntry,
debit: bill.adjustmentLocal < 0 ? bill.adjustmentLocal : 0,
credit: bill.adjustmentLocal > 0 ? bill.adjustmentLocal : 0,
debit: bill.adjustmentLocal > 0 ? adjustmentAmount : 0,
credit: bill.adjustmentLocal < 0 ? adjustmentAmount : 0,
accountId: otherExpensesAccountId,
accountNormal: AccountNormal.DEBIT,
index: 1,