mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-24 05:47:15 +00:00
fix(manufacturing): include the mrp bucket that ends on to_date (#59143)
(cherry picked from commit 5d5eeb5e02)
This commit is contained in:
@@ -1102,7 +1102,7 @@ class MaterialRequirementsPlanningReport:
|
||||
from_date = get_first_day(from_date)
|
||||
|
||||
dates_list = []
|
||||
while getdate(self.filters.to_date) > getdate(from_date):
|
||||
while getdate(from_date) <= getdate(self.filters.to_date):
|
||||
args = {"from_date": from_date}
|
||||
|
||||
days = 1 if bucket_size == "Daily" else 7
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import frappe
|
||||
from frappe.tests.classes.context_managers import freeze_time
|
||||
from frappe.utils import add_days, flt, formatdate, today
|
||||
from frappe.utils import add_days, flt, formatdate, getdate, today
|
||||
|
||||
from erpnext.accounts.doctype.tax_rule.test_tax_rule import make_tax_rule
|
||||
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
|
||||
@@ -188,6 +188,32 @@ class TestMaterialRequirementsPlanningReport(ERPNextTestSuite):
|
||||
purchase_order.grand_total, net_total + net_total * flt(template.taxes[0].rate) / 100
|
||||
)
|
||||
|
||||
def test_buckets_include_the_period_that_ends_on_a_bucket_boundary(self):
|
||||
"""A to_date landing on a bucket's first day must still get that bucket's column."""
|
||||
cases = [
|
||||
("Monthly", "2026-11-01", "2026-12-01", ["2026-11-01", "2026-12-01"]),
|
||||
("Monthly", "2026-12-01", "2026-12-01", ["2026-12-01"]),
|
||||
("Daily", "2026-11-30", "2026-12-01", ["2026-11-30", "2026-12-01"]),
|
||||
("Weekly", "2026-11-30", "2026-12-07", ["2026-11-30", "2026-12-07"]),
|
||||
]
|
||||
|
||||
for bucket_size, from_date, to_date, bucket_starts in cases:
|
||||
with self.subTest(bucket_size=bucket_size, to_date=to_date):
|
||||
report = MaterialRequirementsPlanningReport(
|
||||
frappe._dict({"bucket_size": bucket_size, "from_date": from_date, "to_date": to_date})
|
||||
)
|
||||
|
||||
dates = report.get_dates()
|
||||
self.assertEqual(
|
||||
[getdate(d["from_date"]) for d in dates],
|
||||
[getdate(start) for start in bucket_starts],
|
||||
)
|
||||
if bucket_size == "Monthly":
|
||||
self.assertEqual(
|
||||
[d["label"] for d in dates],
|
||||
[formatdate(start, "MMM YYYY") for start in bucket_starts],
|
||||
)
|
||||
|
||||
|
||||
def make_mrp_plan(test_case, planned_qty=10, rm_qty=2):
|
||||
"""Build a finished good with a submitted BOM and an MPS demanding it, then return the
|
||||
|
||||
Reference in New Issue
Block a user