diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-27 14:47:48 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-27 14:47:48 +0530 |
commit | eedde57b9caff20e1e7d25b43fcb8785e23b3e11 (patch) | |
tree | 3532d795ecf269083e613860c0b27e3689773678 /src/components/Display/DisplayItem.tsx | |
parent | 240d7d56459c656c86330755c7a0b9000a090f77 (diff) |
Fixed DisplayItem and now really big decimal numbers don't show up
Diffstat (limited to 'src/components/Display/DisplayItem.tsx')
-rw-r--r-- | src/components/Display/DisplayItem.tsx | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/components/Display/DisplayItem.tsx b/src/components/Display/DisplayItem.tsx new file mode 100644 index 0000000..448460b --- /dev/null +++ b/src/components/Display/DisplayItem.tsx @@ -0,0 +1,67 @@ +/* + * OpenBills - Self hosted browser app to generate and keep track of simple invoices + * Version - 0 + * Licensed under the MIT license - https://opensource.org/licenses/MIT + * + * Copyright (c) 2021 Vidhu Kant Sharma +*/ + +import React from "react"; +import { Item } from "./../../interfaces"; +import "./Display.scss"; + +interface Props { + defGSTValue: number + itemNumber: number + item: Item +} + +const DisplayItem: React.FC<Props> = (props) => { + const itemNumber = props.itemNumber; + const item = props.item; + + return ( + <tr> + <td>{itemNumber}</td> + <td className={"leftAlign"}>{item.Model}</td> + + <td className={ + // disable if no description + // and left align + item.Description === "" ? "leftAlign disabledBorder" : "leftAlign" + }> + {item.Description} + </td> + + <td>{item.HSN}</td> + <td>{item.Quantity}</td> + <td>{item.UnitPrice}</td> + + <td className={ + // check if discount is zero + item.Discount === 0 ? "disabledBorder hideContents" : "" + }> + <span className="multiValue"> + <span>{item.DiscountValue}</span> + <span>({item.Discount}%)</span> + </span> + </td> + + <td className={ // check if GST is zero or more than default + item.TotalGSTValue === 0 ? "disabledBorder" : + (item.TotalGST === props.defGSTValue ? "" : "warningBorder") + }> + <span className="multiValue"> + <span>{item.TotalGSTValue}</span> + <span>({item.TotalGST}%)</span> + </span> + </td> + + <td> + {(item.TotalValue + (item.TotalGSTValue - item.DiscountValue)).toFixed(2)} + </td> + </tr> + ); +} + +export default DisplayItem; |