* hotfix(medusa-plugin-brightpearl): Use order id in sales order endpoint * feat(medusa-plugin-sendgrid): adds localization option (#238) * chore(deps): bump y18n from 4.0.0 to 4.0.1 in /packages/medusa-cli (#226) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump y18n from 4.0.0 to 4.0.3 in /packages/medusa (#235) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/compare/v4.0.0...y18n-v4.0.3) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump y18n from 4.0.0 to 4.0.1 in /e2e/prod-project (#225) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump y18n in /packages/medusa-core-utils (#224) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(medusa): Swaps on swaps (#229) Co-authored-by: Sebastian Rindom <skrindom@gmail.com> * chore: version bumps * chore: version bumps * chore(release): Publish - babel-preset-medusa-package@1.1.1 - @medusajs/medusa-cli@1.1.5 - medusa-core-utils@1.1.7 - medusa-dev-cli@0.0.6 - medusa-file-spaces@1.1.10 - medusa-fulfillment-manual@1.1.7 - medusa-fulfillment-webshipper@1.1.10 - medusa-interfaces@1.1.8 - medusa-payment-adyen@1.1.10 - medusa-payment-klarna@1.1.11 - medusa-payment-paypal@1.0.10 - medusa-payment-stripe@1.1.10 - medusa-plugin-add-ons@1.1.10 - medusa-plugin-brightpearl@1.1.13 - medusa-plugin-contentful@1.1.11 - medusa-plugin-discount-generator@1.1.1 - medusa-plugin-economic@1.1.10 - medusa-plugin-ip-lookup@1.1.1 - medusa-plugin-mailchimp@1.1.10 - medusa-plugin-permissions@1.1.10 - medusa-plugin-restock-notification@0.0.4 - medusa-plugin-segment@1.1.13 - medusa-plugin-sendgrid@1.1.11 - medusa-plugin-slack-notification@1.1.10 - medusa-plugin-twilio-sms@1.1.10 - medusa-plugin-wishlist@1.1.10 - medusa-test-utils@1.1.10 - @medusajs/medusa@1.1.20 * chore(release): Publish - babel-preset-medusa-package@1.1.2 - @medusajs/medusa-cli@1.1.6 - medusa-core-utils@1.1.8 - medusa-dev-cli@0.0.7 - medusa-file-spaces@1.1.11 - medusa-fulfillment-manual@1.1.8 - medusa-fulfillment-webshipper@1.1.11 - medusa-interfaces@1.1.9 - medusa-payment-adyen@1.1.11 - medusa-payment-klarna@1.1.12 - medusa-payment-paypal@1.0.11 - medusa-payment-stripe@1.1.11 - medusa-plugin-add-ons@1.1.11 - medusa-plugin-brightpearl@1.1.14 - medusa-plugin-contentful@1.1.12 - medusa-plugin-discount-generator@1.1.2 - medusa-plugin-economic@1.1.11 - medusa-plugin-ip-lookup@1.1.2 - medusa-plugin-mailchimp@1.1.11 - medusa-plugin-permissions@1.1.11 - medusa-plugin-restock-notification@0.0.5 - medusa-plugin-segment@1.1.14 - medusa-plugin-sendgrid@1.1.12 - medusa-plugin-slack-notification@1.1.11 - medusa-plugin-twilio-sms@1.1.11 - medusa-plugin-wishlist@1.1.11 - medusa-test-utils@1.1.11 - @medusajs/medusa@1.1.21 Co-authored-by: Sebastian Rindom <skrindom@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
160 lines
3.5 KiB
JavaScript
160 lines
3.5 KiB
JavaScript
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: {},
|
|
});
|
|
};
|