Skip to main content

gst_calculator 0.0.3 copy "gst_calculator: ^0.0.3" to clipboard
gst_calculator: ^0.0.3 copied to clipboard

Indian GST calculator for Dart and Flutter. Add or remove GST, split CGST/SGST/IGST, with optional paise-accurate rounding.

0.0.3 #

Fixed #

  • removeGST with fractionDigits now rounds exact half-unit ties away from zero, as documented. Before, a floating point subtraction made some ties round down (for example 12.39 at 18% gave CGST 0.94 instead of 0.95, and 10.01 at 0.1% gave 0.00 instead of 0.01).
  • Rounded results are now exact for every amount the size check accepts. Before, amounts from about 10¹³ minor units were trimmed to 15 significant digits, so 12345678901234.56 came back as 12345678901234.6 and some tax values were off by one minor unit.
  • addGST without fractionDigits no longer returns Infinity for large finite input when the result fits in a double (for example amount: 1e307). When the total does not fit, it throws an ArgumentError.
  • No result field is ever -0.0 any more. Before, a negative amount at a 0% rate gave CGST -0.0, which formats as "-0.00", and gstRate: -0.0 was passed through.

Changed #

  • Rounding with fractionDigits uses exact integer arithmetic on the shortest decimal form of the amount and rate (what toString prints). Inputs with more digits than fractionDigits are rounded on that decimal value: 1.0049999999999997 (the double just below 1.005) now gives 1.00 where before the 15-digit trim made it 1.01. 1.005 still gives 1.01.
  • Corrected the docs: removeGST returns the amount rounded to fractionDigits as total, and baseAmount + gstAmount == total holds in minor units, not with == on doubles.

Unrounded results (no fractionDigits) are unchanged for valid finite input, except that -0.0 is now 0.0. Rounded results change only for exact half-unit ties in removeGST, for amounts from about 10¹³ minor units, and for amounts whose shortest decimal form sits just below a rounding boundary, as in the 1.0049999999999997 example.

0.0.2 #

Fixed #

  • addGST and removeGST now throw an ArgumentError when the amount is NaN or infinite, or the rate is negative, NaN or infinite. Before, they returned NaN/Infinity values, and removeGST with a rate of -100 divided by zero.

Added #

  • Optional fractionDigits parameter on addGST and removeGST for invoice-ready rounding. CGST and SGST are rounded individually and stay equal, and base + GST equals total exactly at the chosen precision.
  • GstCalculator.maxFractionDigits.
  • GstResult.gstAmount getter (cgst + sgst + igst).
  • GstResult value equality, hashCode and a readable toString().
  • GstResult now has a const constructor.

Changed #

  • The package no longer needs the Flutter SDK for development: dev dependencies moved from flutter_test to test. It is now listed on pub.dev as supporting pure Dart as well as Flutter.
  • Added lints, API documentation, a rewritten README, a fuller example and CI.

Results for valid input without fractionDigits are unchanged.

0.0.1 #

Initial release

  • Add GST calculator
  • Remove GST calculator
  • CGST SGST IGST support
2
likes
160
points
386
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Indian GST calculator for Dart and Flutter. Add or remove GST, split CGST/SGST/IGST, with optional paise-accurate rounding.

Repository (GitHub)
View/report issues

Topics

#gst #tax #calculator #india #invoice

License

MIT (license)

More

Packages that depend on gst_calculator