Merge branch 'develop'

This commit is contained in:
Anand Doshi 2015-10-22 18:53:19 +05:30
commit e3910d02a5
8 changed files with 43 additions and 34 deletions

View File

@ -1,2 +1,2 @@
from __future__ import unicode_literals from __future__ import unicode_literals
__version__ = '6.6.0' __version__ = '6.6.1'

View File

@ -6,7 +6,7 @@ import frappe
from frappe import _ from frappe import _
from frappe.utils import flt, fmt_money, getdate, formatdate from frappe.utils import flt, fmt_money, getdate, formatdate
from frappe.model.document import Document from frappe.model.document import Document
from erpnext.accounts.party import validate_party_gle_currency, get_party_account_currency from erpnext.accounts.party import validate_party_gle_currency
from erpnext.accounts.utils import get_account_currency from erpnext.accounts.utils import get_account_currency
from erpnext.setup.doctype.company.company import get_company_currency from erpnext.setup.doctype.company.company import get_company_currency
from erpnext.exceptions import InvalidAccountCurrency, CustomerFrozen from erpnext.exceptions import InvalidAccountCurrency, CustomerFrozen
@ -114,13 +114,7 @@ class GLEntry(Document):
.format(self.account, (account_currency or company_currency)), InvalidAccountCurrency) .format(self.account, (account_currency or company_currency)), InvalidAccountCurrency)
if self.party_type and self.party: if self.party_type and self.party:
party_account_currency = get_party_account_currency(self.party_type, self.party, self.company) validate_party_gle_currency(self.party_type, self.party, self.company, self.account_currency)
if party_account_currency != self.account_currency:
frappe.throw(_("Accounting Entry for {0}: {1} can only be made in currency: {2}")
.format(self.party_type, self.party, party_account_currency), InvalidAccountCurrency)
validate_party_gle_currency(self.party_type, self.party, self.company)
def validate_balance_type(account, adv_adj=False): def validate_balance_type(account, adv_adj=False):
if not adv_adj and account: if not adv_adj and account:

View File

@ -203,9 +203,11 @@ def get_party_gle_currency(party_type, party, company):
return frappe.local_cache("party_gle_currency", (party_type, party, company), generator) return frappe.local_cache("party_gle_currency", (party_type, party, company), generator)
def validate_party_gle_currency(party_type, party, company): def validate_party_gle_currency(party_type, party, company, party_account_currency=None):
"""Validate party account currency with existing GL Entry's currency""" """Validate party account currency with existing GL Entry's currency"""
if not party_account_currency:
party_account_currency = get_party_account_currency(party_type, party, company) party_account_currency = get_party_account_currency(party_type, party, company)
existing_gle_currency = get_party_gle_currency(party_type, party, company) existing_gle_currency = get_party_gle_currency(party_type, party, company)
if existing_gle_currency and party_account_currency != existing_gle_currency: if existing_gle_currency and party_account_currency != existing_gle_currency:

View File

@ -10,7 +10,7 @@ from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year, get_ac
from erpnext.utilities.transaction_base import TransactionBase from erpnext.utilities.transaction_base import TransactionBase
from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
from erpnext.controllers.sales_and_purchase_return import validate_return from erpnext.controllers.sales_and_purchase_return import validate_return
from erpnext.accounts.party import get_party_account_currency, validate_party_gle_currency from erpnext.accounts.party import get_party_account_currency
from erpnext.exceptions import CustomerFrozen, InvalidCurrency from erpnext.exceptions import CustomerFrozen, InvalidCurrency
force_item_fields = ("item_group", "barcode", "brand", "stock_uom") force_item_fields = ("item_group", "barcode", "brand", "stock_uom")
@ -435,6 +435,8 @@ class AccountsController(TransactionBase):
frappe.throw(_("Accounting Entry for {0}: {1} can only be made in currency: {2}") frappe.throw(_("Accounting Entry for {0}: {1} can only be made in currency: {2}")
.format(party_type, party, party_account_currency), InvalidCurrency) .format(party_type, party, party_account_currency), InvalidCurrency)
# Note: not validating with gle account because we don't have the account at quotation / sales order level and we shouldn't stop someone from creating a sales invoice if sales order is already created
@frappe.whitelist() @frappe.whitelist()
def get_tax_rate(account_head): def get_tax_rate(account_head):
return frappe.db.get_value("Account", account_head, "tax_rate") return frappe.db.get_value("Account", account_head, "tax_rate")

View File

@ -29,7 +29,7 @@ blogs.
""" """
app_icon = "icon-th" app_icon = "icon-th"
app_color = "#e74c3c" app_color = "#e74c3c"
app_version = "6.6.0" app_version = "6.6.1"
github_link = "https://github.com/frappe/erpnext" github_link = "https://github.com/frappe/erpnext"
error_report_email = "support@erpnext.com" error_report_email = "support@erpnext.com"

View File

@ -2,6 +2,7 @@
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
cur_frm.add_fetch('employee','employee_name','employee_name'); cur_frm.add_fetch('employee','employee_name','employee_name');
cur_frm.add_fetch('employee','company','company');
frappe.ui.form.on("Leave Application", { frappe.ui.form.on("Leave Application", {
onload: function(frm) { onload: function(frm) {

View File

@ -33,13 +33,23 @@ def execute():
(pi.name, company.expenses_included_in_valuation)) (pi.name, company.expenses_included_in_valuation))
if gle_for_expenses_included_in_valuation: if gle_for_expenses_included_in_valuation:
print pi.name
frappe.db.sql("""delete from `tabGL Entry` frappe.db.sql("""delete from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no=%s""", pi.name) where voucher_type='Purchase Invoice' and voucher_no=%s""", pi.name)
purchase_invoice = frappe.get_doc("Purchase Invoice", pi.name) purchase_invoice = frappe.get_doc("Purchase Invoice", pi.name)
purchase_invoice.make_gl_entries()
print pi.name # some old entries have missing expense accounts
if purchase_invoice.against_expense_account:
expense_account = purchase_invoice.against_expense_account.split(",")
if len(expense_account) == 1:
expense_account = expense_account[0]
for item in purchase_invoice.items:
if not item.expense_account:
item.db_set("expense_account", expense_account, update_modified=False)
purchase_invoice.make_gl_entries()
def get_frozen_date(company, account): def get_frozen_date(company, account):
# Accounting frozen upto # Accounting frozen upto

View File

@ -1,6 +1,6 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
version = "6.6.0" version = "6.6.1"
with open("requirements.txt", "r") as f: with open("requirements.txt", "r") as f:
install_requires = f.readlines() install_requires = f.readlines()