diff --git a/client/index.js b/client/index.js index 4f7f486a..fbab3a15 100644 --- a/client/index.js +++ b/client/index.js @@ -19,7 +19,9 @@ module.exports = { frappe.desk.menu.addItem('Chart of Accounts', '#tree/Account'); frappe.desk.menu.addItem('Items', '#list/Item'); frappe.desk.menu.addItem('Customers', '#list/Customer'); + frappe.desk.menu.addItem('Quotation', '#list/Quotation'); frappe.desk.menu.addItem('Invoice', '#list/Invoice'); + frappe.desk.menu.addItem('Journal Entry', '#list/JournalEntry'); frappe.desk.menu.addItem('Address', "#list/Address"); frappe.desk.menu.addItem('Contact', "#list/Contact"); frappe.desk.menu.addItem('Settings', () => frappe.desk.showFormModal('SystemSettings')); diff --git a/models/doctype/Address/Address.js b/models/doctype/Address/Address.js index 071e4aef..b6191f8c 100644 --- a/models/doctype/Address/Address.js +++ b/models/doctype/Address/Address.js @@ -104,7 +104,6 @@ module.exports = { return ['addressTitle', 'addressType']; }, getRowHTML(list, data) { - console.log(list, data); return `
${list.getNameHTML(data)} (${data.addressType})
`; } }, diff --git a/models/doctype/JournalEntry/JournalEntry.js b/models/doctype/JournalEntry/JournalEntry.js new file mode 100644 index 00000000..a6ff5931 --- /dev/null +++ b/models/doctype/JournalEntry/JournalEntry.js @@ -0,0 +1,83 @@ +const frappe = require('frappejs'); +const utils = require('../../../accounting/utils'); + +module.exports = { + name: "JournalEntry", + doctype: "DocType", + isSingle: 0, + isChild: 0, + isSubmittable: 1, + keywordFields: ["name"], + showTitle: true, + settings: "JournalEntrySetting", + fields: [ + { + fieldname: "date", + label: "Date", + fieldtype: "Date" + }, + { + fieldname: "entryType", + label: "Entry Type", + fieldtype: "Select", + options: [ + "Journal Entry", + "Bank Entry", + "Cash Entry", + "Credit Card Entry", + "Debit Note", + "Credit Note", + "Contra Entry", + "Excise Entry", + "Write Off Entry", + "Opening Entry", + "Depreciation Entry" + ], + required: 1 + }, + { + fieldname: "accounts", + label: "Account Entries", + fieldtype: "Table", + childtype: "JournalEntryAccount", + required: true + }, + { + fieldname: "referenceNumber", + label: "Reference Number", + fieldtype: "Data", + }, + { + fieldname: "referenceDate", + label: "Reference Date", + fieldtype: "Date", + }, + { + fieldname: "userRemark", + label: "User Remark", + fieldtype: "Text", + } + ], + layout: [ + // section 1 + { + columns: [ + { fields: [ "date" ] }, + { fields: [ "entryType" ] }, + ] + + }, + // section 2 + { fields: ["accounts"]}, + // section 3 + { + columns: [ + { fields: [ "referenceNumber"] }, + { fields: [ "referenceDate"] } + + ] + }, + // section 4 + { fields: [ "userRemark" ] }, + ] +} \ No newline at end of file diff --git a/models/doctype/JournalEntry/JournalEntryServer.js b/models/doctype/JournalEntry/JournalEntryServer.js new file mode 100644 index 00000000..8680dfdd --- /dev/null +++ b/models/doctype/JournalEntry/JournalEntryServer.js @@ -0,0 +1,29 @@ +const BaseDocument = require('frappejs/model/document'); +const frappe = require('frappejs'); +const LedgerPosting = require.main.require('./accounting/ledgerPosting'); + +module.exports = class PaymentServer extends BaseDocument { + /** + + getPosting() { + let entries = new LedgerPosting({reference: this, party: this.party}); + entries.debit(this.paymentAccount, this.amount); + + for (let row of this.for) { + entries.credit(this.account, row.amount, row.referenceType, row.referenceName); + } + + return entries; + + } + + async afterSubmit() { + await this.getPosting().post(); + } + + async afterRevert() { + await this.getPosting().postReverse(); + } + + **/ +} \ No newline at end of file diff --git a/models/doctype/JournalEntryAccount/JournalEntryAccount.js b/models/doctype/JournalEntryAccount/JournalEntryAccount.js new file mode 100644 index 00000000..4419ebe6 --- /dev/null +++ b/models/doctype/JournalEntryAccount/JournalEntryAccount.js @@ -0,0 +1,27 @@ +module.exports = { + name: "JournalEntryAccount", + doctype: "DocType", + isSingle: 0, + isChild: 1, + keywordFields: [], + layout: 'ratio', + fields: [ + { + "fieldname": "account", + "label": "Account", + "fieldtype": "Link", + "target": "Account", + "required": 1, + }, + { + "fieldname": "debit", + "label": "Debit", + "fieldtype": "Currency" + }, + { + "fieldname": "credit", + "label": "Credit", + "fieldtype": "Currency" + } + ] +} \ No newline at end of file diff --git a/models/doctype/JournalEntrySettings/JournalEntrySettings.js b/models/doctype/JournalEntrySettings/JournalEntrySettings.js new file mode 100644 index 00000000..14d77872 --- /dev/null +++ b/models/doctype/JournalEntrySettings/JournalEntrySettings.js @@ -0,0 +1,18 @@ +module.exports = { + "name": "JournalEntrySetting", + "label": "Journal Entry Setting", + "doctype": "DocType", + "isSingle": 1, + "isChild": 0, + "keywordFields": [], + "fields": [ + { + "fieldname": "numberSeries", + "label": "Number Series", + "fieldtype": "Link", + "target": "NumberSeries", + "required": 1, + "default": "JV" + } + ] +} \ No newline at end of file diff --git a/models/doctype/Quotation/Quotation.js b/models/doctype/Quotation/Quotation.js new file mode 100644 index 00000000..5ddb0a85 --- /dev/null +++ b/models/doctype/Quotation/Quotation.js @@ -0,0 +1,8 @@ +const Invoice = require('../Invoice/Invoice'); +const Quotation = Invoice; + +Quotation.name = "Quotation"; +Quotation.label = "Quotation"; +Quotation.settings = "QuotationSettings"; + +module.exports = Quotation; diff --git a/models/doctype/QuotationSettings/QuotationSettings.js b/models/doctype/QuotationSettings/QuotationSettings.js new file mode 100644 index 00000000..fd423aa3 --- /dev/null +++ b/models/doctype/QuotationSettings/QuotationSettings.js @@ -0,0 +1,8 @@ +const InvoiceSettings = require('../InvoiceSettings/InvoiceSettings'); +const QuotationSettings = InvoiceSettings; +QuotationSettings.name = "QuotationSettings"; +QuotationSettings.label = "Quotation Settings"; +QuotationSettings.fields.find((field)=>{ + if (field.fieldname == "numberSeries") field.default = "QTN"; +}); +module.exports = QuotationSettings; \ No newline at end of file diff --git a/models/index.js b/models/index.js index c56b4f95..9c52b07a 100644 --- a/models/index.js +++ b/models/index.js @@ -18,7 +18,15 @@ module.exports = { Tax: require('./doctype/Tax/Tax.js'), TaxDetail: require('./doctype/TaxDetail/TaxDetail.js'), TaxSummary: require('./doctype/TaxSummary/TaxSummary.js'), + Address: require('./doctype/Address/Address.js'), - Contact: require('./doctype/Contact/Contact.js') + Contact: require('./doctype/Contact/Contact.js'), + + JournalEntry: require('./doctype/JournalEntry/JournalEntry.js'), + JournalEntryAccount: require('./doctype/JournalEntryAccount/JournalEntryAccount.js'), + JournalEntrySettings: require('./doctype/JournalEntrySettings/JournalEntrySettings.js'), + + Quotation: require('./doctype/Quotation/Quotation.js'), + QuotationSettings: require('./doctype/QuotationSettings/QuotationSettings.js'), } } diff --git a/server/index.js b/server/index.js index 006124ad..578165cb 100644 --- a/server/index.js +++ b/server/index.js @@ -23,6 +23,7 @@ module.exports = { // set server-side modules frappe.models.Invoice.documentClass = require('../models/doctype/Invoice/InvoiceServer.js'); frappe.models.Payment.documentClass = require('../models/doctype/Payment/PaymentServer.js'); + frappe.models.JournalEntry.documentClass = require('../models/doctype/JournalEntry/JournalEntryServer.js'); frappe.metaCache = {}; @@ -31,6 +32,8 @@ module.exports = { // init naming series if missing await naming.createNumberSeries('INV-', 'InvoiceSettings'); await naming.createNumberSeries('PAY-', 'PaymentSettings'); + await naming.createNumberSeries('JV-', 'JournalEntrySettings'); + await naming.createNumberSeries('QTN-', 'QuotationSettings'); frappe.registerMethod({ method: 'general-ledger',