test(reco-warehouse): Get items for group warehouse

This commit is contained in:
Nabin Hait 2019-01-03 15:24:59 +05:30
parent fcbe410c2f
commit 47c9826b6f
3 changed files with 18 additions and 4 deletions

View File

@ -286,7 +286,6 @@ def get_items(warehouse, posting_date, posting_time):
with_valuation_rate=True) with_valuation_rate=True)
if frappe.db.get_value("Item", item, "disabled") == 0: if frappe.db.get_value("Item", item, "disabled") == 0:
res.append({ res.append({
"item_code": item, "item_code": item,
"warehouse": wh, "warehouse": wh,

View File

@ -10,7 +10,9 @@ from frappe.utils import flt, nowdate, nowtime
from erpnext.accounts.utils import get_stock_and_account_difference from erpnext.accounts.utils import get_stock_and_account_difference
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
from erpnext.stock.stock_ledger import get_previous_sle, update_entries_after from erpnext.stock.stock_ledger import get_previous_sle, update_entries_after
from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import EmptyStockReconciliationItemsError from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import EmptyStockReconciliationItemsError, get_items
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
from erpnext.stock.doctype.item.test_item import make_item
class TestStockReconciliation(unittest.TestCase): class TestStockReconciliation(unittest.TestCase):
def setUp(self): def setUp(self):
@ -79,6 +81,17 @@ class TestStockReconciliation(unittest.TestCase):
set_perpetual_inventory(0) set_perpetual_inventory(0)
def test_get_items(self):
create_warehouse("_Test Warehouse Group 1", {"is_group": 1})
create_warehouse("_Test Warehouse Ledger 1", {"is_group": 0, "parent_warehouse": "_Test Warehouse Group 1 - _TC"})
item1 = make_item("_Test Stock Reco Item", {"default_warehouse": "_Test Warehouse Ledger 1 - _TC",
"is_stock_item": 1, "opening_stock": 100, "valuation_rate": 100})
items = get_items("_Test Warehouse Group 1 - _TC", nowdate(), nowtime())
self.assertEqual(["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100],
[items[0]["item_code"], items[0]["warehouse"], items[0]["qty"]])
def insert_existing_sle(self): def insert_existing_sle(self):
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry

View File

@ -90,7 +90,7 @@ class TestWarehouse(unittest.TestCase):
self.assertTrue(frappe.db.get_value("Warehouse", self.assertTrue(frappe.db.get_value("Warehouse",
filters={"account": "Test Warehouse for Merging 2 - _TC"})) filters={"account": "Test Warehouse for Merging 2 - _TC"}))
def create_warehouse(warehouse_name): def create_warehouse(warehouse_name, properties=None):
if not frappe.db.exists("Warehouse", warehouse_name + " - _TC"): if not frappe.db.exists("Warehouse", warehouse_name + " - _TC"):
w = frappe.new_doc("Warehouse") w = frappe.new_doc("Warehouse")
w.warehouse_name = warehouse_name w.warehouse_name = warehouse_name
@ -98,11 +98,13 @@ def create_warehouse(warehouse_name):
w.company = "_Test Company" w.company = "_Test Company"
make_account_for_warehouse(warehouse_name, w) make_account_for_warehouse(warehouse_name, w)
w.account = warehouse_name + " - _TC" w.account = warehouse_name + " - _TC"
if properties:
w.update(properties)
w.save() w.save()
def make_account_for_warehouse(warehouse_name, warehouse_obj): def make_account_for_warehouse(warehouse_name, warehouse_obj):
if not frappe.db.exists("Account", warehouse_name + " - _TC"): if not frappe.db.exists("Account", warehouse_name + " - _TC"):
parent_account = frappe.db.get_value('Account', parent_account = frappe.db.get_value('Account',
{'company': warehouse_obj.company, 'is_group':1, 'account_type': 'Stock'},'name') {'company': warehouse_obj.company, 'is_group':1, 'account_type': 'Stock'},'name')
account = create_account(account_name=warehouse_name, \ account = create_account(account_name=warehouse_name, \
account_type="Stock", parent_account= parent_account, company=warehouse_obj.company) account_type="Stock", parent_account= parent_account, company=warehouse_obj.company)