Skip to content

Commit

Permalink
fix: balance refreshes
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusantguerrero committed Dec 6, 2023
1 parent 7bd77dd commit b98c1f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions resources/js/Pages/Finance/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const reconcileForm = useForm({
...data,
date: format(data.date, 'yyyy-MM-dd'),
})).post(`/finance/reconciliation/accounts/${selectedAccount.value?.id}`, {
preserveScroll: true,
only: ['transactions', 'accounts', 'stats'],
onFinish() {
reconcileForm.reset()
Expand Down
14 changes: 8 additions & 6 deletions resources/js/domains/transactions/components/AccountItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import IconDrag from "@/Components/icons/IconDrag.vue";
import LogerButtonTab from "@/Components/atoms/LogerButtonTab.vue";
import AccountReconciliationAlert from "./AccountReconciliationAlert.vue";
import { computed } from "vue";
import { computed, toRefs } from "vue";
const { account } = defineProps({
const props = defineProps({
account: {
type: Object,
required: true,
Expand All @@ -19,20 +19,22 @@ const { account } = defineProps({
},
});
const { account } = toRefs(props)
const isDebt = (amount: number) => {
return amount < 0;
};
const hasPendingReconciliation = computed(() => {
return account.reconciliation_last?.status == 'pending';
return account.value.reconciliation_last?.status == 'pending';
})
const isReconciled = computed(() => {
return account.reconciliation_last?.amount == account.balance;
return account.value.reconciliation_last?.amount == account.value.balance;
})
const availableCredit = computed(() => {
return parseFloat(account.credit_limit) + parseFloat(account.balance);
return parseFloat(account.value.credit_limit) + parseFloat(account.value.balance);
})
const creditLimitDate = computed(() => {
const formatter = new Intl.PluralRules('en-US', {
Expand All @@ -45,7 +47,7 @@ const creditLimitDate = computed(() => {
["few", "rd"],
["other", "th"],
]);
return account.credit_closing_day ? ` - ${account.credit_closing_day}${suffixes.get(formatter.select(account.credit_closing_day))}` : '';
return account.value.credit_closing_day ? ` - ${account.value.credit_closing_day}${suffixes.get(formatter.select(account.credit_closing_day))}` : '';
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const onSubmit = (addAnother = false) => {
return data;
})
.submit(action.method, action.url(), {
preserveState: true,
preserveState: false,
preserveScroll: true,
onBefore(evt) {
if (!evt.data.total) {
Expand All @@ -247,7 +247,7 @@ const onSubmit = (addAnother = false) => {
const items = splits.value;
gridSplitsRef.value?.reset(items);
})
if (!isAddingAnother.value) {
if (!addAnother) {
emit("close");
}
transactionStore.emitTransaction(lastSaved as ITransaction, action.method, props.transactionData);
Expand Down

0 comments on commit b98c1f8

Please sign in to comment.