refactor(minor): rename function to be more descriptive

This commit is contained in:
Sagar Sharma 2023-05-12 11:45:33 +05:30
parent e0b22edb2e
commit d6433f803b
4 changed files with 14 additions and 14 deletions

View File

@ -741,7 +741,7 @@ class SubcontractingController(StockController):
sco_doc = frappe.get_doc("Subcontracting Order", sco)
sco_doc.update_status()
def set_missing_values_in_additional_costs(self):
def calculate_additional_costs(self):
self.total_additional_costs = sum(flt(item.amount) for item in self.get("additional_costs"))
if self.total_additional_costs:

View File

@ -36,7 +36,7 @@ class TestSubcontractingController(FrappeTestCase):
sco.remove_empty_rows()
self.assertEqual((len_before - 1), len(sco.service_items))
def test_set_missing_values_in_additional_costs(self):
def test_calculate_additional_costs(self):
sco = get_subcontracting_order(do_not_submit=1)
rate_without_additional_cost = sco.items[0].rate

View File

@ -77,22 +77,22 @@ class SubcontractingOrder(SubcontractingController):
frappe.throw(_(msg))
def set_missing_values(self):
self.set_missing_values_in_additional_costs()
self.set_missing_values_in_service_items()
self.set_missing_values_in_supplied_items()
self.set_missing_values_in_items()
self.calculate_additional_costs()
self.calculate_service_costs()
self.calculate_supplied_items_qty_and_amount()
self.calculate_items_qty_and_amount()
def set_missing_values_in_service_items(self):
def calculate_service_costs(self):
for idx, item in enumerate(self.get("service_items")):
self.items[idx].service_cost_per_qty = item.amount / self.items[idx].qty
def set_missing_values_in_supplied_items(self):
def calculate_supplied_items_qty_and_amount(self):
for item in self.get("items"):
bom = frappe.get_doc("BOM", item.bom)
rm_cost = sum(flt(rm_item.amount) for rm_item in bom.items)
item.rm_cost_per_qty = rm_cost / flt(bom.quantity)
def set_missing_values_in_items(self):
def calculate_items_qty_and_amount(self):
total_qty = total = 0
for item in self.items:
item.rate = item.rm_cost_per_qty + item.service_cost_per_qty + flt(item.additional_cost_per_qty)

View File

@ -113,9 +113,9 @@ class SubcontractingReceipt(SubcontractingController):
@frappe.whitelist()
def set_missing_values(self):
self.set_missing_values_in_additional_costs()
self.set_missing_values_in_supplied_items()
self.set_missing_values_in_items()
self.calculate_additional_costs()
self.calculate_supplied_items_qty_and_amount()
self.calculate_items_qty_and_amount()
def set_available_qty_for_consumption(self):
supplied_items_details = {}
@ -147,13 +147,13 @@ class SubcontractingReceipt(SubcontractingController):
item.rm_item_code, 0
)
def set_missing_values_in_supplied_items(self):
def calculate_supplied_items_qty_and_amount(self):
for item in self.get("supplied_items") or []:
item.amount = item.rate * item.consumed_qty
self.set_available_qty_for_consumption()
def set_missing_values_in_items(self):
def calculate_items_qty_and_amount(self):
rm_supp_cost = {}
for item in self.get("supplied_items") or []:
if item.reference_name in rm_supp_cost: