-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1013 from ever-co/feat#841/inventory
Feat#841/inventory
- Loading branch information
Showing
47 changed files
with
1,482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
apps/api/src/app/product-category/product-category-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { ProductCategory } from './product-category.entity'; | ||
import { ProductCategoryService } from './product-category.service'; | ||
import { ProductCategoryController } from './product-category.controller'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([ProductCategory])], | ||
controllers: [ProductCategoryController], | ||
providers: [ProductCategoryService] | ||
}) | ||
export class ProductCategoriesModule {} |
37 changes: 37 additions & 0 deletions
37
apps/api/src/app/product-category/product-category.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; | ||
import { Controller, Get, HttpStatus, Query } from '@nestjs/common'; | ||
import { CrudController, IPagination } from '../core'; | ||
import { ProductCategory } from './product-category.entity'; | ||
import { ProductCategoryService } from './product-category.service'; | ||
|
||
@ApiTags('Product-Categories') | ||
// @UseGuards(AuthGuard('jwt')) | ||
@Controller() | ||
export class ProductCategoryController extends CrudController<ProductCategory> { | ||
constructor( | ||
private readonly productCategoriesService: ProductCategoryService | ||
) { | ||
super(productCategoriesService); | ||
} | ||
|
||
@ApiOperation({ | ||
summary: 'Find all product categories.' | ||
}) | ||
@ApiResponse({ | ||
status: HttpStatus.OK, | ||
description: 'Found product categories.', | ||
type: ProductCategory | ||
}) | ||
@ApiResponse({ | ||
status: HttpStatus.NOT_FOUND, | ||
description: 'Record not found' | ||
}) | ||
@Get() | ||
async findAllProductCategories( | ||
@Query('findInput') findInput: string | ||
): Promise<IPagination<ProductCategory>> { | ||
return this.productCategoriesService.findAll({ | ||
where: findInput | ||
}); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
apps/api/src/app/product-category/product-category.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Entity, Column, OneToMany } from 'typeorm'; | ||
import { Base } from '../core/entities/base'; | ||
import { ProductCategory as IProductCategory } from '@gauzy/models'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString, IsNotEmpty } from 'class-validator'; | ||
import { Product } from '../product/product.entity'; | ||
|
||
@Entity('product_category') | ||
export class ProductCategory extends Base implements IProductCategory { | ||
@ApiProperty({ type: String }) | ||
@IsString() | ||
@Column() | ||
name: string; | ||
|
||
@ApiProperty({ type: String }) | ||
@IsString() | ||
@IsNotEmpty() | ||
@Column() | ||
organizationId: string; | ||
|
||
@OneToMany( | ||
(type) => Product, | ||
(product) => product.category | ||
) | ||
products: Product[]; | ||
} |
38 changes: 38 additions & 0 deletions
38
apps/api/src/app/product-category/product-category.seed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Connection } from 'typeorm'; | ||
import { Organization } from '@gauzy/models'; | ||
import { ProductCategory } from './product-category.entity'; | ||
|
||
export const createProductCategories = async ( | ||
connection: Connection, | ||
organization: Organization | ||
): Promise<ProductCategory[]> => { | ||
const productCategories = []; | ||
|
||
const productCategory1 = new ProductCategory(); | ||
productCategory1.name = 'product category 1'; | ||
productCategory1.organizationId = organization.id; | ||
productCategories.push(productCategory1); | ||
|
||
const productCategory2 = new ProductCategory(); | ||
productCategory2.name = 'product category 2'; | ||
productCategory2.organizationId = organization.id; | ||
productCategories.push(productCategory2); | ||
|
||
const productCategory3 = new ProductCategory(); | ||
productCategory3.name = 'product category 3'; | ||
productCategory3.organizationId = organization.id; | ||
productCategories.push(productCategory3); | ||
|
||
insertProductCategory(connection, productCategory1); | ||
insertProductCategory(connection, productCategory2); | ||
insertProductCategory(connection, productCategory3); | ||
|
||
return productCategories; | ||
}; | ||
|
||
const insertProductCategory = async ( | ||
connection: Connection, | ||
category: ProductCategory | ||
): Promise<void> => { | ||
await connection.manager.save(category); | ||
}; |
15 changes: 15 additions & 0 deletions
15
apps/api/src/app/product-category/product-category.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { CrudService } from '../core'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { ProductCategory } from './product-category.entity'; | ||
import { Repository } from 'typeorm'; | ||
|
||
@Injectable() | ||
export class ProductCategoryService extends CrudService<ProductCategory> { | ||
constructor( | ||
@InjectRepository(ProductCategory) | ||
private readonly productCategoryRepository: Repository<ProductCategory> | ||
) { | ||
super(productCategoryRepository); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Entity, Column } from 'typeorm'; | ||
import { Base } from '../core/entities/base'; | ||
import { ProductOption as IProductOption } from '@gauzy/models'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString } from 'class-validator'; | ||
import { Product } from '../product/product.entity'; | ||
|
||
@Entity('product_option') | ||
export class ProductOption extends Base implements IProductOption { | ||
@ApiProperty({ type: String }) | ||
@IsString() | ||
@Column() | ||
name: string; | ||
|
||
@ApiProperty({ type: String }) | ||
@IsString() | ||
@Column() | ||
code: string; | ||
|
||
// @ManyToOne(()=> Product, product => product.options) | ||
product: Product; | ||
} |
40 changes: 40 additions & 0 deletions
40
apps/api/src/app/product-settings/product-settings.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Entity, Column } from 'typeorm'; | ||
import { Base } from '../core/entities/base'; | ||
import { ProductVariantSettings as IProductVariantSettings } from '@gauzy/models'; | ||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
|
||
@Entity('product_variant_settings') | ||
export class ProductVariantSettings extends Base | ||
implements IProductVariantSettings { | ||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: false }) | ||
isSubscription: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: false }) | ||
isPurchaseAutomatically: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: true }) | ||
canBeSold: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: true }) | ||
canBePurchased: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: false }) | ||
canBeCharged: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: false }) | ||
canBeRented: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: false }) | ||
isEquipment: boolean; | ||
|
||
@ApiPropertyOptional({ type: Boolean }) | ||
@Column({ default: false }) | ||
trackInventory: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { ProductType } from './product-type.entity'; | ||
import { Module } from '@nestjs/common'; | ||
import { ProductTypeController } from './product-type.controller'; | ||
import { ProductTypeService } from './product-type.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([ProductType])], | ||
controllers: [ProductTypeController], | ||
providers: [ProductTypeService] | ||
}) | ||
export class ProductTypesModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger'; | ||
import { CrudController, IPagination } from '../core'; | ||
import { ProductType } from './product-type.entity'; | ||
import { Controller, HttpStatus, Get, Query } from '@nestjs/common'; | ||
import { ProductTypeService } from './product-type.service'; | ||
|
||
@ApiTags('Product-Types') | ||
// @UseGuards(AuthGuard('jwt')) | ||
@Controller() | ||
export class ProductTypeController extends CrudController<ProductType> { | ||
constructor(private readonly productTypesService: ProductTypeService) { | ||
super(productTypesService); | ||
} | ||
|
||
@ApiOperation({ | ||
summary: 'Find all product types.' | ||
}) | ||
@ApiResponse({ | ||
status: HttpStatus.OK, | ||
description: 'Found product types.', | ||
type: ProductType | ||
}) | ||
@ApiResponse({ | ||
status: HttpStatus.NOT_FOUND, | ||
description: 'Record not found' | ||
}) | ||
@Get() | ||
async findAllProductTypes( | ||
@Query('findInput') findInput: string | ||
): Promise<IPagination<ProductType>> { | ||
return this.productTypesService.findAll({ | ||
where: findInput | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Entity, Column, OneToMany } from 'typeorm'; | ||
import { Base } from '../core/entities/base'; | ||
import { ProductType as IProductType } from '@gauzy/models'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString, IsNotEmpty } from 'class-validator'; | ||
import { Product } from '../product/product.entity'; | ||
|
||
@Entity('product_type') | ||
export class ProductType extends Base implements IProductType { | ||
@ApiProperty({ type: String }) | ||
@IsString() | ||
@Column() | ||
name: string; | ||
|
||
@ApiProperty({ type: String }) | ||
@IsString() | ||
@IsNotEmpty() | ||
@Column() | ||
organizationId: string; | ||
|
||
@OneToMany( | ||
(type) => Product, | ||
(product) => product.type | ||
) | ||
products: Product[]; | ||
} |
Oops, something went wrong.