Skip to content

Commit

Permalink
refactor: remove minor code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarvora committed Jun 22, 2024
1 parent a8412eb commit 4096344
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
24 changes: 8 additions & 16 deletions erpnext/controllers/subcontracting_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,10 @@ def __update_consumed_materials(self, doctype, return_consumed_items=False):
return

voucher_nos = [d.voucher_no for d in consumed_materials if d.voucher_no]
voucher_bundle_data = (
get_voucher_wise_serial_batch_from_bundle(
voucher_no=voucher_nos,
is_outward=1,
get_subcontracted_item=("Subcontracting Receipt Supplied Item", "main_item_code"),
)
if voucher_nos
else {}
voucher_bundle_data = get_voucher_wise_serial_batch_from_bundle(
voucher_no=voucher_nos,
is_outward=1,
get_subcontracted_item=("Subcontracting Receipt Supplied Item", "main_item_code"),
)

for row in consumed_materials:
Expand Down Expand Up @@ -357,14 +353,10 @@ def get_available_materials(self):
transferred_items = self.__get_transferred_items()

voucher_nos = [row.voucher_no for row in transferred_items]
voucher_bundle_data = (
get_voucher_wise_serial_batch_from_bundle(
voucher_no=voucher_nos,
is_outward=0,
get_subcontracted_item=("Stock Entry Detail", "subcontracted_item"),
)
if voucher_nos
else {}
voucher_bundle_data = get_voucher_wise_serial_batch_from_bundle(
voucher_no=voucher_nos,
is_outward=0,
get_subcontracted_item=("Stock Entry Detail", "subcontracted_item"),
)

for row in transferred_items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,9 @@ def get_available_batches(kwargs):

# For work order and subcontracting
def get_voucher_wise_serial_batch_from_bundle(**kwargs) -> dict[str, dict]:
if kwargs.get("voucher_nos") == []:
return {}

data = get_ledgers_from_serial_batch_bundle(**kwargs)
if not data:
return {}
Expand Down

0 comments on commit 4096344

Please sign in to comment.