From 0bcae00ca2f929eca864a76edbab00bb2faac1aa Mon Sep 17 00:00:00 2001 From: vijayg10 <33152110+vijayg10@users.noreply.github.com> Date: Mon, 21 Feb 2022 10:37:46 -0800 Subject: [PATCH] Added filename to funds-in-out API calls (#12) --- docs/external-api.md | 11 ++++++++++- src/App/DFSPs/sagas.ts | 1 - .../Settlements/SettlementFinalizingModal/index.tsx | 1 + src/App/Settlements/sagas.ts | 7 +++++-- src/App/Settlements/types.ts | 1 + webpack.config.js | 9 +++++---- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/external-api.md b/docs/external-api.md index d03e3c5..a6a7c47 100644 --- a/docs/external-api.md +++ b/docs/external-api.md @@ -1,6 +1,6 @@ ## External API -`reporting-hub-bop-settlements-ui` is reliant on two mojaloop services. +`reporting-hub-bop-settlements-ui` is reliant on three mojaloop services. When running locally, you can use the environment variables `CENTRAL_SETTLEMENTS_ENDPOINT`, `CENTRAL_LEDGER_ENDPOINT` and `REPORTING_API_ENDPOINT` in `.env` to specify the location of the api services. @@ -13,3 +13,12 @@ NOTE: These endpoints are a stopgap. In the future these environment variables for the Settlements microfrontend instead of calling Mojaloop services directly. For more information's on React variables check [here](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables). + + +## Port forwarding +If you want connect to the live services deployed in K8S, you can port forward the services using the following commands. +``` +kubectl port-forward -n mojaloop service/moja-centralledger-service 3001:80 & +kubectl port-forward -n mojaloop service/moja-centralsettlement-service 3007:80 & +kubectl port-forward -n mojaloop service/bof-reporting-hub-bop-api-svc 3080:80 & +``` \ No newline at end of file diff --git a/src/App/DFSPs/sagas.ts b/src/App/DFSPs/sagas.ts index 3170566..dfeabf3 100644 --- a/src/App/DFSPs/sagas.ts +++ b/src/App/DFSPs/sagas.ts @@ -13,7 +13,6 @@ function* fetchDfsps() { variables: {}, }, }); - console.log(response); yield put(setDfsps(response.data.data.dfsps)); } catch (e) { yield put(setDfspsError(e.message)); diff --git a/src/App/Settlements/SettlementFinalizingModal/index.tsx b/src/App/Settlements/SettlementFinalizingModal/index.tsx index 188142b..c847791 100644 --- a/src/App/Settlements/SettlementFinalizingModal/index.tsx +++ b/src/App/Settlements/SettlementFinalizingModal/index.tsx @@ -216,6 +216,7 @@ const SettlementFinalizingModal: FC = ({ signal.addEventListener('abort', () => reject(new Error('aborted'))); readFileAsArrayBuffer(file) .then((fileBuf) => deserializeReport(fileBuf)) + .then((report) => ({ ...report, reportFileName: file.name })) .then(resolve, reject); }) .catch((err) => { diff --git a/src/App/Settlements/sagas.ts b/src/App/Settlements/sagas.ts index ee078cc..8b80eba 100644 --- a/src/App/Settlements/sagas.ts +++ b/src/App/Settlements/sagas.ts @@ -100,6 +100,9 @@ function* processAdjustments({ // One partial resolution to this problem might be to process the NDC updates serially and // perform all other processing concurrently. At the time of writing, modifying the following // (working) code to do so was not considered a priority. + + // @ts-ignore + const report: SettlementReport = yield select(getSettlementReport); const results: FinalizeSettlementProcessAdjustmentsError[] = []; for (let i = 0; i < adjustments.length; i++) { const adjustment = adjustments[i]; @@ -188,7 +191,7 @@ function* processAdjustments({ participantName: adjustment.participant.name, accountId: adjustment.settlementAccount.id, body: { - externalReference: description, + externalReference: report?.reportFileName, action: 'recordFundsIn', reason: description, amount: { @@ -219,7 +222,7 @@ function* processAdjustments({ participantName: adjustment.participant.name, accountId: adjustment.settlementAccount.id, body: { - externalReference: description, + externalReference: report?.reportFileName, action: 'recordFundsOutPrepareReserve', reason: description, amount: { diff --git a/src/App/Settlements/types.ts b/src/App/Settlements/types.ts index 6c0d93b..b3edb6a 100644 --- a/src/App/Settlements/types.ts +++ b/src/App/Settlements/types.ts @@ -304,6 +304,7 @@ export interface SettlementReportEntry { export interface SettlementReport { settlementId: SettlementId; entries: SettlementReportEntry[]; + reportFileName?: string; } export enum DateRanges { diff --git a/webpack.config.js b/webpack.config.js index 325d336..1c33aaf 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -20,6 +20,7 @@ const config = { const { ModuleFederationPlugin } = webpack.container; module.exports = { + // mode: "development", // Class names are needed for integration testing of the production build // `testcafe-react-selector` needs these classnames to be present optimization: { @@ -35,7 +36,7 @@ module.exports = { ], }, entry: './src/index', - devtool: 'cheap-module-source-map', + devtool: 'source-map', devServer: { disableHostCheck: true, // Enable gzip compression of generated files. @@ -66,21 +67,21 @@ module.exports = { '/central-settlements': { // For local testing update `target` to point to your // locally hosted or port-forwarded `central-settlements` service - target: 'http://host:port', + target: 'http://localhost:3007', pathRewrite: { '^/central-settlements': '/v2' }, secure: false, }, '/central-ledger': { // For local testing update `target` to point to your // locally hosted or port-forwarded `central-ledger` service - target: 'http://host:port', + target: 'http://localhost:3001', pathRewrite: { '^/central-ledger': '' }, secure: false, }, '/reporting-api': { // For local testing update `target` to point to your // locally hosted or port-forwarded `reporting-hub-bop-api-svc` service - target: 'http://localhost:port', + target: 'http://localhost:3080', pathRewrite: { '^/reporting-api': '' }, secure: false, },