From 64e73813fa17145ae950adde3c08c5e5ad424c9f Mon Sep 17 00:00:00 2001 From: ilham Date: Fri, 10 Dec 2021 10:58:35 +0700 Subject: [PATCH] fix: product --- src/product/entities/product-category.entity.ts | 2 +- .../entities/product-history-price.entity.ts | 13 ++++--------- src/product/entities/product-sub-category.entity.ts | 4 ++-- src/product/entities/product.entity.ts | 2 +- src/product/product.service.ts | 8 ++++---- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/product/entities/product-category.entity.ts b/src/product/entities/product-category.entity.ts index 86da379..0964848 100644 --- a/src/product/entities/product-category.entity.ts +++ b/src/product/entities/product-category.entity.ts @@ -23,5 +23,5 @@ export class ProductCategories extends BaseModel { () => ProductSubCategories, (subCategories) => subCategories.category, ) - subCategories: ProductSubCategories; + sub_categories: ProductSubCategories; } diff --git a/src/product/entities/product-history-price.entity.ts b/src/product/entities/product-history-price.entity.ts index e7d7d16..e50d22d 100644 --- a/src/product/entities/product-history-price.entity.ts +++ b/src/product/entities/product-history-price.entity.ts @@ -1,9 +1,4 @@ -import { - Entity, - Column, - PrimaryGeneratedColumn, - ManyToOne, -} from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; import { Product } from './product.entity'; import { BaseModel } from '../../config/basemodel.entity'; import { productType } from '../../helper/enum-list'; @@ -20,14 +15,14 @@ export class ProductHistoryPrice extends BaseModel { price: number; @Column() - markUpPrice: number; + mark_up_price: number; @Column({ type: 'date' }) startDate: Date; - @Column({ + @Column({ type: 'date', - nullable:true + nullable: true, }) endDate: Date; diff --git a/src/product/entities/product-sub-category.entity.ts b/src/product/entities/product-sub-category.entity.ts index 6cfd1bd..6b129a2 100644 --- a/src/product/entities/product-sub-category.entity.ts +++ b/src/product/entities/product-sub-category.entity.ts @@ -17,9 +17,9 @@ export class ProductSubCategories extends BaseModel { @Column() name: string; - @ManyToOne(() => ProductCategories, (categories) => categories.subCategories) + @ManyToOne(() => ProductCategories, (categories) => categories.sub_categories) category: ProductCategories; - @OneToMany(() => Product, (product) => product.subCategories) + @OneToMany(() => Product, (product) => product.sub_categories) product: Product; } diff --git a/src/product/entities/product.entity.ts b/src/product/entities/product.entity.ts index f754f38..982fa3b 100644 --- a/src/product/entities/product.entity.ts +++ b/src/product/entities/product.entity.ts @@ -42,5 +42,5 @@ export class Product extends BaseModel { return subCategories.product; }, ) - subCategories: ProductSubCategories; + sub_categories: ProductSubCategories; } diff --git a/src/product/product.service.ts b/src/product/product.service.ts index ac5f9bb..dc615a2 100644 --- a/src/product/product.service.ts +++ b/src/product/product.service.ts @@ -27,7 +27,7 @@ export class ProductService { name: createProductDto.name, code: createProductDto.code, status: createProductDto.status, - subCategories: subCategories, + sub_categories: subCategories, price: createProductDto.price, }); @@ -35,7 +35,7 @@ export class ProductService { product: result.identifiers[0], type: productType.NORMAL, price: createProductDto.price, - markUpPrice: createProductDto.markUpPrice, + mark_up_price: createProductDto.markUpPrice, startDate: new Date(), endDate: null, }); @@ -111,7 +111,7 @@ export class ProductService { name: updateProductDto.name, code: updateProductDto.code, status: updateProductDto.status, - subCategories: subCategories, + sub_categories: subCategories, }); return this.productRepository.findOneOrFail(id); @@ -127,7 +127,7 @@ export class ProductService { product: product, type: updatePriceProductDto.type, price: updatePriceProductDto.price, - markUpPrice: updatePriceProductDto.markUpPrice, + mark_up_price: updatePriceProductDto.markUpPrice, startDate: updatePriceProductDto.startDate, endDate: updatePriceProductDto.endDate, });