added changes

This commit is contained in:
--list
2021-07-02 12:11:09 +02:00
parent 46a3cb3710
commit 02b6c19391
3 changed files with 46 additions and 26 deletions
@@ -22,7 +22,7 @@ import { defaultRelations, defaultFields } from "./"
* items: * items:
* type: string * type: string
* no_notification: * no_notification:
* description: If set to true no notification will be send related to this Claim. * description: If set to true no notification will be send related to this Shipment.
* type: boolean * type: boolean
* tags: * tags:
* - Order * - Order
@@ -59,7 +59,7 @@ export default async (req, res) => {
id, id,
value.fulfillment_id, value.fulfillment_id,
value.tracking_numbers.map(n => ({ tracking_number: n })), value.tracking_numbers.map(n => ({ tracking_number: n })),
{noNotification: value.no_notification}, { noNotification: value.no_notification }
) )
const order = await orderService.retrieve(id, { const order = await orderService.retrieve(id, {
@@ -26,7 +26,7 @@ import { defaultRelations, defaultFields } from "./"
* description: A not with additional details about the Refund. * description: A not with additional details about the Refund.
* type: string * type: string
* no_notification: * no_notification:
* description: If set to true no notification will be send related to this Swap. * description: If set to true no notification will be send related to this Refund.
* type: boolean * type: boolean
* tags: * tags:
* - Order * - Order
@@ -62,7 +62,13 @@ export default async (req, res) => {
try { try {
const orderService = req.scope.resolve("orderService") const orderService = req.scope.resolve("orderService")
await orderService.createRefund(id, value.amount, value.reason, value.note, {noNotification: value.no_notification}) await orderService.createRefund(
id,
value.amount,
value.reason,
value.note,
{ noNotification: value.no_notification }
)
const order = await orderService.retrieve(id, { const order = await orderService.retrieve(id, {
select: defaultFields, select: defaultFields,
+36 -22
View File
@@ -135,7 +135,7 @@ class ClaimService extends BaseService {
} }
} }
if( no_notification !== undefined ){ if (no_notification !== undefined) {
claim.no_notification = no_notification claim.no_notification = no_notification
await claimRepo.save(claim) await claimRepo.save(claim)
} }
@@ -150,12 +150,11 @@ class ClaimService extends BaseService {
} }
} }
await this.eventBus_ await this.eventBus_
.withTransaction(manager) .withTransaction(manager)
.emit(ClaimService.Events.UPDATED, { .emit(ClaimService.Events.UPDATED, {
id: claim.id, id: claim.id,
no_notification: claim.no_notification no_notification: claim.no_notification,
}) })
return claim return claim
@@ -241,7 +240,8 @@ class ClaimService extends BaseService {
) )
) )
const evaluatedNoNotification = no_notification !== undefined ? no_notification : order.no_notification const evaluatedNoNotification =
no_notification !== undefined ? no_notification : order.no_notification
const created = claimRepo.create({ const created = claimRepo.create({
shipping_address_id: addressId, shipping_address_id: addressId,
@@ -251,7 +251,7 @@ class ClaimService extends BaseService {
type, type,
additional_items: newItems, additional_items: newItems,
order_id: order.id, order_id: order.id,
no_notification: evaluatedNoNotification no_notification: evaluatedNoNotification,
}) })
const result = await claimRepo.save(created) const result = await claimRepo.save(created)
@@ -292,6 +292,7 @@ class ClaimService extends BaseService {
metadata: ci.metadata, metadata: ci.metadata,
})), })),
shipping_method: return_shipping, shipping_method: return_shipping,
no_notification: evaluatedNoNotification,
}) })
} }
@@ -299,17 +300,20 @@ class ClaimService extends BaseService {
.withTransaction(manager) .withTransaction(manager)
.emit(ClaimService.Events.CREATED, { .emit(ClaimService.Events.CREATED, {
id: result.id, id: result.id,
no_notification: result.no_notification no_notification: result.no_notification,
}) })
return result return result
}) })
} }
createFulfillment(id, config = { createFulfillment(
metadata: {}, id,
noNotification: undefined, config = {
}) { metadata: {},
noNotification: undefined,
}
) {
const { metadata, noNotification } = config const { metadata, noNotification } = config
return this.atomicPhase_(async manager => { return this.atomicPhase_(async manager => {
@@ -348,7 +352,8 @@ class ClaimService extends BaseService {
) )
} }
const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification const evaluatedNoNotification =
noNotification !== undefined ? noNotification : claim.no_notification
const fulfillments = await this.fulfillmentService_ const fulfillments = await this.fulfillmentService_
.withTransaction(manager) .withTransaction(manager)
@@ -415,7 +420,7 @@ class ClaimService extends BaseService {
.emit(ClaimService.Events.FULFILLMENT_CREATED, { .emit(ClaimService.Events.FULFILLMENT_CREATED, {
id: id, id: id,
fulfillment_id: fulfillment.id, fulfillment_id: fulfillment.id,
no_notification: claim.no_notification no_notification: claim.no_notification,
}) })
} }
@@ -451,29 +456,38 @@ class ClaimService extends BaseService {
.withTransaction(manager) .withTransaction(manager)
.emit(ClaimService.Events.REFUND_PROCESSED, { .emit(ClaimService.Events.REFUND_PROCESSED, {
id, id,
no_notification: result.no_notification no_notification: result.no_notification,
}) })
return result return result
}) })
} }
async createShipment(id, fulfillmentId, trackingLinks, config = { async createShipment(
metadata: {}, id,
noNotification: undefined, fulfillmentId,
}) { trackingLinks,
config = {
metadata: {},
noNotification: undefined,
}
) {
const { metadata, noNotification } = config const { metadata, noNotification } = config
return this.atomicPhase_(async manager => { return this.atomicPhase_(async manager => {
const claim = await this.retrieve(id, { const claim = await this.retrieve(id, {
relations: ["additional_items"], relations: ["additional_items"],
}) })
const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification const evaluatedNoNotification =
noNotification !== undefined ? noNotification : claim.no_notification
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,
})
claim.fulfillment_status = "shipped" claim.fulfillment_status = "shipped"
@@ -503,7 +517,7 @@ class ClaimService extends BaseService {
.emit(ClaimService.Events.SHIPMENT_CREATED, { .emit(ClaimService.Events.SHIPMENT_CREATED, {
id, id,
fulfillment_id: shipment.id, fulfillment_id: shipment.id,
no_notification: evaluatedNoNotification no_notification: evaluatedNoNotification,
}) })
return result return result
@@ -554,7 +568,7 @@ class ClaimService extends BaseService {
.withTransaction(manager) .withTransaction(manager)
.emit(ClaimService.Events.CANCELED, { .emit(ClaimService.Events.CANCELED, {
id: result.id, id: result.id,
no_notification: result.no_notification no_notification: result.no_notification,
}) })
return result return result