Skip to content

Commit

Permalink
Added planned dates, shifts, and workstation hours
Browse files Browse the repository at this point in the history
  • Loading branch information
coleandreoli committed Nov 6, 2024
1 parent 5b45ab7 commit 979df0f
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 19 deletions.
136 changes: 120 additions & 16 deletions inventory_tools/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,51 @@
),
]

# workstations = [
# ("Mix Pie Crust Station", "20"),
# ("Roll Pie Crust Station", "20"),
# ("Make Pie Filling Station", "20"),
# ("Cooling Station", "100"),
# ("Box Pie Station", "100"),
# ("Baking Station", "20"),
# ("Assemble Pie Station", "20"),
# ("Mix Pie Filling Station", "20"),
# ("Packaging Station", "2"),
# ("Food Prep Table 2", "10"),
# ("Food Prep Table 1", "5"),
# ("Range Station", "20"),
# ("Cooling Racks Station", "80"),
# ("Refrigerator Station", "200"),
# ("Oven Station", "20"),
# ("Mixer Station", "10"),
# ]

workstations = [
("Mix Pie Crust Station", "20"),
("Roll Pie Crust Station", "20"),
("Make Pie Filling Station", "20"),
("Cooling Station", "100"),
("Box Pie Station", "100"),
("Baking Station", "20"),
("Assemble Pie Station", "20"),
("Mix Pie Filling Station", "20"),
("Packaging Station", "2"),
("Food Prep Table 2", "10"),
("Food Prep Table 1", "5"),
("Range Station", "20"),
("Cooling Racks Station", "80"),
("Refrigerator Station", "200"),
("Oven Station", "20"),
("Mixer Station", "10"),
{"workstation_name": "Mix Pie Crust Station", "production_capacity": "20", "shift_types": ["Day Shift", "Evening Shift"]},
{"workstation_name": "Roll Pie Crust Station", "production_capacity": "20", "shift_types": ["Day Shift"]},
{"workstation_name": "Make Pie Filling Station", "production_capacity": "20", "shift_types": ["Day Shift"]},
{"workstation_name": "Cooling Station", "production_capacity": "100", "shift_types": ["Day Shift", "Evening Shift"]},
{"workstation_name": "Box Pie Station", "production_capacity": "100", "shift_types": ["Day Shift"]},
{"workstation_name": "Baking Station", "production_capacity": "20", "shift_types": ["Day Shift", "Evening Shift"]},
{"workstation_name": "Assemble Pie Station", "production_capacity": "20", "shift_types": ["Day Shift"]},
{"workstation_name": "Mix Pie Filling Station", "production_capacity": "20", "shift_types": ["Day Shift"]},
{"workstation_name": "Packaging Station", "production_capacity": "2", "shift_types": ["Day Shift"]},
{"workstation_name": "Food Prep Table 2", "production_capacity": "10", "shift_types": ["Day Shift"]},
{"workstation_name": "Food Prep Table 1", "production_capacity": "5", "shift_types": ["Day Shift", "Evening Shift"]},
{"workstation_name": "Range Station", "production_capacity": "20", "shift_types": ["Day Shift"]},
{"workstation_name": "Cooling Racks Station", "production_capacity": "80", "shift_types": ["Day Shift"]},
{"workstation_name": "Refrigerator Station", "production_capacity": "200", "shift_types": ["Day Shift"]},
{"workstation_name": "Oven Station", "production_capacity": "20", "shift_types": ["Day Shift", "Evening Shift"]},
{"workstation_name": "Mixer Station", "production_capacity": "10", "shift_types": ["Day Shift"]}
]

shifts = [
{"name": "Day Shift", "start_time": "06:00:00", "end_time": "14:00:00", "color": "Yellow"},
{"name": "Evening Shift", "start_time": "14:00:00", "end_time": "22:00:00", "color": "Blue"},
{"name": "Night Shift", "start_time": "22:00:00", "end_time": "06:00:00", "color": "Violet"}
]


operations = [
(
"Gather Pie Crust Ingredients",
Expand Down Expand Up @@ -1178,3 +1204,81 @@
"Color": ["Yellow", "Red"],
},
}

