From c0680d332d36d8b45102d8dd39431950bfc07df7 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 29 Mar 2023 16:43:03 +0200 Subject: [PATCH 01/11] Transaction info, right-justified, so that the commas --- .../DecayInformation-Long.vue | 20 +++++++++++-------- .../TransactionRows/DurationRow.vue | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/DecayInformations/DecayInformation-Long.vue b/frontend/src/components/DecayInformations/DecayInformation-Long.vue index 782fe049c..0fd6b7f5c 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Long.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Long.vue @@ -14,7 +14,7 @@
{{ $t('decay.last_transaction') }}
- +
{{ $d(new Date(decay.start), 'long') }} @@ -25,11 +25,13 @@ - - + +
{{ $t('decay.decay') }}
- {{ decay.decay | GDD }} + + {{ decay.decay | GDD }} +
@@ -38,15 +40,17 @@ - {{ $t(`decay.types.${typeId.toLowerCase()}`) }} - {{ amount | GDD }} + {{ $t(`decay.types.${typeId.toLowerCase()}`) }} + + {{ amount | GDD }} + - +
{{ $t('decay.total') }}
- + {{ (Number(amount) + Number(decay.decay)) | GDD }}
diff --git a/frontend/src/components/TransactionRows/DurationRow.vue b/frontend/src/components/TransactionRows/DurationRow.vue index 9cadf8c24..aa20132d7 100644 --- a/frontend/src/components/TransactionRows/DurationRow.vue +++ b/frontend/src/components/TransactionRows/DurationRow.vue @@ -4,7 +4,7 @@
{{ $t('decay.past_time') }}
- + {{ durationText }} From 60ccdc5beb194ae771ae7606562b60de74aced6d Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 3 Apr 2023 12:54:11 +0200 Subject: [PATCH 02/11] feat(backend): previuos balance in transaction --- backend/src/graphql/model/Transaction.ts | 11 ++++++++++- backend/src/graphql/resolver/TransactionResolver.ts | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 1b857391b..dc20a5c83 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -9,7 +9,12 @@ import { User } from './User' @ObjectType() export class Transaction { - constructor(transaction: dbTransaction, user: User, linkedUser: User | null = null) { + constructor( + transaction: dbTransaction, + user: User, + linkedUser: User | null = null, + previuosBalance: Decimal = new Decimal(0), + ) { this.id = transaction.id this.user = user this.previous = transaction.previous @@ -47,6 +52,7 @@ export class Transaction { this.linkId = transaction.contribution ? transaction.contribution.contributionLinkId : transaction.transactionLinkId || null + this.previousBalance = previuosBalance } @Field(() => Int) @@ -70,6 +76,9 @@ export class Transaction { @Field(() => Date) balanceDate: Date + @Field(() => Decimal) + previousBalance: Decimal + @Field(() => Decay) decay: Decay diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 430cdb363..8c51c6681 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -283,12 +283,13 @@ export class TransactionResolver { } // transactions - userTransactions.forEach((userTransaction) => { + userTransactions.forEach((userTransaction, idx) => { const linkedUser = userTransaction.typeId === TransactionTypeId.CREATION ? communityUser : involvedUsers.find((u) => u.id === userTransaction.linkedUserId) - transactions.push(new Transaction(userTransaction, self, linkedUser)) + const previousBalance = idx ? userTransactions[idx - 1].balance : new Decimal(0) + transactions.push(new Transaction(userTransaction, self, linkedUser, previousBalance)) }) logger.debug(`TransactionTypeId.CREATION: transactions=${transactions}`) From d5782735896c61abc774292a4a9bdea2b192711e Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 3 Apr 2023 14:17:42 +0200 Subject: [PATCH 03/11] correct calculation of previuos balance --- backend/src/graphql/model/Transaction.ts | 2 +- backend/src/graphql/resolver/TransactionResolver.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index dc20a5c83..50ca7d098 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -52,7 +52,7 @@ export class Transaction { this.linkId = transaction.contribution ? transaction.contribution.contributionLinkId : transaction.transactionLinkId || null - this.previousBalance = previuosBalance + this.previousBalance = previuosBalance.toDecimalPlaces(2, Decimal.ROUND_DOWN) } @Field(() => Int) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 8c51c6681..72e919dad 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -288,7 +288,8 @@ export class TransactionResolver { userTransaction.typeId === TransactionTypeId.CREATION ? communityUser : involvedUsers.find((u) => u.id === userTransaction.linkedUserId) - const previousBalance = idx ? userTransactions[idx - 1].balance : new Decimal(0) + const previousBalance = + idx < userTransactions.length - 1 ? userTransactions[idx + 1].balance : new Decimal(0) transactions.push(new Transaction(userTransaction, self, linkedUser, previousBalance)) }) logger.debug(`TransactionTypeId.CREATION: transactions=${transactions}`) From adbd8b1e5d01a71c7a98aa6a1808bd817c021e90 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 3 Apr 2023 14:50:22 +0200 Subject: [PATCH 04/11] add previous balance to virtual transaction link transaction --- backend/src/graphql/resolver/TransactionResolver.ts | 1 + backend/src/util/virtualTransactions.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 72e919dad..d855a0701 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -276,6 +276,7 @@ export class TransactionResolver { firstDate || now, lastDate || now, self, + (userTransactions.length && userTransactions[0].balance) || new Decimal(0), ), ) logger.debug(`transactions=${transactions}`) diff --git a/backend/src/util/virtualTransactions.ts b/backend/src/util/virtualTransactions.ts index 68a37746b..9f4def31e 100644 --- a/backend/src/util/virtualTransactions.ts +++ b/backend/src/util/virtualTransactions.ts @@ -38,6 +38,7 @@ const virtualLinkTransaction = ( createdAt: Date, validUntil: Date, user: User, + previousBalance: Decimal, ): Transaction => { const linkDbTransaction: dbTransaction = { id: -2, @@ -54,7 +55,12 @@ const virtualLinkTransaction = ( contribution: null, ...defaultModelFunctions, } - return new Transaction(linkDbTransaction, user) + return new Transaction( + linkDbTransaction, + user, + null, + previousBalance.toDecimalPlaces(2, Decimal.ROUND_DOWN), + ) } const virtualDecayTransaction = ( From 0a62c87dd992686302067d02ba2ad23d63b787c2 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 3 Apr 2023 14:54:48 +0200 Subject: [PATCH 05/11] locales for new and old balance --- frontend/src/locales/de.json | 2 ++ frontend/src/locales/en.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index b8635f44a..a5357e6d9 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -89,6 +89,8 @@ "decay_introduced": "Die Vergänglichkeit wurde eingeführt am:", "decay_since_last_transaction": "Vergänglichkeit seit der letzten Transaktion", "last_transaction": "Letzte Transaktion", + "new_balance": "Neuer Kontostand", + "old_balance": "Vorheriger Kontostand", "past_time": "Vergangene Zeit", "Starting_block_decay": "Startblock Vergänglichkeit", "total": "Gesamt", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 15449a208..42f22f709 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -89,6 +89,8 @@ "decay_introduced": "Decay was introduced on:", "decay_since_last_transaction": "Decay since the last transaction", "last_transaction": "Last transaction:", + "new_balance": "New balance", + "old_balance": "Previous balance", "past_time": "Time passed", "Starting_block_decay": "Starting Block Decay", "total": "Total", From 545e55659955c2de3371a7d352fe5a0fa8d5320e Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 3 Apr 2023 14:55:22 +0200 Subject: [PATCH 06/11] previuos balance from server, displayed in decay details --- .../DecayInformation-Decay.vue | 4 +-- .../DecayInformation-Long.vue | 22 +++++++++++---- .../DecayInformations/DecayInformation.vue | 18 ++++++++++++- .../src/components/GddTransactionList.vue | 27 +++---------------- .../Transactions/TransactionCreation.vue | 15 +++++++++-- .../Transactions/TransactionDecay.vue | 9 ++++--- .../Transactions/TransactionReceive.vue | 15 +++++++++-- .../Transactions/TransactionSend.vue | 15 +++++++++-- frontend/src/graphql/queries.js | 1 + 9 files changed, 85 insertions(+), 41 deletions(-) diff --git a/frontend/src/components/DecayInformations/DecayInformation-Decay.vue b/frontend/src/components/DecayInformations/DecayInformation-Decay.vue index 7abdb0f2b..ce679fb30 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Decay.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Decay.vue @@ -12,7 +12,7 @@
- {{ previousBookedBalance | GDD }} + {{ previousBalance | GDD }} {{ decay === '0' ? $t('math.minus') : '' }} {{ decay | GDD }} {{ $t('math.equal') }} {{ balance | GDD }} @@ -35,7 +35,7 @@ export default { type: String, required: true, }, - previousBookedBalance: { + previousBalance: { type: String, required: true, }, diff --git a/frontend/src/components/DecayInformations/DecayInformation-Long.vue b/frontend/src/components/DecayInformations/DecayInformation-Long.vue index 0fd6b7f5c..d7e943225 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Long.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Long.vue @@ -24,8 +24,18 @@ - + + +
{{ $t('decay.old_balance') }}
+
+ + {{ previousBalance | GDD }} + +
+ + +
{{ $t('decay.decay') }}
@@ -38,7 +48,7 @@ - + {{ $t(`decay.types.${typeId.toLowerCase()}`) }} @@ -46,12 +56,12 @@ - + -
{{ $t('decay.total') }}
+
{{ $t('decay.new_balance') }}
- {{ (Number(amount) + Number(decay.decay)) | GDD }} + {{ balance | GDD }}
@@ -67,6 +77,8 @@ export default { DurationRow, }, props: { + balance: { type: String, default: '0' }, + previousBalance: { type: String, default: '0' }, amount: { type: String, default: '0' }, typeId: { type: String, default: '' }, memo: { type: String, default: '' }, diff --git a/frontend/src/components/DecayInformations/DecayInformation.vue b/frontend/src/components/DecayInformations/DecayInformation.vue index 3329fd021..0be12d0de 100644 --- a/frontend/src/components/DecayInformations/DecayInformation.vue +++ b/frontend/src/components/DecayInformations/DecayInformation.vue @@ -7,7 +7,15 @@ :decay="decay" :typeId="typeId" /> - +