+
Skip to content

Fulfillment feature #6480

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

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6bbe653
feat(cart)!: setFFType, Version, method Addnldata
sujithvn Sep 19, 2022
2d4a0c8
feat(catalog): supportedFFTypes allowedValues
sujithvn Sep 19, 2022
146a5a6
feat(products): supportedFFTypes allowedValues
sujithvn Sep 19, 2022
67c3793
feat(orders): supportedFFTypes allowedValues
sujithvn Sep 19, 2022
d49b2dc
feat(orders): refactor placeOrder - validateOrder
sujithvn Sep 19, 2022
ea9bc5e
fix: linter error fix
sujithvn Sep 19, 2022
95d136a
feat: fulfillment roles for shop manager
sujithvn Sep 19, 2022
9db0c9c
feat(fulfillment)!: fulfillment-base first commit
sujithvn Sep 19, 2022
5a248e4
feat(fulfillment)!: fulfillment-shipping commit
sujithvn Sep 19, 2022
54fd6f7
feat(fulfillment)!: fulfillment-type-pickup commit
sujithvn Sep 19, 2022
ec61ca3
feat(fulfillment): fulfillment-pickup-store commit
sujithvn Sep 19, 2022
aa5e279
feat(fulfillment): fulfillment-shipping-ups commit
sujithvn Sep 19, 2022
f1f5879
fix: added missing param fulfillment type id
sujithvn Sep 19, 2022
65479f6
feat(fulfillment)!: fulfillment shipping flat rate
sujithvn Sep 19, 2022
8bba24a
feat(fulfillment)!: updated plugins.json
sujithvn Sep 19, 2022
93f953a
fix: review comments and unit test fixes
sujithvn Sep 20, 2022
d958b07
fix: typo error
sujithvn Sep 20, 2022
eecb993
fix: bug fixes
sujithvn Sep 23, 2022
d681b05
fix: fixes for integration query tests
sujithvn Sep 26, 2022
7e80af9
fix: fixes for integration mutation tests
sujithvn Sep 27, 2022
94a885a
fix: few more fixes for tests
sujithvn Sep 27, 2022
ff5fef6
feat(cart)!: setFFType, Version, method Addnldata
sujithvn Sep 19, 2022
4f7e336
feat(catalog): supportedFFTypes allowedValues
sujithvn Sep 19, 2022
5784a2d
feat(products): supportedFFTypes allowedValues
sujithvn Sep 19, 2022
dc50e53
feat(orders): supportedFFTypes allowedValues
sujithvn Sep 19, 2022
f182530
feat(orders): refactor placeOrder - validateOrder
sujithvn Sep 19, 2022
112c921
fix: linter error fix
sujithvn Sep 19, 2022
5306b5a
feat: fulfillment roles for shop manager
sujithvn Sep 19, 2022
b72af7f
feat(fulfillment)!: fulfillment-base first commit
sujithvn Sep 19, 2022
8d6bee9
feat(fulfillment)!: fulfillment-shipping commit
sujithvn Sep 19, 2022
b5bdc86
feat(fulfillment)!: fulfillment-type-pickup commit
sujithvn Sep 19, 2022
1b51c30
feat(fulfillment): fulfillment-pickup-store commit
sujithvn Sep 19, 2022
2c2dc32
feat(fulfillment): fulfillment-shipping-ups commit
sujithvn Sep 19, 2022
e62f0eb
fix: added missing param fulfillment type id
sujithvn Sep 19, 2022
87a28d7
feat(fulfillment)!: fulfillment shipping flat rate
sujithvn Sep 19, 2022
6f686bd
feat(fulfillment)!: updated plugins.json
sujithvn Sep 19, 2022
7b137f0
fix: review comments and unit test fixes
sujithvn Sep 20, 2022
e298470
fix: typo error
sujithvn Sep 20, 2022
9d5d7bf
fix: bug fixes
sujithvn Sep 23, 2022
a61216e
fix: fixes for integration query tests
sujithvn Sep 26, 2022
b5e927b
fix: fixes for integration mutation tests
sujithvn Sep 27, 2022
6f39afa
fix: few more fixes for tests
sujithvn Sep 27, 2022
1d84157
Merge remote-tracking branch 'origin/sujith/monorepo' into sujith/mon…
sujithvn Sep 30, 2022
92cb238
fix: updated pnpm-lock
sujithvn Sep 30, 2022
d9fa1d6
fix: initial set of review comment fixes
sujithvn Oct 3, 2022
72bd886
fix: fullName error in UI, dynamic assign ff type
sujithvn Oct 14, 2022
d90a43d
Merge branch 'feat/fulfillment-types' into sujith/monorepo
vanpho93 Mar 10, 2023
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
18 changes: 11 additions & 7 deletions apps/reaction/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@
"accounts": "@reactioncommerce/api-plugin-accounts",
"authentication": "@reactioncommerce/api-plugin-authentication",
"authorization": "@reactioncommerce/api-plugin-authorization-simple",
"products": "@reactioncommerce/api-plugin-products",
"catalogs": "@reactioncommerce/api-plugin-catalogs",
"products": "../../packages/api-plugin-products/index.js",
Copy link
Member

