gst_calculator 0.0.3
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 #
removeGSTwithfractionDigitsnow rounds exact half-unit ties away from zero, as documented. Before, a floating point subtraction made some ties round down (for example12.39at 18% gave CGST0.94instead of0.95, and10.01at 0.1% gave0.00instead of0.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.56came back as12345678901234.6and some tax values were off by one minor unit. addGSTwithoutfractionDigitsno longer returnsInfinityfor large finite input when the result fits in adouble(for exampleamount: 1e307). When the total does not fit, it throws anArgumentError.- No result field is ever
-0.0any more. Before, a negative amount at a 0% rate gave CGST-0.0, which formats as"-0.00", andgstRate: -0.0was passed through.
Changed #
- Rounding with
fractionDigitsuses exact integer arithmetic on the shortest decimal form of the amount and rate (whattoStringprints). Inputs with more digits thanfractionDigitsare rounded on that decimal value:1.0049999999999997(thedoublejust below1.005) now gives1.00where before the 15-digit trim made it1.01.1.005still gives1.01. - Corrected the docs:
removeGSTreturns the amount rounded tofractionDigitsastotal, andbaseAmount + gstAmount == totalholds 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 #
addGSTandremoveGSTnow throw anArgumentErrorwhen the amount isNaNor infinite, or the rate is negative,NaNor infinite. Before, they returnedNaN/Infinityvalues, andremoveGSTwith a rate of-100divided by zero.
Added #
- Optional
fractionDigitsparameter onaddGSTandremoveGSTfor 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.gstAmountgetter (cgst + sgst + igst).GstResultvalue equality,hashCodeand a readabletoString().GstResultnow has aconstconstructor.
Changed #
- The package no longer needs the Flutter SDK for development: dev
dependencies moved from
flutter_testtotest. 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