Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!218
This commit is contained in:
commit
b454652177
|
@ -309,11 +309,13 @@ export class ProductService {
|
|||
supplier = (await this.supplierService.findByActive()).id;
|
||||
}
|
||||
|
||||
console.log(supplier, 'asldklaksd')
|
||||
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
|
||||
.leftJoin('product.statusHistory', 'status_history')
|
||||
// .leftJoin('product.statusHistory', 'status_history')
|
||||
|
||||
.leftJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
|
@ -321,12 +323,27 @@ export class ProductService {
|
|||
'current_price',
|
||||
'current_price.partner_id is NULL and current_price.end_date is NULL',
|
||||
)
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentStatus',
|
||||
'product.statusHistory',
|
||||
'history_status',
|
||||
`history_status.status = 'ACTIVE' and history_status.deleted_at is NULL`,
|
||||
{
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
)
|
||||
.where(
|
||||
`product.supplier_id = :supplier_id and status_history.status = 'ACTIVE' and status_history.partner_id is NULL`,
|
||||
`product.supplier_id = :supplier_id`,
|
||||
{
|
||||
supplier_id: supplier,
|
||||
},
|
||||
)
|
||||
.where(
|
||||
`history_status.partner_id is NULL`,
|
||||
{
|
||||
partner_id: null,
|
||||
},
|
||||
)
|
||||
.select(['product.id'])
|
||||
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
|
||||
.addSelect('(current_price.price + current_price.mark_up_price) as price')
|
||||
|
@ -505,16 +522,14 @@ export class ProductService {
|
|||
async findOneActive(
|
||||
code: string,
|
||||
type: string,
|
||||
roles: string,
|
||||
supplierId: string,
|
||||
productId: string
|
||||
) {
|
||||
if (roles == 'Retail') {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
supplier: supplierId,
|
||||
id: productId
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
|
@ -530,28 +545,7 @@ export class ProductService {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOneById(id: string) {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { IsNotEmpty, IsOptional } from 'class-validator';
|
||||
|
||||
export class OrderTransactionDto {
|
||||
|
||||
@IsNotEmpty()
|
||||
productId: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
productCode: string;
|
||||
|
||||
|
|
|
@ -335,14 +335,13 @@ export class TransactionService {
|
|||
currentUser.username,
|
||||
);
|
||||
|
||||
const supplierData = await this.supplierService.findByCode('IRS');
|
||||
// const supplierData = await this.supplierService.findByCode('IRS');
|
||||
|
||||
//GET PRODUCT
|
||||
const product = await this.productService.findOneActive(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
userData.roles.name,
|
||||
supplierData.id
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
const product_price = await this.productHistoryPriceService.findOne(
|
||||
|
@ -491,16 +490,13 @@ export class TransactionService {
|
|||
currentUser.username,
|
||||
);
|
||||
|
||||
const supplierData = await this.supplierService.findByCode('IRS');
|
||||
|
||||
|
||||
// const supplierData = await this.supplierService.findByCode('IRS');
|
||||
|
||||
//GET PRODUCT AND PRICE
|
||||
const product = await this.productService.findOneActive(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
userData.roles.name,
|
||||
supplierData.id
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
|
|
Loading…
Reference in New Issue
Block a user