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