corrected formatting based on walkthrough of pr

This commit is contained in:
--list committed 2021-07-02 12:31:44 +02:00
1 parent 92710eb1de
commit 7cecc021f4
4 files changed
+49 -31

No files matched your search

@@ -59,7 +59,6 @@ export default async (req, res) => {
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
} }
try { try {
const returnService = req.scope.resolve("returnService") const returnService = req.scope.resolve("returnService")
const orderService = req.scope.resolve("orderService") const orderService = req.scope.resolve("orderService")
@@ -19,9 +19,6 @@ import { Product } from "./product"
import { MoneyAmount } from "./money-amount" import { MoneyAmount } from "./money-amount"
import { ProductOptionValue } from "./product-option-value" import { ProductOptionValue } from "./product-option-value"
@Entity() @Entity()
export class ProductVariant { export class ProductVariant {
@PrimaryColumn() @PrimaryColumn()
+12 -4
View File
@@ -249,8 +249,13 @@ class DraftOrderService extends BaseService {
) )
} }
const { items, shipping_methods, discounts, no_notification_order=undefined, ...rest } = data const {
items,
shipping_methods,
discounts,
no_notification_order = undefined,
...rest
} = data
if (discounts) { if (discounts) {
for (const { code } of discounts) { for (const { code } of discounts) {
@@ -265,7 +270,10 @@ class DraftOrderService extends BaseService {
.withTransaction(manager) .withTransaction(manager)
.create({ type: "draft_order", ...rest }) .create({ type: "draft_order", ...rest })
const draftOrder = draftOrderRepo.create({ cart_id: createdCart.id, no_notification_order}) const draftOrder = draftOrderRepo.create({
cart_id: createdCart.id,
no_notification_order,
})
const result = await draftOrderRepo.save(draftOrder) const result = await draftOrderRepo.save(draftOrder)
await this.eventBus_ await this.eventBus_
@@ -367,7 +375,7 @@ class DraftOrderService extends BaseService {
await this.eventBus_ await this.eventBus_
.withTransaction(manager) .withTransaction(manager)
.emit(DraftOrderService.Events.UPDATED, { .emit(DraftOrderService.Events.UPDATED, {
id: draftOrder.id id: draftOrder.id,
}) })
} }
+37 -23
View File
@@ -216,10 +216,10 @@ class SwapService extends BaseService {
additionalItems, additionalItems,
returnShipping, returnShipping,
custom = { custom = {
noNotification: undefined noNotification: undefined,
} }
) { ) {
const { noNotification, ...rest } = custom const { noNotification, ...rest } = custom
return this.atomicPhase_(async manager => { return this.atomicPhase_(async manager => {
if ( if (
order.fulfillment_status === "not_fulfilled" || order.fulfillment_status === "not_fulfilled" ||
@@ -241,16 +241,17 @@ class SwapService extends BaseService {
}) })
) )
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({
...rest , ...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,
additional_items: newItems, additional_items: newItems,
no_notification: evaluatedNoNotification no_notification: evaluatedNoNotification,
}) })
const result = await swapRepo.save(created) const result = await swapRepo.save(created)
@@ -596,7 +597,7 @@ class SwapService extends BaseService {
.withTransaction(manager) .withTransaction(manager)
.emit(SwapService.Events.PAYMENT_COMPLETED, { .emit(SwapService.Events.PAYMENT_COMPLETED, {
id: swap.id, id: swap.id,
no_notification: swap.no_notification no_notification: swap.no_notification,
}) })
return result return result
@@ -644,13 +645,16 @@ class SwapService extends BaseService {
* Fulfills the addtional items associated with the swap. Will call the * Fulfills the addtional items associated with the swap. Will call the
* fulfillment providers associated with the shipping methods. * fulfillment providers associated with the shipping methods.
* @param {string} swapId - the id of the swap to fulfill, * @param {string} swapId - the id of the swap to fulfill,
* @param {object} metadata - optional metadata to attach to the fulfillment. * @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag.
* @returns {Promise<Swap>} the updated swap with new status and fulfillments. * @returns {Promise<Swap>} the updated swap with new status and fulfillments.
*/ */
async createFulfillment(swapId, config = { async createFulfillment(
swapId,
config = {
metadata: {}, metadata: {},
noNotification: undefined noNotification: undefined,
}) { }
) {
const { metadata, noNotification } = config const { metadata, noNotification } = config
return this.atomicPhase_(async manager => { return this.atomicPhase_(async manager => {
@@ -682,7 +686,8 @@ class SwapService extends BaseService {
) )
} }
const evaluatedNoNotification = noNotification !== undefined ? noNotification : swap.no_notification const evaluatedNoNotification =
noNotification !== undefined ? noNotification : swap.no_notification
swap.fulfillments = await this.fulfillmentService_ swap.fulfillments = await this.fulfillmentService_
.withTransaction(manager) .withTransaction(manager)
@@ -744,15 +749,15 @@ class SwapService extends BaseService {
const swapRepo = manager.getCustomRepository(this.swapRepository_) const swapRepo = manager.getCustomRepository(this.swapRepository_)
const result = await swapRepo.save(swap) const result = await swapRepo.save(swap)
await this.eventBus_ await this.eventBus_.withTransaction(manager).emit(
.withTransaction(manager) SwapService.Events.FULFILLMENT_CREATED,
.emit(SwapService.Events.FULFILLMENT_CREATED,
{ {
id: swapId, id: swapId,
fulfillment_id: result.id, fulfillment_id: result.id,
no_notification: evaluatedNoNotification no_notification: evaluatedNoNotification,
}) }
)
return result return result
}) })
@@ -765,13 +770,18 @@ class SwapService extends BaseService {
* has been shipped * has been shipped
* @param {TrackingLink[]} trackingLinks - the tracking numbers associated * @param {TrackingLink[]} trackingLinks - the tracking numbers associated
* with the shipment * with the shipment
* @param {object} metadata - optional metadata to attach to the shipment. * @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag.
* @returns {Promise<Swap>} the updated swap with new fulfillments and status. * @returns {Promise<Swap>} the updated swap with new fulfillments and status.
*/ */
async createShipment(swapId, fulfillmentId, trackingLinks, config = { async createShipment(
swapId,
fulfillmentId,
trackingLinks,
config = {
metadata: {}, metadata: {},
noNotification: undefined, noNotification: undefined,
} ) { }
) {
const { metadata, noNotification } = config const { metadata, noNotification } = config
return this.atomicPhase_(async manager => { return this.atomicPhase_(async manager => {
@@ -779,12 +789,16 @@ class SwapService extends BaseService {
relations: ["additional_items"], relations: ["additional_items"],
}) })
const evaluatedNoNotification = noNotification !== undefined ? noNotification : swap.no_notification const evaluatedNoNotification =
noNotification !== undefined ? noNotification : swap.no_notification
// Update the fulfillment to register // Update the fulfillment to register
const shipment = await this.fulfillmentService_ const shipment = await this.fulfillmentService_
.withTransaction(manager) .withTransaction(manager)
.createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) .createShipment(fulfillmentId, trackingLinks, {
metadata,
noNotification: evaluatedNoNotification,
})
swap.fulfillment_status = "shipped" swap.fulfillment_status = "shipped"
@@ -814,7 +828,7 @@ class SwapService extends BaseService {
.emit(SwapService.Events.SHIPMENT_CREATED, { .emit(SwapService.Events.SHIPMENT_CREATED, {
id: swapId, id: swapId,
fulfillment_id: shipment.id, fulfillment_id: shipment.id,
no_notification: swap.no_notification no_notification: swap.no_notification,
}) })
return result return result
}) })
@@ -871,7 +885,7 @@ class SwapService extends BaseService {
.emit(SwapService.Events.RECEIVED, { .emit(SwapService.Events.RECEIVED, {
id: id, id: id,
order_id: result.order_id, order_id: result.order_id,
no_notification: swap.no_notification no_notification: swap.no_notification,
}) })
return result return result