From 66508d16b455291e96c7ece271c1a51ff3bd9981 Mon Sep 17 00:00:00 2001 From: Jesus Guerrero Date: Sun, 10 Nov 2024 18:20:08 -0400 Subject: [PATCH] fix: return absolute value of difference in reconciliation --- .../Finance/Partials/AccountReconciliationBanner.vue | 10 +++++----- .../js/domains/transactions/models/transactions.ts | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/resources/js/Pages/Finance/Partials/AccountReconciliationBanner.vue b/resources/js/Pages/Finance/Partials/AccountReconciliationBanner.vue index fd8ce878..25b13788 100644 --- a/resources/js/Pages/Finance/Partials/AccountReconciliationBanner.vue +++ b/resources/js/Pages/Finance/Partials/AccountReconciliationBanner.vue @@ -15,7 +15,7 @@ const { account } = defineProps<{ }>(); const goToReconciliation = () => { - router.visit(`/finance/reconciliation/${account?.reconciliation_last.id}`) + router.visit(`/finance/reconciliation/${account?.reconciliation_last?.id}`) } const isMatched = computed(() => { @@ -28,14 +28,14 @@ const adjustmentForm = useForm({ }) const adjustAndFinish = () => { if (!isMatched.value) { - adjustmentForm.put(`/finance/reconciliation/${account?.reconciliation_last.id}/save-adjustment`) + adjustmentForm.put(`/finance/reconciliation/${account?.reconciliation_last?.id}/save-adjustment`) } else { adjustmentForm .transform((data) => ({ ...data, date: account.reconciliation_last?.date, })) - .put(`/finance/reconciliation/${account.reconciliation_last.id}`, { + .put(`/finance/reconciliation/${account.reconciliation_last?.id}`, { onFinish() { adjustmentForm.reset(); }, @@ -48,11 +48,11 @@ const differenceStateText = computed(() => { }) const differenceAmount = computed(() => { - return account.reconciliation_last?.amount - account.balance + return Math.abs(account.reconciliation_last?.amount ?? 0 - account.balance) }) const hasPendingReconciliation = computed(() => { - return account.reconciliation_last?.status == 'pending'; + return account.reconciliation_last?.status == 'pending'; }) diff --git a/resources/js/domains/transactions/models/transactions.ts b/resources/js/domains/transactions/models/transactions.ts index fc212dbf..bc148cba 100644 --- a/resources/js/domains/transactions/models/transactions.ts +++ b/resources/js/domains/transactions/models/transactions.ts @@ -54,6 +54,7 @@ export interface IReconciliation { difference: number; amount: number; date: string; + status: string; } export interface IPayee { id: number;