mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 05:09:11 +00:00
Test case for purchase return
This commit is contained in:
@@ -119,6 +119,38 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
for serial_no in rejected_serial_nos:
|
for serial_no in rejected_serial_nos:
|
||||||
self.assertEquals(frappe.db.get_value("Serial No", serial_no, "warehouse"),
|
self.assertEquals(frappe.db.get_value("Serial No", serial_no, "warehouse"),
|
||||||
pr.get("items")[0].rejected_warehouse)
|
pr.get("items")[0].rejected_warehouse)
|
||||||
|
|
||||||
|
def test_purchase_return(self):
|
||||||
|
set_perpetual_inventory()
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
self.assertEqual(outgoing_rate, 50)
|
||||||
|
|
||||||
|
|
||||||
|
# check gl entries for return
|
||||||
|
gl_entries = get_gl_entries("Purchase Receipt", return_pr.name)
|
||||||
|
|
||||||
|
self.assertTrue(gl_entries)
|
||||||
|
|
||||||
|
expected_values = {
|
||||||
|
"_Test Warehouse - _TC": [0.0, 100.0],
|
||||||
|
"Stock Received But Not Billed - _TC": [100.0, 0.0],
|
||||||
|
}
|
||||||
|
|
||||||
|
for gle in gl_entries:
|
||||||
|
self.assertEquals(expected_values[gle.account][0], gle.debit)
|
||||||
|
self.assertEquals(expected_values[gle.account][1], gle.credit)
|
||||||
|
|
||||||
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
|
|
||||||
def get_gl_entries(voucher_type, voucher_no):
|
def get_gl_entries(voucher_type, voucher_no):
|
||||||
return frappe.db.sql("""select account, debit, credit
|
return frappe.db.sql("""select account, debit, credit
|
||||||
@@ -142,6 +174,8 @@ def make_purchase_receipt(**args):
|
|||||||
pr.is_subcontracted = args.is_subcontracted or "No"
|
pr.is_subcontracted = args.is_subcontracted or "No"
|
||||||
pr.supplier_warehouse = "_Test Warehouse 1 - _TC"
|
pr.supplier_warehouse = "_Test Warehouse 1 - _TC"
|
||||||
pr.currency = args.currency or "INR"
|
pr.currency = args.currency or "INR"
|
||||||
|
pr.is_return = args.is_return
|
||||||
|
pr.return_against = args.return_against
|
||||||
|
|
||||||
pr.append("items", {
|
pr.append("items", {
|
||||||
"item_code": args.item or args.item_code or "_Test Item",
|
"item_code": args.item or args.item_code or "_Test Item",
|
||||||
|
|||||||
Reference in New Issue
Block a user