Fix BOM: apply global discount_pct from metadata to all line items
oci_bom_gen.py from_spec now reads metadata.discount_pct as fallback when individual line items don't specify a discount. This means discount_pct: 0.45 in the spec metadata applies 45% to every SKU. Previously, global discount was silently ignored — only per-item discount fields were read (defaulting to 0.0). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -683,13 +683,17 @@ class OCIBomGenerator:
|
|||||||
|
|
||||||
gen.load_catalog(catalog_path)
|
gen.load_catalog(catalog_path)
|
||||||
|
|
||||||
|
# Global discount from metadata — used as fallback for line items without explicit discount
|
||||||
|
bom_meta = bom.get("metadata", {})
|
||||||
|
global_discount = bom_meta.get("discount_pct", bom.get("discount_pct", 0.0))
|
||||||
|
|
||||||
for item in bom.get("line_items", []):
|
for item in bom.get("line_items", []):
|
||||||
gen.add_line_item(
|
gen.add_line_item(
|
||||||
sku=str(item["sku"]),
|
sku=str(item["sku"]),
|
||||||
qty=item.get("qty", 0),
|
qty=item.get("qty", 0),
|
||||||
hours_units=item.get("hours_units"),
|
hours_units=item.get("hours_units"),
|
||||||
months=item.get("months", 12),
|
months=item.get("months", 12),
|
||||||
discount=item.get("discount", 0.0),
|
discount=item.get("discount", global_discount),
|
||||||
custom_label=item.get("custom_label", ""),
|
custom_label=item.get("custom_label", ""),
|
||||||
custom_note=item.get("custom_note", ""),
|
custom_note=item.get("custom_note", ""),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user