discount profiles and discounts overall implemented and working
This commit is contained in:
@@ -16,7 +16,7 @@ use crate::{
|
||||
models::products,
|
||||
shared::{
|
||||
guard,
|
||||
money::{format_price, parse_price_to_cents},
|
||||
money::{format_price, parse_percent, parse_price_to_cents},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -29,12 +29,6 @@ struct DiscountForm {
|
||||
percent: Option<String>,
|
||||
}
|
||||
|
||||
/// Parse a percentage typed as "20", "20.5" or "20,5" into an `f64`.
|
||||
fn parse_percent(value: &str) -> Option<f64> {
|
||||
let parsed: f64 = value.trim().replace(',', ".").parse().ok()?;
|
||||
parsed.is_finite().then_some(parsed)
|
||||
}
|
||||
|
||||
/// Resolve a percentage off the regular price into a fixed sale price in cents.
|
||||
/// Rounds the discount amount to the nearest cent.
|
||||
fn percent_to_sale_cents(regular_cents: i64, percent: f64) -> i64 {
|
||||
|
||||
Reference in New Issue
Block a user