typed_money/currency/
php.rs1use super::{CurrencyType, LiquidityRating, SymbolPosition, VolatilityRating};
2use crate::Currency;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
20pub struct PHP;
21
22impl Currency for PHP {
23 const DECIMALS: u8 = 2;
24 const CODE: &'static str = "PHP";
25 const SYMBOL: &'static str = "₱";
26
27 const NAME: &'static str = "Philippine Peso";
29 const COUNTRY: &'static str = "Philippines";
30 const REGION: &'static str = "Asia";
31 const CURRENCY_TYPE: CurrencyType = CurrencyType::Fiat;
32 const IS_MAJOR: bool = false;
33 const IS_STABLE: bool = false;
34 const INTRODUCED_YEAR: u16 = 1949;
35 const ISO_4217_NUMBER: u16 = 608;
36 const THOUSANDS_SEPARATOR: char = ',';
37 const DECIMAL_SEPARATOR: char = '.';
38 const SYMBOL_POSITION: SymbolPosition = SymbolPosition::Before;
39 const SPACE_BETWEEN: bool = false;
40 const VOLATILITY_RATING: VolatilityRating = VolatilityRating::Medium;
41 const LIQUIDITY_RATING: LiquidityRating = LiquidityRating::Medium;
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47 use crate::Amount;
48
49 #[test]
50 fn test_php_currency_properties() {
51 assert_eq!(PHP::DECIMALS, 2);
52 assert_eq!(PHP::CODE, "PHP");
53 assert_eq!(PHP::SYMBOL, "₱");
54 }
55
56 #[test]
57 fn test_php_amount_creation() {
58 let amount = Amount::<PHP>::from_major(100);
59 assert_eq!(amount.to_major_floor(), 100);
60 }
61
62 #[test]
63 fn test_php_amount_with_centavos() {
64 let amount = Amount::<PHP>::from_minor(10050); assert_eq!(amount.to_major_floor(), 100);
66 assert_eq!(amount.to_minor(), 10050);
67 }
68}