mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
fix: activate/inactivate item.
This commit is contained in:
@@ -116,6 +116,7 @@ export default class ItemsController extends BaseController {
|
|||||||
|
|
||||||
check('category_id').optional({ nullable: true }).isInt().toInt(),
|
check('category_id').optional({ nullable: true }).isInt().toInt(),
|
||||||
check('note').optional(),
|
check('note').optional(),
|
||||||
|
check('active').optional().isBoolean().toBoolean(),
|
||||||
|
|
||||||
check('media_ids').optional().isArray(),
|
check('media_ids').optional().isArray(),
|
||||||
check('media_ids.*').exists().isNumeric().toInt(),
|
check('media_ids.*').exists().isNumeric().toInt(),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ exports.up = function (knex) {
|
|||||||
table.text('purchase_description').nullable();
|
table.text('purchase_description').nullable();
|
||||||
table.integer('quantity_on_hand');
|
table.integer('quantity_on_hand');
|
||||||
table.text('note').nullable();
|
table.text('note').nullable();
|
||||||
|
table.boolean('active');
|
||||||
table.integer('category_id').unsigned().index().references('id').inTable('items_categories');
|
table.integer('category_id').unsigned().index().references('id').inTable('items_categories');
|
||||||
table.integer('user_id').unsigned().index();
|
table.integer('user_id').unsigned().index();
|
||||||
table.timestamps();
|
table.timestamps();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export interface IItem{
|
|||||||
|
|
||||||
quantityOnHand: number,
|
quantityOnHand: number,
|
||||||
note: string,
|
note: string,
|
||||||
|
active: boolean,
|
||||||
|
|
||||||
categoryId: number,
|
categoryId: number,
|
||||||
userId: number,
|
userId: number,
|
||||||
@@ -52,6 +53,7 @@ export interface IItemDTO {
|
|||||||
|
|
||||||
quantityOnHand: number,
|
quantityOnHand: number,
|
||||||
note: string,
|
note: string,
|
||||||
|
active: boolean,
|
||||||
|
|
||||||
categoryId: number,
|
categoryId: number,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { difference } from "lodash";
|
import { defaultTo, difference } from "lodash";
|
||||||
import { Service, Inject } from "typedi";
|
import { Service, Inject } from "typedi";
|
||||||
import { IItemsFilter, IItemsService, IItemDTO, IItem } from 'interfaces';
|
import { IItemsFilter, IItemsService, IItemDTO, IItem } from 'interfaces';
|
||||||
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
||||||
@@ -176,7 +176,10 @@ export default class ItemsService implements IItemsService {
|
|||||||
if (itemDTO.inventoryAccountId) {
|
if (itemDTO.inventoryAccountId) {
|
||||||
await this.validateItemInventoryAccountExistance(tenantId, itemDTO.inventoryAccountId);
|
await this.validateItemInventoryAccountExistance(tenantId, itemDTO.inventoryAccountId);
|
||||||
}
|
}
|
||||||
const storedItem = await Item.query().insertAndFetch({ ...itemDTO });
|
const storedItem = await Item.query().insertAndFetch({
|
||||||
|
...itemDTO,
|
||||||
|
active: defaultTo(itemDTO.active, 1),
|
||||||
|
});
|
||||||
this.logger.info('[items] item inserted successfully.', { tenantId, itemDTO });
|
this.logger.info('[items] item inserted successfully.', { tenantId, itemDTO });
|
||||||
|
|
||||||
return storedItem;
|
return storedItem;
|
||||||
|
|||||||
Reference in New Issue
Block a user