From 2e574646793e82cc5a716b32b83518f04db7ee74 Mon Sep 17 00:00:00 2001 From: HenriT Date: Wed, 14 Apr 2021 15:58:55 +0300 Subject: [PATCH] Added multiple taxes for invoice rows. Client has_vat => has_tax. Abstracted add row button to separate component. Abstracted invoice row headers to separate component. Remove vat related things, now replaced with custom taxes. Invoice tax totals are calculated per tax based on invoice rows. --- package-lock.json | 7 ++- package.json | 1 + src/components/clients/ClientForm.vue | 4 +- src/components/invoices/InvoiceAddRowBtn.vue | 34 +++++++++++++ src/components/invoices/InvoiceForm.vue | 28 +++-------- src/components/invoices/InvoiceRow.vue | 15 ++++++ src/components/invoices/InvoiceRowsHeader.vue | 27 ++++++++++ src/components/invoices/InvoiceTotals.vue | 29 ++++++----- src/components/invoices/InvoicesList.vue | 7 +-- src/components/team/TeamForm.vue | 2 - src/services/invoice.service.js | 2 - src/services/team.service.js | 1 - src/store/clients.js | 2 +- src/store/invoice-rows.js | 50 ++++++++++++++++--- src/store/invoices.js | 17 +------ src/store/models/client.js | 2 +- src/store/models/invoice-row-tax.js | 16 ++++++ src/store/models/invoice-row.js | 2 + src/store/models/invoice.js | 29 +++++++++-- src/store/models/team.js | 1 - src/store/store.js | 2 + 21 files changed, 196 insertions(+), 82 deletions(-) create mode 100644 src/components/invoices/InvoiceAddRowBtn.vue create mode 100644 src/components/invoices/InvoiceRowsHeader.vue create mode 100644 src/store/models/invoice-row-tax.js diff --git a/package-lock.json b/package-lock.json index b3c201c..88ac434 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7378,10 +7378,9 @@ } }, "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "lodash.defaultsdeep": { "version": "4.6.1", diff --git a/package.json b/package.json index d6842c2..8a3dc22 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dayjs": "^1.10.3", "es6-promise": "^4.2.6", "localforage": "^1.9.0", + "lodash": "^4.17.21", "vue": "^2.6.10", "vue-autosuggest": "^2.2.0", "vue-multiselect": "^2.1.6", diff --git a/src/components/clients/ClientForm.vue b/src/components/clients/ClientForm.vue index 50e1f61..46b9e78 100644 --- a/src/components/clients/ClientForm.vue +++ b/src/components/clients/ClientForm.vue @@ -41,8 +41,8 @@ label="Currency" field="currency" :errors="errors" class="col-sm-4"/> - + + + + + + + + + diff --git a/src/components/invoices/InvoiceForm.vue b/src/components/invoices/InvoiceForm.vue index 0190ebc..2102c2e 100644 --- a/src/components/invoices/InvoiceForm.vue +++ b/src/components/invoices/InvoiceForm.vue @@ -20,26 +20,11 @@
- - - - - - - - - + - - - +
ItemQuantityUnitPriceSum
- - -
@@ -64,11 +49,13 @@ import InvoiceContactDetails from '@/components/invoices/InvoiceContactDetails'; import InvoiceHeader from '@/components/invoices/InvoiceHeader'; import InvoiceTotals from '@/components/invoices/InvoiceTotals'; import AppEditable from '@/components/form/AppEditable'; -import AppError from '@/components/form/AppError'; import TeamLogo from '@/components/team/TeamLogo'; +import InvoiceRowsHeader from '@/components/invoices/InvoiceRowsHeader'; +import InvoiceAddRowBtn from '@/components/invoices/InvoiceAddRowBtn'; export default { components: { + InvoiceAddRowBtn, TeamLogo, InvoiceTotals, InvoiceHeader, @@ -76,9 +63,9 @@ export default { InvoiceBankDetails, InvoiceCompanyDetails, InvoiceRow, + InvoiceRowsHeader, InvoiceClientDetails, AppEditable, - AppError, }, computed: { ...mapState({ @@ -106,9 +93,6 @@ export default { invoiceId: this.invoice.id, }); }, - addRow() { - this.$store.dispatch('invoiceRows/addRow', this.invoice.id); - }, }, }; diff --git a/src/components/invoices/InvoiceRow.vue b/src/components/invoices/InvoiceRow.vue index efab2d9..f580d5a 100644 --- a/src/components/invoices/InvoiceRow.vue +++ b/src/components/invoices/InvoiceRow.vue @@ -28,6 +28,14 @@ placeholder="Enter price" @change="updateProp({ price: $event })"/> + + + {{ (row.quantity * row.price) | currency }}