From bd5d812d779dad0c10ab08b7bead4b317eacb897 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 14 Oct 2019 02:49:28 +0530 Subject: [PATCH] feat: Use InvoiceForm for PurchaseInvoice as well - Button with icon prop --- models/doctype/Party/Party.js | 2 +- .../PurchaseInvoice/PurchaseInvoice.js | 2 +- .../PurchaseInvoice/PurchaseInvoiceList.js | 1 + .../PurchaseInvoice/PurchaseInvoiceServer.js | 2 +- .../PurchaseInvoiceItem.js | 7 +++ models/doctype/SalesInvoice/SalesInvoice.js | 2 +- .../SalesInvoice/SalesInvoiceServer.js | 2 +- src/components/Button.vue | 7 ++- src/pages/Desk.vue | 2 +- src/pages/InvoiceForm.vue | 57 ++++++++++++++----- src/pages/ListView/List.vue | 4 +- src/pages/ListView/ListView.vue | 28 +++++---- src/pages/QuickEditForm.vue | 6 +- 13 files changed, 80 insertions(+), 42 deletions(-) diff --git a/models/doctype/Party/Party.js b/models/doctype/Party/Party.js index cc7ce290..eee0ee16 100644 --- a/models/doctype/Party/Party.js +++ b/models/doctype/Party/Party.js @@ -26,7 +26,7 @@ module.exports = { getFilters: (query, doc) => { return { isGroup: 0, - accountType: doc.customer === 1 ? 'Receivable' : 'Payable' + accountType: doc.customer ? 'Receivable' : 'Payable' }; } }, diff --git a/models/doctype/PurchaseInvoice/PurchaseInvoice.js b/models/doctype/PurchaseInvoice/PurchaseInvoice.js index 65a2c654..389af748 100644 --- a/models/doctype/PurchaseInvoice/PurchaseInvoice.js +++ b/models/doctype/PurchaseInvoice/PurchaseInvoice.js @@ -17,7 +17,7 @@ module.exports = { fieldname: 'date', label: 'Date', fieldtype: 'Date', - defaultValue: new Date().toISOString() + default: new Date().toISOString().slice(0, 10) }, { fieldname: 'supplier', diff --git a/models/doctype/PurchaseInvoice/PurchaseInvoiceList.js b/models/doctype/PurchaseInvoice/PurchaseInvoiceList.js index 7df67256..8fde9d54 100644 --- a/models/doctype/PurchaseInvoice/PurchaseInvoiceList.js +++ b/models/doctype/PurchaseInvoice/PurchaseInvoiceList.js @@ -4,6 +4,7 @@ import indicators from 'frappejs/ui/constants/indicators'; export default { doctype: 'PurchaseInvoice', title: _('Purchase Invoice'), + formRoute: name => `/edit/PurchaseInvoice/${name}`, columns: [ 'supplier', { diff --git a/models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js b/models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js index 769bcc7b..0b58e9cf 100644 --- a/models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js +++ b/models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js @@ -45,7 +45,7 @@ module.exports = class PurchaseInvoiceServer extends PurchaseInvoice { await entries.validateEntries(); } - async afterSubmit() { + async beforeSubmit() { const entries = await this.getPosting(); await entries.post(); await frappe.db.setValue( diff --git a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js index 83fb7015..93997e7d 100644 --- a/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js +++ b/models/doctype/PurchaseInvoiceItem/PurchaseInvoiceItem.js @@ -6,6 +6,13 @@ module.exports = { isChild: 1, keywordFields: [], layout: 'ratio', + tableFields: [ + 'item', + 'tax', + 'quantity', + 'rate', + 'amount' + ], fields: [ { fieldname: 'item', diff --git a/models/doctype/SalesInvoice/SalesInvoice.js b/models/doctype/SalesInvoice/SalesInvoice.js index 9b78a8ae..c790fcd0 100644 --- a/models/doctype/SalesInvoice/SalesInvoice.js +++ b/models/doctype/SalesInvoice/SalesInvoice.js @@ -20,7 +20,7 @@ module.exports = { fieldname: 'date', label: 'Date', fieldtype: 'Date', - defaultValue: new Date().toISOString() + default: new Date().toISOString().slice(0, 10) }, { fieldname: 'customer', diff --git a/models/doctype/SalesInvoice/SalesInvoiceServer.js b/models/doctype/SalesInvoice/SalesInvoiceServer.js index 2a2b6b32..2c9be9bc 100644 --- a/models/doctype/SalesInvoice/SalesInvoiceServer.js +++ b/models/doctype/SalesInvoice/SalesInvoiceServer.js @@ -57,7 +57,7 @@ module.exports = class SalesInvoiceServer extends SalesInvoice { await entries.validateEntries(); } - async afterSubmit() { + async beforeSubmit() { const entries = await this.getPosting(); await entries.post(); await frappe.db.setValue( diff --git a/src/components/Button.vue b/src/components/Button.vue index f7c2b59c..b46b85bb 100644 --- a/src/components/Button.vue +++ b/src/components/Button.vue @@ -1,6 +1,6 @@ @@ -80,7 +78,7 @@ export default { title: this.doctype, doctype: this.doctype, columns: frappe.getMeta(this.doctype).getKeywordFields() - } + }; } }, title() { diff --git a/src/pages/QuickEditForm.vue b/src/pages/QuickEditForm.vue index 9d2b6db9..e91921eb 100644 --- a/src/pages/QuickEditForm.vue +++ b/src/pages/QuickEditForm.vue @@ -1,14 +1,14 @@