

[
  {
    "title": "Discount sign inverted",
    "rationale": "The discount is incorrectly increasing the subtotal because it multiplies by (1 + discount) instead of (1 - discount), causing discounted orders to cost more than the original.",
    "edits": [
      {
        "file": "src/tax.py",
        "find": "    discounted = subtotal * (1 + discount)",
        "replace": "    discounted = subtotal * (1 - discount)"
      }
    ]
  },
  {
    "title": "VAT applied after discount instead of before",
    "rationale": "The intended calculation is to apply VAT first, then the discount. The current implementation applies discount (incorrectly) then VAT, leading to an inflated total. Swapping the order fixes the logic.",
    "edits": [
      {
        "file": "src/tax.py",
        "find": "    subtotal = sum(prices)\n    discounted = subtotal * (1 + discount)\n    return round(discounted + discounted * vat_rate, 2)",
        "replace": "    subtotal = sum(prices)\n    taxed = subtotal * (1 + vat_rate)\n    discounted = taxed * (1 - discount)\n    return round(discounted, 2)"
      }
    ]
  },
  {
    "title": "Unnecessary vat_rate parameter shadows global constant",
    "rationale": "The function defines a vat_rate parameter with default VAT_RATE, but the global constant is sufficient. Keeping the parameter can cause confusion if a different value is passed. Removing the parameter and using the constant directly simplifies the code and eliminates potential misuse.",
    "edits": [
      {
        "file": "src/tax.py",
        "find": "def order_total(prices, discount=0.0, vat_rate=VAT_RATE):",
        "replace": "def order_total(prices, discount=0.0):"
      },
      {
        "file": "src/tax.py",
        "find": "    return round(discounted + discounted * vat_rate, 2)",
        "replace": "    return round(discounted + discounted * VAT_RATE, 2)"
      }
    ]
  }
]