From 2c30acdcb2b7c499ab1b7ad9ad483a9071744202 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 29 May 2015 16:33:36 +0530 Subject: [PATCH] [minor] journal entry, copy over party details to new row and automatically set difference --- .../doctype/journal_entry/journal_entry.js | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 5ff9e5fd2c..3ea92e1b19 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -4,7 +4,7 @@ frappe.provide("erpnext.accounts"); frappe.require("assets/erpnext/js/utils.js"); -erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ +erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ onload: function() { this.load_defaults(); this.setup_queries(); @@ -130,10 +130,31 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ cur_frm.cscript.update_totals(me.frm.doc); } }); - } + }, + + accounts_add: function(doc, cdt, cdn) { + var row = frappe.get_doc(cdt, cdn); + $.each(doc.accounts, function(i, d) { + if(d.account && d.party && d.party_type) { + row.account = d.account; + row.party = d.party; + row.party_type = d.party_type; + } + }); + + // set difference + if(doc.difference) { + if(doc.difference > 0) { + row.credit = doc.difference; + } else { + row.debit = -doc.difference; + } + } + }, + }); -cur_frm.script_manager.make(erpnext.accounts.JournalVoucher); +cur_frm.script_manager.make(erpnext.accounts.JournalEntry); cur_frm.cscript.refresh = function(doc) { erpnext.toggle_naming_series();