fix merge conflicts from develop

This commit is contained in:
olivermrbl
2021-05-25 15:44:26 +02:00
251 changed files with 25580 additions and 4521 deletions
+74 -2
View File
@@ -1,15 +1,68 @@
const { Customer, Region, Cart } = require("@medusajs/medusa");
const {
Customer,
Region,
Cart,
DiscountRule,
Discount,
ShippingProfile,
ShippingOption,
ShippingMethod,
} = require("@medusajs/medusa");
module.exports = async (connection, data = {}) => {
const manager = connection.manager;
await manager.insert(Region, {
const defaultProfile = await manager.findOne(ShippingProfile, {
type: "default",
});
const r = manager.create(Region, {
id: "test-region",
name: "Test Region",
currency_code: "usd",
tax_rate: 0,
});
const freeRule = manager.create(DiscountRule, {
id: "free-shipping-rule",
description: "Free shipping rule",
type: "free_shipping",
value: 100,
allocation: "total",
});
const freeDisc = manager.create(Discount, {
id: "free-shipping",
code: "FREE_SHIPPING",
is_dynamic: false,
is_disabled: false,
});
freeDisc.regions = [r];
freeDisc.rule = freeRule;
await manager.save(freeDisc);
const d = await manager.create(Discount, {
id: "test-discount",
code: "CREATED",
is_dynamic: false,
is_disabled: false,
});
const dr = await manager.create(DiscountRule, {
id: "test-discount-rule",
description: "Created",
type: "fixed",
value: 10000,
allocation: "total",
});
d.rule = dr;
d.regions = [r];
await manager.save(d);
await manager.query(
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
);
@@ -29,6 +82,17 @@ module.exports = async (connection, data = {}) => {
email: "some-customer@email.com",
});
await manager.insert(ShippingOption, {
id: "test-option",
name: "test-option",
provider_id: "test-ful",
region_id: "test-region",
profile_id: defaultProfile.id,
price_type: "flat_rate",
amount: 1000,
data: {},
});
const cart = manager.create(Cart, {
id: "test-cart",
customer_id: "some-customer",
@@ -44,4 +108,12 @@ module.exports = async (connection, data = {}) => {
});
await manager.save(cart);
await manager.insert(ShippingMethod, {
id: "test-method",
shipping_option_id: "test-option",
cart_id: "test-cart",
price: 1000,
data: {},
});
};
+52 -13
View File
@@ -10,6 +10,7 @@ const {
ProductVariant,
Region,
Order,
Swap,
} = require("@medusajs/medusa");
module.exports = async (connection, data = {}) => {
@@ -39,6 +40,26 @@ module.exports = async (connection, data = {}) => {
],
});
await manager.insert(ProductVariant, {
id: "test-variant-2",
title: "Swap product",
product_id: "test-product",
inventory_quantity: 1,
options: [
{
option_id: "test-option",
value: "Large",
},
],
});
const ma2 = manager.create(MoneyAmount, {
variant_id: "test-variant-2",
currency_code: "usd",
amount: 8000,
});
await manager.save(ma2);
const ma = manager.create(MoneyAmount, {
variant_id: "test-variant",
currency_code: "usd",
@@ -73,10 +94,24 @@ module.exports = async (connection, data = {}) => {
data: {},
});
await manager.insert(ShippingOption, {
id: "test-return-option",
name: "Test ret",
profile_id: defaultProfile.id,
region_id: "test-region",
provider_id: "test-ful",
data: {},
price_type: "flat_rate",
amount: 1000,
is_return: true,
});
const order = manager.create(Order, {
id: "test-order",
customer_id: "test-customer",
email: "test@email.com",
payment_status: "captured",
fulfillment_status: "fulfilled",
billing_address: {
id: "test-billing-address",
first_name: "lebron",
@@ -115,27 +150,31 @@ module.exports = async (connection, data = {}) => {
amount: 10000,
currency_code: "usd",
amount_refunded: 0,
provider_id: "test",
provider_id: "test-pay",
data: {},
},
],
items: [
{
id: "test-item",
fulfilled_quantity: 1,
title: "Line Item",
description: "Line Item Desc",
thumbnail: "https://test.js/1234",
unit_price: 8000,
quantity: 1,
variant_id: "test-variant",
},
],
items: [],
...data,
});
await manager.save(order);
const li = manager.create(LineItem, {
id: "test-item",
fulfilled_quantity: 1,
returned_quantity: 0,
title: "Line Item",
description: "Line Item Desc",
thumbnail: "https://test.js/1234",
unit_price: 8000,
quantity: 1,
variant_id: "test-variant",
order_id: "test-order",
});
await manager.save(li);
await manager.insert(ShippingMethod, {
id: "test-method",
order_id: "test-order",
@@ -6,6 +6,7 @@ const {
Product,
ShippingProfile,
ProductVariant,
Image,
} = require("@medusajs/medusa");
module.exports = async (connection, data = {}) => {
@@ -36,6 +37,13 @@ module.exports = async (connection, data = {}) => {
await manager.save(type);
const image = manager.create(Image, {
id: "test-image",
url: "test-image.png",
});
await manager.save(image);
await manager.insert(Region, {
id: "test-region",
name: "Test Region",
@@ -43,7 +51,7 @@ module.exports = async (connection, data = {}) => {
tax_rate: 0,
});
await manager.insert(Product, {
const p = manager.create(Product, {
id: "test-product",
title: "Test product",
profile_id: defaultProfile.id,
@@ -57,6 +65,10 @@ module.exports = async (connection, data = {}) => {
options: [{ id: "test-option", title: "Default value" }],
});
p.images = [image];
await manager.save(p);
await manager.insert(ProductVariant, {
id: "test-variant",
inventory_quantity: 10,
@@ -0,0 +1,159 @@
const {
ShippingProfile,
Customer,
MoneyAmount,
LineItem,
Country,
ShippingOption,
ShippingMethod,
Product,
ProductVariant,
Region,
Order,
Swap,
Return,
} = require("@medusajs/medusa");
module.exports = async (connection, data = {}) => {
const manager = connection.manager;
let orderWithSwap = manager.create(Order, {
id: "order-with-swap",
customer_id: "test-customer",
email: "test@email.com",
payment_status: "captured",
fulfillment_status: "fulfilled",
billing_address: {
id: "test-billing-address",
first_name: "lebron",
},
shipping_address: {
id: "test-shipping-address",
first_name: "lebron",
country_code: "us",
},
region_id: "test-region",
currency_code: "usd",
tax_rate: 0,
discounts: [],
payments: [
{
id: "test-payment",
amount: 10000,
currency_code: "usd",
amount_refunded: 0,
provider_id: "test",
data: {},
},
],
items: [],
...data,
});
orderWithSwap = await manager.save(orderWithSwap);
const li = manager.create(LineItem, {
id: "test-item-2",
fulfilled_quantity: 1,
title: "Line Item",
description: "Line Item Desc",
thumbnail: "https://test.js/1234",
unit_price: 8000,
quantity: 1,
variant_id: "test-variant",
order_id: orderWithSwap.id,
});
await manager.save(li);
const li2 = manager.create(LineItem, {
id: "test-item-many",
fulfilled_quantity: 4,
title: "Line Item",
description: "Line Item Desc",
thumbnail: "https://test.js/1234",
unit_price: 8000,
quantity: 4,
variant_id: "test-variant",
order_id: orderWithSwap.id,
});
await manager.save(li2);
const swap = manager.create(Swap, {
id: "test-swap",
order_id: "order-with-swap",
payment_status: "captured",
fulfillment_status: "fulfilled",
payment: {
id: "test-payment-swap",
amount: 10000,
currency_code: "usd",
amount_refunded: 0,
provider_id: "test",
data: {},
},
additional_items: [
{
id: "test-item-swapped",
fulfilled_quantity: 1,
title: "Line Item",
description: "Line Item Desc",
thumbnail: "https://test.js/1234",
unit_price: 8000,
quantity: 1,
variant_id: "test-variant-2",
},
],
});
await manager.save(swap);
const swapOnSwap = manager.create(Swap, {
id: "swap-on-swap",
order_id: "order-with-swap",
payment_status: "captured",
fulfillment_status: "fulfilled",
return_order: {
id: "return-on-swap",
refund_amount: 9000,
items: [
{
return_id: "return-on-swap",
item_id: "test-item-swapped",
quantity: 1,
},
],
},
payment: {
id: "test-payment-swap-on-swap",
amount: 10000,
currency_code: "usd",
amount_refunded: 0,
provider_id: "test",
data: {},
},
additional_items: [
{
id: "test-item-swap-on-swap",
fulfilled_quantity: 1,
title: "Line Item",
description: "Line Item Desc",
thumbnail: "https://test.js/1234",
unit_price: 8000,
quantity: 1,
variant_id: "test-variant",
},
],
});
await manager.save(swapOnSwap);
await manager.insert(ShippingMethod, {
id: "test-method-swap-order",
shipping_option_id: "test-option",
order_id: "order-with-swap",
price: 1000,
data: {},
});
};