Refactor event handling in AmplidPlugin to improve error handling and streamline status updates for DocumentLineItems

This commit is contained in:
Dennes Schäffler
2026-05-07 09:48:04 +02:00
parent 83eb8b36bd
commit 139fe4bccb

View File

@@ -46,6 +46,9 @@ export class AmplidPlugin implements OnApplicationBootstrap {
this.eventBus.registerBlockingEventHandler(DocumentLineItemStatusChangedEvent, {
id: 'amplid-plugin-document-line-item-status-changed',
handler: async (event) => {
try {
if (event.newStatus == DocumentStatusType.COMPLETED) {
if (!event.dli) {
@@ -70,12 +73,16 @@ export class AmplidPlugin implements OnApplicationBootstrap {
this.logger.info(`Keeping status as completed for DocumentLineItem ${event.dli.id} because bestelltemenge ${bestellteMenge} is not set`);
}
}
} catch (error: any) {
this.logger.error(error);
}
},
});
this.eventBus.registerBlockingEventHandler(EntitySavedEvent, {
id: 'amplid-plugin-post-entity-saved',
handler: async (event) => {
try {
if (event.entity === DocumentLineItem.name) {
let dli = event.input as DocumentLineItem;
@@ -102,6 +109,9 @@ export class AmplidPlugin implements OnApplicationBootstrap {
this.logger.info(`Keeping status as completed for DocumentLineItem ${dli.id} because bestelltemenge ${bestellteMenge} is not set`);
}
}
} catch (error: any) {
this.logger.error(error);
}
},
});
}