+
Aktueller Stand: {{ balance.balance.toFixed(2) }} €
gesperrt
+
+
+
@@ -43,7 +46,11 @@ export default defineComponent({
emit('update:user', selectedUser);
}
- return { user, balance, isLocked, userUpdated };
+ function openHistory() {
+ emit('open-history');
+ }
+
+ return { user, balance, isLocked, userUpdated, openHistory };
}
});
diff --git a/src/plugins/balance/pages/Transfer.vue b/src/plugins/balance/components/BalanceTransfer.vue
similarity index 53%
rename from src/plugins/balance/pages/Transfer.vue
rename to src/plugins/balance/components/BalanceTransfer.vue
index eaa021f..b92d286 100644
--- a/src/plugins/balance/pages/Transfer.vue
+++ b/src/plugins/balance/components/BalanceTransfer.vue
@@ -1,39 +1,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/balance/pages/Admin.vue b/src/plugins/balance/pages/Admin.vue
index cde0f97..e8c53bb 100644
--- a/src/plugins/balance/pages/Admin.vue
+++ b/src/plugins/balance/pages/Admin.vue
@@ -11,25 +11,24 @@
diff --git a/src/plugins/balance/pages/Overview.vue b/src/plugins/balance/pages/Overview.vue
new file mode 100644
index 0000000..50aba60
--- /dev/null
+++ b/src/plugins/balance/pages/Overview.vue
@@ -0,0 +1,154 @@
+
+
+
+
+ Aktueller Stand
+ {{ balance.toFixed(2) }} €
+
+
+
+
+
+
+
+
+
+ {{ props.value }}
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/balance/routes/index.ts b/src/plugins/balance/routes/index.ts
index e84aa82..358c7b0 100644
--- a/src/plugins/balance/routes/index.ts
+++ b/src/plugins/balance/routes/index.ts
@@ -7,32 +7,32 @@ const mainRoutes: FG_Plugin.PluginRouteConfig[] = [
icon: 'mdi-cash-100',
path: 'balance',
name: 'balance',
- redirect: { name: 'balance-add' },
+ redirect: { name: 'balance-view' },
meta: { permissions: ['user'] },
children: [
{
- title: 'Anschreiben',
+ title: 'Übersicht',
icon: 'mdi-cash-plus',
- path: 'add',
- name: 'balance-add',
- shortcut: true,
- meta: { permissions: [permissions.DEBIT_OWN, permissions.SHOW] },
- component: () => import('../pages/Add.vue')
+ path: 'overview',
+ name: 'balance-view',
+ meta: { permissions: [permissions.SHOW] },
+ component: () => import('../pages/Overview.vue')
},
{
- title: 'Übertragen',
- icon: 'mdi-cash-refund',
- path: 'transfer',
- name: 'balance-transfer',
- meta: { permissions: [permissions.SEND] },
- component: () => import('../pages/Transfer.vue')
+ title: 'Buchen',
+ icon: 'mdi-cash-plus',
+ path: 'change',
+ name: 'balance-change',
+ shortcut: true,
+ meta: { permissions: [permissions.DEBIT_OWN, permissions.SHOW] },
+ component: () => import('../pages/MainPage.vue')
},
{
title: 'Verwaltung',
icon: 'mdi-account-cash',
path: 'admin',
name: 'balance-admin',
- meta: { permissions: [permissions.DEBIT_OWN, permissions.SHOW] },
+ meta: { permissions: [permissions.SET_LIMIT, permissions.SHOW_OTHER] },
component: () => import('../pages/Admin.vue')
}
]
diff --git a/src/plugins/balance/store/balance.ts b/src/plugins/balance/store/balance.ts
index e675b72..8199296 100644
--- a/src/plugins/balance/store/balance.ts
+++ b/src/plugins/balance/store/balance.ts
@@ -1,5 +1,5 @@
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex';
-import { StateInterface } from 'src/store';
+import store, { StateInterface } from 'src/store';
import { axios } from 'src/boot/axios';
import { AxiosResponse } from 'axios';
@@ -9,6 +9,15 @@ interface BalanceResponse {
debit: number;
}
+export interface BalancesResponse extends BalanceResponse {
+ userid: string;
+}
+
+export interface TransactionsResponse {
+ transactions: Array
;
+ count?: number;
+}
+
export interface UserBalance extends BalanceResponse {
limit: number | null;
}
@@ -31,6 +40,10 @@ const state: BalanceInterface = {
loading: 0
};
+function fixTransaction(t: FG.Transaction) {
+ t.time = new Date(t.time);
+}
+
const mutations: MutationTree = {
setBalance(state, data: { userid: string; balance: BalanceResponse }) {
state.balances.set(
@@ -59,9 +72,13 @@ const mutations: MutationTree = {
addTransaction(state, data: FG.Transaction) {
state.transactions.push(data);
},
+ addTransactions(state, data: [FG.Transaction]) {
+ state.transactions.push(...data);
+ state.transactions.sort((a, b) => (a.time <= b.time ? -1 : 1));
+ },
reverseTransaction(state, data: { transaction: FG.Transaction; reversal: FG.Transaction }) {
const idx = state.transactions.findIndex(value => value.id === data.transaction.id);
- data.transaction.reversal = data.reversal;
+ data.transaction.reversal_id = data.reversal.id;
if (idx > -1) state.transactions[idx] = data.transaction;
else state.transactions.push(data.transaction);
}
@@ -70,7 +87,7 @@ const mutations: MutationTree = {
const actions: ActionTree = {
addShortcut({ commit, state, rootState }, shortcut) {
const sc = [...state.shortcuts, shortcut];
- sc.sort().reverse();
+ sc.sort();
const user = rootState.user.currentUser;
return axios.put(`/users/${user.userid}/balance/shortcuts`, sc).then(() => {
@@ -109,6 +126,37 @@ const actions: ActionTree = {
})
.finally(() => commit('setLoading', false));
},
+ getBalances() {
+ return axios.get('/balance').then(({ data }: AxiosResponse>) => {
+ return data;
+ });
+ },
+ getTransactions(
+ { commit, rootState },
+ payload: {
+ userid?: string;
+ filter?: {
+ limit?: number;
+ offset?: number;
+ from?: Date;
+ to?: Date;
+ showReversals?: boolean;
+ showCancelled?: boolean;
+ };
+ }
+ ) {
+ commit('setLoading');
+ if (!payload.userid) payload.userid = (rootState.user.currentUser).userid;
+ if (!payload.filter) payload.filter = { limit: 10 };
+ return axios
+ .get(`/users/${payload.userid}/balance/transactions`, { params: payload.filter || {} })
+ .then(({ data }: AxiosResponse) => {
+ data.transactions.forEach(t => fixTransaction(t));
+ commit('addTransactions', data.transactions);
+ return data;
+ })
+ .finally(() => commit('setLoading', false));
+ },
getLimit({ rootState, commit }) {
commit('setLoading');
axios
@@ -125,19 +173,27 @@ const actions: ActionTree = {
revert({ dispatch, commit }, transaction: FG.Transaction) {
return axios
.delete(`/balance/${transaction.id}`)
- .then((response: AxiosResponse) => {
- commit('reverseTransaction', { transaction: transaction, reversal: response.data });
+ .then(({ data }: AxiosResponse) => {
+ fixTransaction(data);
+ commit('reverseTransaction', { transaction: transaction, reversal: data });
dispatch('getBalance').catch(err => console.warn(err));
});
},
- changeBalance({ dispatch, commit }, data: { amount: number; user: string; sender?: string }) {
+ changeBalance(
+ { dispatch, commit, rootState },
+ data: { amount: number; user: string; sender?: string }
+ ) {
commit('setLoading');
return axios
.put(`/users/${data.user}/balance`, data)
.then((response: AxiosResponse) => {
const transaction = response.data;
- transaction.time = new Date(transaction.time);
- commit('addTransaction', transaction);
+ fixTransaction(transaction);
+ if (
+ data.user == rootState.user.currentUser?.userid ||
+ data.sender === rootState.user.currentUser?.userid
+ )
+ commit('addTransaction', transaction);
commit(state.balances.has(data.user) ? 'changeBalance' : 'setBalance', {
userid: data.user,
amount: data.amount
@@ -152,6 +208,7 @@ const actions: ActionTree = {
.catch(err => {
console.debug(err);
// Maybe Balance changed
+ void dispatch('getTransactions', {});
return dispatch('getBalance', data.sender ? data.sender : data.user);
})
.finally(() => commit('setLoading', false));
diff --git a/src/plugins/schedule/components/management/CreateEvent.vue b/src/plugins/schedule/components/management/CreateEvent.vue
index d3798f5..9080ed7 100644
--- a/src/plugins/schedule/components/management/CreateEvent.vue
+++ b/src/plugins/schedule/components/management/CreateEvent.vue
@@ -3,7 +3,7 @@
-
+
Veranstaltung erstellen
-
+
@@ -149,7 +149,7 @@ export default defineComponent({
event.value.id = NaN;
event.value.start = new Date();
event.value.description = '';
- delete event.value['type'];
+ event.value.type = {id: -1, name: ''};
event.value.jobs = [Object.assign({}, newJob.value)];
}
function notEmpty(val: string) {
diff --git a/src/plugins/schedule/components/management/Job.vue b/src/plugins/schedule/components/management/Job.vue
index d0e3251..f10a377 100644
--- a/src/plugins/schedule/components/management/Job.vue
+++ b/src/plugins/schedule/components/management/Job.vue
@@ -89,33 +89,33 @@ export default defineComponent({
function setStart(value: Date) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- emit('setStart', { job: props.job, value });
+ emit('set-start', { job: props.job, value });
}
function setEnd(value: Date) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- emit('setEnd', { job: props.job, value });
+ emit('set-end', { job: props.job, value });
}
function setComment(value: string) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- emit('setComment', { job: props.job, value });
+ emit('set-comment', { job: props.job, value });
}
function setJobType(value: FG.JobType) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
console.log('setJobType', value);
- emit('setJobType', { job: props.job, value });
+ emit('set-job-type', { job: props.job, value });
}
function setRequired(value: number) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- emit('setRequired', { job: props.job, value });
+ emit('set-required', { job: props.job, value });
}
function removeJob() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- emit('removeJob');
+ emit('remove-job');
}
function notEmpty(val: string) {
diff --git a/src/plugins/schedule/routes/index.ts b/src/plugins/schedule/routes/index.ts
index 5a02182..e172fff 100644
--- a/src/plugins/schedule/routes/index.ts
+++ b/src/plugins/schedule/routes/index.ts
@@ -1,25 +1,5 @@
import { FG_Plugin } from 'src/plugins';
-/*const permissions = {
- // Show own and others balance
- SHOW: 'balance_show',
- SHOW_OTHER: 'balance_show_others',
- // Credit balance (give)
- CREDIT: 'balance_credit',
- // Debit balance (take)
- DEBIT: 'balance_debit',
- // Debit own balance only
- DEBIT_OWN: 'balance_debit_own',
- // Send from to other
- SEND: 'balance_send',
- // Send from other to another
- SEND_OTHER: 'balance_send_others',
- // Can set limit for users
- SET_LIMIT: 'balance_set_limit',
- //Allow sending / sub while exceeding the set limit
- EXCEED_LIMIT: 'balance_exceed_limit'
-};*/
-
const mainRoutes: FG_Plugin.PluginRouteConfig[] = [
{
title: 'Dienste',
diff --git a/src/plugins/user/components/settings/Sessions.vue b/src/plugins/user/components/settings/Sessions.vue
index c609bef..77fc6e5 100644
--- a/src/plugins/user/components/settings/Sessions.vue
+++ b/src/plugins/user/components/settings/Sessions.vue
@@ -31,12 +31,7 @@
label="Zeit"
filled
/>
-
+