aboutsummaryrefslogtreecommitdiff
path: root/src/components/tables
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-11-11 23:28:13 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-11-11 23:28:13 +0530
commit9ca1864b79ede841e71836132effc2e260b4e758 (patch)
treedfb76a9cc85a6d7c21803cef842b530a48a2c2fa /src/components/tables
parentb944cfb33efd63c335305f9535054ea4f02acd59 (diff)
added very basic functionality to generate and list invoices
Diffstat (limited to 'src/components/tables')
-rw-r--r--src/components/tables/invoice-summary.js3
-rw-r--r--src/components/tables/invoice-table.js74
2 files changed, 76 insertions, 1 deletions
diff --git a/src/components/tables/invoice-summary.js b/src/components/tables/invoice-summary.js
index a5c594f..75c2ddc 100644
--- a/src/components/tables/invoice-summary.js
+++ b/src/components/tables/invoice-summary.js
@@ -18,7 +18,7 @@
import './scss/summary.scss';
import { currency } from '../../classes/item';
-const InvoiceSummary = ({sum, roundOff}) => {
+const InvoiceSummary = ({sum, roundOff, submit}) => {
const totalRoundedOff = currency(sum.Amount !== undefined ? Math.round(sum.Amount.value) : 0.00);
const roundedOffDiff = sum.Amount !== undefined && roundOff ? sum.Amount.subtract(totalRoundedOff) : currency(0.00);
@@ -59,6 +59,7 @@ const InvoiceSummary = ({sum, roundOff}) => {
}
</tbody>
</table>
+ <button onClick={submit}>Generate Invoice</button>
</>
);
}
diff --git a/src/components/tables/invoice-table.js b/src/components/tables/invoice-table.js
new file mode 100644
index 0000000..3c37fe0
--- /dev/null
+++ b/src/components/tables/invoice-table.js
@@ -0,0 +1,74 @@
+/* OpenBills-web - Web based libre billing software
+ * Copyright (C) 2022 Vidhu Kant Sharma <vidhukant@vidhukant.xyz>
+
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+import './scss/table.scss';
+import { deleteInvoice } from './../../classes/invoice';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
+import { faPencil, faTrashCan } from '@fortawesome/free-solid-svg-icons'
+
+const InvoiceTable = (props) => {
+ const handleEdit = (i) => {
+ props.setInvoiceToEdit(i)
+ }
+
+ const handleDelete = (i) => {
+ // TODO: add confirmation prompt
+ deleteInvoice(i.Id, handleDelSuccess, handleDelFail);
+ }
+
+ const handleDelSuccess = () => {
+ props.refresh();
+ }
+
+ const handleDelFail = () => {
+ alert("fail")
+ }
+
+ return (
+ <table className={"item-table"}>
+ <thead>
+ <tr>
+ <th>S. No</th>
+ <th>Invoice Number</th>
+ <th>Recipient Name</th>
+ <th>Date Created</th>
+ <th>Date Last Updated</th>
+ <th>Total Amount</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {props.items && props.items.map((i, id) => (
+ <tr key={id}>
+ <td>{id+1}</td>
+ <td>{i.InvoiceNumber}</td>
+ <td>{i.Recipient.Name}</td>
+ <td>{i.CreatedAt}</td>
+ <td>{i.UpdatedAt}</td>
+ <td>{i.TotalAmount}</td>
+ <td className={"buttons"}>
+ <FontAwesomeIcon icon={faPencil} onClick={() => handleEdit(i)}/>
+ <FontAwesomeIcon icon={faTrashCan} onClick={() => handleDelete(i)}/>
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ );
+}
+
+export default InvoiceTable;