Merge pull request #4183 from nabinhait/multi_currency_fix

Multi currency fix
This commit is contained in:
Anand Doshi 2015-10-19 15:32:24 +05:30
commit 5302b46955
5 changed files with 15 additions and 6 deletions

View File

@ -76,7 +76,7 @@ class PurchaseInvoice(BuyingController):
def get_advances(self): def get_advances(self):
if not self.is_return: if not self.is_return:
super(PurchaseInvoice, self).get_advances(self.credit_to, "Supplier", self.supplier, super(PurchaseInvoice, self).get_advances(self.credit_to, "Supplier", self.supplier,
"Purchase Invoice Advance", "advances", "debit", "purchase_order") "Purchase Invoice Advance", "advances", "debit_in_account_currency", "purchase_order")
def check_active_purchase_items(self): def check_active_purchase_items(self):
for d in self.get('items'): for d in self.get('items'):

View File

@ -256,7 +256,7 @@ class SalesInvoice(SellingController):
def get_advances(self): def get_advances(self):
if not self.is_return: if not self.is_return:
super(SalesInvoice, self).get_advances(self.debit_to, "Customer", self.customer, super(SalesInvoice, self).get_advances(self.debit_to, "Customer", self.customer,
"Sales Invoice Advance", "advances", "credit", "sales_order") "Sales Invoice Advance", "advances", "credit_in_account_currency", "sales_order")
def get_company_abbr(self): def get_company_abbr(self):
return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0] return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0]

View File

@ -217,11 +217,17 @@ def validate_party_accounts(doc):
for account in doc.get("accounts"): for account in doc.get("accounts"):
if account.company in companies: if account.company in companies:
frappe.throw(_("There can only be 1 Account per Company in {0} {1}").format(doc.doctype, doc.name), frappe.throw(_("There can only be 1 Account per Company in {0} {1}")
DuplicatePartyAccountError) .format(doc.doctype, doc.name), DuplicatePartyAccountError)
else: else:
companies.append(account.company) companies.append(account.company)
party_account_currency = frappe.db.get_value("Account", account.account, "account_currency")
existing_gle_currency = get_party_gle_currency(doc.doctype, doc.name, account.company)
if existing_gle_currency and party_account_currency != existing_gle_currency:
frappe.throw(_("Accounting entries have already been made in currency {0} for company {1}. Please select a receivable or payable account with currency {0}.").format(existing_gle_currency, account.company))
@frappe.whitelist() @frappe.whitelist()
def get_due_date(posting_date, party_type, party, company): def get_due_date(posting_date, party_type, party, company):
"""Set Due Date = Posting Date + Credit Days""" """Set Due Date = Posting Date + Credit Days"""

View File

@ -211,7 +211,8 @@ def update_against_doc(d, jv_obj):
if d['allocated_amt'] < d['unadjusted_amt']: if d['allocated_amt'] < d['unadjusted_amt']:
jvd = frappe.db.sql(""" jvd = frappe.db.sql("""
select cost_center, balance, against_account, is_advance, account_type, exchange_rate select cost_center, balance, against_account, is_advance,
account_type, exchange_rate, account_currency
from `tabJournal Entry Account` where name = %s from `tabJournal Entry Account` where name = %s
""", d['voucher_detail_no'], as_dict=True) """, d['voucher_detail_no'], as_dict=True)
@ -222,6 +223,7 @@ def update_against_doc(d, jv_obj):
ch = jv_obj.append("accounts") ch = jv_obj.append("accounts")
ch.account = d['account'] ch.account = d['account']
ch.account_type = jvd[0]['account_type'] ch.account_type = jvd[0]['account_type']
ch.account_currency = jvd[0]['account_currency']
ch.exchange_rate = jvd[0]['exchange_rate'] ch.exchange_rate = jvd[0]['exchange_rate']
ch.party_type = d["party_type"] ch.party_type = d["party_type"]
ch.party = d["party"] ch.party = d["party"]

View File

@ -495,7 +495,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
} }
if(this.frm.fields_dict["advances"]) { if(this.frm.fields_dict["advances"]) {
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, "advances"); setup_field_label_map(["advance_amount", "allocated_amount"],
this.frm.doc.party_account_currency, "advances");
} }
// toggle columns // toggle columns