release v2.0.0 #4
|
@ -11,25 +11,24 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// TODO: Load all users / balances
|
|
||||||
|
|
||||||
// TODO: Fill usefull data
|
// TODO: Fill usefull data
|
||||||
|
|
||||||
import { computed, defineComponent } from '@vue/composition-api';
|
import { ref, defineComponent, onMounted } from '@vue/composition-api';
|
||||||
import { StateInterfaceBalance } from '../store/balance';
|
import { StateInterfaceBalance, BalancesResponse } from '../store/balance';
|
||||||
import { Store } from 'vuex';
|
import { Store } from 'vuex';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
// name: 'PageName'
|
// name: 'PageName'
|
||||||
setup(_, { root }) {
|
setup(_, { root }) {
|
||||||
const store = <Store<StateInterfaceBalance>>root.$store;
|
const store = <Store<StateInterfaceBalance>>root.$store;
|
||||||
|
|
||||||
const rows = computed(() => {
|
onMounted(
|
||||||
const fo: Array<{ userid: string; balance: number }> = [];
|
() =>
|
||||||
store.state.balance.balances.forEach((value, key) =>
|
void store
|
||||||
fo.push(Object.assign(value, { userid: key }))
|
.dispatch('balance/getBalances')
|
||||||
|
.then((balances: Array<BalancesResponse>) => rows.value.push(...balances))
|
||||||
);
|
);
|
||||||
return fo;
|
|
||||||
});
|
const rows = ref(new Array<BalancesResponse>());
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -41,16 +40,22 @@ export default defineComponent({
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'balance',
|
name: 'credit',
|
||||||
label: 'Kontostand',
|
label: 'Haben',
|
||||||
field: 'balance',
|
field: 'credit',
|
||||||
format: (val: number) => val.toFixed(2)
|
format: (val: number) => val.toFixed(2)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'limit',
|
name: 'debit',
|
||||||
label: 'Limit',
|
label: 'Soll',
|
||||||
field: 'limit',
|
field: 'debit',
|
||||||
format: (val: number) => (val === null ? 'keins' : val)
|
format: (val: number) => val.toFixed(2)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'balance',
|
||||||
|
label: 'Kontostand',
|
||||||
|
format: (_: undefined, row: { debit: number; credit: number }) =>
|
||||||
|
(row.credit - row.debit).toFixed(2)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
return { rows, columns };
|
return { rows, columns };
|
||||||
|
|
|
@ -9,6 +9,10 @@ interface BalanceResponse {
|
||||||
debit: number;
|
debit: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BalancesResponse extends BalanceResponse {
|
||||||
|
userid: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface TransactionsResponse {
|
export interface TransactionsResponse {
|
||||||
transactions: Array<FG.Transaction>;
|
transactions: Array<FG.Transaction>;
|
||||||
count?: number;
|
count?: number;
|
||||||
|
@ -122,6 +126,11 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
|
||||||
})
|
})
|
||||||
.finally(() => commit('setLoading', false));
|
.finally(() => commit('setLoading', false));
|
||||||
},
|
},
|
||||||
|
getBalances() {
|
||||||
|
return axios.get('/balance').then(({ data }: AxiosResponse<Array<BalancesResponse>>) => {
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
},
|
||||||
getTransactions(
|
getTransactions(
|
||||||
{ commit, rootState },
|
{ commit, rootState },
|
||||||
payload: {
|
payload: {
|
||||||
|
|
Loading…
Reference in New Issue