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

Fix Avalara document id #2114

Merged
merged 4 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions imports/plugins/included/taxes-avalara/server/hooks/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ MethodHooks.after("taxes/calculate", (options) => {
Logger.debug("Avalara triggered on taxes/calculate for cartId:", cartId);
if (pkg && pkg.settings.avalara.enabled && pkg.settings.avalara.performTaxCalculation) {
taxCalc.estimateCart(cartToCalc, function (result) {
const taxes = linesToTaxes(result.lines);
if (result && result.totalTax && typeof result.totalTax === "number") {
// we don't use totalTax, that just tells us we have a valid tax calculation
// we don't use totalTax, that just tells us we have a valid tax calculation
if (result && result.totalTax && typeof result.totalTax === "number" && result.lines) {
const taxes = linesToTaxes(result.lines);
const taxAmount = taxes.reduce((totalTaxes, tax) => totalTaxes + tax.tax, 0);
const taxRate = taxAmount / taxCalc.calcTaxable(cartToCalc);
Meteor.call("taxes/setRate", cartId, taxRate, taxes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ function cartToSalesOrder(cart) {
const salesOrder = {
companyCode: companyCode,
type: "SalesOrder",
code: cart._id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: So when we call estimateCart which requires salesOrder object... no form of Id/code is needed on it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. You can pass an ID if you want, but it's not necessary since we don't do anything with the document.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

customerCode: cart.userId,
date: cartDate,
currencyCode: currencyCode,
Expand Down Expand Up @@ -471,7 +470,7 @@ function orderToSalesInvoice(order) {
companyCode: companyCode,
type: documentType,
commit: commitDocuments,
code: order.cartId,
code: order._id,
customerCode: order.userId,
date: orderDate,
currencyCode: currencyCode,
Expand Down