diff --git a/models/doctype/Account/Account.js b/models/doctype/Account/Account.js index e2a84394..2bad659f 100644 --- a/models/doctype/Account/Account.js +++ b/models/doctype/Account/Account.js @@ -1,5 +1,6 @@ module.exports = { name: 'Account', + label: 'Account', doctype: 'DocType', documentClass: require('./AccountDocument.js'), isSingle: 0, diff --git a/models/doctype/GSTR3B/GSTR3B.js b/models/doctype/GSTR3B/GSTR3B.js index 42233400..7a64a087 100644 --- a/models/doctype/GSTR3B/GSTR3B.js +++ b/models/doctype/GSTR3B/GSTR3B.js @@ -2,6 +2,7 @@ const frappe = require('frappejs'); module.exports = { name: 'GSTR3B', + label: 'GSTR 3B', doctype: 'DocType', documentClass: require('./GSTR3BDocument.js'), print: { diff --git a/models/doctype/GSTR3B/GSTR3BDocument.js b/models/doctype/GSTR3B/GSTR3BDocument.js index 6e2722d1..2445c25c 100644 --- a/models/doctype/GSTR3B/GSTR3BDocument.js +++ b/models/doctype/GSTR3B/GSTR3BDocument.js @@ -49,7 +49,7 @@ module.exports = class GSTR3B extends BaseDocument { gstr3bData[0].push(await this.makeGSTRow(ledgerEntry)); } for (let ledgerEntry of gstr2Data) { - ledgerEntry.doctype = 'BiPurchaseInvoicell'; + ledgerEntry.doctype = 'PurchaseInvoice'; gstr3bData[1].push(await this.makeGSTRow(ledgerEntry)); } diff --git a/models/doctype/Payment/Payment.js b/models/doctype/Payment/Payment.js index 51b5b55f..9b80e68f 100644 --- a/models/doctype/Payment/Payment.js +++ b/models/doctype/Payment/Payment.js @@ -27,13 +27,24 @@ module.exports = { label: 'From Account', fieldtype: 'Link', target: 'Account', - required: 1 + required: 1, + getFilters: (query, doc) => { + if (doc.paymentType === 'Pay') { + if (doc.paymentMethod === 'Cash') + return { accountType: 'Cash', isGroup: 0 }; + else + return { + accountType: ['in', ['Bank', 'Cash']], + isGroup: 0 + }; + } + } }, { fieldname: 'paymentType', label: 'Payment Type', fieldtype: 'Select', - options: ['Recieve', 'Pay'], + options: ['', 'Receive', 'Pay'], required: 1 }, { @@ -43,12 +54,13 @@ 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 - }; + if (doc.paymentType === 'Receive') { + if (doc.paymentMethod === 'Cash') { + return { accountType: 'Cash', isGroup: 0 }; + } else { + return { accountType: ['in', ['Bank', 'Cash']], isGroup: 0 }; + } + } } }, { diff --git a/models/doctype/Quotation/Quotation.js b/models/doctype/Quotation/Quotation.js index 3cc36eec..5ce20400 100644 --- a/models/doctype/Quotation/Quotation.js +++ b/models/doctype/Quotation/Quotation.js @@ -1,7 +1,7 @@ const model = require('frappejs/model'); -const Invoice = require('../Invoice/Invoice'); +const SalesInvoice = require('../SalesInvoice/SalesInvoice'); -const Quotation = model.extend(Invoice, { +const Quotation = model.extend(SalesInvoice, { name: "Quotation", label: "Quotation", settings: "QuotationSettings", diff --git a/models/doctype/Quotation/QuotationDocument.js b/models/doctype/Quotation/QuotationDocument.js index 32875acd..dd775931 100644 --- a/models/doctype/Quotation/QuotationDocument.js +++ b/models/doctype/Quotation/QuotationDocument.js @@ -1,3 +1,3 @@ -const InvoiceDocument = require('../Invoice/InvoiceDocument'); +const SalesInvoiceDocument = require('../SalesInvoice/SalesInvoiceDocument'); -module.exports = class Quotation extends InvoiceDocument { } \ No newline at end of file +module.exports = class Quotation extends SalesInvoiceDocument {}; diff --git a/models/doctype/QuotationItem/QuotationItem.js b/models/doctype/QuotationItem/QuotationItem.js index 238b51a2..8203fb90 100644 --- a/models/doctype/QuotationItem/QuotationItem.js +++ b/models/doctype/QuotationItem/QuotationItem.js @@ -1,6 +1,6 @@ const model = require('frappejs/model'); -const InvoiceItem = require('../InvoiceItem/InvoiceItem'); +const SalesInvoiceItem = require('../SalesInvoiceItem/SalesInvoiceItem'); -module.exports = model.extend(InvoiceItem, { +module.exports = model.extend(SalesInvoiceItem, { name: "QuotationItem" }); diff --git a/models/doctype/QuotationSettings/QuotationSettings.js b/models/doctype/QuotationSettings/QuotationSettings.js index 2aa6de9b..d270ebfc 100644 --- a/models/doctype/QuotationSettings/QuotationSettings.js +++ b/models/doctype/QuotationSettings/QuotationSettings.js @@ -1,7 +1,7 @@ const model = require('frappejs/model'); -const InvoiceSettings = require('../InvoiceSettings/InvoiceSettings'); +const SalesInvoiceSettings = require('../SalesInvoiceSettings/SalesInvoiceSettings'); -module.exports = model.extend(InvoiceSettings, { +module.exports = model.extend(SalesInvoiceSettings, { "name": "QuotationSettings", "label": "Quotation Settings", "fields": [ diff --git a/models/doctype/SalesInvoice/SalesInvoice.js b/models/doctype/SalesInvoice/SalesInvoice.js index 8b492e26..78ad5a29 100644 --- a/models/doctype/SalesInvoice/SalesInvoice.js +++ b/models/doctype/SalesInvoice/SalesInvoice.js @@ -145,7 +145,7 @@ module.exports = { form.doc.submitted && form.doc.outstandingAmount !== 0.0, action: async form => { const payment = await frappe.getNewDoc('Payment'); - payment.paymentType = 'Recieve'; + payment.paymentType = 'Receive'; payment.party = form.doc.customer; payment.account = form.doc.account; payment.for = [ diff --git a/models/doctype/SalesInvoice/SalesInvoicePrint.vue b/models/doctype/SalesInvoice/SalesInvoicePrint.vue index 0f985d7d..b6b5c704 100644 --- a/models/doctype/SalesInvoice/SalesInvoicePrint.vue +++ b/models/doctype/SalesInvoice/SalesInvoicePrint.vue @@ -61,15 +61,15 @@ export default { await this.getFont(); }, async getTemplate() { - let invoiceSettings = await frappe.getDoc('InvoiceSettings'); + let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings'); this.template = invoiceTemplates[invoiceSettings.template]; }, async getColor() { - let invoiceSettings = await frappe.getDoc('InvoiceSettings'); + let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings'); this.themeColor = invoiceSettings.themeColor; }, async getFont() { - let invoiceSettings = await frappe.getDoc('InvoiceSettings'); + let invoiceSettings = await frappe.getDoc('SalesInvoiceSettings'); this.font = invoiceSettings.font; }, async toggleCustomizer() { diff --git a/reports/SalesRegister/SalesRegister.js b/reports/SalesRegister/SalesRegister.js index 5a039f96..8fa2ee39 100644 --- a/reports/SalesRegister/SalesRegister.js +++ b/reports/SalesRegister/SalesRegister.js @@ -1,55 +1,53 @@ const frappe = require('frappejs'); class SalesRegister { - async run({ fromDate, toDate, customer }) { - let filters = {}; - if(customer) { - filters.customer = customer; - } - - if (fromDate && toDate) { - filters.date = ['>=', fromDate, '<=', toDate]; - } - else if (fromDate) { - filters.date = ['>=', fromDate]; - } - else if (toDate) { - filters.date = ['<=', toDate]; - } - - const invoices = await frappe.db.getAll({ - doctype: 'Invoice', - fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'], - filters: filters, - orderBy: 'date', - order: 'desc' - }); - - const invoiceNames = invoices.map(d => d.name); - - const taxes = await frappe.db.getAll({ - doctype: 'TaxSummary', - fields: ['parent', 'amount'], - filters: { - parenttype: 'Invoice', - parent: ['in', invoiceNames] - }, - orderBy: 'name' - }); - - for (let invoice of invoices) { - invoice.totalTax = taxes - .filter(tax => tax.parent === invoice.name) - .reduce((acc, tax) => { - if (tax.amount) { - acc = acc + tax.amount; - } - return acc; - }, 0); - } - - return { rows: invoices }; + async run({ fromDate, toDate, customer }) { + let filters = {}; + if (customer) { + filters.customer = customer; } + + if (fromDate && toDate) { + filters.date = ['>=', fromDate, '<=', toDate]; + } else if (fromDate) { + filters.date = ['>=', fromDate]; + } else if (toDate) { + filters.date = ['<=', toDate]; + } + + const invoices = await frappe.db.getAll({ + doctype: 'SalesInvoice', + fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'], + filters: filters, + orderBy: 'date', + order: 'desc' + }); + + const invoiceNames = invoices.map(d => d.name); + + const taxes = await frappe.db.getAll({ + doctype: 'TaxSummary', + fields: ['parent', 'amount'], + filters: { + parenttype: 'Invoice', + parent: ['in', invoiceNames] + }, + orderBy: 'name' + }); + + for (let invoice of invoices) { + invoice.totalTax = taxes + .filter(tax => tax.parent === invoice.name) + .reduce((acc, tax) => { + if (tax.amount) { + acc = acc + tax.amount; + } + return acc; + }, 0); + } + + return { rows: invoices }; + } } module.exports = SalesRegister; diff --git a/src/components/DashboardCard.vue b/src/components/DashboardCard.vue index 2d74c2a1..4bc7902c 100644 --- a/src/components/DashboardCard.vue +++ b/src/components/DashboardCard.vue @@ -1,6 +1,6 @@