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

View File

@@ -22,7 +22,7 @@ import { defaultRelations, defaultFields } from "./"
* items:
* type: string
* 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
* tags:
* - Order
@@ -59,7 +59,7 @@ export default async (req, res) => {
id,
value.fulfillment_id,
value.tracking_numbers.map(n => ({ tracking_number: n })),
{noNotification: value.no_notification},
{ noNotification: value.no_notification }
)
const order = await orderService.retrieve(id, {

View File

@@ -26,7 +26,7 @@ import { defaultRelations, defaultFields } from "./"
* description: A not with additional details about the Refund.
* type: string
* 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
* tags:
* - Order
@@ -62,7 +62,13 @@ export default async (req, res) => {
try {
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, {
select: defaultFields,

View File

@@ -135,7 +135,7 @@ class ClaimService extends BaseService {
}
}
if( no_notification !== undefined ){
if (no_notification !== undefined) {
claim.no_notification = no_notification
await claimRepo.save(claim)
}
@@ -150,12 +150,11 @@ class ClaimService extends BaseService {
}
}
await this.eventBus_
.withTransaction(manager)
.emit(ClaimService.Events.UPDATED, {
id: claim.id,
no_notification: claim.no_notification
no_notification: claim.no_notification,
})
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({
shipping_address_id: addressId,
@@ -251,7 +251,7 @@ class ClaimService extends BaseService {
type,
additional_items: newItems,
order_id: order.id,
no_notification: evaluatedNoNotification
no_notification: evaluatedNoNotification,
})
const result = await claimRepo.save(created)
@@ -292,6 +292,7 @@ class ClaimService extends BaseService {
metadata: ci.metadata,
})),
shipping_method: return_shipping,
no_notification: evaluatedNoNotification,
})
}
@@ -299,17 +300,20 @@ class ClaimService extends BaseService {
.withTransaction(manager)
.emit(ClaimService.Events.CREATED, {
id: result.id,
no_notification: result.no_notification
no_notification: result.no_notification,
})
return result
})
}
createFulfillment(id, config = {
metadata: {},
noNotification: undefined,
}) {
createFulfillment(
id,
config = {
metadata: {},
noNotification: undefined,
}
) {
const { metadata, noNotification } = config
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_
.withTransaction(manager)
@@ -415,7 +420,7 @@ class ClaimService extends BaseService {
.emit(ClaimService.Events.FULFILLMENT_CREATED, {
id: 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)
.emit(ClaimService.Events.REFUND_PROCESSED, {
id,
no_notification: result.no_notification
no_notification: result.no_notification,
})
return result
})
}
async createShipment(id, fulfillmentId, trackingLinks, config = {
metadata: {},
noNotification: undefined,
}) {
async createShipment(
id,
fulfillmentId,
trackingLinks,
config = {
metadata: {},
noNotification: undefined,
}
) {
const { metadata, noNotification } = config
return this.atomicPhase_(async manager => {
const claim = await this.retrieve(id, {
relations: ["additional_items"],
})
const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification
const evaluatedNoNotification =
noNotification !== undefined ? noNotification : claim.no_notification
const shipment = await this.fulfillmentService_
.withTransaction(manager)
.createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification})
.createShipment(fulfillmentId, trackingLinks, {
metadata,
noNotification: evaluatedNoNotification,
})
claim.fulfillment_status = "shipped"
@@ -503,7 +517,7 @@ class ClaimService extends BaseService {
.emit(ClaimService.Events.SHIPMENT_CREATED, {
id,
fulfillment_id: shipment.id,
no_notification: evaluatedNoNotification
no_notification: evaluatedNoNotification,
})
return result
@@ -554,7 +568,7 @@ class ClaimService extends BaseService {
.withTransaction(manager)
.emit(ClaimService.Events.CANCELED, {
id: result.id,
no_notification: result.no_notification
no_notification: result.no_notification,
})
return result