Skip to content

Commit 3c79824

Browse files
authored
Some improvements in settlements demo (#111)
* Some improvements in settlements demo * Bumped up the version
1 parent da44096 commit 3c79824

File tree

9 files changed

+195
-22
lines changed

9 files changed

+195
-22
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ml-testing-toolkit-ui",
3-
"version": "13.1.0",
3+
"version": "13.1.1",
44
"description": "Mojaloop Testing Toolkit Web User Interface",
55
"main": "index.js",
66
"repository": {

src/services/demos/MobileSimulator/mojaloopOutbound.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class OutboundService {
100100
// Replace corresponding values in inputValues
101101
template.inputValues.amount = amount + ''
102102
template.inputValues.currency = currency + ''
103+
template.inputValues.fromFirstName = 'Vijay'
104+
template.inputValues.fromLastName = 'Kumar'
103105
const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } })
104106
// if(typeof response.data === 'object') {
105107
// return response.data

src/services/demos/MobileSimulator/template_executeSettlement.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
"if(environment.winstate===\"PENDING_SETTLEMENT\"){",
289289
"",
290290
"res.participants.map(function (participant) {",
291-
" participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {",
291+
" participant.accounts.forEach(curAccount => {",
292292
"//for(const curAccount of account) { ",
293293
"",
294294
" dfspsacc[i] = {",
@@ -324,7 +324,7 @@
324324
" console.log(\"Window is empty\")",
325325
"}",
326326
"/*res.participants.map(participant => {",
327-
" participant.accounts.filter(account => account.netSettlementAmount.currency === pm.environment.get('SIMPAYER_CURRENCY'))",
327+
" participant.accounts",
328328
" .forEach(curAccount => {*/",
329329
" "
330330
]
@@ -383,7 +383,7 @@
383383
"",
384384
"",
385385
"res.participants.map(function (participant) {",
386-
" participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {",
386+
" participant.accounts.forEach(curAccount => {",
387387
"//for(const curAccount of account) { ",
388388
"",
389389
" dfspsacc[i] = {",
@@ -419,7 +419,7 @@
419419
" console.log(\"Window is empty\")",
420420
"}",
421421
"/*res.participants.map(participant => {",
422-
" participant.accounts.filter(account => account.netSettlementAmount.currency === pm.environment.get('SIMPAYER_CURRENCY'))",
422+
" participant.accounts",
423423
" .forEach(curAccount => {*/",
424424
" "
425425
]
@@ -473,7 +473,7 @@
473473
"",
474474
"",
475475
"res.participants.map(function (participant) {",
476-
" participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {",
476+
" participant.accounts.forEach(curAccount => {",
477477
"//for(const curAccount of account) { ",
478478
"",
479479
" dfspsacc[i] = {",
@@ -509,7 +509,7 @@
509509
" console.log(\"Window is empty\")",
510510
"}",
511511
"/*res.participants.map(participant => {",
512-
" participant.accounts.filter(account => account.netSettlementAmount.currency === pm.environment.get('SIMPAYER_CURRENCY'))",
512+
" participant.accounts",
513513
" .forEach(curAccount => {*/",
514514
" "
515515
]
@@ -563,7 +563,7 @@
563563
"",
564564
"",
565565
"res.participants.map(function (participant) {",
566-
" participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {",
566+
" participant.accounts.forEach(curAccount => {",
567567
"//for(const curAccount of account) { ",
568568
"",
569569
" dfspsacc[i] = {",

