Skip to content

Commit

Permalink
Imp value mismatches (#298)
Browse files Browse the repository at this point in the history
* date function rename

* allow save if duty or import total mismatch, but also show them in modal warning message (if needed)
  • Loading branch information
iaincrawf authored Nov 19, 2021
1 parent 260d5c5 commit 678acb2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function ImpBookPrintOut({
}));
const classes = useStyles();

const getNicerDate = date => {
const dateToDdMmmYyyy = date => {
return date ? moment(date).format('DD-MMM-YYYY') : '-';
};

Expand All @@ -73,7 +73,7 @@ function ImpBookPrintOut({
</Grid>

<Grid item xs={4}>
Date Created: <b>{getNicerDate(dateCreated)}</b>
Date Created: <b>{dateToDdMmmYyyy(dateCreated)}</b>
</Grid>
<Grid item xs={4}>
Created By:{' '}
Expand Down Expand Up @@ -181,7 +181,7 @@ function ImpBookPrintOut({
Delivery Term Code: <b>{deliveryTermCode}</b>
</Grid>
<Grid item xs={3}>
Customs Entry Date: <b>{getNicerDate(customsEntryCodeDate)}</b>
Customs Entry Date: <b>{dateToDdMmmYyyy(customsEntryCodeDate)}</b>
</Grid>

<Grid item xs={9}>
Expand All @@ -192,7 +192,7 @@ function ImpBookPrintOut({
</Grid>

<Grid item xs={9}>
Arrival Date: <b>{getNicerDate(arrivalDate)}</b>
Arrival Date: <b>{dateToDdMmmYyyy(arrivalDate)}</b>
</Grid>
<Grid item xs={3}>
Linn Vat: <b>{linnVat}</b>
Expand Down
64 changes: 54 additions & 10 deletions src/Service.Host/client/src/components/importBooks/ImportBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
};

Expand All @@ -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');
Expand Down Expand Up @@ -386,8 +388,54 @@ function ImportBook({
textAlign: 'center'
}
}));

const classes = useStyles();

const ImportValueMismatchWarning = () => {
if (`${calcRemainingTotal()}` !== '0') {
return (
<Grid item xs={12} className={classes.spaceAbove}>
<Typography variant="h6">
Import Value Mismatch! Difference of: {calcRemainingTotal()}
<br />
(Import Book value is: {state.impbook?.totalImportValue})
</Typography>
</Grid>
);
}
return <></>;
};

const DutyMismatchWarning = () => {
if (`${calcRemainingDuty()}` !== '0') {
return (
<Grid item xs={12} className={classes.spaceAbove}>
<Typography variant="h6">
Duty Mismatch! Difference of: {calcRemainingDuty()}
<br />
(Import Book tab duty is: {state.impbook?.linnDuty})
</Typography>
</Grid>
);
}
return <></>;
};

const WeightMismatchWarning = () => {
if (`${calcRemainingWeight()}` !== '0') {
return (
<Grid item xs={12} className={classes.spaceAbove}>
<Typography variant="h6">
Weight Mismatch! Difference of: {calcRemainingWeight()}
<br />
(Import Book tab weight is: {state.impbook?.weight})
</Typography>
</Grid>
);
}
return <></>;
};

return (
<>
<div className="pageContainer show-only-when-printing">
Expand Down Expand Up @@ -440,13 +488,9 @@ function ImportBook({
<Typography variant="h5">Warning</Typography>
</Grid>
<Grid item xs={12} />
<Grid item xs={12} className={classes.spaceAbove}>
<Typography variant="h6">
Weight Mismatch! Difference of: {calcRemainingWeight()}
<br />
(Import Book tab weight is: {state.impbook?.weight})
</Typography>
</Grid>
<ImportValueMismatchWarning />
<DutyMismatchWarning />
<WeightMismatchWarning />
<Grid item xs={12} />
<Grid item xs={12} container className={classes.spaceAbove}>
<Grid item xs={6}>
Expand Down

0 comments on commit 678acb2

Please sign in to comment.