chore(api): apply rustfmt across modules and tests
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
6c1357ec4d
commit
a4ef6ca49e
@@ -113,14 +113,14 @@ pub fn checkout_discount(
|
||||
}
|
||||
let now = Utc::now();
|
||||
if now < coupon.starts_at || now > coupon.ends_at {
|
||||
return Err(ApiError::Conflict("coupon is outside its active window".into()));
|
||||
return Err(ApiError::Conflict(
|
||||
"coupon is outside its active window".into(),
|
||||
));
|
||||
}
|
||||
let from = currencies
|
||||
.iter()
|
||||
.find(|c| c.code == coupon.currency)
|
||||
.ok_or_else(|| {
|
||||
ApiError::BadRequest(format!("currency {} is disabled", coupon.currency))
|
||||
})?;
|
||||
.ok_or_else(|| ApiError::BadRequest(format!("currency {} is disabled", coupon.currency)))?;
|
||||
let amount = convert_minor(coupon.amount_minor, from, target)?;
|
||||
let threshold = convert_minor(coupon.threshold_minor, from, target)?;
|
||||
if subtotal_minor < threshold {
|
||||
@@ -132,11 +132,7 @@ pub fn checkout_discount(
|
||||
Ok(amount.min(subtotal_minor))
|
||||
}
|
||||
|
||||
pub async fn redeem(
|
||||
tx: &mut PgConnection,
|
||||
coupon_id: Uuid,
|
||||
order_id: Uuid,
|
||||
) -> ApiResult<Coupon> {
|
||||
pub async fn redeem(tx: &mut PgConnection, coupon_id: Uuid, order_id: Uuid) -> ApiResult<Coupon> {
|
||||
repo::redeem(tx, coupon_id, order_id).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user