mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-16 05:15:10 +00:00
test: add unit test for valuation rate on rejected serial/batch item
(cherry picked from commit d002959d35)
This commit is contained in:
@@ -4287,6 +4287,67 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
|
||||
frappe.db.set_single_value("Buying Settings", "set_valuation_rate_for_rejected_materials", 0)
|
||||
|
||||
@IntegrationTestCase.change_settings(
|
||||
"Buying Settings",
|
||||
{"bill_for_rejected_quantity_in_purchase_invoice": 1, "set_valuation_rate_for_rejected_materials": 1},
|
||||
)
|
||||
def test_valuation_rate_for_rejected_materials_with_serial_no(self):
|
||||
item = make_item(
|
||||
"Test Serial Item with Rej Material Valuation",
|
||||
{"is_stock_item": 1, "has_serial_no": 1, "serial_no_series": "SNU-TSIRMV-.#####"},
|
||||
)
|
||||
company = "_Test Company with perpetual inventory"
|
||||
|
||||
warehouse = create_warehouse(
|
||||
"_Test In-ward Warehouse",
|
||||
company="_Test Company with perpetual inventory",
|
||||
)
|
||||
|
||||
rej_warehouse = create_warehouse(
|
||||
"_Test Warehouse - Rejected Material",
|
||||
company="_Test Company with perpetual inventory",
|
||||
)
|
||||
|
||||
pr = make_purchase_receipt(
|
||||
item_code=item.name,
|
||||
qty=10,
|
||||
rate=100,
|
||||
company=company,
|
||||
warehouse=warehouse,
|
||||
rejected_qty=5,
|
||||
rejected_warehouse=rej_warehouse,
|
||||
)
|
||||
|
||||
stock_received_but_not_billed_account = frappe.get_value(
|
||||
"Company",
|
||||
company,
|
||||
"stock_received_but_not_billed",
|
||||
)
|
||||
|
||||
rejected_item_cost = frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{
|
||||
"voucher_type": "Purchase Receipt",
|
||||
"voucher_no": pr.name,
|
||||
"warehouse": rej_warehouse,
|
||||
},
|
||||
"stock_value_difference",
|
||||
)
|
||||
|
||||
self.assertEqual(rejected_item_cost, 500)
|
||||
|
||||
srbnb_cost = frappe.db.get_value(
|
||||
"GL Entry",
|
||||
{
|
||||
"voucher_type": "Purchase Receipt",
|
||||
"voucher_no": pr.name,
|
||||
"account": stock_received_but_not_billed_account,
|
||||
},
|
||||
"credit",
|
||||
)
|
||||
|
||||
self.assertEqual(srbnb_cost, 1500)
|
||||
|
||||
def test_valuation_rate_for_rejected_materials_withoout_accepted_materials(self):
|
||||
item = make_item("Test Item with Rej Material Valuation WO Accepted", {"is_stock_item": 1})
|
||||
company = "_Test Company with perpetual inventory"
|
||||
|
||||
Reference in New Issue
Block a user