- change status to product history status

This commit is contained in:
Fadli 2022-08-29 12:11:49 +07:00
parent b13a38590c
commit 25a48ff39f
2 changed files with 14 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import { ProductSubCategories } from './product-sub-category.entity';
import { BaseModel } from '../../config/basemodel.entity'; import { BaseModel } from '../../config/basemodel.entity';
import { Supplier } from '../../users/entities/supplier.entity'; import { Supplier } from '../../users/entities/supplier.entity';
import { ProductHistoryPrice } from './product-history-price.entity'; import { ProductHistoryPrice } from './product-history-price.entity';
import {ProductHistoryStatus} from "./product-history-status.entity";
@Entity() @Entity()
export class Product extends BaseModel { export class Product extends BaseModel {
@ -53,6 +54,17 @@ export class Product extends BaseModel {
) )
supplier: Supplier; supplier: Supplier;
@OneToMany(
() => {
return ProductHistoryStatus;
},
(php) => {
return php.product;
},
)
statusHistory: ProductHistoryStatus;
@OneToMany( @OneToMany(
() => { () => {
return ProductHistoryPrice; return ProductHistoryPrice;

View File

@ -310,7 +310,7 @@ export class TransactionService {
'prepaid', 'prepaid',
); );
if (!productData.status.includes('ACTIVE')) { if (!productData.statusHistory.status.includes('ACTIVE')) {
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR, statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
@ -467,7 +467,7 @@ export class TransactionService {
'prepaid', 'prepaid',
); );
if (!productData.status.includes('ACTIVE')) { if (!productData.statusHistory.status.includes('ACTIVE')) {
throw new HttpException( throw new HttpException(
{ {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR, statusCode: HttpStatus.INTERNAL_SERVER_ERROR,