From 1d54947764c172cc3c3e162c6d575fc010c76fdf Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 9 Dec 2024 00:44:50 +0200 Subject: [PATCH] fix: correct debit and credit calculations for local adjustments in BillGLEntries --- .../server/src/services/Purchases/Bills/BillGLEntries.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/server/src/services/Purchases/Bills/BillGLEntries.ts b/packages/server/src/services/Purchases/Bills/BillGLEntries.ts index 0f621ca12..a735b9833 100644 --- a/packages/server/src/services/Purchases/Bills/BillGLEntries.ts +++ b/packages/server/src/services/Purchases/Bills/BillGLEntries.ts @@ -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,