Merge pull request #687 from gradido/650-View-for-the-GDT-Transaction-List

650-display of the gdt transactions
This commit is contained in:
Alexander Friedland 2021-08-11 14:32:45 +02:00 committed by GitHub
commit e4b36ebc1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 385 additions and 98 deletions

View File

@ -25,7 +25,10 @@ class AppRequestsController extends AppController
$this->loadComponent('GradidoNumber');
//$this->loadComponent('JsonRpcRequestClient');
//$this->Auth->allow(['add', 'edit']);
$this->Auth->allow(['index', 'sendCoins', 'createCoins', 'getBalance', 'listTransactions', 'getDecayStartBlock']);
$this->Auth->allow([
'index', 'sendCoins', 'createCoins', 'getBalance',
'listTransactions','listGDTTransactions', 'getDecayStartBlock'
]);
}
@ -271,8 +274,6 @@ class AppRequestsController extends AppController
public function getBalance($session_id = 0)
{
$this->viewBuilder()->setLayout('ajax');
$this->response = $this->response->withType('application/json');
$login_result = $this->requestLogin($session_id, false);
if($login_result !== true) {
$this->set('body', $login_result);
@ -303,16 +304,12 @@ class AppRequestsController extends AppController
}
$body['decay_date'] = $now;
$this->addAdminError("AppRequests", "getBalance", $body, $user['id']);
$this->set('body', $body);
}
public function listTransactions($page = 1, $count = 25, $orderDirection = 'ASC', $session_id = 0)
{
$this->viewBuilder()->setLayout('ajax');
$this->response = $this->response->withType('application/json');
$startTime = microtime(true);
$login_result = $this->requestLogin($session_id, false);
@ -409,6 +406,49 @@ class AppRequestsController extends AppController
$this->set('body', $body);
}
public function listGDTTransactions($page = 1, $count = 25, $orderDirection = 'ASC', $session_id = 0)
{
$timeBegin = microtime(true);
$gdtSum = 0;
$gdtCount = -1;
$this->viewBuilder()->setLayout('ajax');
$login_result = $this->requestLogin($session_id, false);
if($login_result !== true) {
return $this->returnJson($login_result);
}
$session = $this->getRequest()->getSession();
$user = $session->read('StateUser');
if(!$user) {
return $this->returnJson(['state' => 'error', 'msg' => 'user not found', 'details' => 'exist a valid session cookie?']);
}
$gdtEntries = $this->JsonRequestClient->sendRequestGDT([
'email' => $user['email'],
'page' => $page,
'count' => $count,
'orderDirection' => $orderDirection
], 'GdtEntries' . DS . 'listPerEmailApi');
$transactions = [];
$result = ['state' => 'success'];
if('success' == $gdtEntries['state']) {
$timeEnd = microtime(true);
$gdtEntries['data']['timeUsed'] = $timeEnd - $timeBegin;
return $this->returnJson($gdtEntries['data']);
} else {
if($user) {
$this->addAdminError('StateBalancesController', 'ajaxGdtOverview', $gdtEntries, $user['id']);
} else {
$this->addAdminError('StateBalancesController', 'ajaxGdtOverview', $gdtEntries, 0);
}
}
return $this->returnJson(['state' => 'error', 'msg' => 'error by requesting gdt server', 'details' => $gdtEntries]);
}
public function getDecayStartBlock()
{
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');

View File

@ -65,36 +65,14 @@ class StateBalancesController extends AppController
if($update_balance_result['success'] !== true) {
$this->addAdminError('StateBalances', 'overview', $update_balance_result, $user['id']);
}
// sendRequestGDT
// listPerEmailApi
$gdtSum = 0;
//if('admin' === $user['role']) {
$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
//var_dump($gdtEntries);
if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
$gdtSum = intval($gdtEntries['data']['sum']);
} else {
if($user) {
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id']);
} else {
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, 0);
}
}
//}
//
//
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
$stateBalancesTable->updateBalances($user['id']);
$gdtSum = 0;
$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
$gdtSum = intval($gdtEntries['data']['sum']);
} else {

View File

@ -419,7 +419,7 @@ return [
'GroupAlias' => 'docker',
'GDTServer' => [
//'host' => 'gdt'
'host' => 'https://gdt.gradido.net' // staging
],
'API' => [
'allowedCaller' => ['login-server']

View File

@ -71,6 +71,7 @@ services:
- mariadb
networks:
- internal-net
- external-net
volumes:
- ./community_server/config/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
- ./community_server/src:/var/www/cakephp/src

View File

@ -125,6 +125,106 @@ Transaction:
- `creation_amount`: only for creation transaction, created account before decay
- `target_date`: only by creation transaction, target date for creation, start time for decay calculation (if < as global decay start time)
## List GDT Transactions
`GET http://localhost/api/listGDTTransactions/[1]/[25]/[DESC]/[session_id]`
Parts symbolized by [] are optional
- first parameter (1) is page for paging
- second parameter (25) is count for paging
- third parameter is ordering of resulting array, default is ASC
- fourth parameter is session_id (session will be searched in php session and GRADIDO_LOGIN cookie and if not found use this )
#### Paging
With count you say how many entrys you like to have in the result.
With page you say on which page you are.
For example 50 transactions are in db.
With 1/25 you get the first 25 transactions (1-25)
With 2/20 you get the second 20 transactions (21-40)
### Response
Assuming session was valid and gdt server was setup correct
{
"state": "success",
"count": 4,
"gdtEntries": [
{
"id": 1,
"amount": 99,
"date": "2020-01-01T13:47:12+00:00",
"email": "dariofrodo@gmx.de",
"comment": "",
"coupon_code": null,
"gdt_entry_type_id": 1,
"factor": 18,
"amount2": 0,
"factor2": 1,
"gdt": 1782
},
{
"id": 10,
"amount": 100.12,
"date": "2021-07-28T13:58:00+00:00",
"email": "tester2@gmail.com",
"comment": null,
"coupon_code": "",
"gdt_entry_type_id": 4,
"factor": 15,
"amount2": 0,
"factor2": 0.05,
"gdt": 75.09000000000002
},
{
"id": 6,
"amount": 1782,
"date": "2021-07-30T13:21:46+00:00",
"email": "dariofrodo@gmx.de",
"comment": "Event 20-20",
"coupon_code": null,
"gdt_entry_type_id": 7,
"factor": 0.2,
"amount2": 0,
"factor2": 1,
"gdt": 356.40000000000006
},
{
"id": 8,
"amount": 10,
"date": "2021-07-31T13:58:00+00:00",
"email": "tester1@gmail.com",
"comment": null,
"coupon_code": "",
"gdt_entry_type_id": 4,
"factor": 15,
"amount2": 0,
"factor2": 0.05,
"gdt": 7.5
}
],
"gdtSum": 2220.99,
"timeUsed": 0.012517929077148438
}
- `count`: Count of total gdt transactions for user
- `gdtEntries`: array with gdt entries, sort by date
- `amount`: amount of payed money in euro, expect by gdt_entry_type_id = 7, then it is GDT Sum for Global Modificator time span
- `date`: date of transaction with let create gdt transaction, date for picking factor and Global Modificator
- `email`: email of user which has payed money, for gdt_entry_type_id = 4 it is the email of user who was recruited
- `comment`: custom comment or Global Modificator name if gdt_entry_type_id = 7
- `gdt_entry_type_id`: type of gdt entry
(1) Form: Single GDT Entry directly created by admin via formular
(2) CVS: Created by importing a CVS-List with multiple GDT Entries
(3) Elopage: Automatic created by Elopage Transaction (with revenue > 0 and payment state success)
(4) Elopage Publisher: Automatic created by Elopage Transaction (with revenue > 0 and payment state success) for publisher
(5) Digistore: Automatic created by Digistore Transaction
(6) CVS2: Created by importing a CVS-List with multiple GDT Entries, other format (used by Bernds old Accounting Tool)
(7) Global Modificator: Global Modificator which grand percental bonus on GDT in possession in event time span
- `factor`: Mulitplication factor for calculating gdt, change(d) over time
- `amount2`: Bonus add amount for gdt, sparly used
- `factor2`: Bonus mulitplication factor used by elopage publisher entry
- `gdt`: GDT Value, calculatedt from other value: gdt = amount * factor * factor2 + amount2
- `gdtSum`: Total GDT Sum of user
- `timeUsed`: GDT Server isn't optimized, this is for easy checking if it is still fast enough
## Creation transaction
Makes a creation transaction to create new Gradido

View File

@ -342,7 +342,7 @@ Ein GDT Eintrag sieht so aus:
```
{
"id": 8857,
"amount": 1000, // = 10,00 Euro
"amount": 1000, // GDT
"date": "2020-06-17T14:12:00+00:00",
"email": "foerderkreis-1@gradido.org",
"comment": null,
@ -379,8 +379,10 @@ Bis zum 5. (Bernd ist 2.)
Diese Beziehung wird durch die connectEntries dargestellt.
Insbesondere durch den publishersPath, connect enthält einfach nur alle mögliche Daten.
# TODO
TODO: Update GDT-Server um paging und Zugriff auf alle Einträge zu erhalten, optimierter Zugriff
GET https://staging.gradido.net/state-balances/ajaxGdtTransactions
Liefert wenn alles in Ordnung ist:
wenn nicht type 7 dann "amount" in euro ansonsten in GDT

Binary file not shown.

Before

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="36px" height="36px" viewBox="0 0 36 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
<title>UI/icons/dark/github</title>
<desc>Created with Sketch.</desc>
<defs/>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="UI/icons/dark/github" fill="#182359">
<path d="M17.9985267,2 C9.16436969,2 2,9.16338746 2,18.0004911 C2,25.0695847 6.58405721,31.0660855 12.9420179,33.1818042 C13.7425335,33.3291384 14.0342552,32.8350778 14.0342552,32.4107554 C14.0342552,32.0306332 14.020504,31.0248319 14.0126462,29.6899843 C9.56217195,30.6564965 8.62316216,27.5447988 8.62316216,27.5447988 C7.89533135,25.696246 6.84631204,25.2041499 6.84631204,25.2041499 C5.3935971,24.2120998 6.95632156,24.2317444 6.95632156,24.2317444 C8.56226404,24.3447006 9.40697996,25.8809049 9.40697996,25.8809049 C10.834157,28.3256699 13.1522146,27.6194481 14.063722,27.2098591 C14.2090917,26.1765554 14.6226097,25.4713159 15.0793456,25.0715492 C11.5266276,24.6678535 7.7912152,23.294699 7.7912152,17.163633 C7.7912152,15.417232 8.41492986,13.9880905 9.43841125,12.8703152 C9.27339697,12.4656374 8.72433162,10.8380859 9.5955677,8.63593112 C9.5955677,8.63593112 10.9382731,8.20571534 13.9949661,10.2762516 C15.27088,9.9206851 16.6401056,9.7438841 18.0004911,9.7370085 C19.3598944,9.7438841 20.7281378,9.9206851 22.0060161,10.2762516 C25.0607447,8.20571534 26.4014856,8.63593112 26.4014856,8.63593112 C27.2746861,10.8380859 26.7256208,12.4656374 26.5615888,12.8703152 C27.5870346,13.9880905 28.2058381,15.417232 28.2058381,17.163633 C28.2058381,23.3104147 24.4645324,24.6629424 20.9010099,25.0587802 C21.4746309,25.5528408 21.9863716,26.5291752 21.9863716,28.0211793 C21.9863716,30.1604715 21.966727,31.8862457 21.966727,32.4107554 C21.966727,32.8390067 22.255502,33.3369962 23.0668222,33.180822 C29.4198717,31.0601921 34,25.0676202 34,18.0004911 C34,9.16338746 26.8356303,2 17.9985267,2" id="icons/icon-github"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="36px" height="36px" viewBox="0 0 36 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
<title>UI/icons/color/google</title>
<desc>Created with Sketch.</desc>
<defs/>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="UI/icons/color/google">
<g id="Group" transform="translate(2.000000, 2.000000)">
<path d="M32.4365525,16.6024012 C32.4365525,15.4515967 32.3313665,14.344128 32.1357206,13.2820585 L16.5492615,13.2820585 L16.5492615,19.5616128 L25.4557094,19.5616128 C25.0721312,21.5908257 23.9059692,23.3098098 22.1535707,24.4613022 L22.1535707,28.5341733 L27.5019274,28.5341733 C30.631561,25.7077204 32.4365525,21.5461142 32.4365525,16.6024012 L32.4365525,16.6024012 Z" id="Shape" fill="#4285F4"/>
<path d="M16.5492615,32.4674071 C21.0175621,32.4674071 24.7635856,31.0139403 27.5019274,28.5341733 L22.1535707,24.4613022 C20.6718508,25.4353244 18.7756982,26.0110706 16.5492615,26.0110706 C12.2387399,26.0110706 8.59088994,23.1557272 7.2893887,19.3181072 L1.76011213,19.3181072 L1.76011213,23.5244249 C4.48302664,28.8299569 10.0796222,32.4674071 16.5492615,32.4674071 L16.5492615,32.4674071 Z" id="Shape" fill="#34A853"/>
<path d="M7.2893887,19.3181072 C6.95840347,18.344085 6.77047118,17.3033395 6.77047118,16.2337035 C6.77047118,15.1640676 6.95840347,14.1233221 7.2893887,13.1492999 L7.2893887,8.94298219 L1.76011213,8.94298219 C0.639530783,11.1345322 0,13.6142992 0,16.2337035 C0,18.8531079 0.639530783,21.3328749 1.76011213,23.5244249 L7.2893887,19.3181072 L7.2893887,19.3181072 Z" id="Shape" fill="#FBBC05"/>
<path d="M16.5492615,6.4563365 C18.9790577,6.4563365 21.160615,7.27558824 22.8758478,8.88382548 L27.6225407,4.22764161 C24.755872,1.60892511 21.0098485,0 16.5492615,0 C10.0803235,0 4.48302664,3.63813805 1.76011213,8.94298219 L7.2893887,13.1492999 C8.59088994,9.31236774 12.2394411,6.4563365 16.5492615,6.4563365 Z" id="Shape" fill="#EA4335"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -40,8 +40,15 @@ const communityAPI = {
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`,
)
},
/* create: async (sessionId, email, amount, memo, target_date = new Date() ) => {
const payload = {
transactionsgdt: async (sessionId, firstPage = 1, items = 5, order = 'DESC') => {
return apiGet(
`${CONFIG.COMMUNITY_API_URL}listGDTTransactions/${firstPage}/${items}/${order}/${sessionId}`,
)
},
/* http://localhost/vue/public/json-example/admin_transactionGdt_list.json
http://localhost/state-balances/ajaxGdtOverview
create: async (sessionId, email, amount, memo, target_date = new Date() ) => {
const payload = {
sessionId,
email,
amount,

View File

@ -94,7 +94,9 @@
"show_all":"Alle <strong>{count}</strong> Transaktionen ansehen",
"nullTransactions":"Du hast noch keine Transaktionen auf deinem Konto.",
"more": "mehr",
"receiverNotFound":"Empfänger nicht gefunden"
"receiverNotFound":"Empfänger nicht gefunden",
"gdd-text":"Gradido Transaktionen",
"gdt-text":"Gradido Transform Transaktionen"
},
"site": {
"login": {
@ -165,5 +167,13 @@
"title": "Passwort zurücksetzen",
"text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünftig in der Gradido-App anmelden kannst.",
"not-authenticated": "Leider konnten wir dich nicht authentifizieren. Bitte wende dich an den Support."
},
"gdt": {
"gdt-received":"Gradido Transform (GDT) erhalten",
"factor":"Faktor",
"conversion-gdt-euro":"Umrechnung Euro / Gradido Transform (GDT)",
"calculation":"Berechnung der Gradido Transform",
"conversion":"Umrechnung",
"formula":"Berechungsformel"
}
}

View File

@ -94,7 +94,9 @@
"show_all":"View all <strong>{count}</strong> transactions.",
"nullTransactions":"You don't have any transactions on your account yet.",
"more": "more",
"receiverNotFound":"Recipient not found"
"receiverNotFound":"Recipient not found",
"gdd-text":"Gradido Transactions",
"gdt-text":"Gradido Transform Transactions"
},
"site": {
"login": {
@ -166,5 +168,13 @@
"title": "Reset Password",
"text": "Now you can save a new password to login to the Gradido-App in the future.",
"not-authenticated": "Unfortunately we could not authenticate you. Please contact the support."
}
},
"gdt": {
"gdt-received": "Gradido Transform (GDT) received",
"factor": "Factor",
"conversion-gdt-euro": "Conversion Euro / Gradido Transform (GDT)",
"calculation": "Calculation of Gradido Transform",
"conversion": "Conversion",
"formula": "Calculation formula"
}
}

View File

@ -49,7 +49,6 @@
<div @click="$sidebar.displaySidebar(false)">
<fade-transition :duration="200" origin="center top" mode="out-in">
<!-- your content here -->
<router-view
:balance="balance"
:gdt-balance="GdtBalance"
@ -71,7 +70,6 @@ import 'perfect-scrollbar/css/perfect-scrollbar.css'
import loginAPI from '../../apis/loginAPI'
import ContentFooter from './ContentFooter.vue'
// import DashboardContent from './Content.vue';
import { FadeTransition } from 'vue2-transitions'
import communityAPI from '../../apis/communityAPI'
import VueQrcode from 'vue-qrcode'
@ -138,7 +136,7 @@ export default {
this.pending = false
} else {
this.pending = true
// what to do when loading balance fails?
this.$toasted.error(result.result.message)
}
},
updateBalance(ammount) {
@ -150,9 +148,3 @@ export default {
},
}
</script>
<style lang="scss">
.xxx {
position: relative;
right: 0px;
}
</style>

View File

@ -125,9 +125,3 @@ export default {
},
}
</script>
<style>
.active {
background-color: rgba(192, 192, 192, 0.568);
}
</style>

View File

@ -24,8 +24,7 @@
{{ $t('form.memo') }}
</small>
</div>
<div v-if="decay">
<br />
<div v-if="decay" class="text-sm">
<b-icon v-if="type != 'decay'" icon="droplet-half" height="15" class="mb-3" />
</div>
</div>

View File

@ -0,0 +1,149 @@
<template>
<div class="gdt-transaction-list">
<b-list-group>
<b-list-group-item
v-for="{
id,
amount,
date,
/*email,*/
comment,
/*coupon_code,*/
gdt_entry_type_id,
factor,
/*amount2,*/
/*factor2,*/
gdt,
} in this.transactionsGdt"
:key="id"
>
<!-- ROW Start -->
<div class="d-flex gdt-transaction-list-item" v-b-toggle="'a' + date + ''">
<!-- ICON -->
<div style="width: 8%"></div>
<!-- Text Links -->
<div class="font1_2em pr-2 text-right" style="width: 36%">
<div>
<div>
<span v-if="gdt_entry_type_id != 7">-</span>
{{ $n(amount, 'decimal') }}
</div>
<div v-if="gdt_entry_type_id != 7">+{{ $n(gdt, 'decimal') }}</div>
</div>
<div v-if="comment">
<small>
{{ $t('form.memo') }}
</small>
</div>
<div v-if="date" class="text-sm">
{{ $t('form.date') }}
</div>
<div v-if="gdt_entry_type_id != 7">
<small>{{ $t('gdt.factor') }}</small>
</div>
</div>
<!-- Text Rechts -->
<div class="font1_2em text-left pl-2" style="width: 55%">
<div>
<div v-if="gdt_entry_type_id != 7">EURO</div>
<div>GDT</div>
</div>
<div v-if="comment">
<small>
{{ comment }}
</small>
</div>
<div v-if="date" class="text-sm">
{{ $d($moment(date), 'long') }} {{ $i18n.locale === 'de' ? 'Uhr' : '' }}
</div>
<div v-if="gdt_entry_type_id != 7">
<small>{{ factor }}</small>
</div>
</div>
<!-- Collaps Toggle Button -->
<div v-if="gdt_entry_type_id" class="text-right" style="width: 5%">
<b-button class="btn-sm">
<b>i</b>
</b-button>
</div>
</div>
<!-- ROW End -->
<!-- Collaps Start -->
<b-collapse v-if="gdt_entry_type_id" :id="'a' + date + ''" class="pb-4">
<b-list-group style="border: 0px; background-color: #f1f1f1">
<div v-if="gdt_entry_type_id != '7'" class="text-center pt-3">
{{ $t('gdt.conversion-gdt-euro') }}
</div>
<div v-else class="text-center pt-3">
{{ $t('gdt.calculation') }}
</div>
<!--EURO / GDT -->
<b-list-group-item
v-if="gdt_entry_type_id != '7'"
style="border: 0px; background-color: #f1f1f1"
>
<div class="d-flex">
<div style="width: 40%" class="text-right pr-3 mr-2">
<div>{{ $t('gdt.factor') }}</div>
<div>{{ $t('gdt.conversion') }}</div>
</div>
<div style="width: 60%">
<div>{{ factor }}</div>
<div>{{ amount }} {{ gdt }} GDT</div>
</div>
</div>
</b-list-group-item>
<!-- Only GDT -->
<b-list-group-item v-else style="border: 0px; background-color: #f1f1f1">
<div class="d-flex">
<div style="width: 40%" class="text-right pr-3 mr-2">{{ $t('gdt.formula') }}:</div>
<div style="width: 60%">{{ amount }} GDT * {{ factor }} = {{ gdt }}</div>
</div>
</b-list-group-item>
</b-list-group>
</b-collapse>
<!-- Collaps End -->
</b-list-group-item>
</b-list-group>
</div>
</template>
<script>
import communityAPI from '../../../apis/communityAPI'
export default {
name: 'gdt-transaction-list',
data() {
return {
transactionsGdt: { default: () => [] },
transactionGdtCount: { type: Number, default: 0 },
}
},
methods: {
async updateGdt() {
const result = await communityAPI.transactionsgdt(this.$store.state.sessionId)
if (result.success) {
this.transactionsGdt = result.result.data.gdtEntries
this.transactionGdtCount = result.result.data.count
} else {
this.$toasted.error(result.result.message)
}
},
},
mounted() {
this.updateGdt()
},
}
</script>
<style>
.el-table .cell {
padding-left: 0px;
padding-right: 0px;
}
</style>

