.PHONY: help install backend frontend test test-all build

help:
	@echo "Amazon A/R Aging Dashboard"
	@echo "  make install     - install backend + frontend deps"
	@echo "  make backend     - run FastAPI on :8000"
	@echo "  make frontend    - run Vite dev server on :5173 (proxies /api -> :8000)"
	@echo "  make test        - fast backend tests"
	@echo "  make test-all    - include the Jan-2026 reconciliation/comparison integration tests"
	@echo "  make build       - production build of the frontend"

install:
	cd backend && python3 -m pip install -r requirements.txt
	cd frontend && npm install

backend:
	cd backend && python3 -m uvicorn app.api.main:app --reload --port 8000

frontend:
	cd frontend && npm run dev

test:
	cd backend && python3 -m pytest tests/test_engine_unit.py tests/test_excel_export.py \
		tests/test_api.py tests/test_robustness.py -p no:warnings -q

# Set AR_SAMPLE_DIR to the folder holding the four sample .xlsx files (defaults to repo root).
test-all:
	cd backend && python3 -m pytest -p no:warnings -q

build:
	cd frontend && npm run build

# One-shot: process a month from the command line and (optionally) write the workbook.
# Usage: make cli FILES="a.xlsx b.xlsx c.xlsx" MONTH_END=2026-01-31 OUT=out.xlsx RESERVE=125.44
cli:
	cd backend && python3 cli.py $(FILES) --month-end $(MONTH_END) \
		$(if $(OUT),--out $(OUT),) $(if $(RESERVE),--reserve-standard $(RESERVE),)
