Compare commits

..

No commits in common. "9584774d18d5a64b50fc9374af2d2ef01f220192" and "86a06e8094df1f198b11ef568165370fb48c2f61" have entirely different histories.

7 changed files with 22 additions and 94 deletions

View File

@ -1,16 +1,6 @@
<template>
<div class="col-sm-4 col-xs-12">
<q-input
v-model.number="amount"
ref="refAmount"
type="number"
filled
label="Eigener Betrag"
step="0.1"
min="0"
suffix="€"
:rules="[check_cent_step]"
/>
<q-input v-model.number="amount" type="number" filled label="Eigener Betrag" step="0.1" min="0" suffix="€" />
</div>
<div class="col-sm-4 col-xs-6">
<q-btn style="width: 100%" color="primary" label="Anschreiben" @click="changeBalance(amount * -1)">
@ -32,11 +22,9 @@
</template>
<script lang="ts">
import { defineComponent, ref, PropType, computed, watch } from 'vue';
import { QInput } from 'quasar';
import { useBalanceStore } from '../store';
import { hasPermission, useUserStore } from '@flaschengeist/api';
import PERMISSIONS from '../permissions';
import { check_cent_step } from '../utils';
export default defineComponent({
name: 'BalanceAddBody',
props: {
@ -56,15 +44,12 @@ export default defineComponent({
const store = useBalanceStore();
const userStore = useUserStore();
const amount = ref<number>(0);
const refAmount = ref<QInput>();
async function changeBalance(amount: number) {
await refAmount.value?.validate();
if (amount != 0 && !refAmount.value?.hasError) await store.changeBalance(amount, user.value);
await store.changeBalance(amount, user.value);
emit('change-balance', user.value);
}
async function addShortcut() {
await refAmount.value?.validate();
if (amount.value != 0 && !refAmount.value?.hasError) void store.createShortcut(amount.value * -1);
function addShortcut() {
if (amount.value != 0) void store.createShortcut(amount.value * -1);
}
const canAddCredit = hasPermission(PERMISSIONS.CREDIT);
const user = computed(() =>
@ -75,7 +60,7 @@ export default defineComponent({
watch(amount, (a) => {
amount.value = Math.abs(a);
});
return { changeBalance, addShortcut, canAddCredit, amount, check_cent_step, refAmount };
return { changeBalance, addShortcut, canAddCredit, amount };
},
});
</script>

View File

@ -10,10 +10,8 @@
<div v-if="showSelector" class="col-6">
<UserSelector v-model="user" />
</div>
<div class="col">
<div class="row fit justify-end content-end items-end">
<q-btn round flat icon="mdi-format-list-checks" @click="openHistory" />
</div>
<div class="col-1 justify-end">
<q-btn round flat icon="mdi-format-list-checks" @click="openHistory" />
</div>
</q-card-section>
</template>

View File

@ -1,16 +1,6 @@
<template>
<div class="col-sm-4 col-xs-12">
<q-input
v-model.number="amount"
ref="refAmount"
type="number"
filled
label="Betrag"
step="0.1"
min="0"
suffix="€"
:rules="[check_cent_step]"
/>
<q-input v-model.number="amount" type="number" filled label="Betrag" step="0.1" min="0" suffix="€" />
</div>
<div class="col-sm-4 col-xs-6">
<UserSelector v-model="receiver" label="Empfänger" />
@ -21,10 +11,8 @@
</template>
<script lang="ts">
import { computed, defineComponent, PropType, ref } from 'vue';
import { QInput } from 'quasar';
import UserSelector from '@flaschengeist/users/src/components/UserSelector.vue';
import { useBalanceStore } from '../store';
import { check_cent_step } from '../utils';
import { useUserStore } from '@flaschengeist/api';
export default defineComponent({
name: 'BalanceTransferBody',
@ -43,7 +31,6 @@ export default defineComponent({
const userStore = useUserStore();
const receiver = ref<FG.User | undefined>(undefined);
const amount = ref<number>(0);
const refAmount = ref<QInput>();
const sender = computed(() =>
(<FG.User>props.user).userid
? <FG.User>props.user
@ -51,18 +38,11 @@ export default defineComponent({
);
const sendDisabled = computed(() => {
return !(
receiver.value &&
sender.value &&
sender.value.userid != receiver.value.userid &&
amount.value > 0 &&
!refAmount.value?.hasError
);
return !(receiver.value && sender.value && sender.value.userid != receiver.value.userid && amount.value > 0);
});
async function sendAmount() {
await refAmount.value?.validate();
if (receiver.value && !refAmount.value?.hasError) {
if (receiver.value) {
await store.changeBalance(amount.value, receiver.value, sender.value);
emit('changeBalance', { sender: sender.value, receiver: receiver.value });
}
@ -73,8 +53,6 @@ export default defineComponent({
amount,
sendAmount,
sendDisabled,
refAmount,
check_cent_step,
};
},
});

View File

@ -15,17 +15,7 @@
<q-icon name="mdi-magnify" />
</template>
</q-input>
<q-input
ref="refLimit"
v-model.number="limit"
label="Limit"
type="number"
step="0.01"
suffix="€"
filled
dense
:rules="[check_cent_step]"
>
<q-input v-model.number="limit" label="Limit" type="number" step="0.01" suffix="€" filled dense>
<template #prepend>
<q-btn
:icon="sign === '+' ? 'mdi-plus' : 'mdi-minus'"
@ -117,8 +107,6 @@
<script lang="ts">
import { ref, defineComponent, computed, onBeforeMount } from 'vue';
import { QInput } from 'quasar';
import { check_cent_step } from '../utils';
import { useBalanceStore } from '../store';
import { useUserStore } from '@flaschengeist/api';
import BalanceAddBody from '../components/BalanceAddBody.vue';
@ -132,7 +120,6 @@ export default defineComponent({
const userStore = useUserStore();
const showMenu = ref<{ [userid: string]: boolean }>({});
const refLimit = ref<QInput>();
onBeforeMount(() => {
void userStore.getUsers();
@ -254,10 +241,6 @@ export default defineComponent({
if (sign.value === '-') {
l = -l;
}
await refLimit.value?.validate();
if (refLimit.value?.hasError) {
return;
}
await store.setLimit(l, userid);
limit.value = undefined;
}
@ -274,14 +257,10 @@ export default defineComponent({
sign.value = sign.value === '+' ? '-' : '+';
}
async function setLimits(l: number) {
function setLimits(l: number) {
if (sign.value === '-') {
l = -l;
}
await refLimit.value?.validate();
if (refLimit.value?.hasError) {
return;
}
void store.setLimits(l);
}
@ -306,8 +285,6 @@ export default defineComponent({
showMenu,
sign,
changeSign,
check_cent_step,
refLimit,
};
},
});

View File

@ -28,7 +28,7 @@
</q-list>
<q-list v-if="show">
<div v-for="(transaction, index) in transactions" :key="index" class="col-sm-12">
<balance-transaction v-model:transaction="transactions[index]" @update:transaction="updateBalance" />
<balance-transaction v-model:transaction="transactions[index]" />
</div>
</q-list>
</q-drawer>
@ -128,7 +128,6 @@ export default defineComponent({
tabs,
transactions,
show,
updateBalance: () => balanceStore.getBalance(mainStore.currentUser),
};
},
});

View File

@ -131,14 +131,14 @@ export const useBalanceStore = defineStore({
user: FG.User,
filter:
| {
limit?: number;
offset?: number;
from?: Date;
to?: Date;
showReversals?: boolean;
showCancelled?: boolean;
descending?: boolean;
}
limit?: number;
offset?: number;
from?: Date;
to?: Date;
showReversals?: boolean;
showCancelled?: boolean;
descending?: boolean;
}
| undefined = undefined
) {
if (!filter) filter = { limit: 10 };
@ -146,13 +146,7 @@ export const useBalanceStore = defineStore({
params: filter,
});
data.transactions.forEach((t) => fixTransaction(t));
if (data.transactions) {
data.transactions.forEach((t) => {
const idx = this.transactions.findIndex((x) => x.id === t.id);
if (idx == -1) this.transactions.push(t);
else this.transactions[idx] = t;
});
}
if (data.transactions) this.transactions.push(...data.transactions);
return data;
},

View File

@ -1,3 +0,0 @@
export function check_cent_step(value: number): boolean | string {
return (value * 100) % 1 === 0 || 'Betrag muss in 1-Cent-Schritten angegeben werden';
}