fix:create customer/vendor

This commit is contained in:
Ahmed Bouhuolia
2025-06-29 16:55:02 +02:00
parent fa5c3bd955
commit 83e698acf3
8 changed files with 17 additions and 10 deletions

View File

@@ -40,7 +40,7 @@ export class DeleteItemService {
const oldItem = await this.itemModel()
.query()
.findOne('id', itemId)
.deleteIfNoRelations();
.throwIfNotFound();
// Delete item in unit of work.
return this.uow.withTransaction(async (trx: Knex.Transaction) => {
@@ -51,8 +51,9 @@ export class DeleteItemService {
} as IItemEventDeletingPayload);
// Deletes the item.
await this.itemModel().query(trx).findById(itemId).delete();
await this.itemModel().query(trx).findById(itemId).deleteIfNoRelations({
type: ERRORS.ITEM_HAS_ASSOCIATED_TRANSACTINS,
});
// Triggers `onItemDeleted` event.
await this.eventEmitter.emitAsync(events.item.onDeleted, {
itemId,