Skip to content

Commit

Permalink
Use correct sign when comparing balance (#77)
Browse files Browse the repository at this point in the history
* Don't display 0 when there are no settlement finalization report warnings

* Display a tick for a validated report

* Reset validation results when selecting a different report

* Use correct sign when comparing balance and improve message to user
  • Loading branch information
partiallyordered authored Dec 10, 2021
1 parent 202eaa0 commit 79af318
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions helm/finance-portal-v2-ui/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "v3.0.0"
appVersion: "v3.0.1"
description: Mojaloop Finance Portal UI v2
name: finance-portal-v2-ui
version: 3.0.0
version: 3.0.1
2 changes: 1 addition & 1 deletion helm/finance-portal-v2-ui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: ghcr.io/mojaloop/finance-portal-v2-ui
tag: v3.0.0
tag: v3.0.1
pullPolicy: IfNotPresent

imagePullCredentials:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "finance-portal-v2-ui",
"version": "3.0.0",
"version": "3.0.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/App/Settlements/SettlementFinalizingModal/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const dispatchProps = (dispatch: Dispatch) => ({
dispatch(actions.setSettlementFinalizingInProgress(true));
dispatch(actions.finalizeSettlement(settlement));
},
onSelectSettlementReport: (report: SettlementReport) => dispatch(actions.setSettlementReport(report || null)),
onSelectSettlementReport: (report: SettlementReport) => {
dispatch(actions.setSettlementReportValidationErrors(null));
dispatch(actions.setSettlementReportValidationWarnings(null));
dispatch(actions.setSettlementReport(report || null));
},
onSettlementReportProcessingError: (err: string) => dispatch(actions.setSettlementReportError(err)),
onSetFundsInOutChange: (e: React.ChangeEvent<HTMLInputElement>) => {
dispatch(actions.setFinalizeProcessFundsInOut(e.target.checked));
Expand Down
37 changes: 19 additions & 18 deletions src/App/Settlements/SettlementFinalizingModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ const SettlementFinalizingModal: FC<ConnectorProps> = ({
}
}}
/>
{settlementReportValidationErrors?.length === 0 ? <>&nbsp;✅</> : <></>}
<br />
<Button
pending={settlementFinalizingInProgress}
Expand Down Expand Up @@ -312,24 +313,24 @@ const SettlementFinalizingModal: FC<ConnectorProps> = ({
>
{content}
{settlementReportValidationWarnings?.length &&
settlementReportValidationWarnings?.length > 0 &&
settlementReportValidationErrors?.length === 0 && (
<Modal title="Settlement Report Validation Warnings" width="1200px" onClose={onClearSettlementReportWarnings}>
<ErrorBox>
<div>
<h3>Warning: the following was found in the settlement finalization report:</h3>
<hr />
{settlementReportValidationWarnings?.map((e: SettlementReportValidation) => (
<div key={hash(e)}>{displaySettlementReportValidation(e)}</div>
))}
<hr />
<h3>
These are not fatal errors. After closing this dialog, it will be possible to process the report.
</h3>
</div>
</ErrorBox>
</Modal>
)}
settlementReportValidationWarnings?.length > 0 &&
settlementReportValidationErrors?.length === 0 ? (
<Modal title="Settlement Report Validation Warnings" width="1200px" onClose={onClearSettlementReportWarnings}>
<ErrorBox>
<div>
<h3>Warning: the following was found in the settlement finalization report:</h3>
<hr />
{settlementReportValidationWarnings?.map((e: SettlementReportValidation) => (
<div key={hash(e)}>{displaySettlementReportValidation(e)}</div>
))}
<hr />
<h3>These are not fatal errors. After closing this dialog, it will be possible to process the report.</h3>
</div>
</ErrorBox>
</Modal>
) : (
<></>
)}
</Modal>
);
};
Expand Down
12 changes: 7 additions & 5 deletions src/App/Settlements/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ export function generateSettlementReportValidationDetail(val: SettlementReportVa
);
case SettlementReportValidationKind.BalanceNotAsExpected:
return (
`Row ${val.data.entry.row.rowNumber} of the report has a balance of ` +
`Row ${val.data.entry.row.rowNumber} of the report indicates a balance of ` +
`${val.data.reportBalance} and a transfer amount of ${val.data.transferAmount}. ` +
`${val.data.entry.participant.name} presently has a liquidity account balance of ` +
`${val.data.account.value}. Applying the transfer to this balance results in an ` +
`expected balance of ${val.data.expectedBalance}. The balance in the report is ` +
`${val.data.reportBalance}.`
`${Math.abs(val.data.account.value)}. Applying the transfer to this balance results in ` +
`an expected balance of ${val.data.expectedBalance}, not ${val.data.reportBalance} as ` +
`per the report.`
);
case SettlementReportValidationKind.AccountsNotPresentInReport: {
// prettier-ignore
Expand Down Expand Up @@ -683,7 +683,9 @@ export const validationFunctions = {
})
.filter((e): e is { entry: SettlementReportEntry; settlementAccount: AccountWithPosition } => e !== undefined)
.forEach(({ entry, settlementAccount }) => {
const expectedBalance = settlementAccount.value + entry.transferAmount;
// The switch uses negative numeric values to represent credit. The switch does not support
// debit settlement account balances. Therefore we use Math.abs here.
const expectedBalance = Math.abs(settlementAccount.value) + entry.transferAmount;
const reportBalance = entry.balance;
if (!equal(expectedBalance, reportBalance)) {
result.add({
Expand Down

0 comments on commit 79af318

Please sign in to comment.