feat(promotion-code): Complete promotion code integration and testing
- Add comprehensive promotion code methods to Order model - Implement Stripe invoice integration for promotion code discounts - Display promotion codes on invoice with proper discount breakdown - Fix and enhance all unit tests for promotion code functionality - Add discount calculation with capping to prevent negative totals - Ensure promotion codes work across entire order lifecycle 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -166,6 +166,23 @@ class StripeInvoiceService
|
||||
})
|
||||
end
|
||||
|
||||
# Add promotion code discounts as negative line items
|
||||
@order.promotion_codes.each do |promo_code|
|
||||
Stripe::InvoiceItem.create({
|
||||
customer: customer.id,
|
||||
invoice: invoice.id,
|
||||
amount: -promo_code.discount_amount_cents, # Negative amount for discount
|
||||
currency: "eur",
|
||||
description: "Réduction promotionnelle (Code: #{promo_code.code})",
|
||||
metadata: {
|
||||
promotion_code_id: promo_code.id,
|
||||
promotion_code: promo_code.code,
|
||||
discount_amount_cents: promo_code.discount_amount_cents,
|
||||
type: "promotion_discount"
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
# No service fee on customer invoice; platform fee deducted from promoter payout
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user