From 2d2c9d4e6af73b4514a996e752c16bd4116a973d Mon Sep 17 00:00:00 2001 From: thefalconx33 Date: Mon, 22 Jul 2019 15:26:30 +0530 Subject: [PATCH] Minor Fixes --- models/doctype/Party/RegionalChanges.js | 23 ++++-- models/doctype/Payment/Payment.js | 7 +- models/doctype/Payment/PaymentServer.js | 3 +- .../BankReconciliation/BankReconciliation.js | 16 +++- reports/BankReconciliation/viewConfig.js | 14 +++- .../GoodsAndServiceTax/GoodsAndServiceTax.js | 78 +++++++++++-------- reports/GoodsAndServiceTax/viewConfig.js | 10 ++- src/components/PageHeader.vue | 41 +++++++++- src/components/Sidebar.vue | 76 +++++++++--------- src/pages/FormView/FormView.vue | 16 ++++ src/pages/Report/index.vue | 23 +++++- src/router/index.js | 3 +- 12 files changed, 209 insertions(+), 101 deletions(-) diff --git a/models/doctype/Party/RegionalChanges.js b/models/doctype/Party/RegionalChanges.js index 95cb7350..9b933f8d 100644 --- a/models/doctype/Party/RegionalChanges.js +++ b/models/doctype/Party/RegionalChanges.js @@ -1,12 +1,21 @@ -const party = require('./Party') +const party = require('./Party'); -party.fields.splice(3, 0, { //insert at 3rd position +party.fields.splice(3, 0, { + //insert at 3rd position fieldname: 'gstin', label: 'GSTIN No.', fieldtype: 'Data', - hidden: 0 -}) -party.fields.join() -const newParty = party + hidden: form => { + return form.individualType === 'Registered Regular' ? 0 : 1; + } +}); +party.fields.splice(4, 0, { + fieldname: 'individualType', + label: 'GST Registration Type', + fieldtype: 'Select', + options: ['Unregistered', 'Registered Regular', 'Consumer'] +}); +party.fields.join(); +const newParty = party; -module.exports = newParty \ No newline at end of file +module.exports = newParty; diff --git a/models/doctype/Payment/Payment.js b/models/doctype/Payment/Payment.js index 4237c241..51b5b55f 100644 --- a/models/doctype/Payment/Payment.js +++ b/models/doctype/Payment/Payment.js @@ -43,7 +43,10 @@ module.exports = { target: 'Account', required: 1, getFilters: (query, doc) => { + if (doc.paymentMethod === 'Cash') + return { accountType: 'Cash', isGroup: 0 }; return { + accountType: ['in', ['Bank', 'Cash']], isGroup: 0 }; } @@ -52,7 +55,7 @@ module.exports = { fieldname: 'paymentMethod', label: 'Payment Method', fieldtype: 'Select', - options: ['', 'Cash', 'Cheque'], + options: ['', 'Cash', 'Cheque', 'Transfer'], required: 1 }, { @@ -71,7 +74,7 @@ module.exports = { label: 'Clearance Date', fieldtype: 'Date', hidden: doc => { - return doc.paymentMethod === 'Cheque' ? 0 : 1; + return doc.paymentMethod === 'Cash' ? 1 : 0; } }, { diff --git a/models/doctype/Payment/PaymentServer.js b/models/doctype/Payment/PaymentServer.js index 3572a692..2d454b08 100644 --- a/models/doctype/Payment/PaymentServer.js +++ b/models/doctype/Payment/PaymentServer.js @@ -15,7 +15,7 @@ module.exports = class PaymentServer extends BaseDocument { async afterSubmit() { for (let row of this.for) { if (['Invoice', 'Bill'].includes(row.referenceType)) { - const { outstandingAmount, grandTotal } = await frappe.getDoc( + let { outstandingAmount, grandTotal } = await frappe.getDoc( row.referenceType, row.referenceName ); @@ -26,6 +26,7 @@ module.exports = class PaymentServer extends BaseDocument { if (this.amount > outstandingAmount) { console.log('Over Payment'); } else { + console.log('Payment Done'); await frappe.db.setValue( row.referenceType, row.referenceName, diff --git a/reports/BankReconciliation/BankReconciliation.js b/reports/BankReconciliation/BankReconciliation.js index f87e2c41..6088fff4 100644 --- a/reports/BankReconciliation/BankReconciliation.js +++ b/reports/BankReconciliation/BankReconciliation.js @@ -13,10 +13,20 @@ class BankReconciliation { if (params.fromDate) filters.date.push('>=', params.fromDate); } + filters.paymentMethod = ['in', ['Cheque', 'Transfer']]; + let data = await frappe.db.getAll({ doctype: 'Payment', - fields: ['date', 'account', 'paymentAccount', 'party', 'name', 'referenceDate','clearanceDate'], - filters: filters, + fields: [ + 'date', + 'account', + 'paymentAccount', + 'party', + 'name', + 'referenceDate', + 'clearanceDate' + ], + filters: filters }); for (var i = 0; i < data.length; i++) { @@ -28,7 +38,7 @@ class BankReconciliation { account: data[i].paymentAccount, referenceName: data[i].name } - }) + }); data[i].credit = ledger[0].credit; data[i].debit = ledger[0].debit; data[i].referenceName = ledger[0].referenceName; diff --git a/reports/BankReconciliation/viewConfig.js b/reports/BankReconciliation/viewConfig.js index 6fc88d23..93b735b3 100644 --- a/reports/BankReconciliation/viewConfig.js +++ b/reports/BankReconciliation/viewConfig.js @@ -2,11 +2,18 @@ const title = 'Bank Reconciliation'; module.exports = { title: title, method: 'bank-reconciliation', - filterFields: [{ + filterFields: [ + { fieldtype: 'Link', target: 'Account', label: 'Payement Account', - fieldname: 'paymentAccount' + fieldname: 'paymentAccount', + getFilters: () => { + return { + accountType: 'Bank', + isGroup: 0 + }; + } }, { fieldtype: 'Link', @@ -26,7 +33,8 @@ module.exports = { } ], getColumns() { - return [{ + return [ + { label: 'Posting Date', fieldtype: 'Date', fieldname: 'date' diff --git a/reports/GoodsAndServiceTax/GoodsAndServiceTax.js b/reports/GoodsAndServiceTax/GoodsAndServiceTax.js index cbcefb47..8e8b2c9b 100644 --- a/reports/GoodsAndServiceTax/GoodsAndServiceTax.js +++ b/reports/GoodsAndServiceTax/GoodsAndServiceTax.js @@ -10,34 +10,48 @@ class GoodsAndServiceTax { } if (params.transferType) filters.transferType = params.transferType; - let invoiceNames = await frappe.db.getAll({ - doctype: 'Invoice', - filter: filters - }); - - let tableData = []; - for (let invoice of invoiceNames) { - const row = await this.getRow(invoice.name); - tableData.push(row); - } - - if (Object.keys(filters).length != 0) { - tableData = tableData.filter(row => { - if (filters.account) return row.account === filters.account; - if (filters.transferType) - return row.transferType === filters.transferType; - if (filters.place) return row.place === filters.place; - return true; - }); - } - - return tableData; + const data = await this.getReport(params.reportType, filters); + return data; } - async getRow(invoiceName) { + async getReport(type, filters) { + if (['GSTR-1', 'GSTR-2'].includes(type)) { + let entries = await frappe.db.getAll({ + doctype: type === 'GSTR-1' ? 'Invoice' : 'Bill', + filter: filters + }); + + let tableData = []; + for (let entry of entries) { + const row = await this.getRow({ + doctype: type === 'GSTR-1' ? 'Invoice' : 'Bill', + name: entry.name + }); + tableData.push(row); + } + + if (Object.keys(filters).length != 0) { + tableData = tableData.filter(row => { + if (filters.account) return row.account === filters.account; + if (filters.transferType) + return row.transferType === filters.transferType; + if (filters.place) return row.place === filters.place; + return true; + }); + } + return tableData; + } else { + return []; + } + } + + async getRow(entry) { let row = {}; - let invoiceDetails = await frappe.getDoc('Invoice', invoiceName); - let customerDetails = await frappe.getDoc('Party', invoiceDetails.customer); + let entryDetails = await frappe.getDoc(entry.doctype, entry.name); + let customerDetails = await frappe.getDoc( + 'Party', + entryDetails.customer || entryDetails.supplier + ); if (customerDetails.address) { let addressDetails = await frappe.getDoc( 'Address', @@ -46,15 +60,15 @@ class GoodsAndServiceTax { row.place = addressDetails.state || ''; } row.gstin = customerDetails.gstin; - row.cusName = invoiceDetails.customer; - row.invNo = invoiceDetails.name; - row.invDate = invoiceDetails.date; + row.partyName = entryDetails.customer || entryDetails.supplier; + row.invNo = entryDetails.name; + row.invDate = entryDetails.date; row.rate = 0; row.transferType = 'In State'; - invoiceDetails.taxes.forEach(tax => { + entryDetails.taxes.forEach(tax => { row.rate += tax.rate; - const taxAmt = (tax.rate * invoiceDetails.netTotal) / 100; + const taxAmt = (tax.rate * entryDetails.netTotal) / 100; if (tax.account === 'IGST') { row.transferType = 'Out of State'; row.igstAmt = taxAmt; @@ -62,8 +76,8 @@ class GoodsAndServiceTax { if (tax.account === 'CGST') row.cgstAmt = taxAmt; if (tax.account === 'SGST') row.sgstAmt = taxAmt; }); - row.invAmt = invoiceDetails.grandTotal; - row.taxAmt = invoiceDetails.netTotal; + row.invAmt = entryDetails.grandTotal; + row.taxAmt = entryDetails.netTotal; return row; } } diff --git a/reports/GoodsAndServiceTax/viewConfig.js b/reports/GoodsAndServiceTax/viewConfig.js index 1cbf00fd..3d28ae1e 100644 --- a/reports/GoodsAndServiceTax/viewConfig.js +++ b/reports/GoodsAndServiceTax/viewConfig.js @@ -3,6 +3,12 @@ module.exports = { title: title, method: 'gst-taxes', filterFields: [ + { + fieldtype: 'Select', + label: 'Report Type', + fieldname: 'reportType', + options: ['', 'GSTR-1', 'GSTR-2', 'GSTR-3B'] + }, { fieldtype: 'Data', label: 'Transfer Type', @@ -35,8 +41,8 @@ module.exports = { }, { fieldtype: 'Data', - fieldname: 'cusName', - label: 'Customer Name', + fieldname: 'partyName', + label: 'Party', width: 100 }, { diff --git a/src/components/PageHeader.vue b/src/components/PageHeader.vue index a149bee1..7078a58b 100644 --- a/src/components/PageHeader.vue +++ b/src/components/PageHeader.vue @@ -1,17 +1,50 @@ - diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index de0a74a1..66536a04 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -5,36 +5,36 @@
{{ companyName }}
- -
-
-
- - {{group }} -
-
- -
-
-
{{ item.label }}
+ +
+
+
+ + {{group }}
- -
- + +
+
+
{{ item.label }}
+
+
+
+
+
diff --git a/src/pages/FormView/FormView.vue b/src/pages/FormView/FormView.vue index 703e6904..c3becff6 100644 --- a/src/pages/FormView/FormView.vue +++ b/src/pages/FormView/FormView.vue @@ -1,5 +1,6 @@