src/services/demos/MobileSimulator/template_provisioning.json

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,83 @@
897897
}
898898
]
899899
}
900+
},
901+
{
902+
"id": 27,
903+
"description": "Add participant second currency",
904+
"apiVersion": {
905+
"minorVersion": 3,
906+
"majorVersion": 9,
907+
"type": "central_admin"
908+
},
909+
"operationPath": "/participants",
910+
"path": "/participants",
911+
"method": "post",
912+
"body": {
913+
"name": "{$inputs.mobileSimPayerFsp}",
914+
"currency": "{$inputs.currency2}"
915+
},
916+
"headers": {
917+
"Content-Type": "application/json"
918+
},
919+
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
920+
"tests": {
921+
"assertions": [
922+
{
923+
"id": 1,
924+
"description": "status to be 201 if not exists or 400 if exists",
925+
"exec": [
926+
"if (response.body.errorInformation) {",
927+
" expect(response.status).to.equal(400)",
928+
"} else {",
929+
" expect(response.status).to.equal(201)",
930+
"}"
931+
]
932+
}
933+
]
934+
}
935+
},
936+
{
937+
"id": 28,
938+
"description": "Add initial position and limits second currency",
939+
"apiVersion": {
940+
"minorVersion": 3,
941+
"majorVersion": 9,
942+
"type": "central_admin"
943+
},
944+
"operationPath": "/participants/{name}/initialPositionAndLimits",
945+
"path": "/participants/{$inputs.mobileSimPayerFsp}/initialPositionAndLimits",
946+
"method": "post",
947+
"params": {
948+
"name": "{$inputs.mobileSimPayerFsp}"
949+
},
950+
"body": {
951+
"currency": "{$inputs.currency2}",
952+
"limit": {
953+
"type": "NET_DEBIT_CAP",
954+
"value": 1000000
955+
},
956+
"initialPosition": 0
957+
},
958+
"headers": {
959+
"Content-Type": "application/json"
960+
},
961+
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
962+
"tests": {
963+
"assertions": [
964+
{
965+
"id": 1,
966+
"description": "status to be 201 if not exists or 500 if exists",
967+
"exec": [
968+
"if (response.body.errorInformation) {",
969+
" expect(response.status).to.equal(500)",
970+
"} else {",
971+
" expect(response.status).to.equal(201)",
972+
"}"
973+
]
974+
}
975+
]
976+
}
900977
}
901978
]
902979
},
@@ -1796,6 +1873,83 @@
17961873
}
17971874
]
17981875
}
1876+
},
1877+
{
1878+
"id": 27,
1879+
"description": "Add participant second currency",
1880+
"apiVersion": {
1881+
"minorVersion": 3,
1882+
"majorVersion": 9,
1883+
"type": "central_admin"
1884+
},
1885+
"operationPath": "/participants",
1886+
"path": "/participants",
1887+
"method": "post",
1888+
"body": {
1889+
"name": "{$inputs.mobileSimPayeeFsp}",
1890+
"currency": "{$inputs.currency2}"
1891+
},
1892+
"headers": {
1893+
"Content-Type": "application/json"
1894+
},
1895+
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
1896+
"tests": {
1897+
"assertions": [
1898+
{
1899+
"id": 1,
1900+
"description": "status to be 201 if not exists or 400 if exists",
1901+
"exec": [
1902+
"if (response.body.errorInformation) {",
1903+
" expect(response.status).to.equal(400)",
1904+
"} else {",
1905+
" expect(response.status).to.equal(201)",
1906+
"}"
1907+
]
1908+
}
1909+
]
1910+
}
1911+
},
1912+
{
1913+
"id": 28,
1914+
"description": "Add initial position and limits second currency",
1915+
"apiVersion": {
1916+
"minorVersion": 3,
1917+
"majorVersion": 9,
1918+
"type": "central_admin"
1919+
},
1920+
"operationPath": "/participants/{name}/initialPositionAndLimits",
1921+
"path": "/participants/{$inputs.mobileSimPayeeFsp}/initialPositionAndLimits",
1922+
"method": "post",
1923+
"params": {
1924+
"name": "{$inputs.mobileSimPayeeFsp}"
1925+
},
1926+
"body": {
1927+
"currency": "{$inputs.currency2}",
1928+
"limit": {
1929+
"type": "NET_DEBIT_CAP",
1930+
"value": 1000000
1931+
},
1932+
"initialPosition": 0
1933+
},
1934+
"headers": {
1935+
"Content-Type": "application/json"
1936+
},
1937+
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
1938+
"tests": {
1939+
"assertions": [
1940+
{
1941+
"id": 1,
1942+
"description": "status to be 201 if not exists or 500 if exists",
1943+
"exec": [
1944+
"if (response.body.errorInformation) {",
1945+
" expect(response.status).to.equal(500)",
1946+
"} else {",
1947+
" expect(response.status).to.equal(201)",
1948+
"}"
1949+
]
1950+
}
1951+
]
1952+
}
17991953
}
18001954
]
18011955
}

src/utils/styleHelpers.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,18 @@ export const TTKColors = {
33
assertionFailed: '#f50',
44
assertionSkipped: '#f4c10b', // Or use #D7D700
55
}
6+
7+
export const hashRGB = (str) => {
8+
// Calculage hash
9+
var hash = 0;
10+
for (var i = 0; i < str.length; i++) {
11+
hash = str.charCodeAt(i) + ((hash << 12) - hash);
12+
}
13+
14+
var c = (hash & 0xFFFFFF)
15+
.toString(16)
16+
.toUpperCase();
17+
console.log(c, hash)
18+
19+
return '#' + "00000".substring(0, 6 - c.length) + c;
20+
}

src/views/demos/MobileSimulator/HUBConsole.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
******/
2424
import React from "react";
2525
import { Row, Col, Typography, Button, Table, Tag, Progress, Descriptions, Select } from 'antd';
26+
import { hashRGB } from '../../../utils/styleHelpers'
2627
const { Text, Title } = Typography
2728
const { Option } = Select;
2829

