diff --git a/backend/src/graphql/model/TransactionList.ts b/backend/src/graphql/model/TransactionList.ts index c34a594f5..9e8356747 100644 --- a/backend/src/graphql/model/TransactionList.ts +++ b/backend/src/graphql/model/TransactionList.ts @@ -9,12 +9,14 @@ export class TransactionList { balance: Decimal, transactions: Transaction[], count: number, + linkCount: number, balanceGDT?: number | null, decayStartBlock: Date = CONFIG.DECAY_START_TIME, ) { this.balance = balance this.transactions = transactions this.count = count + this.linkCount = linkCount this.balanceGDT = balanceGDT || null this.decayStartBlock = decayStartBlock } @@ -25,6 +27,9 @@ export class TransactionList { @Field(() => Number) count: number + @Field(() => Number) + linkCount: number + @Field(() => Decimal) balance: Decimal diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index d2bfd7f28..f64ba19e9 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -170,7 +170,7 @@ export class TransactionResolver { } if (!lastTransaction) { - return new TransactionList(new Decimal(0), [], 0, balanceGDT) + return new TransactionList(new Decimal(0), [], 0, 0, balanceGDT) } // find transactions @@ -204,7 +204,7 @@ export class TransactionResolver { const transactions: Transaction[] = [] const transactionLinkRepository = getCustomRepository(TransactionLinkRepository) - const { sumHoldAvailableAmount, sumAmount, lastDate, firstDate } = + const { sumHoldAvailableAmount, sumAmount, lastDate, firstDate, transactionLinkcount } = await transactionLinkRepository.summary(user.id, now) // decay & link transactions @@ -217,9 +217,9 @@ export class TransactionResolver { transactions.push( virtualLinkTransaction( lastTransaction.balance.minus(sumHoldAvailableAmount.toString()), - sumAmount, - sumHoldAvailableAmount, - sumHoldAvailableAmount.minus(sumAmount.toString()), + sumAmount.mul(-1), + sumHoldAvailableAmount.mul(-1), + sumHoldAvailableAmount.minus(sumAmount.toString()).mul(-1), firstDate || now, lastDate || now, self, @@ -244,6 +244,7 @@ export class TransactionResolver { ), transactions, userTransactionsCount, + transactionLinkcount, balanceGDT, ) } diff --git a/backend/src/typeorm/repository/TransactionLink.ts b/backend/src/typeorm/repository/TransactionLink.ts index 2ce937d8d..46926673a 100644 --- a/backend/src/typeorm/repository/TransactionLink.ts +++ b/backend/src/typeorm/repository/TransactionLink.ts @@ -12,13 +12,15 @@ export class TransactionLinkRepository extends Repository { sumAmount: Decimal lastDate: Date | null firstDate: Date | null + transactionLinkcount: number }> { - const { sumHoldAvailableAmount, sumAmount, lastDate, firstDate } = + const { sumHoldAvailableAmount, sumAmount, lastDate, firstDate, count } = await this.createQueryBuilder('transactionLinks') .select('SUM(transactionLinks.holdAvailableAmount)', 'sumHoldAvailableAmount') .addSelect('SUM(transactionLinks.amount)', 'sumAmount') .addSelect('MAX(transactionLinks.validUntil)', 'lastDate') .addSelect('MIN(transactionLinks.createdAt)', 'firstDate') + .addSelect('COUNT(*)', 'count') .where('transactionLinks.userId = :userId', { userId }) .andWhere('transactionLinks.redeemedAt is NULL') .andWhere('transactionLinks.validUntil > :date', { date }) @@ -31,6 +33,7 @@ export class TransactionLinkRepository extends Repository { sumAmount: sumAmount ? new Decimal(sumAmount) : new Decimal(0), lastDate: lastDate || null, firstDate: firstDate || null, + transactionLinkcount: count || 0, } } } diff --git a/frontend/src/components/DecayInformations/CollapseLinksList.vue b/frontend/src/components/DecayInformations/CollapseLinksList.vue new file mode 100644 index 000000000..3c6bab053 --- /dev/null +++ b/frontend/src/components/DecayInformations/CollapseLinksList.vue @@ -0,0 +1,14 @@ + + diff --git a/frontend/src/components/DecayInformations/DecayInformation-Short.vue b/frontend/src/components/DecayInformations/DecayInformation-Short.vue index 3bed4b9cc..1cd0a2d09 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Short.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Short.vue @@ -1,6 +1,6 @@ diff --git a/frontend/src/components/Transactions/TransactionCreation.vue b/frontend/src/components/Transactions/TransactionCreation.vue index 33b048c07..43178e5f2 100644 --- a/frontend/src/components/Transactions/TransactionCreation.vue +++ b/frontend/src/components/Transactions/TransactionCreation.vue @@ -60,42 +60,37 @@ export default { props: { amount: { type: String, - }, - balance: { - type: String, + required: true, }, balanceDate: { type: String, + required: true, }, decay: { type: Object, - }, - id: { - type: Number, + required: true, }, linkedUser: { type: Object, + required: true, }, memo: { type: String, + required: true, }, typeId: { type: String, + required: true, }, - properties: { - type: Object, + decayStartBlock: { + type: Date, + required: true, }, - decayStartBlock: { type: Date }, }, data() { return { visible: false, } }, - computed: { - isStartBlock() { - return new Date(this.decay.start).getTime() === this.decayStartBlock.getTime() - }, - }, } diff --git a/frontend/src/components/Transactions/TransactionDecay.vue b/frontend/src/components/Transactions/TransactionDecay.vue index d6c210d9d..4038e782f 100644 --- a/frontend/src/components/Transactions/TransactionDecay.vue +++ b/frontend/src/components/Transactions/TransactionDecay.vue @@ -43,12 +43,15 @@ export default { props: { amount: { type: String, + required: true, }, balance: { type: String, + required: true, }, decay: { type: Object, + required: true, }, }, data() { diff --git a/frontend/src/components/Transactions/TransactionLink.vue b/frontend/src/components/Transactions/TransactionLink.vue new file mode 100644 index 000000000..5c261adbf --- /dev/null +++ b/frontend/src/components/Transactions/TransactionLink.vue @@ -0,0 +1,70 @@ + + diff --git a/frontend/src/components/Transactions/TransactionReceive.vue b/frontend/src/components/Transactions/TransactionReceive.vue index 8766fbfa3..e9dc23cdb 100644 --- a/frontend/src/components/Transactions/TransactionReceive.vue +++ b/frontend/src/components/Transactions/TransactionReceive.vue @@ -61,39 +61,36 @@ export default { props: { amount: { type: String, - }, - balance: { - type: String, + required: true, }, balanceDate: { type: String, + required: true, }, decay: { type: Object, - }, - id: { - type: Number, + required: true, }, linkedUser: { type: Object, + required: true, }, memo: { type: String, + required: true, }, typeId: { type: String, }, - decayStartBlock: { type: Date }, + decayStartBlock: { + type: Date, + required: true, + }, }, data() { return { visible: false, } }, - computed: { - isStartBlock() { - return new Date(this.decay.start).getTime() === this.decayStartBlock.getTime() - }, - }, } diff --git a/frontend/src/components/Transactions/TransactionSend.vue b/frontend/src/components/Transactions/TransactionSend.vue index 0ae8495f5..18112f8e1 100644 --- a/frontend/src/components/Transactions/TransactionSend.vue +++ b/frontend/src/components/Transactions/TransactionSend.vue @@ -61,29 +61,32 @@ export default { props: { amount: { type: String, - }, - balance: { - type: String, + required: true, }, balanceDate: { type: String, + required: true, }, decay: { type: Object, - }, - id: { - type: Number, + required: true, }, linkedUser: { type: Object, + required: true, }, memo: { type: String, + required: true, }, typeId: { type: String, + required: true, + }, + decayStartBlock: { + type: Date, + required: true, }, - decayStartBlock: { type: Date }, }, data() { return { diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 4a7051bdf..5887d585a 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -57,6 +57,7 @@ export const transactionsQuery = gql` ) { balanceGDT count + linkCount balance decayStartBlock transactions { diff --git a/frontend/src/layouts/DashboardLayout_gdd.spec.js b/frontend/src/layouts/DashboardLayout_gdd.spec.js index 8765c95e7..2a8b7bf42 100644 --- a/frontend/src/layouts/DashboardLayout_gdd.spec.js +++ b/frontend/src/layouts/DashboardLayout_gdd.spec.js @@ -155,6 +155,7 @@ describe('DashboardLayoutGdd', () => { transactionList: { balanceGDT: 100, count: 4, + linkCount: 8, balance: 1450, decay: 1250, transactions: ['transaction', 'transaction', 'transaction', 'transaction'], @@ -198,6 +199,10 @@ describe('DashboardLayoutGdd', () => { it('updates transaction count', () => { expect(wrapper.vm.transactionCount).toBe(4) }) + + it('updates transaction link count', () => { + expect(wrapper.vm.transactionLinkCount).toBe(8) + }) }) describe('update transactions returns error', () => { diff --git a/frontend/src/layouts/DashboardLayout_gdd.vue b/frontend/src/layouts/DashboardLayout_gdd.vue index 66221993f..e35faab2a 100755 --- a/frontend/src/layouts/DashboardLayout_gdd.vue +++ b/frontend/src/layouts/DashboardLayout_gdd.vue @@ -24,6 +24,7 @@ :gdt-balance="GdtBalance" :transactions="transactions" :transactionCount="transactionCount" + :transactionLinkCount="transactionLinkCount" :pending="pending" :decayStartBlock="decayStartBlock" @update-balance="updateBalance" @@ -59,6 +60,7 @@ export default { transactions: [], bookedBalance: 0, transactionCount: 0, + transactionLinkCount: 0, pending: true, visible: false, decayStartBlock: new Date(), @@ -99,6 +101,7 @@ export default { this.transactions = transactionList.transactions this.balance = Number(transactionList.balance) this.transactionCount = transactionList.count + this.transactionLinkCount = transactionList.linkCount this.decayStartBlock = new Date(transactionList.decayStartBlock) this.pending = false }) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 94b1e8eb0..9c0e440b0 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -106,6 +106,8 @@ "decay-14-day": "Vergänglichkeit für 14 Tage", "header": "Gradidos versenden per Link", "link-copied": "Link wurde in die Zwischenablage kopiert", + "links_count": "Aktive Links", + "links_sum": "Summe deiner versendeten Gradidos", "not-copied": "Konnte den Link nicht kopieren: {err}", "sentence_1": "Wähle einen Betrag aus, welchen du per Link versenden möchtest. Du kannst auch noch eine Nachricht eintragen. Beim Klick „jetzt generieren“ wird ein Link erstellt, den du versenden kannst.", "sentence_2": "Der Link ist 14 Tage gültig!", @@ -132,6 +134,9 @@ }, "imprint": "Impressum", "language": "Sprache", + "links-list": { + "header": "Liste deiner aktiven Links" + }, "login": "Anmeldung", "logout": "Abmelden", "members_area": "Mitgliederbereich", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 685ca499f..a454ee785 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -106,6 +106,8 @@ "decay-14-day": "Decay for 14 days", "header": "Send Gradidos via link", "link-copied": "Link copied to clipboard", + "links_count": "Active links", + "links_sum": "Total of your sent Gradidos", "not-copied": "Could not copy link: {err}", "sentence_1": "Select an amount that you would like to send via link. You can also enter a message. Click 'Generate now' to create a link that you can share.", "sentence_2": "The link is valid for 14 days!", @@ -132,6 +134,9 @@ }, "imprint": "Legal notice", "language": "Language", + "links-list": { + "header": "List of your active links" + }, "login": "Login", "logout": "Logout", "members_area": "Members area", diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue index 842f6d2d5..93344b3ee 100644 --- a/frontend/src/pages/Overview.vue +++ b/frontend/src/pages/Overview.vue @@ -20,6 +20,7 @@ :timestamp="timestamp" :decayStartBlock="decayStartBlock" :transaction-count="transactionCount" + :transactionLinkCount="transactionLinkCount" @update-transactions="updateTransactions" /> @@ -51,6 +52,7 @@ export default { default: () => [], }, transactionCount: { type: Number, default: 0 }, + transactionLinkCount: { type: Number, default: 0 }, pending: { type: Boolean, default: true, diff --git a/frontend/src/pages/Transactions.vue b/frontend/src/pages/Transactions.vue index 31094e454..6fc588b10 100644 --- a/frontend/src/pages/Transactions.vue +++ b/frontend/src/pages/Transactions.vue @@ -7,6 +7,7 @@ [], }, transactionCount: { type: Number, default: 0 }, + transactionLinkCount: { type: Number, default: 0 }, decayStartBlock: { type: Date }, }, data() {