diff --git a/pages/banking/statements/[mode]/[[id]].vue b/pages/banking/statements/[mode]/[[id]].vue index 5cde083..d714154 100644 --- a/pages/banking/statements/[mode]/[[id]].vue +++ b/pages/banking/statements/[mode]/[[id]].vue @@ -39,7 +39,7 @@ const ownaccounts = ref([]) const loading = ref(true) const setup = async () => { if(route.params.id) { - itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*, cd_id(*, customer(*)), ii_id(*))").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id)) + itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*, cd_id(*), ii_id(*))").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id)) } if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value)) @@ -98,17 +98,23 @@ const getInvoiceSum = (invoice) => { sum += account.amountTax sum += account.amountNet }) - return sum.toFixed(2) + console.log(sum) + + if(invoice.expense) { + return (sum * -1).toFixed(2) + } else { + return sum.toFixed(2) + } } const calculateOpenSum = computed(() => { let startingAmount = 0 itemInfo.value.statementallocations.forEach(item => { - startingAmount += Math.abs(item.amount) + startingAmount += item.amount }) - return (Math.abs(itemInfo.value.amount) - startingAmount).toFixed(2) + return (itemInfo.value.amount - startingAmount).toFixed(2) }) @@ -150,6 +156,10 @@ const saveAllocation = async (allocation) => { if(data) { await setup() accountToSave.value = null + vendorAccountToSave.value = null + customerAccountToSave.value = null + ownAccountToSave.value = null + allocationDescription.value = null } @@ -351,15 +361,15 @@ setup() @@ -443,74 +453,39 @@ setup() + + + + - - - - - - - - - - - @@ -721,8 +696,6 @@ setup() - - @@ -787,7 +760,7 @@ setup()