test: for subcontracting item be received

This commit is contained in:
Anurag Mishra 2019-05-06 16:30:52 +05:30
parent d0cdb4a1e9
commit 9acb2bf28f
3 changed files with 43 additions and 6 deletions

View File

@ -52,7 +52,7 @@ def get_columns():
{
"label": _("Required Quantity"),
"fieldtype": "Float",
"fieldname": "r_qty",
"fieldname": "required_qty",
"width": 100
},
{
@ -64,7 +64,7 @@ def get_columns():
{
"label": _("Pending Quantity"),
"fieldtype": "Float",
"fieldname": "p_qty",
"fieldname": "pending_qty",
"width": 100
}
]
@ -72,7 +72,6 @@ def get_columns():
def get_data(data, filters):
po = get_po(filters)
po_name = [v.name for v in po]
print(po_name)
sub_items = get_purchase_order_item_supplied(po_name)
for item in sub_items:
for order in po:
@ -83,9 +82,9 @@ def get_data(data, filters):
'supplier': order.supplier,
'fg_item_code': item.item_code,
'item_name': item.item_name,
'r_qty': item.qty,
'required_qty': item.qty,
'received_qty':item.received_qty,
'p_qty':item.qty - item.received_qty
'pending_qty':item.qty - item.received_qty
}
data.append(row)

View File

@ -0,0 +1,36 @@
# Python bytecode 2.7 (62211)
# Embedded file name: /Users/anuragmishra/frappe-develop/apps/erpnext/erpnext/buying/report/subcontracted_item_to_be_received/test_subcontracted_item_to_be_received.py
# Compiled at: 2019-05-06 09:51:46
# Decompiled by https://python-decompiler.com
from __future__ import unicode_literals
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
from erpnext.buying.report.subcontracted_item_to_be_received.subcontracted_item_to_be_received import execute
import frappe, unittest
from pprint import pprint
class TestSubcontractedItemToBeReceived(unittest.TestCase):
def test_pending_and_received_qty(self):
po = create_purchase_order(item_code='_Test FG Item', is_subcontracted='Yes')
transfer_param = []
make_stock_entry(item_code='_Test Item', target='_Test Warehouse 1 - _TC', qty=100, basic_rate=100)
make_stock_entry(item_code='_Test Item Home Desktop 100', target='_Test Warehouse 1 - _TC', qty=100, basic_rate=100)
make_purchase_receipt_against_po(po.name)
po.reload()
col, data = execute(filters=frappe._dict({'supplier': po.supplier,
'from_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=-10)),
'to_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=10))}))
self.assertEqual(data[0]['pending_qty'], 5)
self.assertEqual(data[0]['received_qty'], 5)
self.assertEqual(data[0]['purchase_order'], po.name)
self.assertEqual(data[0]['supplier'], po.supplier)
def make_purchase_receipt_against_po(po, quantity=5):
pr = make_purchase_receipt(po)
pr.items[0].qty = quantity
pr.supplier_warehouse = '_Test Warehouse 1 - _TC'
pr.insert()
pr.submit()

View File

@ -100,7 +100,8 @@ def get_transferred_quantity(po_name):
stock_entries = get_stock_entry(po_name)
stock_entries_detail = get_stock_entry_detail([v.name for v in stock_entries])
po_transferred_qty_map = {}
from pprint import pprint
pprint(stock_entries)
for entry in stock_entries:
for details in stock_entries_detail:
if details.parent == entry.name:
@ -115,6 +116,7 @@ def get_transferred_quantity(po_name):
def get_stock_entry(po):
print(po)
return frappe.get_all("Stock Entry", filters=[
('purchase_order', 'IN', po),
('stock_entry_type', '=', 'Send to Subcontractor'),