Removed account and party balance in company currency from Journal Entry

This commit is contained in:
Nabin Hait 2015-09-04 13:26:23 +05:30
parent 34fe81f7eb
commit c0e3b1a0c7
3 changed files with 12 additions and 55 deletions

View File

@ -29,8 +29,7 @@ frappe.ui.form.on("Journal Entry", {
}) })
erpnext.journal_entry.toggle_fields_based_on_currency = function(frm) { erpnext.journal_entry.toggle_fields_based_on_currency = function(frm) {
var fields = ["balance_in_account_currency", "party_balance_in_account_currency", var fields = ["debit_in_account_currency", "credit_in_account_currency"];
"debit_in_account_currency", "credit_in_account_currency"];
var company_currency = erpnext.get_currency(frm.doc.company); var company_currency = erpnext.get_currency(frm.doc.company);

View File

@ -71,31 +71,8 @@
"no_copy": 1, "no_copy": 1,
"oldfieldname": "balance", "oldfieldname": "balance",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"options": "Company:company:default_currency",
"permlevel": 0,
"print_hide": 1,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "balance_in_account_currency",
"fieldtype": "Currency",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Balance in Account Currency",
"no_copy": 1,
"options": "account_currency", "options": "account_currency",
"permlevel": 0, "permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"read_only": 1, "read_only": 1,
"report_hide": 0, "report_hide": 0,
@ -208,33 +185,10 @@
"in_list_view": 0, "in_list_view": 0,
"label": "Party Balance", "label": "Party Balance",
"no_copy": 0, "no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "party_balance_in_account_currency",
"fieldtype": "Currency",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Party Balance in Account Currency",
"no_copy": 1,
"options": "account_currency", "options": "account_currency",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 1, "print_hide": 0,
"read_only": 1, "read_only": 1,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
@ -520,7 +474,7 @@
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"modified": "2015-08-31 17:50:04.145031", "modified": "2015-09-04 03:29:37.127968",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Journal Entry Account", "name": "Journal Entry Account",

View File

@ -50,7 +50,7 @@ def validate_fiscal_year(date, fiscal_year, label=_("Date"), doc=None):
throw(_("{0} '{1}' not in Fiscal Year {2}").format(label, formatdate(date), fiscal_year)) throw(_("{0} '{1}' not in Fiscal Year {2}").format(label, formatdate(date), fiscal_year))
@frappe.whitelist() @frappe.whitelist()
def get_balance_on(account=None, date=None, party_type=None, party=None): def get_balance_on(account=None, date=None, party_type=None, party=None, in_account_currency=True):
if not account and frappe.form_dict.get("account"): if not account and frappe.form_dict.get("account"):
account = frappe.form_dict.get("account") account = frappe.form_dict.get("account")
if not date and frappe.form_dict.get("date"): if not date and frappe.form_dict.get("date"):
@ -102,10 +102,14 @@ def get_balance_on(account=None, date=None, party_type=None, party=None):
(party_type.replace('"', '\\"'), party.replace('"', '\\"'))) (party_type.replace('"', '\\"'), party.replace('"', '\\"')))
if account or (party_type and party): if account or (party_type and party):
if in_account_currency:
select_field = "sum(ifnull(debit_in_account_currency, 0)) - sum(ifnull(credit_in_account_currency, 0))"
else:
select_field = "sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))"
bal = frappe.db.sql(""" bal = frappe.db.sql("""
SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) SELECT {0}
FROM `tabGL Entry` gle FROM `tabGL Entry` gle
WHERE %s""" % " and ".join(cond))[0][0] WHERE {1}""".format(select_field, " and ".join(cond)))[0][0]
# if bal is None, return 0 # if bal is None, return 0
return flt(bal) return flt(bal)
@ -273,7 +277,7 @@ def get_stock_and_account_difference(account_list=None, posting_date=None):
and name in (%s)""" % ', '.join(['%s']*len(account_list)), account_list)) and name in (%s)""" % ', '.join(['%s']*len(account_list)), account_list))
for account, warehouse in account_warehouse.items(): for account, warehouse in account_warehouse.items():
account_balance = get_balance_on(account, posting_date) account_balance = get_balance_on(account, posting_date, in_account_currency=False)
stock_value = get_stock_value_on(warehouse, posting_date) stock_value = get_stock_value_on(warehouse, posting_date)
if abs(flt(stock_value) - flt(account_balance)) > 0.005: if abs(flt(stock_value) - flt(account_balance)) > 0.005:
difference.setdefault(account, flt(stock_value) - flt(account_balance)) difference.setdefault(account, flt(stock_value) - flt(account_balance))
@ -378,7 +382,7 @@ def get_stock_rbnb_difference(posting_date, company):
# Balance as per system # Balance as per system
stock_rbnb_account = "Stock Received But Not Billed - " + frappe.db.get_value("Company", company, "abbr") stock_rbnb_account = "Stock Received But Not Billed - " + frappe.db.get_value("Company", company, "abbr")
sys_bal = get_balance_on(stock_rbnb_account, posting_date) sys_bal = get_balance_on(stock_rbnb_account, posting_date, in_account_currency=False)
# Amount should be credited # Amount should be credited
return flt(stock_rbnb) + flt(sys_bal) return flt(stock_rbnb) + flt(sys_bal)