-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add detailed field to __buildSalesTaxContext #27
Conversation
This is so we can generate Canadian invoices with this library. In Canada, you need to list individual amounts of taxes on the invoice because they are filed to different government bodies.
Isn't this the same as just calling additionally i.e. |
It isn't, no. Without this change, it'll output like {
type: 'gst+qst',
rate: 0.14975,
area: 'national',
exchange: 'consumer',
charge: { direct: true, reverse: false }
} With this change, it'll output {
type: 'gst+qst',
rate: 0.14975,
detailed: { gst: 0.05, qst: 0.09975 },
area: 'national',
exchange: 'consumer',
charge: { direct: true, reverse: false }
} While technically For getAmountWithSalesTax, it looks like this SalesTax.getAmountWithSalesTax("CA", "QC", 100).then(console.log); {
type: 'gst+qst',
rate: 0.14975,
price: 100,
total: 114.97500000000001,
area: 'national',
exchange: 'consumer',
charge: { direct: true, reverse: false },
detailed: [
{ type: 'gst', rate: 0.05, amount: 5 },
{ type: 'qst', rate: 0.09975, amount: 9.975000000000001 }
]
} It's so we can use the same library for generating invoice + calculating total. |
Thanks for your PR. It's agreed on my side, I'll make some reworks and integrate your PR work in a separate commit. |
…T + HST in Canada) ref #27 Signed-off-by: Valerian Saliou <valerian@valeriansaliou.name>
I've integrated your changes manually, coded unit tests as well as added documentation in the README about this new "details" object. Changes relative to your PR:
(See the README for more on how to use it.) |
Closing this as this has been integrated. Thanks a lot for your work! Pushing a new release on NPMJS now, all tests are green. |
Released |
Thanks to you @valeriansaliou. Big fan of Crisp btw. Cheers. |
This is so we can generate Canadian invoices with this library. In Canada, you need to list individual amounts of taxes on the invoice because they are filed to different government bodies.
It passes jshint, and no tests are broken (this is purely additive).
Hope we can get this merged.
Merci!