Choose a reason for hiding this comment

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

should use @reactioncommerce/... for all plugins including new ones.

"catalogs": "../../packages/api-plugin-catalogs/index.js",
"tags": "@reactioncommerce/api-plugin-tags",
"pricingSimple": "@reactioncommerce/api-plugin-pricing-simple",
"inventory": "@reactioncommerce/api-plugin-inventory",
"inventorySimple": "@reactioncommerce/api-plugin-inventory-simple",
"carts": "@reactioncommerce/api-plugin-carts",
"orders": "@reactioncommerce/api-plugin-orders",
"carts": "../../packages/api-plugin-carts/index.js",
"orders": "../../packages/api-plugin-orders/index.js",
"payments": "@reactioncommerce/api-plugin-payments",
"paymentsStripeSCA": "@reactioncommerce/api-plugin-payments-stripe-sca",
"paymentsExample": "@reactioncommerce/api-plugin-payments-example",
"discounts": "@reactioncommerce/api-plugin-discounts",
"discountCodes": "@reactioncommerce/api-plugin-discounts-codes",
"surcharges": "@reactioncommerce/api-plugin-surcharges",
"shipments": "@reactioncommerce/api-plugin-shipments",
"shipmentsFlatRate": "@reactioncommerce/api-plugin-shipments-flat-rate",
"taxes": "@reactioncommerce/api-plugin-taxes",
"taxesFlatRate": "@reactioncommerce/api-plugin-taxes-flat-rate",
"navigation": "@reactioncommerce/api-plugin-navigation",
"sitemapGenerator": "@reactioncommerce/api-plugin-sitemap-generator",
"notifications": "@reactioncommerce/api-plugin-notifications",
"addressValidationTest": "@reactioncommerce/api-plugin-address-validation-test"
"addressValidationTest": "@reactioncommerce/api-plugin-address-validation-test",
"fulfillment": "../../packages/api-plugin-fulfillment/index.js",
"fulfillmentTypeShipping": "../../packages/api-plugin-fulfillment-type-shipping/index.js",
"fulfillmentMethodShippingFlatRate": "../../packages/api-plugin-fulfillment-method-shipping-flat-rate/index.js",
"fulfillmentMethodShippingUPS": "../../packages/api-plugin-fulfillment-method-shipping-ups/index.js",
"fulfillmentTypePickup": "../../packages/api-plugin-fulfillment-type-pickup/index.js",
"fulfillmentMethodPickupStore": "../../packages/api-plugin-fulfillment-method-pickup-store/index.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,37 @@ const mockShipmentMethod = {
handling: 0,
label: "mockLabel",
name: "mockName",
fulfillmentMethod: "flatRate",
rate: 3.99
};

