fix(Journals): sync posting datetime with jorunal entries.

This commit is contained in:
a.bouhuolia
2021-03-29 10:50:44 +02:00
parent 40b2ba099e
commit 9a204282a2
38 changed files with 477 additions and 302 deletions

View File

@@ -50,6 +50,29 @@ export default class ItemsEntriesService {
return inventoryItemsEntries;
}
/**
* Filter the given entries to inventory entries.
* @param {IItemEntry[]} entries -
* @returns {IItemEntry[]}
*/
public async filterInventoryEntries(
tenantId: number,
entries: IItemEntry[]
): Promise<IItemEntry[]> {
const { Item } = this.tenancy.models(tenantId);
const entriesItemsIds = entries.map((e) => e.itemId);
// Retrieve entries inventory items.
const inventoryItems = await Item.query()
.whereIn('id', entriesItemsIds)
.where('type', 'inventory');
const inventoryEntries = entries.filter((entry) =>
inventoryItems.some((item) => item.id === entry.itemId)
);
return inventoryEntries;
}
/**
* Validates the entries items ids.
* @async

View File

@@ -22,7 +22,6 @@ import {
ACCOUNT_TYPE,
} from 'data/AccountTypes';
import { ERRORS } from './constants';
import { AccountTransaction } from 'models';
@Service()
export default class ItemsService implements IItemsService {