diff --git a/build_purchases.py b/build_purchases.py index a6781d9..7907748 100644 --- a/build_purchases.py +++ b/build_purchases.py @@ -33,6 +33,8 @@ PURCHASE_FIELDS = [ "measure_type", "line_total", "unit_price", + "matched_discount_amount", + "net_line_total", "store_name", "store_number", "store_city", @@ -94,7 +96,7 @@ def decimal_or_zero(value): def derive_metrics(row): - line_total = to_decimal(row.get("line_total")) + line_total = to_decimal(row.get("net_line_total") or row.get("line_total")) qty = to_decimal(row.get("qty")) pack_qty = to_decimal(row.get("pack_qty")) size_value = to_decimal(row.get("size_value")) @@ -292,6 +294,8 @@ def build_purchase_rows( "measure_type": row["measure_type"], "line_total": row["line_total"], "unit_price": row["unit_price"], + "matched_discount_amount": row.get("matched_discount_amount", ""), + "net_line_total": row.get("net_line_total", ""), "store_name": order_row.get("store_name", ""), "store_number": order_row.get("store_number", ""), "store_city": order_row.get("store_city", ""), diff --git a/enrich_costco.py b/enrich_costco.py index 1b254ea..4a4d358 100644 --- a/enrich_costco.py +++ b/enrich_costco.py @@ -1,6 +1,7 @@ import csv import json import re +from collections import defaultdict from pathlib import Path import click @@ -29,6 +30,7 @@ HASH_SIZE_RE = re.compile(r"(?