diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 9b76a14381..51c85ce48b 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -118,6 +118,28 @@ class TestPurchaseReceipt(unittest.TestCase): self.assertFalse(frappe.db.get_value("Serial No", pr.get("purchase_receipt_details")[0].serial_no, "warehouse")) + def test_rejected_serial_no(self): + pr = frappe.copy_doc(test_records[0]) + pr.get("purchase_receipt_details")[0].item_code = "_Test Serialized Item With Series" + pr.get("purchase_receipt_details")[0].qty = 3 + pr.get("purchase_receipt_details")[0].rejected_qty = 2 + pr.get("purchase_receipt_details")[0].received_qty = 5 + pr.get("purchase_receipt_details")[0].rejected_warehouse = "_Test Rejected Warehouse - _TC" + pr.insert() + pr.submit() + + accepted_serial_nos = pr.get("purchase_receipt_details")[0].serial_no.split("\n") + self.assertEquals(len(accepted_serial_nos), 3) + for serial_no in accepted_serial_nos: + self.assertEquals(frappe.db.get_value("Serial No", serial_no, "warehouse"), + pr.get("purchase_receipt_details")[0].warehouse) + + rejected_serial_nos = pr.get("purchase_receipt_details")[0].rejected_serial_no.split("\n") + self.assertEquals(len(rejected_serial_nos), 2) + for serial_no in rejected_serial_nos: + self.assertEquals(frappe.db.get_value("Serial No", serial_no, "warehouse"), + pr.get("purchase_receipt_details")[0].rejected_warehouse) + def get_gl_entries(voucher_type, voucher_no): return frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type=%s and voucher_no=%s diff --git a/erpnext/stock/doctype/warehouse/test_records.json b/erpnext/stock/doctype/warehouse/test_records.json index 72071f88ca..d5df1759d8 100644 --- a/erpnext/stock/doctype/warehouse/test_records.json +++ b/erpnext/stock/doctype/warehouse/test_records.json @@ -11,6 +11,12 @@ "doctype": "Warehouse", "warehouse_name": "_Test Warehouse 1" }, + { + "company": "_Test Company", + "create_account_under": "Stock Assets - _TC", + "doctype": "Warehouse", + "warehouse_name": "_Test Rejected Warehouse" + }, { "company": "_Test Company 1", "create_account_under": "Stock Assets - _TC1",