View File

@ -3,11 +3,31 @@ import UserProfileTransactionList from './UserProfileTransactionList'
const localVue = global.localVue
const mutationObserverMock = jest.fn(function MutationObserver(callback) {
this.observe = jest.fn()
this.disconnect = jest.fn()
this.trigger = (mockedMutationsList) => {
callback(mockedMutationsList, this)
}
})
global.MutationObserver = mutationObserverMock
describe('UserProfileTransactionList', () => {
let wrapper
const mocks = {
$t: jest.fn((t) => t),
$n: jest.fn((n) => String(n)),
$d: jest.fn((d) => d),
$i18n: {
locale: jest.fn(() => 'en'),
},
$store: {
state: {
sessionId: 1,
},
},
}
const Wrapper = () => {
@ -37,5 +57,9 @@ describe('UserProfileTransactionList', () => {
expect.arrayContaining([expect.arrayContaining([{ firstPage: 2, items: 25 }])]),
)
})
it('renders the transaction gradido transform table', () => {
expect(wrapper.findComponent({ name: 'GdtTransactionList' }).exists()).toBeTruthy()
})
})
})

View File

@ -1,29 +1,39 @@
<template>
<div>
<b-container fluid>
<b-row>
<b-col class="order-xl-1">
<gdd-transaction-list
:timestamp="timestamp"
:transactionCount="transactionCount"
:transactions="transactions"
:show-pagination="true"
@update-transactions="updateTransactions"
/>
</b-col>
</b-row>
</b-container>
<div class="pb-4">
<b-tabs content-class="mt-3 pt-4 pb-4" justified>
<b-tab :title="'Gradido (' + $n(balance, 'decimal') + ' GDD)'" class="px-4">
<p class="tab-tex">{{ $t('transaction.gdd-text') }}</p>
<gdd-transaction-list
:timestamp="timestamp"
:transactionCount="transactionCount"
:transactions="transactions"
:show-pagination="true"
@update-transactions="updateTransactions"
/>
</b-tab>
<b-tab :title="'Gradido Transform (' + $n(GdtBalance, 'decimal') + ' GDT)'" class="px-4">
<p class="">{{ $t('transaction.gdt-text') }}</p>
<gdt-transaction-list />
</b-tab>
</b-tabs>
</div>
</template>
<script>
import GddTransactionList from './AccountOverview/GddTransactionList.vue'
import GdtTransactionList from './AccountOverview/GdtTransactionList.vue'
export default {
name: 'UserProfileTransactionList',
components: {
GddTransactionList,
GdtTransactionList,
},
props: {
balance: { type: Number, default: 0 },
GdtBalance: { type: Number, default: 0 },
transactions: {
default: () => [],
},