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