[Fix] Get account of the mode of payment on sales invoice and pos profile

This commit is contained in:
Rohit Waghchaure 2016-08-08 22:54:38 +05:30
parent 88fff46ab4
commit 70be24d6f0
3 changed files with 45 additions and 16 deletions

View File

@ -1,5 +1,6 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
{% include "erpnext/public/js/controllers/accounts.js" %}
frappe.ui.form.on('Payment Entry', {
onload: function(frm) {
@ -257,22 +258,6 @@ frappe.ui.form.on('Payment Entry', {
}
},
mode_of_payment: function(frm) {
return frappe.call({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
args: {
"mode_of_payment": frm.doc.mode_of_payment,
"company": frm.doc.company
},
callback: function(r, rt) {
if(r.message) {
var payment_account_field = frm.doc.payment_type == "Receive" ? "paid_to" : "paid_from";
frm.set_value(payment_account_field, r.message['account']);
}
}
});
},
paid_from: function(frm) {
if(frm.set_party_account_based_on_party) return;

View File

@ -1,6 +1,8 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
{% include "erpnext/public/js/controllers/accounts.js" %}
frappe.ui.form.on("POS Profile", "onload", function(frm) {
frm.set_query("selling_price_list", function() {
return { filters: { selling: 1 } };

View File

@ -55,6 +55,48 @@ frappe.ui.form.on(cur_frm.doctype, {
}
});
frappe.ui.form.on('Sales Invoice Payment', {
mode_of_payment: function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
get_payment_mode_account(frm, d.mode_of_payment, function(account){
frappe.model.set_value(cdt, cdn, 'account', account)
})
}
})
frappe.ui.form.on('Purchase Invoice', {
mode_of_payment: function(frm) {
get_payment_mode_account(frm, frm.doc.mode_of_payment, function(account){
frm.set_value('cash_bank_account', account);
})
}
})
frappe.ui.form.on('Payment Entry', {
mode_of_payment: function(frm) {
get_payment_mode_account(frm, frm.doc.mode_of_payment, function(account){
var payment_account_field = frm.doc.payment_type == "Receive" ? "paid_to" : "paid_from";
frm.set_value(payment_account_field, account);
})
}
})
get_payment_mode_account = function(frm, mode_of_payment, callback){
return frappe.call({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account",
args: {
"mode_of_payment": mode_of_payment,
"company": frm.doc.company
},
callback: function(r, rt) {
if(r.message) {
callback(r.message.account)
}
}
});
}
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.account_head){