pub enum PriceAdjustment {
Tax {
name: String,
percentage: Decimal,
},
Discount {
name: String,
percentage: Decimal,
},
Fixed {
name: String,
amount: Decimal,
currency: Currency,
},
}Expand description
Represents additional price modifications such as tax, discount, or fixed fees.
This enum is used to define adjustments that can be applied to a PricingDetail.
These adjustments are later converted and applied using a CurrencyConverter,
resulting in one or more AppliedAdjustment entries with actual values.
§Variants
-
Tax: Represents a tax to be applied as a percentage of the current sell price. Useful for applying VAT, Tax, or sales tax.name: A human-readable label (e.g.,"Tax 11%")percentage: The tax rate as a percentage (e.g.,11.0for 11%)
-
Discount: Represents a discount applied as a percentage of the current sell price. Useful for promotions or campaigns.name: A human-readable label (e.g.,"Promo New Year")percentage: The discount rate as a percentage (e.g.,5.0for 5%)
-
Fixed: Represents a fixed fee adjustment, such as a service or admin fee. This amount can be in a different currency and will be converted accordingly.Use
sell_currencyas the default currency for fixed amount adjustments. Caller is responsible for providing the correct currency context.name: A human-readable label (e.g.,"Admin Fee")amount: The raw fixed amount before conversioncurrency: The original currency of the fixed amount
§Example
use rust_decimal_macros::dec;
use pricing_kit::{Currency, PriceAdjustment};
let discount = PriceAdjustment::Discount {
name: "Year End Promo".into(),
percentage: dec!(5.0),
};
let tax = PriceAdjustment::Tax {
name: "Tax 11%".into(),
percentage: dec!(11.0),
};
let fixed_fee = PriceAdjustment::Fixed {
name: "Admin Fee".into(),
amount: dec!(2.0),
currency: Currency::new("USD", "US Dollar"),
};Adjustments are intended to be applied in order using PricingDetail::apply_adjustments().
Variants§
Trait Implementations§
Source§impl Clone for PriceAdjustment
impl Clone for PriceAdjustment
Source§fn clone(&self) -> PriceAdjustment
fn clone(&self) -> PriceAdjustment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more