Compare commits
No commits in common. "main" and "v1.0.0-alpha.3" have entirely different histories.
main
...
v1.0.0-alp
10
package.json
10
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"license": "MIT",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-alpha.3",
|
||||
"name": "@flaschengeist/balance",
|
||||
"author": "Ferdinand Thiessen <rpm@fthiessen.de>",
|
||||
"homepage": "https://flaschengeist.dev/Flaschengeist",
|
||||
|
@ -19,8 +19,8 @@
|
|||
"lint": "eslint --ext .js,.ts,.vue ./src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@flaschengeist/api": "^1.0.0",
|
||||
"@flaschengeist/types": "^1.0.0",
|
||||
"@flaschengeist/api": "^1.0.0-alpha.8",
|
||||
"@flaschengeist/types": "^1.0.0-alpha.10",
|
||||
"@quasar/app-webpack": "^3.7.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
||||
"@typescript-eslint/parser": "^5.8.0",
|
||||
|
@ -37,8 +37,8 @@
|
|||
"typescript": "^4.5.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@flaschengeist/api": "1.0.0",
|
||||
"@flaschengeist/users": "1.0.0"
|
||||
"@flaschengeist/api": "1.0.0-alpha.8",
|
||||
"@flaschengeist/users": "1.0.0-alpha.4"
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
<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">
|
||||
<div class="col-1 justify-end">
|
||||
<q-btn round flat icon="mdi-format-list-checks" @click="openHistory" />
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ const BalanceTypes = {
|
|||
sub_from: 0x04,
|
||||
};
|
||||
|
||||
function transpile (msg: FG_Plugin.Notification) {
|
||||
function transpile(msg: FG_Plugin.Notification) {
|
||||
console.log('notification:', msg);
|
||||
const message = msg as BalanceNotification;
|
||||
message.icon = 'mdi-cash';
|
||||
|
@ -20,7 +20,8 @@ function transpile (msg: FG_Plugin.Notification) {
|
|||
if (message.data.type === BalanceTypes.send_from) {
|
||||
const receiver = <FG.User>store.findUser((<SendFromNotification>message.data).receiver_id);
|
||||
const author = <FG.User>store.findUser((<SendFromNotification>message.data).author_id);
|
||||
message.text = `${author.display_name} hat ${message.data.amount.toFixed(2)}€ von dir zu ${receiver.display_name
|
||||
message.text = `${author.display_name} hat ${message.data.amount.toFixed(2)}€ von dir zu ${
|
||||
receiver.display_name
|
||||
} überwiesen.`;
|
||||
} else if (message.data.type === BalanceTypes.send_to) {
|
||||
const sender = <FG.User>store.findUser((<SendToNotification>message.data).sender_id);
|
||||
|
@ -39,7 +40,7 @@ const plugin: FG_Plugin.Plugin = {
|
|||
name: 'Balance',
|
||||
innerRoutes: routes,
|
||||
requiredModules: [['balance']],
|
||||
version: '1.0.0',
|
||||
version: '0.0.2',
|
||||
notification: transpile,
|
||||
widgets: [
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
||||
|
|
|
@ -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';
|
||||
}
|
Loading…
Reference in New Issue