[patch] Multi currency
This commit is contained in:
parent
4ffd7f3d05
commit
54fe26dcfb
@ -263,7 +263,7 @@ class JournalEntry(AccountsController):
|
|||||||
|
|
||||||
self.difference = flt(self.total_debit, self.precision("total_debit")) - \
|
self.difference = flt(self.total_debit, self.precision("total_debit")) - \
|
||||||
flt(self.total_credit, self.precision("total_credit"))
|
flt(self.total_credit, self.precision("total_credit"))
|
||||||
|
print self.difference
|
||||||
if self.difference:
|
if self.difference:
|
||||||
frappe.throw(_("Total Debit must be equal to Total Credit. The difference is {0}")
|
frappe.throw(_("Total Debit must be equal to Total Credit. The difference is {0}")
|
||||||
.format(self.difference))
|
.format(self.difference))
|
||||||
|
@ -270,14 +270,14 @@
|
|||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Debit",
|
"label": "Debit in Company Currency",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "debit",
|
"oldfieldname": "debit",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@ -331,14 +331,14 @@
|
|||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Credit",
|
"label": "Credit in Company Currency",
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "credit",
|
"oldfieldname": "credit",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@ -476,7 +476,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-08-18 17:23:28.378231",
|
"modified": "2015-08-27 12:52:20.914258",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Journal Entry Account",
|
"name": "Journal Entry Account",
|
||||||
|
@ -193,3 +193,4 @@ execute:frappe.db.sql("update `tabProduction Order` pro set description = (selec
|
|||||||
erpnext.patches.v5_7.item_template_attributes
|
erpnext.patches.v5_7.item_template_attributes
|
||||||
erpnext.patches.v4_2.repost_reserved_qty #2015-08-20
|
erpnext.patches.v4_2.repost_reserved_qty #2015-08-20
|
||||||
erpnext.patches.v5_4.update_purchase_cost_against_project
|
erpnext.patches.v5_4.update_purchase_cost_against_project
|
||||||
|
erpnext.patches.v6_0.multi_currency
|
@ -1,10 +0,0 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
||||||
# License: GNU General Public License v3. See license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import frappe
|
|
||||||
|
|
||||||
def execute():
|
|
||||||
frappe.db.sql("""update `tabAccount` acc
|
|
||||||
set currency = (select default_currency from tabCompany where name=acc.company)
|
|
||||||
where ifnull(currency, '') = ''""")
|
|
0
erpnext/patches/v6_0/__init__.py
Normal file
0
erpnext/patches/v6_0/__init__.py
Normal file
85
erpnext/patches/v6_0/multi_currency.py
Normal file
85
erpnext/patches/v6_0/multi_currency.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
# Reload doctype
|
||||||
|
for dt in ("Account", "GL Entry", "Journal Entry",
|
||||||
|
"Journal Entry Account", "Sales Invoice", "Purchase Invoice"):
|
||||||
|
frappe.reload_doctype(dt)
|
||||||
|
|
||||||
|
for company in frappe.get_all("Company", fields=["name", "default_currency", "default_receivable_account"]):
|
||||||
|
|
||||||
|
# update currency in account and gl entry as per company currency
|
||||||
|
frappe.db.sql("""update `tabAccount` set currency = %s
|
||||||
|
where ifnull(currency, '') = '' and company=%s""", (company.default_currency, company.name))
|
||||||
|
|
||||||
|
# update newly introduced field's value in sales / purchase invoice
|
||||||
|
frappe.db.sql("""
|
||||||
|
update
|
||||||
|
`tabSales Invoice`
|
||||||
|
set
|
||||||
|
base_paid_amount=paid_amount,
|
||||||
|
base_write_off_amount=write_off_amount,
|
||||||
|
party_account_currency=%s
|
||||||
|
where company=%s
|
||||||
|
""", (company.default_currency, company.name))
|
||||||
|
|
||||||
|
frappe.db.sql("""
|
||||||
|
update
|
||||||
|
`tabPurchase Invoice`
|
||||||
|
set
|
||||||
|
base_write_off_amount=write_off_amount,
|
||||||
|
party_account_currency=%s
|
||||||
|
where company=%s
|
||||||
|
""", (company.default_currency, company.name))
|
||||||
|
|
||||||
|
# update exchange rate, debit/credit in account currency in Journal Entry
|
||||||
|
frappe.db.sql("""update `tabJournal Entry` set exchange_rate=1""")
|
||||||
|
|
||||||
|
frappe.db.sql("""
|
||||||
|
update
|
||||||
|
`tabJournal Entry Account` jea, `tabJournal Entry` je
|
||||||
|
set
|
||||||
|
debit_in_account_currency=debit,
|
||||||
|
credit_in_account_currency=credit,
|
||||||
|
currency=%s
|
||||||
|
where
|
||||||
|
jea.parent = je.name
|
||||||
|
and je.company=%s
|
||||||
|
""", (company.default_currency, company.name))
|
||||||
|
|
||||||
|
# update debit/credit in account currency in GL Entry
|
||||||
|
frappe.db.sql("""
|
||||||
|
update
|
||||||
|
`tabGL Entry`
|
||||||
|
set
|
||||||
|
debit_in_account_currency=debit,
|
||||||
|
credit_in_account_currency=credit,
|
||||||
|
currency=%s
|
||||||
|
where
|
||||||
|
company=%s
|
||||||
|
""", (company.default_currency, company.name))
|
||||||
|
|
||||||
|
# Set party account if default currency of party other than company's default currency
|
||||||
|
for dt in ("Customer", "Supplier"):
|
||||||
|
parties = frappe.db.sql("""select name from `tab{0}` p
|
||||||
|
where ifnull(default_currency, '') != '' and default_currency != %s
|
||||||
|
and not exists(select name from `tabParty Account` where parent=p.name and company=%s)"""
|
||||||
|
.format(dt), (company.default_currency, company.name))
|
||||||
|
|
||||||
|
for p in parties:
|
||||||
|
party = frappe.get_doc(dt, p[0])
|
||||||
|
party_gle = frappe.db.get_value("GL Entry", {"party_type": dt, "party": p[0],
|
||||||
|
"company": company.name}, ["account"], as_dict=True)
|
||||||
|
|
||||||
|
party_account = party_gle.account or company.default_receivable_account
|
||||||
|
|
||||||
|
party.append("party_accounts", {
|
||||||
|
"company": company.name,
|
||||||
|
"account": party_account
|
||||||
|
})
|
||||||
|
party.ignore_mandatory()
|
||||||
|
party.save()
|
Loading…
x
Reference in New Issue
Block a user