From aafd046063cfd8c1b4418d2915548abd03c668b4 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 9 Jan 2020 02:26:35 +0100 Subject: [PATCH] show rounded decimals for default values; handle zero as normal input --- .../components/SingleIncidentsTable.js | 6 +++--- services/integration/bookingChangeCharges.js | 2 +- services/integration/doorLockCharges.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js index 1324972..d15dee2 100644 --- a/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js +++ b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js @@ -292,12 +292,12 @@ class SingleIncidentsTable extends Component { totalFee = changedFee; priceFontColor = 'red'; }else{ - totalFee = (props.row['_original'].incidentPrice || props.value) || 0; + totalFee = parseFloat((props.row['_original'].incidentPrice || props.value) || 0).toFixed(2); } - const totalFeeFormatted = parseFloat(totalFee).toFixed(2); + // const totalFeeFormatted = parseFloat(totalFee).toFixed(2); priceAsNumber = totalFee; priceInputID = `${props.row['_original'].incidentType || ''}-${props.row['_original'].incidentId || ''}`; - cellValue = `$ ${totalFeeFormatted}`; + // cellValue = `$ ${totalFeeFormatted}`; columnContentsAlignment = columnAlignments.right; break; case 'oldReservation': diff --git a/services/integration/bookingChangeCharges.js b/services/integration/bookingChangeCharges.js index 9d760bd..93e5361 100644 --- a/services/integration/bookingChangeCharges.js +++ b/services/integration/bookingChangeCharges.js @@ -289,7 +289,7 @@ const updateBookingChangeIncidentsById = (incidentFees) => { const asyncUpdateActions = []; incidentIds.forEach((incidentId) => { - const newFeeCharge = incidentFees[incidentId] ? parseFloat(incidentFees[incidentId]) : null; + const newFeeCharge = parseFloat(incidentFees[incidentId]); if (newFeeCharge || (newFeeCharge === 0)){ asyncUpdateActions.push(db.bookingChangeIncident.update({chargeFee: newFeeCharge}, {where: {id: incidentId}})); diff --git a/services/integration/doorLockCharges.js b/services/integration/doorLockCharges.js index a506b27..b18d95c 100644 --- a/services/integration/doorLockCharges.js +++ b/services/integration/doorLockCharges.js @@ -86,7 +86,7 @@ const updateUnscheduledIncidentsById = (incidentFees) => { const asyncUpdateActions = []; incidentIds.forEach((incidentId) => { - const newFeeCharge = incidentFees[incidentId] ? parseFloat(incidentFees[incidentId]) : null; + const newFeeCharge = parseFloat(incidentFees[incidentId]); if (newFeeCharge || (newFeeCharge === 0)){ asyncUpdateActions.push(db.unscheduledIncident.update({ @@ -150,7 +150,7 @@ const updateUnlockedIncidentsById = (incidentFees) => { const asyncUpdateActions = []; incidentIds.forEach((incidentId) => { - const newFeeCharge = incidentFees[incidentId] ? parseFloat(incidentFees[incidentId]) : null; + const newFeeCharge = parseFloat(incidentFees[incidentId]); if (newFeeCharge || (newFeeCharge === 0)){ asyncUpdateActions.push(db.unlockedIncident.update({incidentLevelPrice: newFeeCharge}, {where: {id: incidentId}}));