@@ -237,20 +238,21 @@ class HUBConsole extends React.Component {
237238

238239
const dfspValuesData = Object.entries(this.state.dfsps).map((dfspItem,index) => {
239240
const positionData = dfspItem[1].accountsData.filter(item => item.ledgerAccountType === 'POSITION').reduce((prevVal,currVal,idx) => {
240-
const detail = currVal.currency + ': ' + currVal.value
241-
return idx == 0 ? detail : prevVal + ', ' + detail
241+
const detail = <Tag color={hashRGB(currVal.currency)}>{currVal.currency + ': ' + currVal.value}</Tag>
242+
return idx == 0 ? detail : (<>{prevVal}<br />{detail}</>)
242243
}, '')
243244
const netDebitCapData = dfspItem[1].NET_DEBIT_CAP && Object.entries(dfspItem[1].NET_DEBIT_CAP).reduce((prevVal,currVal,idx) => {
244-
const detail = currVal[0] + ': ' + currVal[1]
245-
return idx == 0 ? detail : prevVal + ', ' + detail
245+
const detail = <Tag color={hashRGB(currVal[0])}>{currVal[0] + ': ' + currVal[1]}</Tag>
246+
return idx == 0 ? detail : (<>{prevVal}<br />{detail}</>)
246247
}, '')
247248
const settlementData = dfspItem[1].accountsData.filter(item => item.ledgerAccountType === 'SETTLEMENT').reduce((prevVal,currVal,idx) => {
248-
const detail = currVal.currency + ': ' + currVal.value
249-
return idx == 0 ? detail : prevVal + ', ' + detail
249+
const detail = <Tag color={hashRGB(currVal.currency)}>{currVal.currency + ': ' + currVal.value}</Tag>
250+
// const detail = currVal.currency + ': ' + currVal.value
251+
return idx == 0 ? detail : (<>{prevVal}<br />{detail}</>)
250252
}, '')
251253
const interchangeFeeData = dfspItem[1].accountsData.filter(item => item.ledgerAccountType === 'INTERCHANGE_FEE').reduce((prevVal,currVal,idx) => {
252-
const detail = currVal.currency + ': ' + currVal.value
253-
return idx == 0 ? detail : prevVal + ', ' + detail
254+
const detail = <Tag color={hashRGB(currVal.currency)}>{currVal.currency + ': ' + currVal.value}</Tag>
255+
return idx == 0 ? detail : (<>{prevVal}<br />{detail}</>)
254256
}, '')
255257
return {
256258
key: index,

src/views/demos/MobileSimulator/PayeeMobile.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PayeeMobile extends React.Component {
3737
}
3838

3939
resetState = () => {
40-
this.setState({receivedAmount: null, payerComplexName: null, stage: null})
40+
this.setState({receivedAmount: null, payeeReceiveAmount: null, payerComplexName: null, stage: null})
4141
}
4242

4343
handleNotificationEvents = (event) => {
@@ -70,7 +70,7 @@ class PayeeMobile extends React.Component {
7070
// }
7171
case 'payeePutQuotes':
7272
{
73-
this.setState({payeeReceiveAmount: event.data.requestBody && event.data.requestBody.payeeReceiveAmount && event.data.requestBody.payeeReceiveAmount.amount})
73+
this.setState({payeeReceiveAmount: event.data.requestBody && event.data.requestBody.payeeReceiveAmount})
7474
break
7575
}
7676
// case 'payeePutQuotesResponse':
@@ -109,8 +109,8 @@ class PayeeMobile extends React.Component {
109109
<Col span={24} className='text-center'>
110110
<Result
111111
status="success"
112-
title={'Received ' + this.state.receivedAmount}
113-
subTitle={'from ' + this.state.payerComplexName.lastName}
112+
title={'Received ' + this.state.receivedAmount.amount + ' ' + this.state.receivedAmount.currency}
113+
subTitle={'from ' + this.state.payerComplexName.firstName}
114114
/>
115115
</Col>
116116
</Row>

src/views/demos/MobileSimulator/PayerMobile.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class PayerMobile extends React.Component {
246246
? (
247247
<Result
248248
status="success"
249-
title={'Sent $' + this.state.amount}
249+
title={'Sent ' + this.state.amount + ' ' + this.state.selectedCurrency}
250250
subTitle={this.state.partyInfo && this.state.partyInfo.personalInfo && this.state.partyInfo.personalInfo.complexName && 'to ' + this.state.partyInfo.personalInfo.complexName.lastName}
251251
/>
252252
)

0 commit comments

Comments
 (0)