Skip to content

Commit

Permalink
[FIX] ddmrp: buffer_a in test should use a manufactured buffer profile
Browse files Browse the repository at this point in the history
all test adjusted accordingly and added new test for lead_days as
it is useless in manufactured buffer profiles
  • Loading branch information
LoisRForgeFlow committed Oct 11, 2023
1 parent b746639 commit eb56578
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
26 changes: 24 additions & 2 deletions ddmrp/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,22 @@ def setUpClass(cls):
"delay": 8.0,
}
)
# Product D (distributed):
cls.product_distributed = cls.productModel.create(
{
"name": "product Distributed",
"standard_price": 1,
"type": "product",
"uom_id": cls.uom_unit.id,
"default_code": "D",
# TODO: "route_ids": [(6, 0, distribution_route.id)],
}
)

# Create buffers:
cls.buffer_a = cls.bufferModel.create(
{
# TODO: this should a manufacture buffer profile. task for v14 mig.
"buffer_profile_id": cls.buffer_profile_pur.id,
"buffer_profile_id": cls.buffer_profile_mmm.id,
"product_id": cls.productA.id,
"location_id": cls.stock_location.id,
"warehouse_id": cls.warehouse.id,
Expand Down Expand Up @@ -296,6 +306,18 @@ def setUpClass(cls):
"adu_fixed": 5.0,
}
)
cls.buffer_distributed = cls.bufferModel.create(
{
"buffer_profile_id": cls.buffer_profile_distr.id,
"product_id": cls.product_distributed.id,
"location_id": cls.stock_location.id,
"warehouse_id": cls.warehouse.id,
"qty_multiple": 1.0,
"adu_calculation_method": cls.adu_fixed.id,
"adu_fixed": 5.0,
"lead_days": 20,
}
)

# dates for a period of 120 days for estimates.
cls.estimate_date_from = cls.calendar.plan_days(1, datetime.today()).date()
Expand Down
34 changes: 19 additions & 15 deletions ddmrp/tests/test_ddmrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,43 +468,33 @@ def test_20_buffer_zones_red(self):
self.buffer_a, red_base_qty=20, red_safety_qty=10, red_zone_qty=30
)

self.buffer_a.lead_days = 20
self._check_red_zone(
self.buffer_a, red_base_qty=40, red_safety_qty=20, red_zone_qty=60
)

self.buffer_a.buffer_profile_id.lead_time_id.factor = 1
self._check_red_zone(
self.buffer_a, red_base_qty=80, red_safety_qty=40, red_zone_qty=120
self.buffer_a, red_base_qty=40, red_safety_qty=20, red_zone_qty=60
)

self.buffer_a.buffer_profile_id.variability_id.factor = 1
self._check_red_zone(
self.buffer_a, red_base_qty=80, red_safety_qty=80, red_zone_qty=160
self.buffer_a, red_base_qty=40, red_safety_qty=40, red_zone_qty=80
)

self.buffer_a.adu_fixed = 2
self.bufferModel.cron_ddmrp_adu()
self._check_red_zone(
self.buffer_a, red_base_qty=40, red_safety_qty=40, red_zone_qty=80
self.buffer_a, red_base_qty=20, red_safety_qty=20, red_zone_qty=40
)

def test_21_buffer_zones_yellow(self):
self._check_yellow_zone(self.buffer_a, yellow_zone_qty=40.0, top_of_yellow=70.0)

self.buffer_a.lead_days = 20
self._check_yellow_zone(
self.buffer_a, yellow_zone_qty=80.0, top_of_yellow=140.0
)

self.buffer_a.adu_fixed = 2
self.bufferModel.cron_ddmrp_adu()
self._check_yellow_zone(self.buffer_a, yellow_zone_qty=40.0, top_of_yellow=70.0)
self._check_yellow_zone(self.buffer_a, yellow_zone_qty=20.0, top_of_yellow=35.0)

self.buffer_a.buffer_profile_id.lead_time_id.factor = 1
self.buffer_a.buffer_profile_id.variability_id.factor = 1
self._check_yellow_zone(
self.buffer_a, yellow_zone_qty=40.0, top_of_yellow=120.0
self.buffer_a, yellow_zone_qty=20.0, top_of_yellow=60.0
)

def test_22_procure_recommended(self):
Expand Down Expand Up @@ -816,6 +806,20 @@ def test_27_qty_multiple_tolerance(self):
buffer.cron_actions()
self.assertEqual(buffer.procure_recommended_qty, 500)

def test_28_lead_days(self):
self._check_red_zone(
self.buffer_distributed, red_base_qty=50, red_safety_qty=25, red_zone_qty=75
)
self._check_yellow_zone(self.buffer_distributed, yellow_zone_qty=100.0, top_of_yellow=175.0)
self.buffer_distributed.lead_days = 30
self.buffer_distributed.cron_actions()
self._check_red_zone(
self.buffer_distributed, red_base_qty=75, red_safety_qty=37.5, red_zone_qty=112.5
)
self._check_yellow_zone(
self.buffer_distributed, yellow_zone_qty=150.0, top_of_yellow=262.5
)

# TEST SECTION 3: DLT, BoM's and misc

def test_30_bom_buffer_fields(self):
Expand Down

0 comments on commit eb56578

Please sign in to comment.