Merge pull request #4221 from nabinhait/fix22

[fix] Value mapping while making bank entry from Expense Claim
This commit is contained in:
Nabin Hait 2015-10-26 13:00:52 +05:30
commit c4a1a943ef
2 changed files with 10 additions and 6 deletions

View File

@ -498,14 +498,17 @@ def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None):
if voucher_type=="Bank Entry":
account = frappe.db.get_value("Company", company, "default_bank_account")
if not account:
account = frappe.db.get_value("Account", {"company": company, "account_type": "Bank", "is_group": 0})
account = frappe.db.get_value("Account",
{"company": company, "account_type": "Bank", "is_group": 0})
elif voucher_type=="Cash Entry":
account = frappe.db.get_value("Company", company, "default_cash_account")
if not account:
account = frappe.db.get_value("Account", {"company": company, "account_type": "Cash", "is_group": 0})
account = frappe.db.get_value("Account",
{"company": company, "account_type": "Cash", "is_group": 0})
if account:
account_details = frappe.db.get_value("Account", account, ["account_currency", "account_type"], as_dict=1)
account_details = frappe.db.get_value("Account", account,
["account_currency", "account_type"], as_dict=1)
return {
"account": account,
"balance": get_balance_on(account),

View File

@ -18,24 +18,25 @@ erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({
jv.voucher_type = 'Bank Entry';
jv.company = cur_frm.doc.company;
jv.remark = 'Payment against Expense Claim: ' + cur_frm.doc.name;
jv.fiscal_year = cur_frm.doc.fiscal_year;
var expense = cur_frm.doc.expenses || [];
for(var i = 0; i < expense.length; i++){
var d1 = frappe.model.add_child(jv, 'Journal Entry Account', 'accounts');
d1.debit = expense[i].sanctioned_amount;
d1.account = expense[i].default_account;
d1.debit_in_account_currency = expense[i].sanctioned_amount;
d1.reference_type = cur_frm.doc.doctype;
d1.reference_name = cur_frm.doc.name;
}
// credit to bank
var d1 = frappe.model.add_child(jv, 'Journal Entry Account', 'accounts');
d1.credit = cur_frm.doc.total_sanctioned_amount;
d1.credit_in_account_currency = cur_frm.doc.total_sanctioned_amount;
d1.reference_type = cur_frm.doc.doctype;
d1.reference_name = cur_frm.doc.name;
if(r.message) {
d1.account = r.message.account;
d1.balance = r.message.balance;
d1.account_currency = r.message.account_currency;
d1.account_type = r.message.account_type;
}
loaddoc('Journal Entry', jv.name);