planned_dates = {
"Ambrosia Pie": {
"planned_start_date": "11-01",
"planned_end_date": "11-05",
"expected_delivery_date": "11-07",
},
"Double Plum Pie": {
"planned_start_date": "11-03",
"planned_end_date": "11-08",
"expected_delivery_date": "11-10",
},
"Gooseberry Pie": {
"planned_start_date": "11-02",
"planned_end_date": "11-06",
"expected_delivery_date": "11-09",
},
"Kaduka Key Lime Pie": {
"planned_start_date": "11-04",
"planned_end_date": "11-09",
"expected_delivery_date": "11-12",
},
"Pocketful of Bay": {
"planned_start_date": "11-14",
"planned_end_date": "11-28",
"expected_delivery_date": "12-01",
},
"Tower of Bay-bel": {
"planned_start_date": "11-15",
"planned_end_date": "11-29",
"expected_delivery_date": "12-02",
},
"Pie Crust": {
"planned_start_date": "11-16",
"planned_end_date": "11-30",
"expected_delivery_date": "12-03",
},
"Ambrosia Pie Filling": {
"planned_start_date": "11-17",
"planned_end_date": "12-01",
"expected_delivery_date": "12-04",
},
"Kaduka Key Lime Pie Filling": {
"planned_start_date": "11-18",
"planned_end_date": "12-02",
"expected_delivery_date": "12-05",
},
"Gooseberry Pie Filling": {
"planned_start_date": "11-19",
"planned_end_date": "12-03",
"expected_delivery_date": "12-06",
},
"Bayberry Pocket": {
"planned_start_date": "11-20",
"planned_end_date": "12-04",
"expected_delivery_date": "12-07",
},
"Bayberry Popper": {
"planned_start_date": "11-21",
"planned_end_date": "12-05",
"expected_delivery_date": "12-08",
},
"Bayberry Pie": {
"planned_start_date": "11-22",
"planned_end_date": "12-06",
"expected_delivery_date": "12-09",
},
"Bayberry Pie Filling": {
"planned_start_date": "11-23",
"planned_end_date": "12-07",
"expected_delivery_date": "12-10",
},
"Double Plum Pie Filling": {
"planned_start_date": "11-24",
"planned_end_date": "12-08",
"expected_delivery_date": "12-11",
},
}
34 changes: 31 additions & 3 deletions inventory_tools/tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
specifications,
suppliers,
workstations,
planned_dates,
shifts,
)


Expand Down Expand Up @@ -89,6 +91,8 @@ def create_test_data():
frappe.db.set_single_value("Stock Settings", "default_warehouse", "")
create_warehouses(settings)
setup_manufacturing_settings(settings)
# create_shift_types is a pre-req for createworkstations
create_shift_types()
create_workstations()
create_operations()
create_item_groups(settings)
Expand Down Expand Up @@ -203,13 +207,33 @@ def setup_manufacturing_settings(settings):
frappe.set_value("Inventory Tools Settings", settings.company, "show_in_listview", 1)


def create_shift_types():
for shift in shifts:
if frappe.db.exists("Shift Type", shift["name"]):
continue
sh = frappe.new_doc("Shift Type")
sh.name = shift["name"]
sh.start_time = shift["start_time"]
sh.end_time = shift["end_time"]
sh.color = shift["color"]
sh.save()

def create_workstations():
for ws in workstations:
if frappe.db.exists("Workstation", ws[0]):
if frappe.db.exists("Workstation", ws["workstation_name"]):
continue
work = frappe.new_doc("Workstation")
work.workstation_name = ws[0]
work.production_capacity = ws[1]
work.workstation_name = ws["workstation_name"]
work.production_capacity = ws["production_capacity"]
for shift_type in ws['shift_types']:
for sh in shifts:
if sh["name"] == shift_type:
result = sh
work.append("working_hours", {
"shift_type": shift_type,
"start_time": result["start_time"],
"end_time": result["end_time"]
})
work.save()


Expand Down Expand Up @@ -638,6 +662,10 @@ def create_production_plan(settings, prod_plan_from_doc):
for wo in wos:
wo = frappe.get_doc("Work Order", wo)
wo.wip_warehouse = "Kitchen - APC"
current_year = str(settings.day.year)
wo.planned_start_date = f'{current_year}-{planned_dates[wo.item_name]["planned_start_date"]}'
wo.planned_end_date = f'{current_year}-{planned_dates[wo.item_name]["planned_end_date"]}'
wo.expected_delivery_date = f'{current_year}-{planned_dates[wo.item_name]["expected_delivery_date"]}'
wo.save()
wo.submit()
job_cards = frappe.get_all("Job Card", {"work_order": wo.name})
Expand Down

0 comments on commit 979df0f

Please sign in to comment.