diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-11-11 23:28:13 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-11-11 23:28:13 +0530 |
commit | 9ca1864b79ede841e71836132effc2e260b4e758 (patch) | |
tree | dfb76a9cc85a6d7c21803cef842b530a48a2c2fa /src/classes | |
parent | b944cfb33efd63c335305f9535054ea4f02acd59 (diff) |
added very basic functionality to generate and list invoices
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/client.js | 4 | ||||
-rw-r--r-- | src/classes/invoice.js | 49 |
2 files changed, 50 insertions, 3 deletions
diff --git a/src/classes/client.js b/src/classes/client.js index d05655d..baa2ed7 100644 --- a/src/classes/client.js +++ b/src/classes/client.js @@ -54,8 +54,8 @@ export class InvoiceClient extends Client { } } -export const saveClient = (item, ok, fail) => { - axios.post("/client/new", item) +export const saveClient = (client, ok, fail) => { + axios.post("/client/new", client) .then(res => ok(res)) .catch(err => fail(err)) } diff --git a/src/classes/invoice.js b/src/classes/invoice.js index 1032b47..066cbc3 100644 --- a/src/classes/invoice.js +++ b/src/classes/invoice.js @@ -15,7 +15,10 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -//import axios from "axios"; +import { InvoiceItem } from "./item"; +import { Client, Address } from "./client"; + +import axios from "axios"; export class Transporter { constructor() { @@ -35,3 +38,47 @@ export class Transport { this.TransportMethod = ""; } } + +export class Invoice { + constructor() { + this.Id = null; + this.InvoiceNumber = 0; + this.TotalAmount = 0.00; + this.CreatedAt = new Date(); + this.LastUpdated = null; + this.Recipient = new Client(); + this.Paid = false; + this.TransactionId = ""; + this.Transport = new Transport(); + this.DiscountPercentage = 0; + this.BillingAddress = new Address(); + this.ShippingAddress = new Address(); + this.Items = []; + this.Note = ""; + this.Draft = true; + } +} + +export const getAllInvoices = (ok, fail) => { + axios.get("/invoice/all") + .then(res => ok(res.data)) + .catch(err => fail()) +} + +export const saveInvoice = (invoice, ok, fail) => { + axios.post("/invoice/new", invoice) + .then(res => ok(res)) + .catch(err => fail(err)) +} + +export const deleteInvoice = (id, ok, fail) => { + axios.delete(`/invoice/${id}`) + .then(res => ok()) + .catch((err) => fail()) +} + +export const editInvoice = (item, ok, fail) => { + axios.put(`/invoice/${item.Id}`, item) + .then(res => ok()) + .catch(err => fail()); +} |