Skip to content

Commit

Permalink
billing migration tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
spencern committed Oct 7, 2017
1 parent fedf54c commit 76a03de
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Migrations } from "meteor/percolate:migrations";
import { Cart, Orders, Packages } from "/lib/collections";
import { Orders, Packages } from "/lib/collections";

const paymentNameDict = {
Example: "example-paymentmethod",
Expand All @@ -14,7 +14,7 @@ Migrations.add({
version: 16,
up() {
Orders.find().forEach((order) => {
order.billing.forEach((billing) => {
const newBilling = order.billing.map((billing) => {
const packageData = Packages.findOne({
name: paymentNameDict[billing.paymentMethod.processor],
shopId: billing.shopId
Expand All @@ -35,10 +35,11 @@ Migrations.add({
billing.paymentMethod.paymentSettingsKey = settingsKey;
billing.paymentMethod.shopId = billing.shopId;
billing.paymentMethod.items = cartItems;
return billing;
});

Orders.update({ _id: order._id }, {
$set: { billing: order.billing }
$set: { billing: newBilling }
});
});
},
Expand Down

0 comments on commit 76a03de

Please sign in to comment.