Attach Costco discounts to purchase rows

This commit is contained in:
ben
2026-03-17 15:07:45 -04:00
parent 967e19e561
commit 56a03bcb1d
4 changed files with 117 additions and 1 deletions

View File

@@ -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", ""),