Crate vat_ph

Crate vat_ph 

Source
Expand description

§vat_ph

License

vat_ph is a library for computing Value Added Tax (VAT) in the Philippines. The computed VAT follows the guidelines set by the Bureau of Internal Revenue (BIR) under Republic Act 12023. The computation uses rust_decimal crate to ensure precise financial calculations.

§Usage

Using compute_vat(), you can compute the VAT given net, gross, or VAT. The result will be a struct containing all of the three mentioned.

use rust_decimal::dec;
use vat_ph::compute_vat;
use vat_ph::VatInput;

let result = compute_vat(VatInput::Net(dec!(1000.0)), None);
assert!(result.is_ok());

let vat = result.unwrap();
assert_eq!(vat.net, dec!(1000.0));
assert_eq!(vat.vat, dec!(120.0));
assert_eq!(vat.gross, dec!(1120.0));

§Contribution

In order to contribute to this project, you can follow these steps:

  1. Clone this repository.
  2. Install the rust toolchain version 1.86.0.
  3. Build the project with cargo build.
  4. Run test using cargo test.

Structs§

Vat
Represents the result of a VAT computation, containing net, VAT, and gross amounts.

Enums§

Error
Error type for VAT computation errors.
VatInput
Enum representing the different types of VAT input that can be provided for computation.

Functions§

compute_vat
Computes the VAT based on the provided input and optional rate. If you were to pass a custom rate, be sure its value is between 0.0 and 100.0 (inclusive).