copy expense account to all row if entered in one
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 31a7ce8..9532a54 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -421,17 +421,24 @@
cur_frm.cscript.income_account = function(doc, cdt, cdn){
+ cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "income_account");
+}
+
+cur_frm.cscript.expense_account = function(doc, cdt, cdn){
+ cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "expense_account");
+}
+
+cur_frm.cscript.copy_account_in_all_row = function(doc, cdt, cdn, fieldname) {
var d = locals[cdt][cdn];
- if(d.income_account){
+ if(d[fieldname]){
var cl = getchildren('Sales Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
for(var i = 0; i < cl.length; i++){
- if(!cl[i].income_account) cl[i].income_account = d.income_account;
+ if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname];
}
}
refresh_field(cur_frm.cscript.fname);
}
-
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.cost_center){
@@ -443,10 +450,6 @@
refresh_field(cur_frm.cscript.fname);
}
-/* **************************************** Utility Functions *************************************** */
-
-// Details Calculation
-// --------------------
cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
var doc = locals[doc.doctype][doc.name];
var el = getchildren('Sales Invoice Advance',doc.name,'advance_adjustment_details');
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index c7feb1b..61df6b0 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -310,6 +310,17 @@
}
}
+cur_frm.cscript.expense_account = function(doc, cdt, cdn){
+ var d = locals[cdt][cdn];
+ if(d.expense_account) {
+ var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype);
+ for(var i = 0; i < cl.length; i++){
+ if(!cl[i].expense_account) cl[i].expense_account = d.expense_account;
+ }
+ }
+ refresh_field(cur_frm.cscript.fname);
+}
+
// expense account
cur_frm.fields_dict['delivery_note_details'].grid.get_field('expense_account').get_query = function(doc) {
return {