From 3c798249ca357eaf638fac7dcca3eb3bb60203d7 Mon Sep 17 00:00:00 2001 From: vijayg10 <33152110+vijayg10@users.noreply.github.com> Date: Wed, 21 Jul 2021 18:07:41 +0530 Subject: [PATCH] Some improvements in settlements demo (#111) * Some improvements in settlements demo * Bumped up the version --- package-lock.json | 2 +- package.json | 2 +- .../demos/MobileSimulator/mojaloopOutbound.js | 2 + .../template_executeSettlement.json | 14 +- .../template_provisioning.json | 154 ++++++++++++++++++ src/utils/styleHelpers.js | 15 ++ .../demos/MobileSimulator/HUBConsole.jsx | 18 +- .../demos/MobileSimulator/PayeeMobile.jsx | 8 +- .../demos/MobileSimulator/PayerMobile.jsx | 2 +- 9 files changed, 195 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25818a94..903935d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ml-testing-toolkit-ui", - "version": "13.1.0", + "version": "13.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7b1e7172..848ef4d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ml-testing-toolkit-ui", - "version": "13.1.0", + "version": "13.1.1", "description": "Mojaloop Testing Toolkit Web User Interface", "main": "index.js", "repository": { diff --git a/src/services/demos/MobileSimulator/mojaloopOutbound.js b/src/services/demos/MobileSimulator/mojaloopOutbound.js index 34ceefed..478fe391 100644 --- a/src/services/demos/MobileSimulator/mojaloopOutbound.js +++ b/src/services/demos/MobileSimulator/mojaloopOutbound.js @@ -100,6 +100,8 @@ class OutboundService { // Replace corresponding values in inputValues template.inputValues.amount = amount + '' template.inputValues.currency = currency + '' + template.inputValues.fromFirstName = 'Vijay' + template.inputValues.fromLastName = 'Kumar' const resp = await axios.post(this.apiBaseUrl + "/api/outbound/template/" + traceId, template , { headers: { 'Content-Type': 'application/json' } }) // if(typeof response.data === 'object') { // return response.data diff --git a/src/services/demos/MobileSimulator/template_executeSettlement.json b/src/services/demos/MobileSimulator/template_executeSettlement.json index 1b90b808..c9243098 100644 --- a/src/services/demos/MobileSimulator/template_executeSettlement.json +++ b/src/services/demos/MobileSimulator/template_executeSettlement.json @@ -288,7 +288,7 @@ "if(environment.winstate===\"PENDING_SETTLEMENT\"){", "", "res.participants.map(function (participant) {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {", + " participant.accounts.forEach(curAccount => {", "//for(const curAccount of account) { ", "", " dfspsacc[i] = {", @@ -324,7 +324,7 @@ " console.log(\"Window is empty\")", "}", "/*res.participants.map(participant => {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === pm.environment.get('SIMPAYER_CURRENCY'))", + " participant.accounts", " .forEach(curAccount => {*/", " " ] @@ -383,7 +383,7 @@ "", "", "res.participants.map(function (participant) {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {", + " participant.accounts.forEach(curAccount => {", "//for(const curAccount of account) { ", "", " dfspsacc[i] = {", @@ -419,7 +419,7 @@ " console.log(\"Window is empty\")", "}", "/*res.participants.map(participant => {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === pm.environment.get('SIMPAYER_CURRENCY'))", + " participant.accounts", " .forEach(curAccount => {*/", " " ] @@ -473,7 +473,7 @@ "", "", "res.participants.map(function (participant) {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {", + " participant.accounts.forEach(curAccount => {", "//for(const curAccount of account) { ", "", " dfspsacc[i] = {", @@ -509,7 +509,7 @@ " console.log(\"Window is empty\")", "}", "/*res.participants.map(participant => {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === pm.environment.get('SIMPAYER_CURRENCY'))", + " participant.accounts", " .forEach(curAccount => {*/", " " ] @@ -563,7 +563,7 @@ "", "", "res.participants.map(function (participant) {", - " participant.accounts.filter(account => account.netSettlementAmount.currency === environment.SIMPAYER_CURRENCY).forEach(curAccount => {", + " participant.accounts.forEach(curAccount => {", "//for(const curAccount of account) { ", "", " dfspsacc[i] = {", diff --git a/src/services/demos/MobileSimulator/template_provisioning.json b/src/services/demos/MobileSimulator/template_provisioning.json index aae66993..db91d210 100644 --- a/src/services/demos/MobileSimulator/template_provisioning.json +++ b/src/services/demos/MobileSimulator/template_provisioning.json @@ -897,6 +897,83 @@ } ] } + }, + { + "id": 27, + "description": "Add participant second currency", + "apiVersion": { + "minorVersion": 3, + "majorVersion": 9, + "type": "central_admin" + }, + "operationPath": "/participants", + "path": "/participants", + "method": "post", + "body": { + "name": "{$inputs.mobileSimPayerFsp}", + "currency": "{$inputs.currency2}" + }, + "headers": { + "Content-Type": "application/json" + }, + "url": "{$inputs.HOST_CENTRAL_LEDGER}", + "tests": { + "assertions": [ + { + "id": 1, + "description": "status to be 201 if not exists or 400 if exists", + "exec": [ + "if (response.body.errorInformation) {", + " expect(response.status).to.equal(400)", + "} else {", + " expect(response.status).to.equal(201)", + "}" + ] + } + ] + } + }, + { + "id": 28, + "description": "Add initial position and limits second currency", + "apiVersion": { + "minorVersion": 3, + "majorVersion": 9, + "type": "central_admin" + }, + "operationPath": "/participants/{name}/initialPositionAndLimits", + "path": "/participants/{$inputs.mobileSimPayerFsp}/initialPositionAndLimits", + "method": "post", + "params": { + "name": "{$inputs.mobileSimPayerFsp}" + }, + "body": { + "currency": "{$inputs.currency2}", + "limit": { + "type": "NET_DEBIT_CAP", + "value": 1000000 + }, + "initialPosition": 0 + }, + "headers": { + "Content-Type": "application/json" + }, + "url": "{$inputs.HOST_CENTRAL_LEDGER}", + "tests": { + "assertions": [ + { + "id": 1, + "description": "status to be 201 if not exists or 500 if exists", + "exec": [ + "if (response.body.errorInformation) {", + " expect(response.status).to.equal(500)", + "} else {", + " expect(response.status).to.equal(201)", + "}" + ] + } + ] + } } ] }, @@ -1796,6 +1873,83 @@ } ] } + }, + { + "id": 27, + "description": "Add participant second currency", + "apiVersion": { + "minorVersion": 3, + "majorVersion": 9, + "type": "central_admin" + }, + "operationPath": "/participants", + "path": "/participants", + "method": "post", + "body": { + "name": "{$inputs.mobileSimPayeeFsp}", + "currency": "{$inputs.currency2}" + }, + "headers": { + "Content-Type": "application/json" + }, + "url": "{$inputs.HOST_CENTRAL_LEDGER}", + "tests": { + "assertions": [ + { + "id": 1, + "description": "status to be 201 if not exists or 400 if exists", + "exec": [ + "if (response.body.errorInformation) {", + " expect(response.status).to.equal(400)", + "} else {", + " expect(response.status).to.equal(201)", + "}" + ] + } + ] + } + }, + { + "id": 28, + "description": "Add initial position and limits second currency", + "apiVersion": { + "minorVersion": 3, + "majorVersion": 9, + "type": "central_admin" + }, + "operationPath": "/participants/{name}/initialPositionAndLimits", + "path": "/participants/{$inputs.mobileSimPayeeFsp}/initialPositionAndLimits", + "method": "post", + "params": { + "name": "{$inputs.mobileSimPayeeFsp}" + }, + "body": { + "currency": "{$inputs.currency2}", + "limit": { + "type": "NET_DEBIT_CAP", + "value": 1000000 + }, + "initialPosition": 0 + }, + "headers": { + "Content-Type": "application/json" + }, + "url": "{$inputs.HOST_CENTRAL_LEDGER}", + "tests": { + "assertions": [ + { + "id": 1, + "description": "status to be 201 if not exists or 500 if exists", + "exec": [ + "if (response.body.errorInformation) {", + " expect(response.status).to.equal(500)", + "} else {", + " expect(response.status).to.equal(201)", + "}" + ] + } + ] + } } ] } diff --git a/src/utils/styleHelpers.js b/src/utils/styleHelpers.js index f9ad8928..0afeb4c8 100644 --- a/src/utils/styleHelpers.js +++ b/src/utils/styleHelpers.js @@ -3,3 +3,18 @@ export const TTKColors = { assertionFailed: '#f50', assertionSkipped: '#f4c10b', // Or use #D7D700 } + +export const hashRGB = (str) => { + // Calculage hash + var hash = 0; + for (var i = 0; i < str.length; i++) { + hash = str.charCodeAt(i) + ((hash << 12) - hash); + } + + var c = (hash & 0xFFFFFF) + .toString(16) + .toUpperCase(); + console.log(c, hash) + + return '#' + "00000".substring(0, 6 - c.length) + c; +} \ No newline at end of file diff --git a/src/views/demos/MobileSimulator/HUBConsole.jsx b/src/views/demos/MobileSimulator/HUBConsole.jsx index 60e94f4d..2226bdd4 100644 --- a/src/views/demos/MobileSimulator/HUBConsole.jsx +++ b/src/views/demos/MobileSimulator/HUBConsole.jsx @@ -23,6 +23,7 @@ ******/ import React from "react"; import { Row, Col, Typography, Button, Table, Tag, Progress, Descriptions, Select } from 'antd'; +import { hashRGB } from '../../../utils/styleHelpers' const { Text, Title } = Typography const { Option } = Select; @@ -237,20 +238,21 @@ class HUBConsole extends React.Component { const dfspValuesData = Object.entries(this.state.dfsps).map((dfspItem,index) => { const positionData = dfspItem[1].accountsData.filter(item => item.ledgerAccountType === 'POSITION').reduce((prevVal,currVal,idx) => { - const detail = currVal.currency + ': ' + currVal.value - return idx == 0 ? detail : prevVal + ', ' + detail + const detail = {currVal.currency + ': ' + currVal.value} + return idx == 0 ? detail : (<>{prevVal}
{detail}) }, '') const netDebitCapData = dfspItem[1].NET_DEBIT_CAP && Object.entries(dfspItem[1].NET_DEBIT_CAP).reduce((prevVal,currVal,idx) => { - const detail = currVal[0] + ': ' + currVal[1] - return idx == 0 ? detail : prevVal + ', ' + detail + const detail = {currVal[0] + ': ' + currVal[1]} + return idx == 0 ? detail : (<>{prevVal}
{detail}) }, '') const settlementData = dfspItem[1].accountsData.filter(item => item.ledgerAccountType === 'SETTLEMENT').reduce((prevVal,currVal,idx) => { - const detail = currVal.currency + ': ' + currVal.value - return idx == 0 ? detail : prevVal + ', ' + detail + const detail = {currVal.currency + ': ' + currVal.value} + // const detail = currVal.currency + ': ' + currVal.value + return idx == 0 ? detail : (<>{prevVal}
{detail}) }, '') const interchangeFeeData = dfspItem[1].accountsData.filter(item => item.ledgerAccountType === 'INTERCHANGE_FEE').reduce((prevVal,currVal,idx) => { - const detail = currVal.currency + ': ' + currVal.value - return idx == 0 ? detail : prevVal + ', ' + detail + const detail = {currVal.currency + ': ' + currVal.value} + return idx == 0 ? detail : (<>{prevVal}
{detail}) }, '') return { key: index, diff --git a/src/views/demos/MobileSimulator/PayeeMobile.jsx b/src/views/demos/MobileSimulator/PayeeMobile.jsx index c565ede8..43c08084 100644 --- a/src/views/demos/MobileSimulator/PayeeMobile.jsx +++ b/src/views/demos/MobileSimulator/PayeeMobile.jsx @@ -37,7 +37,7 @@ class PayeeMobile extends React.Component { } resetState = () => { - this.setState({receivedAmount: null, payerComplexName: null, stage: null}) + this.setState({receivedAmount: null, payeeReceiveAmount: null, payerComplexName: null, stage: null}) } handleNotificationEvents = (event) => { @@ -70,7 +70,7 @@ class PayeeMobile extends React.Component { // } case 'payeePutQuotes': { - this.setState({payeeReceiveAmount: event.data.requestBody && event.data.requestBody.payeeReceiveAmount && event.data.requestBody.payeeReceiveAmount.amount}) + this.setState({payeeReceiveAmount: event.data.requestBody && event.data.requestBody.payeeReceiveAmount}) break } // case 'payeePutQuotesResponse': @@ -109,8 +109,8 @@ class PayeeMobile extends React.Component { diff --git a/src/views/demos/MobileSimulator/PayerMobile.jsx b/src/views/demos/MobileSimulator/PayerMobile.jsx index 893e5191..33f36759 100644 --- a/src/views/demos/MobileSimulator/PayerMobile.jsx +++ b/src/views/demos/MobileSimulator/PayerMobile.jsx @@ -246,7 +246,7 @@ class PayerMobile extends React.Component { ? ( )