diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-04-26 16:20:08 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-04-26 16:20:08 +0530 |
commit | 66b4673b4e05275643353026275360001e4a9172 (patch) | |
tree | e3de21ac4ba854fd756afa2ced0965bc2bf041c0 /src/components/Display/SummaryDisplay.js | |
parent | e2c31632d326f5f201172dba08b06b422abfa593 (diff) |
minor ui changes
Diffstat (limited to 'src/components/Display/SummaryDisplay.js')
-rw-r--r-- | src/components/Display/SummaryDisplay.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/components/Display/SummaryDisplay.js b/src/components/Display/SummaryDisplay.js index aabd111..97c24b5 100644 --- a/src/components/Display/SummaryDisplay.js +++ b/src/components/Display/SummaryDisplay.js @@ -20,14 +20,16 @@ const getBasicSummary = (items) => { const getFullSummary = (items) => { let totalRawPrice = 0; - let totalDiscountPrice = 0; // to be subtracted from totalRawPrice + let totalDiscount = 0; // to be subtracted from totalRawPrice + let totalTax = 0; for (let i = 0; i < items.length; i++) { const itemTotalPrice = items[i].TotalPrice; const itemDiscount = items[i].Discount; totalRawPrice += itemTotalPrice; - totalDiscountPrice += (itemDiscount / 100) * itemTotalPrice; + totalDiscount += (itemDiscount / 100) * itemTotalPrice; + totalTax += (items[i].GST / 100) * itemTotalPrice; } // TODO: add support for calculating gst from TotalPriceAfterDiscount @@ -35,7 +37,10 @@ const getFullSummary = (items) => { return ( { "TotalRawPrice": totalRawPrice, - "TotalPriceAfterDiscount": totalRawPrice - totalDiscountPrice + "TotalDiscountPrice": totalDiscount, + "TotalPriceAfterDiscount": totalRawPrice - totalDiscount, + "TotalTaxAmount": totalTax, + "TotalPrice": (totalRawPrice - totalDiscount) + totalTax, } ); } @@ -61,10 +66,12 @@ const SummaryDisplay = (props) => { const summary = getFullSummary(props.items); return ( - <> - <p>Total: {summary.TotalRawPrice}</p> - <p>Total after discount: {summary.TotalPriceAfterDiscount}</p> - </> + <div className={"SummaryDisplay"}> + <p>Total raw: {summary.TotalRawPrice}</p> + <p>Total after discount: {summary.TotalRawPrice} - {summary.TotalDiscountPrice} = {summary.TotalPriceAfterDiscount}</p> + <p>Total tax: {summary.TotalTaxAmount}</p> + <p>Total: {summary.TotalPriceAfterDiscount} + {summary.TotalTaxAmount} = {summary.TotalPrice}</p> + </div> ); } |