mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix(Journals): sync posting datetime with jorunal entries.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user