6 releases
0.2.0 | Jan 11, 2024 |
---|---|
0.1.10 | Jan 5, 2024 |
0.1.6 | Dec 31, 2023 |
#183 in Finance
77KB
1.5K
SLoC
baggins
Utilities to Perform Sales Totals and Subtotals Calculation Operations.
Use
baggins exposes a calculator to obtain sales subtotals, into which taxes and discounts can be entered.
use baggins::{Calculator, discount, tax};
let mut c = baggins::DetailCalculator::new();
let err = c.add_discount_from_str(
"10.0",
discount::Mode::Percentual
);
assert!(err.is_none(), "error adding percentual discount {:?}", err);
let err = c.add_tax_from_str(
"16.0",
tax::Stage::OverTaxable,
tax::Mode::Percentual,
);
assert!(err.is_none(), "error adding percentual 16% tax {:?}", err);
Once taxes and discounts have been entered, the compute
method can be called to obtain the results
let r = c.compute(
BigDecimal::from_str("100.0").unwrap(),
BigDecimal::from_str("2.0").unwrap(),
None,
);
match r {
Ok(calc) => {
println!("calc: {}", calc);
}
Err(e) => {
panic!("{e}")
}
}
lib.rs
:
baggins
baggins
provides a series of utilities to easily and efficiently calculate sales operations.
Due to the nature of monetary calculations, the Bigdecimal crate is used as a backend.
The focus is on ease of use and learning Rust, so there are many opportunities for improvement.
baggins
provee una serie de utilidades para calcular facil y eficientemente totales
y subtotales de lineas de detalle de procesos de venta.
El foco está en la facilidad de uso y en aprender Rust, por lo que hay muchas oportunidades de mejora.
Dependencies
~1.4–2.1MB
~46K SLoC