revamped way of propegating noNotification, now redo tests
This commit is contained in:
@@ -90,8 +90,6 @@ export default async (req, res) => {
|
|||||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("..>")
|
|
||||||
|
|
||||||
const idempotencyKeyService = req.scope.resolve("idempotencyKeyService")
|
const idempotencyKeyService = req.scope.resolve("idempotencyKeyService")
|
||||||
|
|
||||||
const headerKey = req.get("Idempotency-Key") || ""
|
const headerKey = req.get("Idempotency-Key") || ""
|
||||||
|
|||||||
@@ -191,13 +191,20 @@ export const defaultRelations = [
|
|||||||
"returns.items.reason",
|
"returns.items.reason",
|
||||||
"gift_cards",
|
"gift_cards",
|
||||||
"gift_card_transactions",
|
"gift_card_transactions",
|
||||||
|
"items",
|
||||||
|
"items.variant",
|
||||||
|
"items.variant.product",
|
||||||
"claims",
|
"claims",
|
||||||
"claims.return_order",
|
"claims.return_order",
|
||||||
"claims.shipping_methods",
|
"claims.shipping_methods",
|
||||||
"claims.shipping_address",
|
"claims.shipping_address",
|
||||||
"claims.additional_items",
|
"claims.additional_items",
|
||||||
|
"claims.additional_items.variant",
|
||||||
|
"claims.additional_items.variant.product",
|
||||||
"claims.fulfillments",
|
"claims.fulfillments",
|
||||||
"claims.claim_items",
|
"claims.claim_items",
|
||||||
|
"claims.claim_items.variant",
|
||||||
|
"claims.claim_items.variant.product",
|
||||||
"claims.claim_items.images",
|
"claims.claim_items.images",
|
||||||
// "claims.claim_items.tags",
|
// "claims.claim_items.tags",
|
||||||
"swaps",
|
"swaps",
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ export default async (req, res) => {
|
|||||||
"return_order",
|
"return_order",
|
||||||
"fulfillments",
|
"fulfillments",
|
||||||
"payment",
|
"payment",
|
||||||
|
"items",
|
||||||
|
"items.variant",
|
||||||
|
"items.variant.product",
|
||||||
"shipping_address",
|
"shipping_address",
|
||||||
"shipping_methods",
|
"shipping_methods",
|
||||||
"cart",
|
"cart",
|
||||||
|
|||||||
@@ -168,12 +168,7 @@ class FulfillmentService extends BaseService {
|
|||||||
* @param {object} config - potential configurations, including metadata to add
|
* @param {object} config - potential configurations, including metadata to add
|
||||||
* @return {Fulfillment[]} the created fulfillments
|
* @return {Fulfillment[]} the created fulfillments
|
||||||
*/
|
*/
|
||||||
async createFulfillment(order, itemsToFulfill, config = {
|
async createFulfillment(order, itemsToFulfill, custom = {}) {
|
||||||
noNotification: undefined,
|
|
||||||
custom: {},
|
|
||||||
}) {
|
|
||||||
const {custom, noNotification} = config
|
|
||||||
|
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async manager => {
|
||||||
const fulfillmentRepository = manager.getCustomRepository(
|
const fulfillmentRepository = manager.getCustomRepository(
|
||||||
this.fulfillmentRepository_
|
this.fulfillmentRepository_
|
||||||
@@ -185,6 +180,8 @@ class FulfillmentService extends BaseService {
|
|||||||
this.validateFulfillmentLineItem_
|
this.validateFulfillmentLineItem_
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const { noNotification, ...rest} = custom
|
||||||
|
|
||||||
const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification
|
const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification
|
||||||
|
|
||||||
const { shipping_methods } = order
|
const { shipping_methods } = order
|
||||||
@@ -195,7 +192,7 @@ class FulfillmentService extends BaseService {
|
|||||||
const created = await Promise.all(
|
const created = await Promise.all(
|
||||||
fulfillments.map(async ({ shipping_method, items }) => {
|
fulfillments.map(async ({ shipping_method, items }) => {
|
||||||
const ful = fulfillmentRepository.create({
|
const ful = fulfillmentRepository.create({
|
||||||
...custom,
|
...rest,
|
||||||
provider_id: shipping_method.shipping_option.provider_id,
|
provider_id: shipping_method.shipping_option.provider_id,
|
||||||
items: items.map(i => ({ item_id: i.id, quantity: i.quantity })),
|
items: items.map(i => ({ item_id: i.id, quantity: i.quantity })),
|
||||||
no_notification: evaluatedNoNotification,
|
no_notification: evaluatedNoNotification,
|
||||||
|
|||||||
@@ -1025,9 +1025,6 @@ class OrderService extends BaseService {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
console.log("metadata:" + metadata)
|
|
||||||
|
|
||||||
if (!order.shipping_methods?.length) {
|
if (!order.shipping_methods?.length) {
|
||||||
throw new MedusaError(
|
throw new MedusaError(
|
||||||
MedusaError.Types.NOT_ALLOWED,
|
MedusaError.Types.NOT_ALLOWED,
|
||||||
@@ -1040,8 +1037,8 @@ class OrderService extends BaseService {
|
|||||||
.withTransaction(manager)
|
.withTransaction(manager)
|
||||||
.createFulfillment(order, itemsToFulfill, {
|
.createFulfillment(order, itemsToFulfill, {
|
||||||
metadata,
|
metadata,
|
||||||
|
noNotification: noNotification,
|
||||||
order_id: orderId,
|
order_id: orderId,
|
||||||
no_notification: noNotification
|
|
||||||
})
|
})
|
||||||
let successfullyFulfilled = []
|
let successfullyFulfilled = []
|
||||||
for (const f of fulfillments) {
|
for (const f of fulfillments) {
|
||||||
|
|||||||
@@ -215,12 +215,8 @@ class SwapService extends BaseService {
|
|||||||
returnItems,
|
returnItems,
|
||||||
additionalItems,
|
additionalItems,
|
||||||
returnShipping,
|
returnShipping,
|
||||||
config = {
|
custom = {}
|
||||||
custom: {},
|
|
||||||
noNotification: undefined,
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
const { noNotification, custom } = config
|
|
||||||
|
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async manager => {
|
||||||
if (
|
if (
|
||||||
@@ -243,11 +239,13 @@ class SwapService extends BaseService {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const { noNotification, ...rest } = custom
|
||||||
|
|
||||||
const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification
|
const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification
|
||||||
|
|
||||||
const swapRepo = manager.getCustomRepository(this.swapRepository_)
|
const swapRepo = manager.getCustomRepository(this.swapRepository_)
|
||||||
const created = swapRepo.create({
|
const created = swapRepo.create({
|
||||||
...custom,
|
...rest ,
|
||||||
fulfillment_status: "not_fulfilled",
|
fulfillment_status: "not_fulfilled",
|
||||||
payment_status: "not_paid",
|
payment_status: "not_paid",
|
||||||
order_id: order.id,
|
order_id: order.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user