From cc1c7ad2dfa14ef2deda6376252984520bedecdb Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 2 Sep 2016 16:19:10 +0530 Subject: [PATCH] added test cases --- .../purchase_receipt/test_purchase_receipt.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index eba9201cb4..f961cdd1ef 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -125,7 +125,7 @@ class TestPurchaseReceipt(unittest.TestCase): pr = make_purchase_receipt() return_pr = make_purchase_receipt(is_return=1, return_against=pr.name, qty=-2) - + # check sle outgoing_rate = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Purchase Receipt", "voucher_no": return_pr.name}, "outgoing_rate") @@ -148,7 +148,21 @@ class TestPurchaseReceipt(unittest.TestCase): self.assertEquals(expected_values[gle.account][1], gle.credit) set_perpetual_inventory(0) + + def test_purchase_return_for_rejected_qty(self): + set_perpetual_inventory() + + pr = make_purchase_receipt(received_qty=4, qty=2) + + return_pr = make_purchase_receipt(is_return=1, return_against=pr.name, received_qty = -4, qty=-2) + + actual_qty = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Purchase Receipt", + "voucher_no": return_pr.name, 'warehouse': return_pr.items[0].rejected_warehouse}, "actual_qty") + self.assertEqual(actual_qty, -2) + + set_perpetual_inventory(0) + def test_purchase_return_for_serialized_items(self): def _check_serial_no_values(serial_no, field_values): serial_no = frappe.get_doc("Serial No", serial_no) @@ -248,17 +262,23 @@ def make_purchase_receipt(**args): pr.currency = args.currency or "INR" pr.is_return = args.is_return pr.return_against = args.return_against - + qty = args.qty or 5 + received_qty = args.received_qty or qty + rejected_qty = args.rejected_qty or flt(received_qty) - flt(qty) + pr.append("items", { "item_code": args.item or args.item_code or "_Test Item", "warehouse": args.warehouse or "_Test Warehouse - _TC", - "qty": args.qty or 5, - "received_qty": args.qty or 5, + "qty": qty, + "received_qty": received_qty, + "rejected_qty": rejected_qty, + "rejected_warehouse": args.rejected_warehouse or "_Test Rejected Warehouse - _TC" if rejected_qty != 0 else "", "rate": args.rate or 50, "conversion_factor": 1.0, "serial_no": args.serial_no, "stock_uom": "_Test UOM" }) + if not args.do_not_save: pr.insert() if not args.do_not_submit: