Crates.io | vat_jp |
lib.rs | vat_jp |
version | 0.1.2 |
source | src |
created_at | 2023-03-02 13:04:55.233202 |
updated_at | 2023-03-02 13:29:55.70099 |
description | vat_jp calculates consumption tax (incl. sales tax, VAT, excise duty, etc.) in Japan. |
homepage | |
repository | https://github.com/nabetama/vat_jp/ |
max_upload_size | |
id | 798875 |
size | 12,662 |
vat_jp calculates consumption tax (incl. sales tax, VAT, excise duty, etc.) in Japan.
With vat_jp, you can know the price including VAT and the VAT rate at any point in time.
use chrono::{Local, NaiveDate};
use vat_jp;
// To find out the current price including tax,
// pass the amount as the first argument and `None` as the second argument.
assert_eq!(110, vat_jp::amount_with_tax::<NaiveDate>(100, None));
assert_eq!(
110,
vat_jp::amount_with_tax::<DateTime<Local>>(100, Some(Local::now()))
);
// When there was no VAT...
let mut today = NaiveDate::from_ymd_opt(1989, 3, 31).unwrap();
assert_eq!(100, vat_jp::amount_with_tax::<NaiveDate>(100, Some(today)));
// VAT rate
assert_eq!(1.1, vat_jp::get_rate::<DateTime<Local>>(Local::now()));