Skip to content

Commit

Permalink
Merge pull request #5043 from reactioncommerce/fix-aldeed-tax-issue
Browse files Browse the repository at this point in the history
fix: naming issue caused taxes to not be calculated
  • Loading branch information
nnnnat authored Mar 14, 2019
2 parents 1e92603 + 0491631 commit a63f5e7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions imports/node-app/devserver/extendSchemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "/imports/plugins/core/taxes/lib/extendCoreSchemas";
1 change: 1 addition & 0 deletions imports/node-app/devserver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import queries from "./queries";
import resolvers from "./resolvers";
import schemas from "./schemas";
import filesStartup from "./filesStartup";
import "./extendSchemas";

const { MONGO_URL, PORT = 3030, ROOT_URL } = process.env;
if (!MONGO_URL) throw new Error("You must set MONGO_URL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export default async function addTaxesToGroup(context, {
discountTotal
});

// A taxes plugin is expected to add a mutation named `setTaxesOnFulfillmentGroup`.
// A taxes plugin is expected to add a mutation named `setTaxesOnOrderFulfillmentGroup`.
// If this isn't done, assume 0 tax.
if (typeof mutations.setTaxesOnFulfillmentGroup !== "function") {
if (typeof mutations.setTaxesOnOrderFulfillmentGroup !== "function") {
return { taxTotal: 0, taxableAmount: 0 };
}

// This will mutate `group` to add whatever tax fields the `taxes` plugin has added to the schemas.
return mutations.setTaxesOnFulfillmentGroup(context, { group, commonOrder });
return mutations.setTaxesOnOrderFulfillmentGroup(context, { group, commonOrder });
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @param {Object} commonOrder The group in CommonOrder schema
* @returns {Object} An object with `taxableAmount` and `taxTotal` properties. Also mutates `group`.
*/
export default async function setTaxesOnFulfillmentGroup(context, { group, commonOrder }) {
export default async function setTaxesOnOrderFulfillmentGroup(context, { group, commonOrder }) {
const { itemTaxes, taxSummary } = await context.mutations.getFulfillmentGroupTaxes(context, { order: commonOrder, forceZeroes: true });
group.items = group.items.map((item) => {
const itemTax = itemTaxes.find((entry) => entry.itemId === item._id) || {};
Expand Down
1 change: 1 addition & 0 deletions tests/TestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import mutations from "../imports/node-app/devserver/mutations";
import queries from "../imports/node-app/devserver/queries";
import schemas from "../imports/node-app/devserver/schemas";
import resolvers from "../imports/node-app/devserver/resolvers";
import "../imports/node-app/devserver/extendSchemas";

class TestApp {
constructor(options = {}) {
Expand Down

0 comments on commit a63f5e7

Please sign in to comment.