mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: remove parent item category from item categories service.
This commit is contained in:
@@ -84,10 +84,6 @@ export default class ItemsCategoriesController extends BaseController {
|
||||
.trim()
|
||||
.escape()
|
||||
.isLength({ min: 0, max: DATATYPES_LENGTH.STRING }),
|
||||
check('parent_category_id')
|
||||
.optional({ nullable: true })
|
||||
.isInt({ min: 0, max: DATATYPES_LENGTH.INT_10 })
|
||||
.toInt(),
|
||||
check('description')
|
||||
.optional({ nullable: true })
|
||||
.isString()
|
||||
|
||||
@@ -3,7 +3,7 @@ exports.up = function (knex) {
|
||||
return knex.schema.createTable('items_categories', (table) => {
|
||||
table.increments();
|
||||
table.string('name').index();
|
||||
table.integer('parent_category_id').unsigned().references('id').inTable('items_categories');
|
||||
|
||||
table.text('description');
|
||||
table.integer('user_id').unsigned().index();
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import { ISystemUser } from "./User";
|
||||
export interface IItemCategory {
|
||||
id: number,
|
||||
name: string,
|
||||
|
||||
parentCategoryId?: number,
|
||||
description?: string,
|
||||
userId: number,
|
||||
|
||||
@@ -19,7 +17,6 @@ export interface IItemCategory {
|
||||
export interface IItemCategoryOTD {
|
||||
name: string,
|
||||
|
||||
parentCategoryId?: number,
|
||||
description?: string,
|
||||
userId: number,
|
||||
|
||||
|
||||
@@ -57,13 +57,6 @@ export default class ItemCategory extends TenantModel {
|
||||
column: 'description',
|
||||
columnType: 'string'
|
||||
},
|
||||
parent_category_id: {
|
||||
label: 'Parent category',
|
||||
column: 'parent_category_id',
|
||||
relation: 'items_categories.id',
|
||||
relationColumn: 'items_categories.id',
|
||||
optionsResource: 'item_category',
|
||||
},
|
||||
user: {
|
||||
label: 'User',
|
||||
column: 'user_id',
|
||||
|
||||
@@ -99,9 +99,6 @@ export default class ItemCategoriesService implements IItemCategoriesService {
|
||||
if (itemCategoryOTD.inventoryAccountId) {
|
||||
await this.validateInventoryAccount(tenantId, itemCategoryOTD.inventoryAccountId);
|
||||
}
|
||||
if (itemCategoryOTD.parentCategoryId) {
|
||||
await this.getItemCategoryOrThrowError(tenantId, itemCategoryOTD.parentCategoryId);
|
||||
}
|
||||
|
||||
const itemCategoryObj = this.transformOTDToObject(itemCategoryOTD, authorizedUser);
|
||||
const itemCategory = await ItemCategory.query().insert({ ...itemCategoryObj });
|
||||
@@ -203,10 +200,6 @@ export default class ItemCategoriesService implements IItemCategoriesService {
|
||||
if (itemCategoryOTD.inventoryAccountId) {
|
||||
await this.validateInventoryAccount(tenantId, itemCategoryOTD.inventoryAccountId);
|
||||
}
|
||||
if (itemCategoryOTD.parentCategoryId) {
|
||||
await this.getItemCategoryOrThrowError(tenantId, itemCategoryOTD.parentCategoryId);
|
||||
}
|
||||
|
||||
const itemCategoryObj = this.transformOTDToObject(itemCategoryOTD, authorizedUser);
|
||||
const itemCategory = await ItemCategory.query().patchAndFetchById(itemCategoryId, { ...itemCategoryObj });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user