feat: one-click demo account

This commit is contained in:
Ahmed Bouhuolia
2024-08-22 19:21:23 +02:00
parent 59f480f9d5
commit 4a99f6c0cf
15 changed files with 83 additions and 43 deletions

View File

@@ -5,6 +5,7 @@ import { ServiceError } from '@/exceptions';
import TenancyService from '@/services/Tenancy/TenancyService';
import { ItemEntry } from '@/models';
import { entriesAmountDiff } from 'utils';
import { Knex } from 'knex';
const ERRORS = {
ITEMS_NOT_FOUND: 'ITEMS_NOT_FOUND',
@@ -58,13 +59,14 @@ export default class ItemsEntriesService {
*/
public async filterInventoryEntries(
tenantId: number,
entries: IItemEntry[]
entries: IItemEntry[],
trx?: Knex.Transaction
): Promise<IItemEntry[]> {
const { Item } = this.tenancy.models(tenantId);
const entriesItemsIds = entries.map((e) => e.itemId);
// Retrieve entries inventory items.
const inventoryItems = await Item.query()
const inventoryItems = await Item.query(trx)
.whereIn('id', entriesItemsIds)
.where('type', 'inventory');