fix: handle delete vendor/vendors that has/have associated bills.

This commit is contained in:
a.bouhuolia
2021-01-02 13:38:01 +02:00
parent db70d04743
commit 905cbbed70
3 changed files with 19 additions and 7 deletions

View File

@@ -483,10 +483,14 @@ export default class ItemsService implements IItemsService {
tenantId,
itemsIds,
});
/// Validates the given items exist on the storage.
await this.validateItemsIdsExists(tenantId, itemsIds);
// Validate the items have no associated invoices or bills.
await this.validateHasNoInvoicesOrBills(tenantId, itemsIds);
await Item.query().whereIn('id', itemsIds).delete();
this.logger.info('[items] deleted successfully in bulk.', {
tenantId,
itemsIds,