[balance] fix sort in overview
This commit is contained in:
parent
a8a6cd8814
commit
a83ba72cfa
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<q-card-section class="fit row justify-left content-center items-center q-col-gutter-sm">
|
<q-card-section class="fit row justify-between content-center items-center q-col-gutter-sm">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<div v-if="balance" class="text-h6">
|
<div v-if="balance" class="text-h6">
|
||||||
Aktueller Stand: {{ balance.balance.toFixed(2) }} €
|
Aktueller Stand: {{ balance.balance.toFixed(2) }} €
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<div v-if="showSelector" class="col-6">
|
<div v-if="showSelector" class="col-6">
|
||||||
<UserSelector v-model="user" />
|
<UserSelector v-model="user" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1 justify-end">
|
<div class="col-1 justify-end text-right">
|
||||||
<q-btn round flat icon="mdi-format-list-checks" @click="openHistory" />
|
<q-btn round flat icon="mdi-format-list-checks" @click="openHistory" />
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<q-btn
|
<q-btn
|
||||||
:color="isReversed ? 'positive' : 'negative'"
|
:color="isReversed ? 'positive' : 'negative'"
|
||||||
aria-label="Reverse transaction"
|
aria-label="Reverse transaction"
|
||||||
:icon="!isReversed ? 'mdi-trash-can' : 'mdi-check-bold'"
|
:icon="!isReversed ? 'mdi-delete' : 'mdi-check-bold'"
|
||||||
size="sm"
|
size="sm"
|
||||||
round
|
round
|
||||||
:disable="!canReverse"
|
:disable="!canReverse"
|
||||||
|
|
|
@ -32,28 +32,28 @@ export default defineComponent({
|
||||||
field: 'userid',
|
field: 'userid',
|
||||||
required: true,
|
required: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'credit',
|
name: 'credit',
|
||||||
label: 'Haben',
|
label: 'Haben',
|
||||||
field: 'credit',
|
field: 'credit',
|
||||||
format: (val: number) => val.toFixed(2)
|
format: (val: number) => val.toFixed(2),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'debit',
|
name: 'debit',
|
||||||
label: 'Soll',
|
label: 'Soll',
|
||||||
field: 'debit',
|
field: 'debit',
|
||||||
format: (val: number) => val.toFixed(2)
|
format: (val: number) => val.toFixed(2),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'balance',
|
name: 'balance',
|
||||||
label: 'Kontostand',
|
label: 'Kontostand',
|
||||||
format: (_: undefined, row: { debit: number; credit: number }) =>
|
format: (_: undefined, row: { debit: number; credit: number }) =>
|
||||||
(row.credit - row.debit).toFixed(2)
|
(row.credit - row.debit).toFixed(2),
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
return { rows, columns };
|
return { rows, columns };
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<q-page padding>
|
<q-page>
|
||||||
<q-card>
|
<q-card flat>
|
||||||
<q-card-section class="text-center">
|
<q-card-section class="text-center">
|
||||||
<div class="text-h4">Aktueller Stand</div>
|
<div class="text-h4">Aktueller Stand</div>
|
||||||
<div style="font-size: 2em">{{ balance.toFixed(2) }} €</div>
|
<div style="font-size: 2em">{{ balance.toFixed(2) }} €</div>
|
||||||
|
@ -17,8 +17,12 @@
|
||||||
binary-state-sort
|
binary-state-sort
|
||||||
@request="onRequest"
|
@request="onRequest"
|
||||||
>
|
>
|
||||||
<template #top>
|
<template #top="props">
|
||||||
<q-toggle v-model="showCancelled" label="Stornierte einblenden" />
|
<q-toggle
|
||||||
|
v-model="showCancelled"
|
||||||
|
label="Stornierte einblenden"
|
||||||
|
@update:model-value="onRequest({ pagination: props.pagination })"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell="props">
|
<template #body-cell="props">
|
||||||
<q-td :props="props" :class="{ 'bg-grey': props.row.reversal_id != null }">
|
<q-td :props="props" :class="{ 'bg-grey': props.row.reversal_id != null }">
|
||||||
|
@ -50,7 +54,7 @@ export default defineComponent({
|
||||||
void userStore.getUsers().then(() =>
|
void userStore.getUsers().then(() =>
|
||||||
onRequest({
|
onRequest({
|
||||||
pagination: pagination.value,
|
pagination: pagination.value,
|
||||||
filter: undefined
|
filter: undefined,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -60,10 +64,10 @@ export default defineComponent({
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
sortBy: 'time',
|
sortBy: 'time',
|
||||||
descending: false,
|
descending: true,
|
||||||
page: 1,
|
page: 1,
|
||||||
rowsPerPage: 3,
|
rowsPerPage: 10,
|
||||||
rowsNumber: 10
|
rowsNumber: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
interface PaginationInterface {
|
interface PaginationInterface {
|
||||||
|
@ -87,7 +91,8 @@ export default defineComponent({
|
||||||
offset: startRow,
|
offset: startRow,
|
||||||
limit: fetchCount,
|
limit: fetchCount,
|
||||||
showCancelled: showCancelled.value,
|
showCancelled: showCancelled.value,
|
||||||
showReversals: false
|
showReversals: false,
|
||||||
|
descending,
|
||||||
});
|
});
|
||||||
// clear out existing data and add new
|
// clear out existing data and add new
|
||||||
data.value.splice(0, data.value.length, ...result.transactions);
|
data.value.splice(0, data.value.length, ...result.transactions);
|
||||||
|
@ -112,7 +117,7 @@ export default defineComponent({
|
||||||
field: 'time',
|
field: 'time',
|
||||||
required: true,
|
required: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
format: (val: Date) => formatDateTime(new Date(val), true, true, true)
|
format: (val: Date) => formatDateTime(new Date(val), true, true, true),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'type',
|
name: 'type',
|
||||||
|
@ -126,27 +131,13 @@ export default defineComponent({
|
||||||
else return 'Gesendet an X';
|
else return 'Gesendet an X';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'text',
|
|
||||||
label: 'Text',
|
|
||||||
format: (_: undefined, row: FG.Transaction) => {
|
|
||||||
if (row.sender_id == null) return 'Gutschrift';
|
|
||||||
else {
|
|
||||||
if (row.receiver_id == null) return 'Angeschrieben';
|
|
||||||
else {
|
|
||||||
if (row.receiver_id === mainStore.currentUser.userid) return 'Bekommen von X';
|
|
||||||
else return 'Gesendet an X';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'amount',
|
name: 'amount',
|
||||||
label: 'Betrag',
|
label: 'Betrag',
|
||||||
field: 'amount',
|
field: 'amount',
|
||||||
format: (val: number) => `${val.toFixed(2)}€`
|
format: (val: number) => `${val.toFixed(2)}€`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'author_id',
|
name: 'author_id',
|
||||||
|
@ -156,11 +147,11 @@ export default defineComponent({
|
||||||
const user = userStore.users.filter((x) => x.userid == val);
|
const user = userStore.users.filter((x) => x.userid == val);
|
||||||
if (user.length > 0) return user[0].display_name;
|
if (user.length > 0) return user[0].display_name;
|
||||||
else return val;
|
else return val;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return { data, pagination, onRequest, loading, balance, columns, showCancelled };
|
return { data, pagination, onRequest, loading, balance, columns, showCancelled };
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -136,6 +136,7 @@ export const useBalanceStore = defineStore({
|
||||||
to?: Date;
|
to?: Date;
|
||||||
showReversals?: boolean;
|
showReversals?: boolean;
|
||||||
showCancelled?: boolean;
|
showCancelled?: boolean;
|
||||||
|
descending?: boolean;
|
||||||
}
|
}
|
||||||
| undefined = undefined
|
| undefined = undefined
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in New Issue