From 3aafda331b432b9cb05e1953badea47bd6895dd3 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 14 Jul 2026 10:20:41 +0530 Subject: [PATCH] fix: duplicate scorecard period when supplier is created on a month end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make_all_scorecards' dedup query used strict bounds, so a single-day period (supplier created on a month's last day -> start == end under "Per Month") never matched its own window and was re-created on every call. The daily refresh_scorecards job would insert a duplicate submitted period each day for such suppliers, and test_make_all_scorecards_is_idempotent fails on any date where nowdate() - 75 days lands on a month end — both nightly server suites went red on 2026-07-14 (75 days after April 30). Inclusive bounds cannot false-match adjacent periods: each next period starts at end_date + 1, so closed intervals never touch. --- .../buying/doctype/supplier_scorecard/supplier_scorecard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py index 82abbb3ae09..1b99160a3c8 100644 --- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py @@ -201,14 +201,16 @@ def make_all_scorecards(docname: str): while (start_date < todays) and (end_date <= todays): # check to make sure there is no scorecard period already created + # (inclusive bounds: a single-day period — supplier created on a month's + # last day — must match its own window, else it is re-created every run) scorecards = frappe.get_all( "Supplier Scorecard Period", fields=["name"], filters={ "scorecard": docname, "docstatus": 1, - "start_date": ["<", end_date], - "end_date": [">", start_date], + "start_date": ["<=", end_date], + "end_date": [">=", start_date], }, order_by="end_date desc", )