Skip to content

Commit 8a68850

Browse files
authored
feat: time_logs as mobile_v15 (#287)
1 parent 61b660d commit 8a68850

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

beam/beam/scan/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ def get_form_action(barcode_doc: frappe._dict, context: frappe._dict) -> list[di
249249
actions = frm.get(barcode_doc.doc.doctype, {}).get(context.frm, [])
250250
for action in actions:
251251
action["context"] = target
252-
if isinstance(action.get("target"), str) and "." in action.get("target"):
253-
serialized_target = action.get("target").split(".")
252+
target_value = action.get("target")
253+
if isinstance(target_value, str) and "." in target_value:
254+
serialized_target = target_value.split(".")
254255
action["target"] = target.get(serialized_target[1])
255256

256257
return actions

beam/tests/setup.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,22 +533,35 @@ def create_production_plan(settings, prod_plan_from_doc):
533533

534534
pp.make_work_order()
535535
wos = frappe.get_all("Work Order", {"production_plan": pp.name})
536+
start_time = datetime.datetime(settings.day.year, settings.day.month, settings.day.day, 0, 0)
536537
for wo in wos:
537538
wo = frappe.get_doc("Work Order", wo)
538539
wo.wip_warehouse = "Kitchen - APC"
540+
wo.actual_start_date = wo.planned_start_date = start_time
541+
wo.required_items = sorted(wo.required_items, key=lambda x: x.get("item_code"))
542+
for idx, w in enumerate(wo.required_items, start=1):
543+
w.idx = idx
539544
wo.save()
540545
wo.submit()
546+
frappe.db.set_value("Work Order", wo.name, "creation", start_time)
541547
job_cards = frappe.get_all("Job Card", {"work_order": wo.name})
542548
for job_card in job_cards:
543549
job_card = frappe.get_doc("Job Card", job_card)
550+
batch_size, total_operation_time = frappe.get_value(
551+
"Operation", job_card.operation, ["batch_size", "total_operation_time"]
552+
)
553+
time_in_mins = (total_operation_time / batch_size) * wo.qty
544554
job_card.append(
545555
"time_logs",
546556
{
547-
"completed_qty": wo.qty,
557+
"from_time": start_time,
558+
"to_time": start_time + datetime.timedelta(minutes=time_in_mins),
559+
"time_in_mins": time_in_mins,
560+
"remaining_time_in_mins": time_in_mins,
548561
},
549562
)
550563
job_card.save()
551-
job_card.submit()
564+
start_time = job_card.time_logs[0].to_time + datetime.timedelta(minutes=2)
552565

553566

554567
def create_purchase_receipt_for_received_qty_test(settings):

0 commit comments

Comments
 (0)