mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: Re-compute the given items cost job.
feat: Optimize the architecture.
This commit is contained in:
@@ -3,6 +3,44 @@ import { Item } from '@/models';
|
||||
|
||||
export default class ItemsService {
|
||||
|
||||
static async newItem(item) {
|
||||
const storedItem = await Item.tenant()
|
||||
.query()
|
||||
.insertAndFetch({
|
||||
...item,
|
||||
});
|
||||
return storedItem;
|
||||
}
|
||||
|
||||
static async editItem(item, itemId) {
|
||||
const updateItem = await Item.tenant()
|
||||
.query()
|
||||
.findById(itemId)
|
||||
.patch({
|
||||
...item,
|
||||
});
|
||||
return updateItem;
|
||||
}
|
||||
|
||||
static async deleteItem(itemId) {
|
||||
return Item.tenant()
|
||||
.query()
|
||||
.findById(itemId)
|
||||
.delete();
|
||||
}
|
||||
|
||||
static async getItemWithMetadata(itemId) {
|
||||
return Item.tenant()
|
||||
.query()
|
||||
.findById(itemId)
|
||||
.withGraphFetched(
|
||||
'costAccount',
|
||||
'sellAccount',
|
||||
'inventoryAccount',
|
||||
'category'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the given items IDs exists or not returns the not found ones.
|
||||
* @param {Array} itemsIDs
|
||||
|
||||
Reference in New Issue
Block a user