aboutsummaryrefslogtreecommitdiff
path: root/src/components/Display/DisplayItem.tsx
blob: 26137f537b3495518d16ff32ff96290fcd8c6e91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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/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;