diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index b83524e1a..4ea1f2fd1 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -28,9 +28,12 @@ import { LoginEmailOptIn } from '@entity/LoginEmailOptIn' import { User } from '@entity/User' import { TransactionTypeId } from '../enum/TransactionTypeId' import Decimal from 'decimal.js-light' +import { Decay } from '../model/Decay' // const EMAIL_OPT_IN_REGISTER = 1 // const EMAIL_OPT_UNKNOWN = 3 // elopage? +const MAX_CREATION_AMOUNT = 1000 +const FULL_CREATION_AVAILABLE = [MAX_CREATION_AMOUNT, MAX_CREATION_AMOUNT, MAX_CREATION_AMOUNT] @Resolver() export class AdminResolver { @@ -104,7 +107,7 @@ export class AdminResolver { const userCreations = creations.find((c) => c.id === user.id) const adminUser = new UserAdmin( user, - userCreations ? userCreations.creations : [1000, 1000, 1000], + userCreations ? userCreations.creations : FULL_CREATION_AVAILABLE, await hasElopageBuys(user.email), emailConfirmationSend, ) @@ -170,7 +173,7 @@ export class AdminResolver { if (isCreationValid(creations, amount, creationDateObj)) { const adminPendingCreation = AdminPendingCreation.create() adminPendingCreation.userId = user.id - adminPendingCreation.amount = BigInt(amount * 10000) + adminPendingCreation.amount = BigInt(amount) adminPendingCreation.created = new Date() adminPendingCreation.date = creationDateObj adminPendingCreation.memo = memo @@ -235,7 +238,7 @@ export class AdminResolver { if (!isCreationValid(creations, amount, creationDateObj)) { throw new Error('Creation is not valid') } - pendingCreationToUpdate.amount = BigInt(amount * 10000) + pendingCreationToUpdate.amount = BigInt(amount) pendingCreationToUpdate.memo = memo pendingCreationToUpdate.date = new Date(creationDate) pendingCreationToUpdate.moderator = moderator @@ -270,11 +273,11 @@ export class AdminResolver { return { ...pendingCreation, - amount: Number(parseInt(pendingCreation.amount.toString()) / 10000), + amount: Number(pendingCreation.amount.toString()), firstName: user ? user.firstName : '', lastName: user ? user.lastName : '', email: user ? user.email : '', - creation: creation ? creation.creations : [1000, 1000, 1000], + creation: creation ? creation.creations : FULL_CREATION_AVAILABLE, } }) } @@ -300,7 +303,7 @@ export class AdminResolver { if (user.deletedAt) throw new Error('This user was deleted. Cannot confirm a creation.') const creations = await getUserCreation(pendingCreation.userId, false) - if (!isCreationValid(creations, Number(pendingCreation.amount) / 10000, pendingCreation.date)) { + if (!isCreationValid(creations, Number(pendingCreation.amount), pendingCreation.date)) { throw new Error('Creation is not valid!!') } @@ -310,25 +313,26 @@ export class AdminResolver { const lastTransaction = await transactionRepository.findLastForUser(pendingCreation.userId) let newBalance = new Decimal(0) + let decay: Decay | null = null if (lastTransaction) { - newBalance = calculateDecay( - lastTransaction.balance, - lastTransaction.balanceDate, - receivedCallDate, - ).balance + decay = calculateDecay(lastTransaction.balance, lastTransaction.balanceDate, receivedCallDate) + newBalance = decay.balance } // TODO pending creations decimal - newBalance = newBalance.add(new Decimal(Number(pendingCreation.amount))) + newBalance = newBalance.add(new Decimal(Number(pendingCreation.amount)).toString()) const transaction = new Transaction() transaction.typeId = TransactionTypeId.CREATION transaction.memo = pendingCreation.memo transaction.userId = pendingCreation.userId + transaction.previous = lastTransaction ? lastTransaction.id : null // TODO pending creations decimal transaction.amount = new Decimal(Number(pendingCreation.amount)) transaction.creationDate = pendingCreation.date transaction.balance = newBalance transaction.balanceDate = receivedCallDate + transaction.decay = decay ? decay.decay : new Decimal(0) + transaction.decayStart = decay ? decay.start : null await transaction.save() await AdminPendingCreation.delete(pendingCreation) @@ -344,7 +348,7 @@ interface CreationMap { async function getUserCreation(id: number, includePending = true): Promise { const creations = await getUserCreations([id], includePending) - return creations[0] ? creations[0].creations : [1000, 1000, 1000] + return creations[0] ? creations[0].creations : FULL_CREATION_AVAILABLE } async function getUserCreations(ids: number[], includePending = true): Promise { @@ -384,7 +388,7 @@ async function getUserCreations(ids: number[], includePending = true): Promise parseInt(raw.month) === month && parseInt(raw.id) === id, ) - return 1000 - (creation ? Number(creation.sum) / 10000 : 0) + return MAX_CREATION_AMOUNT - (creation ? Number(creation.sum) : 0) }), } }) diff --git a/database/entity/0028-decimal_types/Transaction.ts b/database/entity/0028-decimal_types/Transaction.ts index e53508c61..9352e6335 100644 --- a/database/entity/0028-decimal_types/Transaction.ts +++ b/database/entity/0028-decimal_types/Transaction.ts @@ -10,8 +10,8 @@ export class Transaction extends BaseEntity { @Column({ name: 'user_id', unsigned: true, nullable: false }) userId: number - @Column({ unsigned: true, nullable: true, default: null }) - previous: number + @Column({ type: 'int', unsigned: true, nullable: true, default: null }) + previous: number | null @Column({ name: 'type_id', unsigned: true, nullable: false }) typeId: number diff --git a/frontend/package.json b/frontend/package.json index 7498513f0..dcf9baf53 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,7 +10,7 @@ "lint": "eslint --max-warnings=0 --ext .js,.vue .", "dev": "yarn run serve", "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'", - "test": "jest --coverage", + "test": "TZ=UTC jest --coverage", "locales": "scripts/missing-keys.sh && scripts/sort.sh" }, "dependencies": { diff --git a/frontend/src/components/DecayInformation.vue b/frontend/src/components/DecayInformation.vue deleted file mode 100644 index 9da5e4b2c..000000000 --- a/frontend/src/components/DecayInformation.vue +++ /dev/null @@ -1,135 +0,0 @@ - - diff --git a/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue b/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue new file mode 100644 index 000000000..c0f34e24d --- /dev/null +++ b/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue @@ -0,0 +1,12 @@ + + diff --git a/frontend/src/components/DecayInformations/DecayInformation-Decay.vue b/frontend/src/components/DecayInformations/DecayInformation-Decay.vue new file mode 100644 index 000000000..0dc00a79a --- /dev/null +++ b/frontend/src/components/DecayInformations/DecayInformation-Decay.vue @@ -0,0 +1,36 @@ + + diff --git a/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue b/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue new file mode 100644 index 000000000..678fc9f09 --- /dev/null +++ b/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue @@ -0,0 +1,89 @@ + + diff --git a/frontend/src/components/DecayInformations/DecayInformation-Long.vue b/frontend/src/components/DecayInformations/DecayInformation-Long.vue new file mode 100644 index 000000000..ac53b77b7 --- /dev/null +++ b/frontend/src/components/DecayInformations/DecayInformation-Long.vue @@ -0,0 +1,109 @@ + + diff --git a/frontend/src/components/DecayInformations/DecayInformation-Short.vue b/frontend/src/components/DecayInformations/DecayInformation-Short.vue new file mode 100644 index 000000000..8dba700d5 --- /dev/null +++ b/frontend/src/components/DecayInformations/DecayInformation-Short.vue @@ -0,0 +1,15 @@ + + diff --git a/frontend/src/components/TransactionListItem.vue b/frontend/src/components/TransactionListItem.vue new file mode 100644 index 000000000..f2f7f3e90 --- /dev/null +++ b/frontend/src/components/TransactionListItem.vue @@ -0,0 +1,16 @@ + + diff --git a/frontend/src/components/Transactions/TransactionCreation.spec.js b/frontend/src/components/Transactions/TransactionCreation.spec.js new file mode 100644 index 000000000..62de8a9a2 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionCreation.spec.js @@ -0,0 +1,52 @@ +import { mount } from '@vue/test-utils' +import TransactionCreation from './TransactionCreation' + +const localVue = global.localVue + +const mocks = { + $i18n: { + locale: 'en', + }, + $n: jest.fn((n) => n), + $t: jest.fn((t) => t), + $d: jest.fn((d) => d), +} + +const propsData = { + amount: '12.45', + balance: '31.76099091058521', + balanceDate: '2022-02-28T13:55:47.000Z', + decay: { + decay: '-0.2038314055482643084', + start: '2022-02-25T07:29:26.000Z', + end: '2022-02-28T13:55:47.000Z', + duration: 282381, + __typename: 'CREATION', + }, + id: 9, + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + memo: 'sadasd asdasdasdasdadadd da dad aad', + typeId: 'DECAY', + decayStartBlock: new Date('2021-05-13T17:46:31.000Z'), +} + +describe('TransactionCreation', () => { + let wrapper + + const Wrapper = () => { + return mount(TransactionCreation, { localVue, mocks, propsData }) + } + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component transaction-slot-creation', () => { + expect(wrapper.find('div.transaction-slot-creation').exists()).toBeTruthy() + }) + }) +}) diff --git a/frontend/src/components/Transactions/TransactionCreation.vue b/frontend/src/components/Transactions/TransactionCreation.vue new file mode 100644 index 000000000..69d1b8b13 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionCreation.vue @@ -0,0 +1,147 @@ + + diff --git a/frontend/src/components/Transactions/TransactionDecay.spec.js b/frontend/src/components/Transactions/TransactionDecay.spec.js new file mode 100644 index 000000000..7b4b658a4 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionDecay.spec.js @@ -0,0 +1,52 @@ +import { mount } from '@vue/test-utils' +import TransactionDecay from './TransactionDecay' + +const localVue = global.localVue + +const mocks = { + $i18n: { + locale: 'en', + }, + $n: jest.fn((n) => n), + $t: jest.fn((t) => t), + $d: jest.fn((d) => d), +} + +const propsData = { + amount: '12.45', + balance: '31.76099091058521', + balanceDate: '2022-02-28T13:55:47.000Z', + decay: { + decay: '-0.2038314055482643084', + start: '2022-02-25T07:29:26.000Z', + end: '2022-02-28T13:55:47.000Z', + duration: 282381, + __typename: 'Decay', + }, + id: 9, + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + memo: 'sadasd asdasdasdasdadadd da dad aad', + typeId: 'DECAY', + decayStartBlock: new Date('2021-05-13T17:46:31.000Z'), +} + +describe('TransactionDecay', () => { + let wrapper + + const Wrapper = () => { + return mount(TransactionDecay, { localVue, mocks, propsData }) + } + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component transaction-slot-decay', () => { + expect(wrapper.find('div.transaction-slot-decay').exists()).toBeTruthy() + }) + }) +}) diff --git a/frontend/src/components/Transactions/TransactionDecay.vue b/frontend/src/components/Transactions/TransactionDecay.vue new file mode 100644 index 000000000..ab5a0f561 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionDecay.vue @@ -0,0 +1,82 @@ + + diff --git a/frontend/src/components/Transactions/TransactionReceive.spec.js b/frontend/src/components/Transactions/TransactionReceive.spec.js new file mode 100644 index 000000000..6643553f8 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionReceive.spec.js @@ -0,0 +1,52 @@ +import { mount } from '@vue/test-utils' +import TransactionReceive from './TransactionReceive' + +const localVue = global.localVue + +const mocks = { + $i18n: { + locale: 'en', + }, + $n: jest.fn((n) => n), + $t: jest.fn((t) => t), + $d: jest.fn((d) => d), +} + +const propsData = { + amount: '12.45', + balance: '31.76099091058521', + balanceDate: '2022-02-28T13:55:47.000Z', + decay: { + decay: '-0.2038314055482643084', + start: '2022-02-25T07:29:26.000Z', + end: '2022-02-28T13:55:47.000Z', + duration: 282381, + __typename: 'Decay', + }, + id: 9, + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + memo: 'sadasd asdasdasdasdadadd da dad aad', + typeId: 'RECEIVE', + decayStartBlock: new Date('2021-05-13T17:46:31.000Z'), +} + +describe('TransactionReceive', () => { + let wrapper + + const Wrapper = () => { + return mount(TransactionReceive, { localVue, mocks, propsData }) + } + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component transaction-slot-receive', () => { + expect(wrapper.find('div.transaction-slot-receive').exists()).toBeTruthy() + }) + }) +}) diff --git a/frontend/src/components/Transactions/TransactionReceive.vue b/frontend/src/components/Transactions/TransactionReceive.vue new file mode 100644 index 000000000..43159a059 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionReceive.vue @@ -0,0 +1,147 @@ + + diff --git a/frontend/src/components/Transactions/TransactionSend.spec.js b/frontend/src/components/Transactions/TransactionSend.spec.js new file mode 100644 index 000000000..40c93437c --- /dev/null +++ b/frontend/src/components/Transactions/TransactionSend.spec.js @@ -0,0 +1,52 @@ +import { mount } from '@vue/test-utils' +import TransactionSend from './TransactionSend' + +const localVue = global.localVue + +const mocks = { + $i18n: { + locale: 'en', + }, + $n: jest.fn((n) => n), + $t: jest.fn((t) => t), + $d: jest.fn((d) => d), +} + +const propsData = { + amount: '12.45', + balance: '31.76099091058521', + balanceDate: '2022-02-28T13:55:47.000Z', + decay: { + decay: '-0.2038314055482643084', + start: '2022-02-25T07:29:26.000Z', + end: '2022-02-28T13:55:47.000Z', + duration: 282381, + __typename: 'Decay', + }, + id: 9, + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + memo: 'sadasd asdasdasdasdadadd da dad aad', + typeId: 'SEND', + decayStartBlock: new Date('2021-05-13T17:46:31.000Z'), +} + +describe('TransactionSend', () => { + let wrapper + + const Wrapper = () => { + return mount(TransactionSend, { localVue, mocks, propsData }) + } + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component transaction-slot-send', () => { + expect(wrapper.find('div.transaction-slot-send').exists()).toBeTruthy() + }) + }) +}) diff --git a/frontend/src/components/Transactions/TransactionSend.vue b/frontend/src/components/Transactions/TransactionSend.vue new file mode 100644 index 000000000..baaa346c5 --- /dev/null +++ b/frontend/src/components/Transactions/TransactionSend.vue @@ -0,0 +1,143 @@ + + diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index c833fb845..94a5e59f3 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -63,6 +63,7 @@ export const transactionsQuery = gql` id typeId amount + balance balanceDate memo linkedUser { diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 3bfad63e8..748bffe25 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -21,7 +21,7 @@ "switch-to-this-community": "zu dieser Gemeinschaft wechseln" }, "decay": { - "befor_startblock_transaction": "Diese Transaktion beinhaltet keine Vergänglichkeit.", + "before_startblock_transaction": "Diese Transaktion beinhaltet keine Vergänglichkeit.", "calculation_decay": "Berechnung der Vergänglichkeit", "calculation_total": "Berechnung der Gesamtsumme", "created": "Geschöpft", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index b06030947..557c0a42c 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -21,7 +21,7 @@ "switch-to-this-community": "Switch to this community" }, "decay": { - "befor_startblock_transaction": "This transaction does not include decay.", + "before_startblock_transaction": "This transaction does not include decay.", "calculation_decay": "Calculation of Decay", "calculation_total": "Calculation of the total Amount", "created": "Created", diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index d12c5e43e..87362a6c3 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -153,7 +153,7 @@ describe('DashboardLayoutGdd', () => { apolloMock.mockResolvedValue({ data: { transactionList: { - gdtSum: 100, + balanceGDT: 100, count: 4, balance: 1450, decay: 1250, @@ -179,7 +179,7 @@ describe('DashboardLayoutGdd', () => { }) it('updates balance', () => { - expect(wrapper.vm.balance).toBe(1250) + expect(wrapper.vm.balance).toBe(1450) }) it('updates transactions', () => { diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index a473469b6..3ec3091de 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -25,6 +25,7 @@ :transactions="transactions" :transactionCount="transactionCount" :pending="pending" + :decayStartBlock="decayStartBlock" @update-balance="updateBalance" @update-transactions="updateTransactions" > @@ -60,6 +61,7 @@ export default { transactionCount: 0, pending: true, visible: false, + decayStartBlock: new Date(), } }, methods: { @@ -92,11 +94,12 @@ export default { const { data: { transactionList }, } = result - this.GdtBalance = transactionList.gdtSum === null ? null : Number(transactionList.gdtSum) + this.GdtBalance = + transactionList.balanceGDT === null ? null : Number(transactionList.balanceGDT) this.transactions = transactionList.transactions - this.balance = Number(transactionList.decay) - this.bookedBalance = Number(transactionList.balance) + this.balance = Number(transactionList.balance) this.transactionCount = transactionList.count + this.decayStartBlock = new Date(transactionList.decayStartBlock) this.pending = false }) .catch((error) => { diff --git a/frontend/src/views/Pages/AccountOverview.vue b/frontend/src/views/Pages/AccountOverview.vue index c0ba55155..ee11f7fdc 100644 --- a/frontend/src/views/Pages/AccountOverview.vue +++ b/frontend/src/views/Pages/AccountOverview.vue @@ -15,10 +15,10 @@ @@ -46,6 +46,7 @@ export default { props: { balance: { type: Number, default: 0 }, GdtBalance: { type: Number, default: 0 }, + decayStartBlock: { type: Date }, transactions: { default: () => [], }, diff --git a/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js b/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js index 450415dd8..b68d59958 100644 --- a/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js @@ -52,7 +52,7 @@ describe('GddTransactionList', () => { beforeEach(async () => { await wrapper.setProps({ transactions: [], - transactionCount: 0, + count: 0, }) }) it('Transactions Array is empty, 0 transactions', () => { @@ -64,7 +64,7 @@ describe('GddTransactionList', () => { beforeEach(async () => { await wrapper.setProps({ transactions: [], - transactionCount: -1, + count: -1, }) }) it('renders text saying that there are error.empty-transactionlist ', () => { @@ -91,250 +91,98 @@ describe('GddTransactionList', () => { await wrapper.setProps({ transactions: [ { - balance: 19.93, - date: '2021-05-25T17:38:13+00:00', - memo: 'Alles Gute zum Geburtstag', - name: 'Bob der Baumeister', - transaction_id: 29, - type: 'send', - decay: { balance: '0.5' }, + id: -1, + typeId: 'DECAY', + amount: '-0.16778637075575395772595', + balance: '31.59320453982945549519405', + balanceDate: '2022-03-03T08:54:54.020Z', + memo: '', + linkedUser: null, + decay: { + decay: '-0.16778637075575395772595', + start: '2022-02-28T13:55:47.000Z', + end: '2022-03-03T08:54:54.020Z', + duration: 241147.02, + __typename: 'Decay', + }, + __typename: 'Transaction', }, { - balance: 1000, - date: '2021-04-29T15:34:49+00:00', - memo: 'Gut das du da bist!', - name: 'Gradido Akademie', - transaction_id: 3, - type: 'creation', + id: 9, + typeId: 'SEND', + amount: '1', + balance: '31.76099091058520945292', + balanceDate: '2022-02-28T13:55:47.000Z', + memo: 'adasd adada', + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + decay: { + decay: '-0.2038314055482643084', + start: '2022-02-25T07:29:26.000Z', + end: '2022-02-28T13:55:47.000Z', + duration: 282381, + __typename: 'Decay', + }, + __typename: 'Transaction', }, { - balance: 314.98, - date: '2021-04-29T17:26:40+00:00', - memo: 'Für das Fahrrad!', - name: 'Jan Ulrich', - transaction_id: 8, - type: 'receive', - decay: { balance: '1.5' }, + id: 8, + typeId: 'CREATION', + amount: '1000', + balance: '32.96482231613347376132', + balanceDate: '2022-02-25T07:29:26.000Z', + memo: 'asd adada dad', + linkedUser: { + firstName: 'Gradido', + lastName: 'Akademie', + __typename: 'User', + }, + decay: { + decay: '-0.03517768386652623868', + start: '2022-02-23T10:55:30.000Z', + end: '2022-02-25T07:29:26.000Z', + duration: 160436, + __typename: 'Decay', + }, + __typename: 'Transaction', }, { - balance: 1.07, - type: 'decay', + id: 6, + typeId: 'RECEIVE', + amount: '10', + balance: '10', + balanceDate: '2022-02-23T10:55:30.000Z', + memo: 'asd adaaad adad addad ', + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + decay: { + decay: '0', + start: null, + end: null, + duration: null, + __typename: 'Decay', + }, + __typename: 'Transaction', }, ], - transactionCount: 12, + count: 12, }) }) it('renders 4 transactions', () => { - expect(wrapper.findAll('div.gdd-transaction-list-item')).toHaveLength(4) - }) - - describe('send transactions', () => { - let transaction - beforeEach(() => { - transaction = wrapper.findAll('div.gdd-transaction-list-item').at(0) - }) - - it('has a bi-caret-down-square icon', () => { - expect(transaction.findAll('svg').at(0).classes()).toEqual([ - 'bi-caret-down-square', - 'b-icon', - 'bi', - 'text-muted', - ]) - }) - - // it('transaction is clicked', async () => { - // await transaction.trigger('click') - // expect(transaction.findAll('svg').at(0).classes()).toEqual([ - // 'bi-caret-up-square', - // 'b-icon', - // 'bi', - // 'text-muted', - // ]) - // }) - - it('has a bi-arrow-left-circle icon', () => { - expect(transaction.findAll('svg').at(1).classes()).toContain('bi-arrow-left-circle') - }) - - it('has text-danger color', () => { - expect(transaction.findAll('svg').at(1).classes()).toContain('text-danger') - }) - - it('has a minus operator', () => { - expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( - '−', - ) - }) - - it('shows the amount of transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( - '19.93', - ) - }) - - it('shows the name of the receiver', () => { - expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain( - 'Bob der Baumeister', - ) - }) - - it('shows the message of the transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-message').at(0).text()).toContain( - 'Alles Gute zum Geburtstag', - ) - }) - - it('shows the date of the transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain( - 'Tue May 25 2021', - ) - }) - - it('shows the decay calculation', () => { - expect(transaction.findAll('div.gdd-transaction-list-item-decay').at(0).text()).toContain( - '− 0.5', - ) - }) - }) - - describe('creation transactions', () => { - let transaction - beforeEach(() => { - transaction = wrapper.findAll('div.gdd-transaction-list-item').at(1) - }) - - it('has a bi-caret-down-square icon', () => { - expect(transaction.findAll('svg').at(0).classes()).toEqual([ - 'bi-caret-down-square', - 'b-icon', - 'bi', - 'text-muted', - ]) - }) - - // it('transaction is clicked', async () => { - // await transaction.trigger('click') - // expect(transaction.findAll('svg').at(0).classes()).toEqual([ - // 'bi-caret-up-square', - // 'b-icon', - // 'bi', - // 'text-muted', - // ]) - // }) - - it('has a bi-gift icon', () => { - expect(transaction.findAll('svg').at(1).classes()).toContain('bi-gift') - }) - - it('has gradido-global-color-accent color', () => { - expect(transaction.findAll('svg').at(1).classes()).toContain( - 'gradido-global-color-accent', - ) - }) - - it('has a plus operator', () => { - expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( - '+', - ) - }) - - it('shows the amount of transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( - '1000', - ) - }) - - it('shows the name of the receiver', () => { - expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain( - 'Gradido Akademie', - ) - }) - - it('shows the date of the transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain( - 'Thu Apr 29 2021', - ) - }) - }) - - describe('receive transactions', () => { - let transaction - beforeEach(() => { - transaction = wrapper.findAll('div.gdd-transaction-list-item').at(2) - }) - - it('has a bi-caret-down-square icon', () => { - expect(transaction.findAll('svg').at(0).classes()).toEqual([ - 'bi-caret-down-square', - 'b-icon', - 'bi', - 'text-muted', - ]) - }) - - // it('transaction is clicked', async () => { - // await transaction.trigger('click') - // expect(transaction.findAll('svg').at(0).classes()).toEqual([ - // 'bi-caret-up-square', - // 'b-icon', - // 'bi', - // 'text-muted', - // ]) - // }) - - it('has a bi-arrow-right-circle icon', () => { - expect(transaction.findAll('svg').at(1).classes()).toContain('bi-arrow-right-circle') - }) - - it('has gradido-global-color-accent color', () => { - expect(transaction.findAll('svg').at(1).classes()).toContain( - 'gradido-global-color-accent', - ) - }) - - it('has a plus operator', () => { - expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( - '+', - ) - }) - - it('shows the amount of transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( - '314.98', - ) - }) - - it('shows the name of the recipient', () => { - expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain( - 'Jan Ulrich', - ) - }) - - it('shows the message of the transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-message').at(0).text()).toContain( - 'Für das Fahrrad!', - ) - }) - - it('shows the date of the transaction', () => { - expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain( - 'Thu Apr 29 2021', - ) - }) - - it('shows the decay calculation', () => { - expect(transaction.findAll('.gdd-transaction-list-item-decay').at(0).text()).toContain( - '− 1.5', - ) - }) + expect(wrapper.findAll('div.list-group-item')).toHaveLength(3) }) describe('decay transactions', () => { let transaction beforeEach(() => { - transaction = wrapper.findAll('div.gdd-transaction-list-item').at(3) + transaction = wrapper.findAll('div.list-group-item').at(0) }) it('has a bi-caret-down-square icon', () => { @@ -346,16 +194,6 @@ describe('GddTransactionList', () => { ]) }) - // it('transaction is clicked', async () => { - // await transaction.trigger('click') - // expect(transaction.findAll('svg').at(0).classes()).toEqual([ - // 'bi-caret-up-square', - // 'b-icon', - // 'bi', - // 'text-muted', - // ]) - // }) - it('has a bi-droplet-half icon', () => { expect(transaction.findAll('svg').at(1).classes()).toContain('bi-droplet-half') }) @@ -364,15 +202,9 @@ describe('GddTransactionList', () => { expect(transaction.findAll('svg').at(1).classes()).toContain('gradido-global-color-gray') }) - it('has a minus operator', () => { - expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( - '−', - ) - }) - it('shows the amount of transaction', () => { expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( - '1.07', + '0.16778637075575395', ) }) @@ -382,38 +214,206 @@ describe('GddTransactionList', () => { ) }) }) - }) - describe('with invalid transaction type', () => { - beforeEach(async () => { - await wrapper.setProps({ - transactions: [ - { - balance: '19.93', - date: '2021-05-25T17:38:13+00:00', - memo: 'Alles Gute zum Geburtstag', - name: 'Bob der Baumeister', - transaction_id: 29, - type: 'invalid', - }, - ], + describe('send transactions', () => { + let transaction + beforeEach(() => { + transaction = wrapper.findAll('div.list-group-item').at(1) + }) + + it('has a bi-caret-down-square icon', () => { + expect(transaction.findAll('svg').at(0).classes()).toEqual([ + 'bi-caret-down-square', + 'b-icon', + 'bi', + 'text-muted', + ]) + }) + + it('has a bi-arrow-left-circle icon', () => { + expect(transaction.findAll('svg').at(1).classes()).toContain('bi-arrow-left-circle') + }) + + it('has text-danger color', () => { + expect(transaction.findAll('svg').at(1).classes()).toContain('text-danger') + }) + + // it('has a minus operator', () => { + // expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( + // '-', + // ) + // }) + + it('shows the amount of transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( + '1', + ) + }) + + it('shows the name of the receiver', () => { + expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain( + 'Bibi Bloxberg', + ) + }) + + it('shows the message of the transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-message').at(0).text()).toContain( + 'adasd adada', + ) + }) + + it('shows the date of the transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain( + 'Mon Feb 28 2022 13:55:47 GMT+0000 (Coordinated Universal Time)', + ) + }) + + it('shows the decay calculation', () => { + expect(transaction.findAll('div.gdd-transaction-list-item-decay').at(0).text()).toContain( + '− 0.20383140554826432', + ) }) }) - it('throws an error', () => { - expect(errorHandler).toHaveBeenCalled() + describe('creation transactions', () => { + let transaction + + beforeEach(() => { + transaction = wrapper.findAll('div.list-group-item').at(2) + }) + + it('has a bi-caret-down-square icon', () => { + expect(transaction.findAll('svg').at(0).classes()).toEqual([ + 'bi-caret-down-square', + 'b-icon', + 'bi', + 'text-muted', + ]) + }) + + it('has a bi-gift icon', () => { + expect(transaction.findAll('svg').at(1).classes()).toEqual([ + 'bi-arrow-right-circle', + 'gradido-global-color-accent', + 'm-mb-1', + 'font2em', + 'b-icon', + 'bi', + ]) + }) + + it('has gradido-global-color-accent color', () => { + expect(transaction.findAll('svg').at(1).classes()).toContain( + 'gradido-global-color-accent', + ) + }) + + it('has a plus operator', () => { + expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( + '+', + ) + }) + + it('shows the amount of transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( + '10', + ) + }) + + it('shows the name of the receiver', () => { + expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain( + 'Bibi Bloxberg', + ) + }) + + it('shows the date of the transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain( + 'Wed Feb 23 2022 10:55:30 GMT+0000 (Coordinated Universal Time)', + ) + }) + }) + + describe('receive transactions', () => { + let transaction + beforeEach(() => { + transaction = wrapper.findAll('div.list-group-item').at(2) + }) + + it('has a bi-caret-down-square icon', () => { + expect(transaction.findAll('svg').at(0).classes()).toEqual([ + 'bi-caret-down-square', + 'b-icon', + 'bi', + 'text-muted', + ]) + }) + + it('has a bi-arrow-right-circle icon', () => { + expect(transaction.findAll('svg').at(1).classes()).toContain('bi-arrow-right-circle') + }) + + it('has gradido-global-color-accent color', () => { + expect(transaction.findAll('svg').at(1).classes()).toEqual([ + 'bi-arrow-right-circle', + 'gradido-global-color-accent', + 'm-mb-1', + 'font2em', + 'b-icon', + 'bi', + ]) + }) + + it('has a plus operator', () => { + expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain( + '+', + ) + }) + + it('shows the amount of transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain( + '10', + ) + }) + + it('shows the name of the recipient', () => { + expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain( + 'Bibi Bloxberg', + ) + }) + + it('shows the message of the transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-message').at(0).text()).toContain( + 'asd adaaad adad addad', + ) + }) + + it('shows the date of the transaction', () => { + expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain( + 'Wed Feb 23 2022 10:55:30 GMT+0000 (Coordinated Universal Time)', + ) + }) + + it('shows the decay calculation', () => { + expect(transaction.findAll('.gdd-transaction-list-item-decay').at(0).text()).toContain( + '0', + ) + }) }) }) describe('pagination buttons', () => { const transactions = Array.from({ length: 42 }, (_, idx) => { return { - balance: '3.14', - date: '2021-04-29T17:26:40+00:00', + amount: '3.14', + balanceDate: '2021-04-29T17:26:40+00:00', memo: 'Kreiszahl PI', - name: 'Euklid', - transaction_id: idx + 1, - type: 'receive', + linkedUser: { + firstName: 'Bibi', + lastName: 'Bloxberg', + __typename: 'User', + }, + id: idx + 1, + typeId: 'RECEIVE', } }) diff --git a/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue b/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue index db24e90ba..bd66630eb 100644 --- a/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue +++ b/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue @@ -11,198 +11,76 @@ {{ $t('error.empty-transactionlist') }} -
-
- -
- + + + + - - - - -
- - {{ getProperties(type).operator }} - - - {{ $n(balance, 'decimal') }} - -
-
- -
- {{ type !== 'decay' ? name : $t('decay.decay_since_last_transaction') }} -
-
-
+ - - - -
{{ $t('form.memo') }}
-
- -
{{ memo }}
-
-
- - - - -
{{ $t('form.date') }}
-
- -
- {{ $d(new Date(date), 'long') }} {{ $i18n.locale === 'de' ? 'Uhr' : '' }} -
-
-
- - - - -
- -
-
- -
- -
-
-
- - -
- -
-
- -
- {{ $t('decay.Starting_block_decay') }} -
-
-
-
- -
- - - - -
- -
- {{ $t('decay.first_transaction') }} -
- -
- {{ $t('decay.befor_startblock_transaction') }} -
-
- -
-
-
- - -
-
- -
- {{ $t('transaction.nullTransactions') }} + +
+ +
+ {{ $t('transaction.nullTransactions') }} +