Implement closing of accounts #36
@ -7,7 +7,7 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'submit'): void,
|
(e: 'submit', event : {cancel:boolean}): boolean,
|
||||||
(e: 'open'): void,
|
(e: 'open'): void,
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
@ -20,8 +20,12 @@ function openDialog() {
|
|||||||
visible.value = true;
|
visible.value = true;
|
||||||
};
|
};
|
||||||
function submitDialog() {
|
function submitDialog() {
|
||||||
|
const e = {cancel: false};
|
||||||
|
emit("submit", e);
|
||||||
|
if(e.cancel)
|
||||||
|
return;
|
||||||
|
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
emit("submit");
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -14,8 +14,16 @@ const CurrentAccount = computed(() => accountStore.CurrentAccount);
|
|||||||
const accountName = ref("");
|
const accountName = ref("");
|
||||||
const accountOnBudget = ref(true);
|
const accountOnBudget = ref(true);
|
||||||
const accountOpen = ref(true);
|
const accountOpen = ref(true);
|
||||||
|
const error = ref("");
|
||||||
|
|
||||||
function editAccount(e : any) {
|
function editAccount(e : {cancel:boolean}) : boolean {
|
||||||
|
if(CurrentAccount.value?.ClearedBalance != 0 && !accountOpen.value){
|
||||||
|
e.cancel = true;
|
||||||
|
error.value = "Cannot close account with balance";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
error.value = "";
|
||||||
accountStore.EditAccount(CurrentAccount.value?.ID ?? "", accountName.value, accountOnBudget.value, accountOpen.value);
|
accountStore.EditAccount(CurrentAccount.value?.ID ?? "", accountName.value, accountOnBudget.value, accountOpen.value);
|
||||||
|
|
||||||
// account closed, move to Budget
|
// account closed, move to Budget
|
||||||
@ -23,6 +31,7 @@ function editAccount(e : any) {
|
|||||||
const currentBudgetID = useBudgetsStore().CurrentBudgetID;
|
const currentBudgetID = useBudgetsStore().CurrentBudgetID;
|
||||||
router.replace('/budget/'+currentBudgetID+'/budgeting');
|
router.replace('/budget/'+currentBudgetID+'/budgeting');
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEditAccount(e : any) {
|
function openEditAccount(e : any) {
|
||||||
@ -37,7 +46,7 @@ function openEditAccount(e : any) {
|
|||||||
<template v-slot:placeholder><span class="ml-2">✎</span></template>
|
<template v-slot:placeholder><span class="ml-2">✎</span></template>
|
||||||
<div class="mt-2 px-7 py-3">
|
<div class="mt-2 px-7 py-3">
|
||||||
<Input
|
<Input
|
||||||
class="border-2"
|
class="border-2 dark:border-gray-700"
|
||||||
type="text"
|
type="text"
|
||||||
v-model="accountName"
|
v-model="accountName"
|
||||||
placeholder="Account name"
|
placeholder="Account name"
|
||||||
@ -60,5 +69,8 @@ function openEditAccount(e : any) {
|
|||||||
/>
|
/>
|
||||||
<label>Open</label>
|
<label>Open</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="error != ''" class="dark:text-red-300 text-red-700">
|
||||||
|
{{ error }}
|
||||||
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
Loading…
x
Reference in New Issue
Block a user