v0.1.27
Fix: Throughput API v1 available - Details posted to Irving. POWERBI_KEY was missing from the .ENV file, so was not live. Add: Editor now supports editing a mix's resolved formula directly, with % and kg dual entry on ingredient rows Fix: Mix Editor should bring through correct ingredients. New resolved formula (same logic we use in Mix Calculator). Fix: Security headers on all API responses (hardening) Add: New mix button available on the Mix Editor. Add: New ingredient button available on the Ingredient Editor
This commit is contained in:
@@ -266,6 +266,60 @@ def test_upload_import_keeps_blank_destination_flags_false():
|
||||
assert entry.job_number is None
|
||||
|
||||
|
||||
def test_upload_import_detects_month_first_dates_consistently():
|
||||
# The pasted sheet is US month-first (M/D/Y). "9/23/2025" is unambiguous, so
|
||||
# the ambiguous "12/9/2025" must follow the same convention: 9 December, not
|
||||
# 12 September (which the old day-first-by-default parser produced).
|
||||
db = _session()
|
||||
csv_bytes = (
|
||||
"Date,Product,Item ID,Quantity,Type,Bag Size,Packed By\n"
|
||||
"12/9/2025,Whole Wheat Cleaned & Graded 20kg,373022,156,bags,20,Jake\n"
|
||||
"9/23/2025,Steam Rolled Barley 20kg,568240,34,bags,20,jake\n"
|
||||
"9/24/2025,Stock Mix 20kg,540725,153,bags,20,jake\n"
|
||||
).encode("utf-8")
|
||||
|
||||
result = import_entries_from_file(
|
||||
db,
|
||||
filename="throughput-import.csv",
|
||||
content=csv_bytes,
|
||||
tenant_id="test-tenant",
|
||||
created_by="tester@example.com",
|
||||
)
|
||||
|
||||
assert result["entries_imported"] == 3
|
||||
dates = {
|
||||
e.product_name_snapshot: e.production_date
|
||||
for e in db.scalars(select(ProductionThroughput)).all()
|
||||
}
|
||||
assert dates["Whole Wheat Cleaned & Graded 20kg"] == date(2025, 12, 9)
|
||||
assert dates["Steam Rolled Barley 20kg"] == date(2025, 9, 23)
|
||||
assert dates["Stock Mix 20kg"] == date(2025, 9, 24)
|
||||
|
||||
|
||||
def test_upload_import_keeps_day_first_dates_for_australian_sheets():
|
||||
# A genuinely day-first file (23/9/2025 proves D/M/Y) must stay day-first, so
|
||||
# 12/9/2025 reads as 12 September.
|
||||
db = _session()
|
||||
csv_bytes = (
|
||||
"Date,Product,Quantity,Type,Bag Size\n"
|
||||
"23/9/2025,Stock Mix 20kg,10,bags,20\n"
|
||||
"12/9/2025,Stock Mix 20kg,10,bags,20\n"
|
||||
).encode("utf-8")
|
||||
|
||||
import_entries_from_file(
|
||||
db,
|
||||
filename="throughput-import.csv",
|
||||
content=csv_bytes,
|
||||
tenant_id="test-tenant",
|
||||
created_by="tester@example.com",
|
||||
)
|
||||
|
||||
produced = sorted(
|
||||
e.production_date for e in db.scalars(select(ProductionThroughput)).all()
|
||||
)
|
||||
assert produced == [date(2025, 9, 12), date(2025, 9, 23)]
|
||||
|
||||
|
||||
def test_upload_import_does_not_treat_unknown_destination_text_as_true():
|
||||
db = _session()
|
||||
csv_bytes = (
|
||||
|
||||
Reference in New Issue
Block a user