Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use ct order number when present, fallback to order id #32

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions event/src/controllers/eventController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class EventController {
switch (resourceRef.typeId) {
case 'order':
if (this.isOrderStateConfirmedMessage(message) || this.isOrderCreatedWithStateConfirmedMessage(message)) {
await this.orderProcessor.processOrder(resourceRef.id);
await this.orderProcessor.processOrder(resourceRef.id, message.resourceUserProvidedIdentifiers?.orderNumber);
} else if (this.isOrderStateCancelledMessage(message) || this.isOrderDeletedMessage(message)) {
await this.orderProcessor.cancelOrder(resourceRef.id);
await this.orderProcessor.cancelOrder(resourceRef.id, message.resourceUserProvidedIdentifiers?.orderNumber);
}
break;
case 'channel':
Expand Down
8 changes: 4 additions & 4 deletions event/src/order/orderProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export class OrderProcessor {

constructor(private readonly fftOrderService: FftOrderService, private readonly orderMapper: OrderMapper) {}

async processOrder(orderId: string) {
async processOrder(orderId: string, orderNumber?: string) {
this.removeOldLocks(60);
this.lockOrder(orderId);
try {
const fftOrder = await this.fftOrderService.findByTenantOrderId(orderId);
const fftOrder = await this.fftOrderService.findByTenantOrderId(orderNumber || orderId);
if (fftOrder) {
logger.info(`fulfillmenttools order for CT order '${orderId}' already exists => skip`);
return;
Expand All @@ -25,11 +25,11 @@ export class OrderProcessor {
}
}

async cancelOrder(orderId: string) {
async cancelOrder(orderId: string, orderNumber?: string) {
this.removeOldLocks(60);
this.lockOrder(orderId);
try {
const fftOrder = await this.fftOrderService.findByTenantOrderId(orderId);
const fftOrder = await this.fftOrderService.findByTenantOrderId(orderNumber || orderId);
if (!fftOrder) {
logger.info(`fulfillmenttools order for CT order '${orderId}' does not exist => nothing to cancel`);
return;
Expand Down
Loading