const mockFulfillmentEntry = {
_id: "mockShippingMethod",
name: "Default Shipping Provider",
provider: {
enabled: true,
label: "Flat Rate",
name: "flatRates"
},
fulfillmentType: "shipping",
methods: [
{
cost: 2.5,
fulfillmentTypes: [
"shipping"
],
fulfillmentMethod: "flatRate",
group: "Ground",
handling: 1.5,
label: "Standard mockMethod",
name: "mockMethod",
rate: 1,
_id: "METHOD_ID",
enabled: true
}
]
};

const mockInvoice = Factory.OrderInvoice.makeOne({
currencyCode: "USD",
// Need to ensure 0 discount to avoid creating negative totals
Expand Down Expand Up @@ -58,14 +86,18 @@ beforeAll(async () => {
testApp.registerPlugin({
name: "addOrderFulfillmentGroup.test.js",
functionsByType: {
getFulfillmentMethodsWithQuotes: [getFulfillmentMethodsWithQuotes]
getFulfillmentMethodsWithQuotesshipping: [getFulfillmentMethodsWithQuotes]
}
});

await testApp.start();

shopId = await insertPrimaryShop(testApp.context);

// Add shipping methods
mockFulfillmentEntry.shopId = shopId;
await testApp.collections.Fulfillment.insertOne(mockFulfillmentEntry);

const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
Expand Down Expand Up @@ -165,6 +197,7 @@ test("user with `reaction:legacy:orders/update` role can add an order fulfillmen
const group = Factory.OrderFulfillmentGroup.makeOne({
invoice: mockInvoice,
items: [orderItem],
type: "shipping",
shopId
});

Expand Down Expand Up @@ -303,6 +336,7 @@ test("user with `reaction:legacy:orders/move:item` role can add an order fulfill
currencyCode: "USD"
},
shopId,
type: "shipping",
totalItemQuantity: 12
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import encodeOpaqueId from "@reactioncommerce/api-utils/encodeOpaqueId.js";
import importAsString from "@reactioncommerce/api-utils/importAsString.js";
import getCommonData from "./checkoutTestsCommon.js";

Expand Down Expand Up @@ -94,6 +95,7 @@ describe("as an anonymous user", () => {
productId: opaqueProductId,
productVariantId: opaqueCartProductVariantId
},
selectedFulfillmentType: "shipping",
quantity: 1
}
}
Expand Down Expand Up @@ -269,7 +271,12 @@ describe("as an anonymous user", () => {
return;
}

const option = result.updateFulfillmentOptionsForGroup.cart.checkout.fulfillmentGroups[0].availableFulfillmentOptions[0];
const mockFulfillmentMethodId = "mockMethod";
const opaqueMockFulfillmentMethodId = encodeOpaqueId("reaction/fulfillmentMethod", mockFulfillmentMethodId);

// From the multiple Fulfillment methods, find out the exact method we are looking for
const options = result.updateFulfillmentOptionsForGroup.cart.checkout.fulfillmentGroups[0].availableFulfillmentOptions;
const option = options.find((opt) => opt.fulfillmentMethod._id === opaqueMockFulfillmentMethodId);
opaqueFulfillmentMethodId = option.fulfillmentMethod._id;

expect(option).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ describe("as an anonymous user", () => {
productId: opaqueProductId,
productVariantId: opaqueCartProductVariantId
},
selectedFulfillmentType: "shipping",
quantity: 1
}
}
Expand Down Expand Up @@ -294,7 +295,12 @@ describe("as an anonymous user", () => {
return;
}

const option = result.updateFulfillmentOptionsForGroup.cart.checkout.fulfillmentGroups[0].availableFulfillmentOptions[0];
const mockFulfillmentMethodId = "mockMethod";
const opaqueMockFulfillmentMethodId = encodeOpaqueId("reaction/fulfillmentMethod", mockFulfillmentMethodId);

// From the multiple Fulfillment methods, find out the exact method we are looking for
const options = result.updateFulfillmentOptionsForGroup.cart.checkout.fulfillmentGroups[0].availableFulfillmentOptions;
const option = options.find((opt) => opt.fulfillmentMethod._id === opaqueMockFulfillmentMethodId);
opaqueFulfillmentMethodId = option.fulfillmentMethod._id;

expect(option).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ describe("as a signed in user", () => {
productId: opaqueProductId,
productVariantId: opaqueCartProductVariantId
},
selectedFulfillmentType: "shipping",
quantity: 1
}
}
Expand Down Expand Up @@ -293,7 +294,12 @@ describe("as a signed in user", () => {
return;
}

const option = result.updateFulfillmentOptionsForGroup.cart.checkout.fulfillmentGroups[0].availableFulfillmentOptions[0];
const mockFulfillmentMethodId = "mockMethod";
const opaqueMockFulfillmentMethodId = encodeOpaqueId("reaction/fulfillmentMethod", mockFulfillmentMethodId);

// From the multiple Fulfillment methods, find out the exact method we are looking for
const options = result.updateFulfillmentOptionsForGroup.cart.checkout.fulfillmentGroups[0].availableFulfillmentOptions;
const option = options.find((opt) => opt.fulfillmentMethod._id === opaqueMockFulfillmentMethodId);
opaqueFulfillmentMethodId = option.fulfillmentMethod._id;

expect(option).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ const mockShippingMethod = {
label: "Flat Rate",
name: "flatRates"
},
fulfillmentType: "shipping",
methods: [
{
cost: 2.5,
fulfillmentTypes: [
"shipping"
],
fulfillmentMethod: "flatRate",
group: "Ground",
handling: 1.5,
label: "Standard mockMethod",
Expand Down Expand Up @@ -186,7 +188,7 @@ beforeAll(async () => {

// Add shipping methods
mockShippingMethod.shopId = internalShopId;
await testApp.collections.Shipping.insertOne(mockShippingMethod);
await testApp.collections.Fulfillment.insertOne(mockShippingMethod);

// Add Tags and products
mockProduct.shopId = internalShopId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const expectedProduct = {
{ service: "pinterest", message: "" },
{ service: "twitter", message: "" }
],
supportedFulfillmentTypes: ["shipping"],
// supportedFulfillmentTypes: ["shipping"], // we no longer add default value here
supportedFulfillmentTypes: [],
tagIds: [],
title: "",
updatedAt: jasmine.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,37 @@ const mockShipmentMethod = {
handling: 0,
label: "mockLabel",
name: "mockName",
fulfillmentMethod: "flatRate",
rate: 3.99
};

const mockFulfillmentEntry = {
_id: "mockShippingMethod",
name: "Default Shipping Provider",
provider: {
enabled: true,
label: "Flat Rate",
name: "flatRates"
},
fulfillmentType: "shipping",
methods: [
{
cost: 2.5,
fulfillmentTypes: [
"shipping"
],
fulfillmentMethod: "flatRate",
group: "Ground",
handling: 1.5,
label: "Standard mockMethod",
name: "mockMethod",
rate: 1,
_id: "METHOD_ID",
enabled: true
}
]
};

beforeAll(async () => {
const getFulfillmentMethodsWithQuotes = (context, commonOrderExtended, [rates]) => {
rates.push({
Expand All @@ -46,13 +74,17 @@ beforeAll(async () => {
testApp.registerPlugin({
name: "moveOrderItems.test.js",
functionsByType: {
getFulfillmentMethodsWithQuotes: [getFulfillmentMethodsWithQuotes]
getFulfillmentMethodsWithQuotesshipping: [getFulfillmentMethodsWithQuotes]
}
});

await testApp.start();
shopId = await insertPrimaryShop(testApp.context);

// Add shipping methods
mockFulfillmentEntry.shopId = shopId;
await testApp.collections.Fulfillment.insertOne(mockFulfillmentEntry);

catalogItem = Factory.Catalog.makeOne({
isDeleted: false,
product: Factory.CatalogProduct.makeOne({
Expand Down Expand Up @@ -124,6 +156,7 @@ test("user who placed an order can move an order item", async () => {
...mockShipmentMethod,
currencyCode: "USD"
},
type: "shipping",
shopId
});

Expand All @@ -138,6 +171,7 @@ test("user who placed an order can move an order item", async () => {
...mockShipmentMethod,
currencyCode: "USD"
},
type: "shipping",
shopId
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:shippingMethods/create"],
permissions: ["reaction:legacy:fulfillmentMethods/create"],
slug: "admin",
shopId: internalShopId
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:shippingRestrictions/create"],
permissions: ["reaction:legacy:fulfillmentRestrictions/create"],
slug: "admin",
shopId: internalShopId
});
Expand Down Expand Up @@ -81,7 +81,7 @@ test("shop owner cannot update flat rate fulfillment restriction if not logged i
}
});

test("user with `reaction:legacy:shippingMethods/create` permissions can update flat rate fulfillment restriction", async () => {
test("user with `reaction:legacy:fulfillmentMethods/create` permissions can update flat rate fulfillment restriction", async () => {
let result;
await testApp.setLoggedInUser(mockOwnerAccount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:shippingMethods/delete"],
permissions: ["reaction:legacy:fulfillmentMethods/delete"],
slug: "admin",
shopId: internalShopId
});
Expand Down Expand Up @@ -80,7 +80,7 @@ beforeAll(async () => {
await testApp.collections.Groups.insertOne(adminGroup);
await testApp.collections.Groups.insertOne(customerGroup);

await testApp.collections.Shipping.insertOne({
await testApp.collections.Fulfillment.insertOne({
methods: [{
_id: mockFulfillmentMethodId,
shopId: internalShopId,
Expand Down Expand Up @@ -114,7 +114,7 @@ test("user can not delete flat rate fulfillment method if admin is not logged in
}
});

test("user can delete flat rate fulfillment method if they have `reaction:legacy:shippingMethods/delete` permissions", async () => {
test("user can delete flat rate fulfillment method if they have `reaction:legacy:fulfillmentMethods/delete` permissions", async () => {
await testApp.setLoggedInUser(mockAdminAccount);

let result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:shippingRestrictions/delete"],
permissions: ["reaction:legacy:fulfillmentRestrictions/delete"],
slug: "admin",
shopId: internalShopId
});
Expand All @@ -58,7 +58,7 @@ beforeAll(async () => {
await testApp.start();

await insertPrimaryShop(testApp.context, { _id: internalShopId, name: shopName });
await testApp.collections.FlatRateFulfillmentRestrictions.insertOne(mockFulfillmentRestriction);
await testApp.collections.FulfillmentRestrictions.insertOne(mockFulfillmentRestriction);
await testApp.collections.Groups.insertOne(adminGroup);

await testApp.createUserAndAccount(mockOwnerAccount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:shippingMethods/update"],
permissions: ["reaction:legacy:fulfillmentMethods/update"],
slug: "admin",
shopId: internalShopId
});
Expand Down Expand Up @@ -87,7 +87,7 @@ beforeAll(async () => {
await testApp.collections.Groups.insertOne(adminGroup);
await testApp.collections.Groups.insertOne(customerGroup);

await testApp.collections.Shipping.insertOne({
await testApp.collections.Fulfillment.insertOne({
methods: [mockFulfillmentMethod],
shopId: internalShopId
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:shippingRestrictions/update"],
permissions: ["reaction:legacy:fulfillmentRestrictions/update"],
slug: "admin",
shopId: internalShopId
});
Expand Down Expand Up @@ -68,7 +68,7 @@ beforeAll(async () => {
await testApp.start();

await insertPrimaryShop(testApp.context, { _id: internalShopId, name: shopName });
await testApp.collections.FlatRateFulfillmentRestrictions.insertOne(mockFulfillmentRestriction);
await testApp.collections.FulfillmentRestrictions.insertOne(mockFulfillmentRestriction);
await testApp.collections.Groups.insertOne(adminGroup);

await testApp.createUserAndAccount(mockOwnerAccount);
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载