Merge pull request 'Implement custom checkbox' (#35) from checkbox into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #35
This commit is contained in:
Jan Bader 2022-03-02 21:34:27 +01:00
commit 5d1b49c896
7 changed files with 50 additions and 26 deletions

View File

@ -0,0 +1,11 @@
<script lang="ts" setup>
const props = defineProps(["modelValue"]);
</script>
<template>
<input
type="checkbox"
:checked="modelValue"
@change="$emit('update:modelValue', ($event.target as HTMLInputElement)?.checked)"
class="dark:bg-slate-900">
</template>

View File

@ -4,7 +4,7 @@ const props = defineProps(["modelValue"]);
<template> <template>
<input <input
v-model="modelValue" :value="modelValue"
@input="$emit('update:modelValue', ($event.target as HTMLInputElement)?.value)" @input="$emit('update:modelValue', ($event.target as HTMLInputElement)?.value)"
class="dark:bg-slate-900"> class="dark:bg-slate-900">
</template> </template>

View File

@ -7,6 +7,7 @@ import TransactionEditRow from "./TransactionEditRow.vue";
import { formatDate } from "../date"; import { formatDate } from "../date";
import { useAccountStore } from "../stores/budget-account"; import { useAccountStore } from "../stores/budget-account";
import Input from "./Input.vue"; import Input from "./Input.vue";
import Checkbox from "./Checkbox.vue";
const props = defineProps<{ const props = defineProps<{
transactionid: string, transactionid: string,
@ -70,7 +71,7 @@ function getStatusSymbol() {
{{ TX.GroupID ? "☀" : "" }} {{ TX.GroupID ? "☀" : "" }}
{{ getStatusSymbol() }} {{ getStatusSymbol() }}
<a @click="edit = true;"></a> <a @click="edit = true;"></a>
<Input v-if="Reconciling && TX.Status != 'Reconciled'" type="checkbox" v-model="TX.Reconciled" /> <Checkbox v-if="Reconciling && TX.Status != 'Reconciled'" v-model="TX.Reconciled" />
</td> </td>
</tr> </tr>
<TransactionEditRow v-if="edit" :transactionid="TX.ID" @save="edit = false" /> <TransactionEditRow v-if="edit" :transactionid="TX.ID" @save="edit = false" />

View File

@ -49,41 +49,48 @@ function createReconcilationTransaction() {
</h1> </h1>
<div class="text-right flex flex-wrap flex-col md:flex-row justify-end gap-2 max-w-sm"> <div class="text-right flex flex-wrap flex-col md:flex-row justify-end gap-2 max-w-sm">
<span class="border-2 rounded-lg p-1 whitespace-nowrap flex-1"> <span class="rounded-lg p-1 whitespace-nowrap flex-1">
Working: Working:
<Currency :value="accounts.CurrentAccount?.WorkingBalance" /> <Currency :value="accounts.CurrentAccount?.WorkingBalance" />
</span> </span>
<span class="border-2 rounded-lg p-1 whitespace-nowrap flex-1"> <span class="rounded-lg p-1 whitespace-nowrap flex-1">
Cleared: Cleared:
<Currency :value="accounts.CurrentAccount?.ClearedBalance" /> <Currency :value="accounts.CurrentAccount?.ClearedBalance" />
</span> </span>
<span <span
class="border-2 border-blue-500 rounded-lg bg-blue-500 p-1 whitespace-nowrap flex-1" class="rounded-lg bg-blue-500 p-1 whitespace-nowrap flex-1"
v-if="!transactions.Reconciling" v-if="!transactions.Reconciling"
@click="transactions.Reconciling = true" @click="transactions.Reconciling = true"
> >
Reconciled: Reconciled:
<Currency :value="accounts.CurrentAccount?.ReconciledBalance" /> <Currency :value="accounts.CurrentAccount?.ReconciledBalance" />
</span> </span>
</div>
<span v-if="transactions.Reconciling" class="border-2 block bg-gray-200 dark:bg-gray-800 rounded-lg p-2"> <span v-if="transactions.Reconciling" class="contents">
Is <Button @click="submitReconcilation"
<Currency :value="transactions.ReconcilingBalance" />your current balance? class="bg-blue-500 p-1 whitespace-nowrap flex-1">
<Button class="bg-blue-500 mx-3 py-2" @click="submitReconcilation">Yes!</Button> My current balance is&nbsp;
<br />No, it's: <Currency :value="transactions.ReconcilingBalance" />
<Input class="text-right" type="number" v-model="TargetReconcilingBalance" /> </Button>
Difference:
<Currency :value="transactions.ReconcilingBalance - TargetReconcilingBalance" /> <Button @click="createReconcilationTransaction"
<Button class="bg-orange-500 p-1 whitespace-nowrap flex-1">
class="bg-orange-500 mx-3 py-2" No, it's:
v-if="Math.abs(transactions.ReconcilingBalance - TargetReconcilingBalance) > 0.01" <Input
@click="createReconcilationTransaction" class="text-right w-20 bg-transparent dark:bg-transparent border-b-2"
>Create reconciling Transaction</Button> type="number"
<Button class="bg-red-500 mx-3 py-2" @click="cancelReconcilation">Cancel</Button> v-model="TargetReconcilingBalance"
</span> />
(Difference
<Currency
:value="transactions.ReconcilingBalance - TargetReconcilingBalance"
/>)
</Button>
<Button class="bg-red-500 p-1 flex-1" @click="cancelReconcilation">Cancel</Button>
</span>
</div>
</div> </div>
<table> <table>
@ -97,7 +104,11 @@ function createReconcilationTransaction() {
<Input v-if="transactions.Reconciling" type="checkbox" @input="setReconciled" /> <Input v-if="transactions.Reconciling" type="checkbox" @input="setReconciled" />
</td> </td>
</tr> </tr>
<TransactionInputRow class="hidden md:table-row" :budgetid="budgetid" :accountid="accountid" /> <TransactionInputRow
class="hidden md:table-row"
:budgetid="budgetid"
:accountid="accountid"
/>
<TransactionRow <TransactionRow
v-for="(transaction, index) in transactions.TransactionsList" v-for="(transaction, index) in transactions.TransactionsList"
:key="transaction.ID" :key="transaction.ID"
@ -110,7 +121,11 @@ function createReconcilationTransaction() {
<template v-slot:placeholder> <template v-slot:placeholder>
<Button class="fixed right-4 bottom-4 font-bold text-lg bg-blue-500 py-2">+</Button> <Button class="fixed right-4 bottom-4 font-bold text-lg bg-blue-500 py-2">+</Button>
</template> </template>
<TransactionInputRow class="grid grid-cols-2" :budgetid="budgetid" :accountid="accountid" /> <TransactionInputRow
class="grid grid-cols-2"
:budgetid="budgetid"
:accountid="accountid"
/>
</Modal> </Modal>
</div> </div>
</template> </template>

View File

@ -20,7 +20,6 @@ const OffBudgetAccountsBalance = computed(() => accountStore.OffBudgetAccountsBa
function isRecentlyReconciled(account : Account) { function isRecentlyReconciled(account : Account) {
const now = new Date().getTime(); const now = new Date().getTime();
const recently = 7 * 24 * 60 * 60 * 1000; const recently = 7 * 24 * 60 * 60 * 1000;
console.log(account.Name, account.LastReconciled, now, recently, new Date(now-recently));
return new Date(now - recently).getTime() < account.LastReconciled.getTime(); return new Date(now - recently).getTime() < account.LastReconciled.getTime();
} }

View File

@ -57,7 +57,6 @@ onMounted(() => {
const expandedGroups = ref<Map<string, boolean>>(new Map<string, boolean>()) const expandedGroups = ref<Map<string, boolean>>(new Map<string, boolean>())
function toggleGroup(group: { Name: string, Expand: boolean }) { function toggleGroup(group: { Name: string, Expand: boolean }) {
console.log(expandedGroups.value);
expandedGroups.value.set(group.Name, !(expandedGroups.value.get(group.Name) ?? group.Expand)) expandedGroups.value.set(group.Name, !(expandedGroups.value.get(group.Name) ?? group.Expand))
} }

View File

@ -84,7 +84,6 @@ export const useTransactionsStore = defineStore("budget/transactions", {
this.AddTransactions([recTrans]); this.AddTransactions([recTrans]);
account.Transactions.unshift(recTrans.ID); account.Transactions.unshift(recTrans.ID);
} }
console.log("Reconcile: " + response.message);
}, },
logout() { logout() {
this.$reset() this.$reset()