discounts
This commit is contained in:
@@ -61,13 +61,15 @@ pub async fn place(ctx: &AppContext, items: &[(i32, i32)], details: Checkout) ->
|
||||
)));
|
||||
}
|
||||
currency = product.currency.clone();
|
||||
subtotal += product.price_cents * i64::from(*qty);
|
||||
// Snapshot the effective price (honouring any active discount).
|
||||
let unit_price_cents = product.effective_price_cents();
|
||||
subtotal += unit_price_cents * i64::from(*qty);
|
||||
|
||||
let mut active = product.clone().into_active_model();
|
||||
active.stock = Set(product.stock - *qty);
|
||||
active.update(&txn).await?;
|
||||
|
||||
snapshots.push((product.id, product.name, product.price_cents, *qty));
|
||||
snapshots.push((product.id, product.name, unit_price_cents, *qty));
|
||||
}
|
||||
|
||||
let order = ActiveModel {
|
||||
|
||||
Reference in New Issue
Block a user