This commit is contained in:
2022-04-23 11:26:58 +00:00
committed by Gitea
parent c30b33a070
commit 91ac05b575
6 changed files with 29 additions and 69 deletions

View File

@ -8,8 +8,8 @@ import Input from "./Input.vue";
import Button from "./SimpleButton.vue";
const props = defineProps<{
transactionid: string
withAccount: bool
transactionid: string,
withAccount: boolean,
}>()
const emit = defineEmits(["save"]);
@ -19,74 +19,47 @@ const TX = transactionsStore.Transactions.get(props.transactionid)!;
const payeeType = ref<string|undefined>(undefined);
const payload = computed(() => JSON.stringify({
date: TX.Date.toISOString().split("T")[0],
payee: {
Name: TX.Payee,
ID: TX.PayeeID,
Type: payeeType.value,
},
categoryId: TX.CategoryID,
memo: TX.Memo,
amount: TX.Amount.toString(),
state: "Uncleared"
date: TX.Date.toISOString().split("T")[0],
payee: {
Name: TX.Payee,
ID: TX.PayeeID,
Type: payeeType.value,
},
categoryId: TX.CategoryID,
memo: TX.Memo,
amount: TX.Amount.toString(),
state: "Uncleared"
}));
function saveTransaction(e: MouseEvent) {
e.preventDefault();
transactionsStore.editTransaction(TX.ID, payload.value);
emit('save');
e.preventDefault();
transactionsStore.editTransaction(TX.ID, payload.value);
emit('save');
}
</script>
<template>
<tr>
<td class="text-sm">
<DateInput
v-model="TX.Date"
class="border-b-2 border-black"
/>
<DateInput v-model="TX.Date" class="border-b-2 border-black" />
</td>
<td v-if="withAccount">
<Autocomplete
v-model:text="TX.Account"
v-model:id="TX.AccountID"
model="accounts"
/>
<Autocomplete v-model:text="TX.Account" v-model:id="TX.AccountID" model="accounts" />
</td>
<td>
<Autocomplete
v-model:text="TX.Payee"
v-model:id="TX.PayeeID"
v-model:type="payeeType"
model="payees"
/>
<Autocomplete v-model:text="TX.Payee" v-model:id="TX.PayeeID" v-model:type="payeeType" model="payees" />
</td>
<td>
<Autocomplete
v-model:text="TX.Category"
v-model:id="TX.CategoryID"
model="categories"
/>
<Autocomplete v-model:text="TX.Category" v-model:id="TX.CategoryID" model="categories" />
</td>
<td>
<Input
v-model="TX.Memo"
class="block w-full border-b-2 border-black"
type="text"
/>
<Input v-model="TX.Memo" class="block w-full border-b-2 border-black" type="text" />
</td>
<td class="text-right">
<Input
v-model="TX.Amount"
class="text-right block w-full border-b-2 border-black"
type="currency"
/>
<Input v-model="TX.Amount" class="text-right block w-full border-b-2 border-black" type="currency" />
</td>
<td>
<Button
class="bg-blue-500"
@click="saveTransaction"
>
<Button class="bg-blue-500" @click="saveTransaction">
Save
</Button>
</td>

View File

@ -24,7 +24,9 @@ const TX = ref<Transaction>({
ID: "",
Status: "Uncleared",
TransferAccount: "",
Reconciled: false
Reconciled: false,
Account: "",
AccountID: "",
});
const payeeType = ref<string|undefined>(undefined);

View File

@ -11,7 +11,7 @@ import Checkbox from "./Checkbox.vue";
const props = defineProps<{
transactionid: string,
index: number,
withAccount: bool,
withAccount: boolean,
}>();
const edit = ref(false);