Skip to content

Instantly share code, notes, and snippets.

@jeffreyjurgajtis
Created February 21, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyjurgajtis/e6ff31af1c04bb2cf6ac0a2fd78f9cef to your computer and use it in GitHub Desktop.
Save jeffreyjurgajtis/e6ff31af1c04bb2cf6ac0a2fd78f9cef to your computer and use it in GitHub Desktop.
# Customer Signs up
# $100 Advanced (Product)
# $50 Minutes (Component)
#
# -$10 Coupon One (Single Use)
# -$20 Coupon Two (Multi Use)
Sale.new(
sale_amount_in_cents: 150_00,
discount_amount_in_cents: -30_00,
total_in_cents: 120_00,
...
lines: [],
...
discounts: [
{
id: coupon_one.id,
type: "single-use",
name: "$10 OFF NOW",
product_id: advanced.id,
component_id: 0, # a zero for component_id means this is a baseline, setup, one-time, etc charge
discount_amount_in_cents: -8_00,
},
{
id: coupon_one.id,
type: "single-use",
name: "$10 OFF NOW",
product_id: advanced.id,
component_id: minutes.id,
discount_amount_in_cents: -2_00
},
{
id: coupon_two.id,
type: "multi-use",
name: "$20 OFF BLACK FRIDAY",
product_id: advanced.id,
component_id: 0, # a zero for component_id means this is a baseline, setup, one-time, etc charge
discount_amount_in_cents: -16_00
},
{
id: coupon_two.id,
type: "multi-use",
name: "$20 OFF BLACK FRIDAY",
product_id: advanced.id,
component_id: minutes.id,
discount_amount_in_cents: -4_00
}
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment