mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 06:59:20 +00:00
refactor!: Stock Ledger Entry
This commit is contained in:
@@ -405,61 +405,6 @@ class TestStockLedgerEntry(FrappeTestCase):
|
|||||||
lcv.cancel()
|
lcv.cancel()
|
||||||
pr.cancel()
|
pr.cancel()
|
||||||
|
|
||||||
def test_sub_contracted_item_costing(self):
|
|
||||||
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
|
|
||||||
|
|
||||||
company = "_Test Company"
|
|
||||||
rm_item_code = "_Test Item for Reposting"
|
|
||||||
subcontracted_item = "_Test Subcontracted Item for Reposting"
|
|
||||||
|
|
||||||
frappe.db.set_value(
|
|
||||||
"Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM"
|
|
||||||
)
|
|
||||||
make_bom(item=subcontracted_item, raw_materials=[rm_item_code], currency="INR")
|
|
||||||
|
|
||||||
# Purchase raw materials on supplier warehouse: Qty = 50, Rate = 100
|
|
||||||
pr = make_purchase_receipt(
|
|
||||||
company=company,
|
|
||||||
posting_date="2020-04-10",
|
|
||||||
warehouse="Stores - _TC",
|
|
||||||
item_code=rm_item_code,
|
|
||||||
qty=10,
|
|
||||||
rate=100,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Purchase Receipt for subcontracted item
|
|
||||||
pr1 = make_purchase_receipt(
|
|
||||||
company=company,
|
|
||||||
posting_date="2020-04-20",
|
|
||||||
warehouse="Finished Goods - _TC",
|
|
||||||
supplier_warehouse="Stores - _TC",
|
|
||||||
item_code=subcontracted_item,
|
|
||||||
qty=10,
|
|
||||||
rate=20,
|
|
||||||
is_subcontracted=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(pr1.items[0].valuation_rate, 120)
|
|
||||||
|
|
||||||
# Update raw material's valuation via LCV, Additional cost = 50
|
|
||||||
lcv = create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company)
|
|
||||||
|
|
||||||
pr1.reload()
|
|
||||||
self.assertEqual(pr1.items[0].valuation_rate, 125)
|
|
||||||
|
|
||||||
# check outgoing_rate for DN after reposting
|
|
||||||
incoming_rate = frappe.db.get_value(
|
|
||||||
"Stock Ledger Entry",
|
|
||||||
{"voucher_type": "Purchase Receipt", "voucher_no": pr1.name, "item_code": subcontracted_item},
|
|
||||||
"incoming_rate",
|
|
||||||
)
|
|
||||||
self.assertEqual(incoming_rate, 125)
|
|
||||||
|
|
||||||
# cleanup data
|
|
||||||
pr1.cancel()
|
|
||||||
lcv.cancel()
|
|
||||||
pr.cancel()
|
|
||||||
|
|
||||||
def test_back_dated_entry_not_allowed(self):
|
def test_back_dated_entry_not_allowed(self):
|
||||||
# Back dated stock transactions are only allowed to stock managers
|
# Back dated stock transactions are only allowed to stock managers
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
|
|||||||
Reference in New Issue
Block a user