fix: test case added for FG_BASED OPERTING COST
This commit is contained in:
parent
ddc0127e05
commit
f0c0a64984
@ -202,6 +202,33 @@ class TestBOM(FrappeTestCase):
|
||||
|
||||
self.assertEqual(bom.items[0].rate, 20)
|
||||
|
||||
def test_bom_cost_with_fg_based_operating_cost(self):
|
||||
bom = frappe.copy_doc(test_records[4])
|
||||
bom.insert()
|
||||
|
||||
raw_material_cost = 0.0
|
||||
op_cost = 0.0
|
||||
|
||||
op_cost = bom.quantity * bom.operating_cost_per_bom_quantity
|
||||
|
||||
for row in bom.items:
|
||||
raw_material_cost += row.amount
|
||||
|
||||
base_raw_material_cost = raw_material_cost * flt(
|
||||
bom.conversion_rate, bom.precision("conversion_rate")
|
||||
)
|
||||
base_op_cost = op_cost * flt(bom.conversion_rate, bom.precision("conversion_rate"))
|
||||
|
||||
# test amounts in selected currency, almostEqual checks for 7 digits by default
|
||||
self.assertAlmostEqual(bom.operating_cost, op_cost)
|
||||
self.assertAlmostEqual(bom.raw_material_cost, raw_material_cost)
|
||||
self.assertAlmostEqual(bom.total_cost, raw_material_cost + op_cost)
|
||||
|
||||
# test amounts in selected currency
|
||||
self.assertAlmostEqual(bom.base_operating_cost, base_op_cost)
|
||||
self.assertAlmostEqual(bom.base_raw_material_cost, base_raw_material_cost)
|
||||
self.assertAlmostEqual(bom.base_total_cost, base_raw_material_cost + base_op_cost)
|
||||
|
||||
def test_subcontractor_sourced_item(self):
|
||||
item_code = "_Test Subcontracted FG Item 1"
|
||||
set_backflush_based_on("Material Transferred for Subcontract")
|
||||
|
@ -162,5 +162,31 @@
|
||||
"item": "_Test Variant Item",
|
||||
"quantity": 1.0,
|
||||
"with_operations": 1
|
||||
},
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"amount": 5000.0,
|
||||
"doctype": "BOM Item",
|
||||
"item_code": "_Test Item",
|
||||
"parentfield": "items",
|
||||
"qty": 2.0,
|
||||
"rate": 3000.0,
|
||||
"uom": "_Test UOM",
|
||||
"stock_uom": "_Test UOM",
|
||||
"source_warehouse": "_Test Warehouse - _TC",
|
||||
"include_item_in_manufacturing": 1
|
||||
}
|
||||
],
|
||||
"docstatus": 1,
|
||||
"doctype": "BOM",
|
||||
"is_active": 1,
|
||||
"is_default": 1,
|
||||
"currency": "USD",
|
||||
"item": "_Test Variant Item",
|
||||
"quantity": 1.0,
|
||||
"with_operations": 0,
|
||||
"fg_based_operating_cost": 1,
|
||||
"operating_cost_per_bom_quantity": 140
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user