aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-27 14:47:48 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-06-27 14:47:48 +0530
commiteedde57b9caff20e1e7d25b43fcb8785e23b3e11 (patch)
tree3532d795ecf269083e613860c0b27e3689773678
parent240d7d56459c656c86330755c7a0b9000a090f77 (diff)
Fixed DisplayItem and now really big decimal numbers don't show up
-rw-r--r--src/components/Display/Display.scss9
-rw-r--r--src/components/Display/DisplayItem.js34
-rw-r--r--src/components/Display/DisplayItem.tsx67
-rw-r--r--src/components/Display/ItemsDisplay.tsx4
-rw-r--r--src/components/Display/SummaryDisplay.tsx6
-rw-r--r--src/components/Form/Document/DocumentInfoForm.tsx (renamed from src/components/Form/Document/DocumentInfoForm.js)6
6 files changed, 85 insertions, 41 deletions
diff --git a/src/components/Display/Display.scss b/src/components/Display/Display.scss
index 592f4ec..8be6c4e 100644
--- a/src/components/Display/Display.scss
+++ b/src/components/Display/Display.scss
@@ -43,6 +43,15 @@
text-align: left;
}
+.ItemsDisplay .multiValue {
+ display: flex;
+ justify-content: space-around;
+}
+
+.ItemsDisplay .hideContents * {
+ display: none;
+}
+
.SummaryDisplayTR td {
color: $foreground2;
font-size: 1.7rem;
diff --git a/src/components/Display/DisplayItem.js b/src/components/Display/DisplayItem.js
deleted file mode 100644
index 02693ab..0000000
--- a/src/components/Display/DisplayItem.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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 "./Display.scss";
-
-const DisplayItem = (props) => {
- const itemNumber = props.itemNumber;
- const item = props.item;
-
- return (
- <tr>
- <td>{itemNumber}</td>
- <td className={"leftAlign"}>{item.Model}</td>
- <td className={item.Description === "" ? "leftAlign disabledBorder" : "leftAlign"}>{item.Description}</td>
- <td>{item.Quantity}</td>
- <td className={item.Discount === 0 ? "disabledBorder" : ""}>{item.Discount}</td>
-
- <td className={item.cgst === "" ? "disabledBorder" : (props.defGSTValue / 2 ? "" : "warningBorder")}>{item.sgst}</td>
- <td className={item.sgst === "" ? "disabledBorder" : (props.defGSTValue / 2 ? "" : "warningBorder")}>{item.cgst}</td>
- <td className={item.igst === "" ? "disabledBorder" : (item.igst === props.defGSTValue ? "" : "warningBorder")}>{item.igst}</td>
-
- <td>{item.HSN}</td>
- <td>{item.TotalPrice}</td>
- </tr>
- );
-}
-
-export default DisplayItem;
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;
diff --git a/src/components/Display/ItemsDisplay.tsx b/src/components/Display/ItemsDisplay.tsx
index db3d336..78c5094 100644
--- a/src/components/Display/ItemsDisplay.tsx
+++ b/src/components/Display/ItemsDisplay.tsx
@@ -33,9 +33,7 @@ const ItemsDisplay: React.FC<Props> = (props) => {
<th>Quantity</th>
<th>Unit Price</th>
<th>Discount</th>
- <th>sgst</th>
- <th>cgst</th>
- <th>igst</th>
+ <th>Tax</th>
<th>Price</th>
</tr>
diff --git a/src/components/Display/SummaryDisplay.tsx b/src/components/Display/SummaryDisplay.tsx
index 9488836..22f2e52 100644
--- a/src/components/Display/SummaryDisplay.tsx
+++ b/src/components/Display/SummaryDisplay.tsx
@@ -85,14 +85,14 @@ const SummaryDisplay: React.FC<props> = (props) => {
{summary.TotalDiscount !== 0.00 &&
<tr>
<td>After Discount</td>
- <td>{summary.TotalPriceAfterDiscount}</td>
+ <td>{(summary.TotalPriceAfterDiscount).toFixed(2)}</td>
<td>(-{summary.TotalDiscount})</td>
</tr>
}
<tr>
<td>After Tax</td>
- <td>{summary.TotalRawPrice + summary.TotalGST}</td>
+ <td>{(summary.TotalRawPrice + summary.TotalGST).toFixed(2)}</td>
<td>(+{summary.TotalGST})</td>
</tr>
@@ -105,7 +105,7 @@ const SummaryDisplay: React.FC<props> = (props) => {
<tr className={"grandTotal"}>
<td>Grand Total</td>
- <td>{summary.TotalRawPrice + (summary.TotalGST - summary.TotalDiscount)}</td>
+ <td>{Math.round(summary.TotalRawPrice + (summary.TotalGST - summary.TotalDiscount))}</td>
</tr>
</tbody>
</table>
diff --git a/src/components/Form/Document/DocumentInfoForm.js b/src/components/Form/Document/DocumentInfoForm.tsx
index 09bb9c6..7f33046 100644
--- a/src/components/Form/Document/DocumentInfoForm.js
+++ b/src/components/Form/Document/DocumentInfoForm.tsx
@@ -7,12 +7,16 @@
*/
import React/*, { useState }*/ from "react";
+import { Person } from "./../../../interfaces";
import "./../Form.scss";
import SelectClientForm from "./../People/SelectClientForm";
+interface Props {
+ savedPeople: Person[]
+}
-const DocumentInfoForm = (props) => {
+const DocumentInfoForm: React.FC<Props> = (props) => {
return (
<div className={"DocumentInfoForm"}>
<SelectClientForm