Monolista: correggi date SAM e soglie delle picking list

This commit is contained in:
2026-11-06 10:05:00 +01:00
parent 9d87b07648
commit 1553427c21
9 changed files with 98 additions and 13 deletions

View File

@@ -213,7 +213,9 @@ if _MODULE_LOG_ENABLED:
# Operational picking-list management uses the Python-only residual view.
# Unlike the historical view, this dataset intentionally contains only UDCs
# that still have to be exhausted by the warehouse workflow.
SQL_PL = """
# Include today and the preceding days - 1 civil dates, regardless of time.
_SAM_FIRST_DAY = "DATEDIFF(day, CONVERT(date, '18991230', 112), GETDATE()) + 1 - :days"
SQL_PL = f"""
SELECT
COUNT(DISTINCT NULLIF(LTRIM(RTRIM(CAST(Pallet AS varchar(32)))), '')) AS Pallet,
COUNT(DISTINCT Lotto) AS Lotto,
@@ -232,16 +234,16 @@ SELECT
MIN(Ordinamento) AS Ordinamento,
MAX(IDStato) AS IDStato
FROM dbo.py_ViewPackingListPrelievo
WHERE DataDocumento > CAST((GETDATE() - :days) AS int)
WHERE DataDocumento >= {_SAM_FIRST_DAY}
GROUP BY Documento, CodNazione, NAZIONE, Stato
ORDER BY MIN(OrdinePrelievoGruppo), MIN(Ordinamento), Documento, NAZIONE, Stato;
"""
SQL_PL_DETAILS = """
SQL_PL_DETAILS = f"""
SELECT *
FROM dbo.py_ViewPackingListPrelievo
WHERE Documento = :Documento
AND DataDocumento > CAST((GETDATE() - :days) AS int)
AND DataDocumento >= {_SAM_FIRST_DAY}
ORDER BY OrdinePrelievoGruppo, Ordinamento, Pallet;
"""