Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

maktouch
Copy link

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!

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.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 85.843% when pulling 7c6c9f2 on wisercpd:master into e7063d8 on valeriansaliou:master.

@adrai
Copy link
Contributor

adrai commented Jun 12, 2020

Isn't this the same as just calling additionally i.e. SalesTax.getSalesTax("CA", "SK") yourself?

@maktouch
Copy link
Author

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 0.14975 is the good rate, in the invoicing part, it needs to be split.

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.

@valeriansaliou
Copy link
Owner

Thanks for your PR. It's agreed on my side, I'll make some reworks and integrate your PR work in a separate commit.

valeriansaliou added a commit that referenced this pull request Jun 12, 2020
…T + HST in Canada) ref #27

Signed-off-by: Valerian Saliou <valerian@valeriansaliou.name>
@valeriansaliou
Copy link
Owner

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:

  • Renamed "detailed" into "details"
  • Moved the "details" object type to an array type

(See the README for more on how to use it.)

@valeriansaliou
Copy link
Owner

Closing this as this has been integrated. Thanks a lot for your work! Pushing a new release on NPMJS now, all tests are green.

@valeriansaliou
Copy link
Owner

@maktouch
Copy link
Author

Thanks to you @valeriansaliou. Big fan of Crisp btw.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants