"""Produit un rapport des écarts entre inventaires et catalogue."""

from pathlib import Path

from lib.rebrickable.inventory_reconciliation import (
    compute_inventory_gaps,
    index_sets_by_num,
    load_sets,
    write_inventory_gaps_csv,
    write_inventory_gaps_markdown,
)


SETS_PATH = Path("data/intermediate/sets_enriched.csv")
PARTS_PATH = Path("data/intermediate/parts_filtered.csv")
DESTINATION_PATH = Path("data/final/inventory_gaps.csv")
MARKDOWN_PATH = Path("data/final/inventory_gaps.md")


def main() -> None:
    """Génère le fichier d'écarts d'inventaire."""
    sets = load_sets(SETS_PATH)
    sets_by_num = index_sets_by_num(sets)
    gaps = compute_inventory_gaps(SETS_PATH, PARTS_PATH)
    write_inventory_gaps_csv(DESTINATION_PATH, gaps)
    write_inventory_gaps_markdown(MARKDOWN_PATH, gaps, sets_by_num)


if __name__ == "__main__":
    main()
