This commit is contained in:
Nabin Hait 2013-03-12 10:58:11 +05:30
parent bffbc18b2d
commit f7df8b28d2
4 changed files with 99 additions and 24 deletions

View File

@ -1,6 +1,6 @@
import webnotes import webnotes
def execute(): def execute():
webnotes.reload_doc("website", "doctype", "blog_post")
from website.utils import clear_cache from website.utils import clear_cache
clear_cache() clear_cache()

View File

@ -18,6 +18,7 @@ from __future__ import unicode_literals
patch_list = [ patch_list = [
"execute:webnotes.reload_doc('core', 'doctype', 'docfield')", "execute:webnotes.reload_doc('core', 'doctype', 'docfield')",
"execute:webnotes.reload_doc('core', 'doctype', 'report')", "execute:webnotes.reload_doc('core', 'doctype', 'report')",
"execute:webnotes.reload_doc('core', 'doctype', 'doctype')",
"patches.mar_2012.so_rv_mapper_fix", "patches.mar_2012.so_rv_mapper_fix",
"patches.mar_2012.clean_property_setter", "patches.mar_2012.clean_property_setter",
"patches.april_2012.naming_series_patch", "patches.april_2012.naming_series_patch",

View File

@ -22,6 +22,77 @@ class TestStockEntry(unittest.TestCase):
self.assertTrue(mr_name) self.assertTrue(mr_name)
def test_material_receipt_gl_entry(self):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
mr = webnotes.bean(copy=test_records[0])
mr.insert()
mr.submit()
stock_in_hand_account = webnotes.conn.get_value("Company", "_Test Company",
"stock_in_hand_account")
self.check_stock_ledger_entries("Stock Entry", mr.doc.name,
[["_Test Item", "_Test Warehouse", 50.0]])
self.check_gl_entries("Stock Entry", mr.doc.name,
sorted([
[stock_in_hand_account, 5000.0, 0.0],
["Stock Adjustment - _TC", 0.0, 5000.0]
])
)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
def test_material_issue_gl_entry(self):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
mr = webnotes.bean(copy=test_records[0])
mr.insert()
mr.submit()
stock_in_hand_account = webnotes.conn.get_value("Company", "_Test Company",
"stock_in_hand_account")
self.check_stock_ledger_entries("Stock Entry", mr.doc.name,
[["_Test Item", "_Test Warehouse", 50.0]])
self.check_gl_entries("Stock Entry", mr.doc.name,
sorted([
[stock_in_hand_account, 5000.0, 0.0],
["Stock Adjustment - _TC", 0.0, 5000.0]
])
)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
def check_stock_ledger_entries(self, voucher_type, voucher_no, expected_sle):
# check stock ledger entries
sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry`
where voucher_type = %s and voucher_no = %s order by item_code, warehouse""",
(voucher_type, voucher_no), as_dict=1)
self.assertTrue(sle)
for i, sle in enumerate(sle):
self.assertEquals(expected_sle[i][0], sle.item_code)
self.assertEquals(expected_sle[i][1], sle.warehouse)
self.assertEquals(expected_sle[i][2], sle.actual_qty)
def check_gl_entries(self, voucher_type, voucher_no, expected_gl_entries):
# check gl entries
gl_entries = webnotes.conn.sql("""select account, debit, credit
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
order by account asc, debit asc""", (voucher_type, voucher_no), as_dict=1)
self.assertTrue(gl_entries)
for i, gle in enumerate(gl_entries):
self.assertEquals(expected_gl_entries[i][0], gle.account)
self.assertEquals(expected_gl_entries[i][1], gle.debit)
self.assertEquals(expected_gl_entries[i][2], gle.credit)
test_records = [ test_records = [
[ [
{ {

View File

@ -1,8 +1,8 @@
[ [
{ {
"creation": "2013-01-10 16:34:30", "creation": "2013-03-07 18:50:32",
"docstatus": 0, "docstatus": 0,
"modified": "2013-02-04 11:35:53", "modified": "2013-03-11 17:58:45",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -21,7 +21,8 @@
"name": "__common__", "name": "__common__",
"parent": "Warehouse", "parent": "Warehouse",
"parentfield": "fields", "parentfield": "fields",
"parenttype": "DocType" "parenttype": "DocType",
"read_only": 0
}, },
{ {
"doctype": "DocPerm", "doctype": "DocPerm",
@ -190,7 +191,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "This feature is for merging duplicate warehouses. It will replace all the links of this warehouse by \"Merge With\" warehouse. After merging you can delete this warehouse, as stock level for this warehouse will be zero.", "description": "This feature is for merging duplicate warehouses. It will replace all the links of this warehouse by \"Merge Into\" warehouse. After merging you can delete this warehouse, as stock level for this warehouse will be zero.",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "merge_warehouses_section", "fieldname": "merge_warehouses_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -201,7 +202,7 @@
"doctype": "DocField", "doctype": "DocField",
"fieldname": "merge_with", "fieldname": "merge_with",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Merge With", "label": "Merge Into",
"options": "Warehouse", "options": "Warehouse",
"permlevel": 2 "permlevel": 2
}, },
@ -221,24 +222,6 @@
"role": "Material Master Manager", "role": "Material Master Manager",
"write": 1 "write": 1
}, },
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material User",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 2,
"role": "Material User",
"write": 0
},
{ {
"cancel": 1, "cancel": 1,
"create": 1, "create": 1,
@ -248,6 +231,26 @@
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material Manager",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material User",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0, "create": 0,
"doctype": "DocPerm", "doctype": "DocPerm",
"permlevel": 2, "permlevel": 2,