mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +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('note').optional(),
|
||||
check('active').optional().isBoolean().toBoolean(),
|
||||
|
||||
check('media_ids').optional().isArray(),
|
||||
check('media_ids.*').exists().isNumeric().toInt(),
|
||||
|
||||
@@ -18,6 +18,7 @@ exports.up = function (knex) {
|
||||
table.text('purchase_description').nullable();
|
||||
table.integer('quantity_on_hand');
|
||||
table.text('note').nullable();
|
||||
table.boolean('active');
|
||||
table.integer('category_id').unsigned().index().references('id').inTable('items_categories');
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.timestamps();
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface IItem{
|
||||
|
||||
quantityOnHand: number,
|
||||
note: string,
|
||||
active: boolean,
|
||||
|
||||
categoryId: number,
|
||||
userId: number,
|
||||
@@ -52,6 +53,7 @@ export interface IItemDTO {
|
||||
|
||||
quantityOnHand: number,
|
||||
note: string,
|
||||
active: boolean,
|
||||
|
||||
categoryId: number,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { difference } from "lodash";
|
||||
import { defaultTo, difference } from "lodash";
|
||||
import { Service, Inject } from "typedi";
|
||||
import { IItemsFilter, IItemsService, IItemDTO, IItem } from 'interfaces';
|
||||
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
||||
@@ -176,7 +176,10 @@ export default class ItemsService implements IItemsService {
|
||||
if (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 });
|
||||
|
||||
return storedItem;
|
||||
|
||||
Reference in New Issue
Block a user