mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
Merge branch 'edge' of github.com:webnotes/erpnext into webshop
Conflicts: patches/april_2013/p05_update_file_data.py
This commit is contained in:
@@ -81,7 +81,7 @@ class DocType(DocTypeNestedSet):
|
||||
"""
|
||||
Cost Center name must be unique
|
||||
"""
|
||||
if (self.doc.__islocal or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
|
||||
if (self.doc.fields.get("__islocal") or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
|
||||
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
||||
|
||||
self.validate_mandatory()
|
||||
|
||||
@@ -108,8 +108,8 @@ class DocType:
|
||||
and not 'Accounts Manager' in webnotes.user.get_roles():
|
||||
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
|
||||
Only Accounts Manager can do transaction against this account"), raise_exception=1)
|
||||
|
||||
if ret and ret[0]["company"] != self.doc.company:
|
||||
|
||||
if self.doc.is_cancelled in ("No", None) and ret and ret[0]["company"] != self.doc.company:
|
||||
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
|
||||
+ ": " + self.doc.company, raise_exception=1)
|
||||
|
||||
@@ -124,9 +124,10 @@ class DocType:
|
||||
|
||||
return self.cost_center_company[self.doc.cost_center]
|
||||
|
||||
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
||||
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
|
||||
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
|
||||
if self.doc.is_cancelled in ("No", None) and \
|
||||
self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
||||
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
|
||||
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
|
||||
|
||||
def check_freezing_date(self, adv_adj):
|
||||
"""
|
||||
|
||||
@@ -72,7 +72,38 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
["Stock Received But Not Billed - _TC", 750.0, 0],
|
||||
["_Test Account Shipping Charges - _TC", 100.0, 0],
|
||||
["_Test Account VAT - _TC", 120.0, 0],
|
||||
["Expenses Included In Valuation - _TC", 0, 250.0]
|
||||
["Expenses Included In Valuation - _TC", 0, 250.0],
|
||||
])
|
||||
|
||||
for i, gle in enumerate(gl_entries):
|
||||
self.assertEquals(expected_values[i][0], gle.account)
|
||||
self.assertEquals(expected_values[i][1], gle.debit)
|
||||
self.assertEquals(expected_values[i][2], gle.credit)
|
||||
|
||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
|
||||
|
||||
def test_gl_entries_with_aia_for_non_stock_items(self):
|
||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
||||
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_inventory_accounting")), 1)
|
||||
|
||||
pi = webnotes.bean(copy=test_records[1])
|
||||
pi.doclist[1].item_code = "_Test Non Stock Item"
|
||||
pi.doclist[1].expense_head = "_Test Account Cost for Goods Sold - _TC"
|
||||
pi.doclist.pop(2)
|
||||
pi.doclist.pop(3)
|
||||
pi.run_method("calculate_taxes_and_totals")
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
|
||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||
order by account asc""", pi.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
|
||||
expected_values = sorted([
|
||||
["_Test Supplier - _TC", 0, 620],
|
||||
["_Test Account Cost for Goods Sold - _TC", 500.0, 0],
|
||||
["_Test Account VAT - _TC", 120.0, 0],
|
||||
])
|
||||
|
||||
for i, gle in enumerate(gl_entries):
|
||||
@@ -106,7 +137,6 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEqual(tax.account_head, expected_values[i][0])
|
||||
self.assertEqual(tax.tax_amount, expected_values[i][1])
|
||||
self.assertEqual(tax.total, expected_values[i][2])
|
||||
# print tax.account_head, tax.tax_amount, tax.item_wise_tax_detail
|
||||
|
||||
expected_values = [
|
||||
["_Test Item Home Desktop 100", 90, 59],
|
||||
@@ -142,7 +172,6 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEqual(tax.account_head, expected_values[i][0])
|
||||
self.assertEqual(tax.tax_amount, expected_values[i][1])
|
||||
self.assertEqual(tax.total, expected_values[i][2])
|
||||
# print tax.account_head, tax.tax_amount, tax.item_wise_tax_detail
|
||||
|
||||
expected_values = [
|
||||
["_Test FG Item", 90, 7059],
|
||||
|
||||
Reference in New Issue
Block a user