From 678acb254c6c67a28b6645deac79fe3efe00e897 Mon Sep 17 00:00:00 2001 From: iaincrawf <51612225+iaincrawf@users.noreply.github.com> Date: Fri, 19 Nov 2021 11:35:11 +0000 Subject: [PATCH] Imp value mismatches (#298) * date function rename * allow save if duty or import total mismatch, but also show them in modal warning message (if needed) --- .../components/importBooks/ImpBookPrintOut.js | 8 +-- .../src/components/importBooks/ImportBook.js | 64 ++++++++++++++++--- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/Service.Host/client/src/components/importBooks/ImpBookPrintOut.js b/src/Service.Host/client/src/components/importBooks/ImpBookPrintOut.js index bf5a7eeb5..cca4c6d94 100644 --- a/src/Service.Host/client/src/components/importBooks/ImpBookPrintOut.js +++ b/src/Service.Host/client/src/components/importBooks/ImpBookPrintOut.js @@ -57,7 +57,7 @@ function ImpBookPrintOut({ })); const classes = useStyles(); - const getNicerDate = date => { + const dateToDdMmmYyyy = date => { return date ? moment(date).format('DD-MMM-YYYY') : '-'; }; @@ -73,7 +73,7 @@ function ImpBookPrintOut({ - Date Created: {getNicerDate(dateCreated)} + Date Created: {dateToDdMmmYyyy(dateCreated)} Created By:{' '} @@ -181,7 +181,7 @@ function ImpBookPrintOut({ Delivery Term Code: {deliveryTermCode} - Customs Entry Date: {getNicerDate(customsEntryCodeDate)} + Customs Entry Date: {dateToDdMmmYyyy(customsEntryCodeDate)} @@ -192,7 +192,7 @@ function ImpBookPrintOut({ - Arrival Date: {getNicerDate(arrivalDate)} + Arrival Date: {dateToDdMmmYyyy(arrivalDate)} Linn Vat: {linnVat} diff --git a/src/Service.Host/client/src/components/importBooks/ImportBook.js b/src/Service.Host/client/src/components/importBooks/ImportBook.js index 86cb9a2b4..c454e6e3f 100644 --- a/src/Service.Host/client/src/components/importBooks/ImportBook.js +++ b/src/Service.Host/client/src/components/importBooks/ImportBook.js @@ -346,9 +346,7 @@ function ImportBook({ !state.impbook.totalImportValue || !state.impbook.deliveryTermCode || !state.impbook.pva || - !state.impbook.foreignCurrency || - `${calcRemainingTotal()}` !== '0' || - `${calcRemainingDuty()}` !== '0' + !state.impbook.foreignCurrency ); }; @@ -357,6 +355,10 @@ function ImportBook({ const handleSaveClick = () => { if (`${calcRemainingWeight()}` !== '0' && !dialogOpen) { setDialogOpen(true); + } else if (`${calcRemainingTotal()}` !== '0' && !dialogOpen) { + setDialogOpen(true); + } else if (`${calcRemainingDuty()}` !== '0' && !dialogOpen) { + setDialogOpen(true); } else if (creating()) { addItem(state.impbook); setEditStatus('view'); @@ -386,8 +388,54 @@ function ImportBook({ textAlign: 'center' } })); + const classes = useStyles(); + const ImportValueMismatchWarning = () => { + if (`${calcRemainingTotal()}` !== '0') { + return ( + + + Import Value Mismatch! Difference of: {calcRemainingTotal()} +
+ (Import Book value is: {state.impbook?.totalImportValue}) +
+
+ ); + } + return <>; + }; + + const DutyMismatchWarning = () => { + if (`${calcRemainingDuty()}` !== '0') { + return ( + + + Duty Mismatch! Difference of: {calcRemainingDuty()} +
+ (Import Book tab duty is: {state.impbook?.linnDuty}) +
+
+ ); + } + return <>; + }; + + const WeightMismatchWarning = () => { + if (`${calcRemainingWeight()}` !== '0') { + return ( + + + Weight Mismatch! Difference of: {calcRemainingWeight()} +
+ (Import Book tab weight is: {state.impbook?.weight}) +
+
+ ); + } + return <>; + }; + return ( <>
@@ -440,13 +488,9 @@ function ImportBook({ Warning - - - Weight Mismatch! Difference of: {calcRemainingWeight()} -
- (Import Book tab weight is: {state.impbook?.weight}) -
-
+ + +