add all request for si hemat :
- Login - Request Transaction PrePaid - Request Inquiry / Check Bill PostPaid - Request Payment PostPaid
This commit is contained in:
parent
a5683666aa
commit
9b14685a92
|
@ -7,28 +7,46 @@ const irs_user = 'D10BD0';
|
|||
const irs_pass = '6251F3';
|
||||
|
||||
export const doTransaction = async (
|
||||
productCode,
|
||||
destination,
|
||||
idtrx,
|
||||
supplier,
|
||||
productCode,
|
||||
destination,
|
||||
idtrx,
|
||||
supplier,
|
||||
authorization,
|
||||
typePaid,
|
||||
) => {
|
||||
try {
|
||||
if(supplier.code == 'IRS'){
|
||||
if (supplier.code == 'IRS') {
|
||||
const res = await axios.get(
|
||||
`${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
||||
`${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else if (supplier.code == 'NIRS') {
|
||||
const res = await axios.get(
|
||||
`${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else {
|
||||
const res = await axios.get(
|
||||
`${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`,
|
||||
);
|
||||
} else if (supplier.code == 'Hemat') {
|
||||
const options = {
|
||||
headers: { Authorization: `${authorization}` },
|
||||
};
|
||||
const data = {
|
||||
idtransaction: idtrx,
|
||||
destination: `${destination}`,
|
||||
code: `${productCode}`,
|
||||
type: `${typePaid}`,
|
||||
};
|
||||
const res = await axios.post(`${supplier.url}`, data, options);
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
const res = await axios.get(
|
||||
`${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
|
|
15
src/helper/sihemat-authorization.ts
Normal file
15
src/helper/sihemat-authorization.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export const doAuthorizeHemat = async (user, pass, supplier) => {
|
||||
try {
|
||||
const data = {
|
||||
username: `${user}`,
|
||||
password: `${pass}`,
|
||||
};
|
||||
const res = await axios.post(`${supplier.url}`, data);
|
||||
|
||||
return res.data;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
};
|
|
@ -17,21 +17,21 @@ import { ProductHistoryStatus } from './entities/product-history-status.entity';
|
|||
|
||||
export class ProductService {
|
||||
constructor(
|
||||
@InjectRepository(Product)
|
||||
private productRepository: Repository<Product>,
|
||||
@InjectRepository(ProductHistoryPrice)
|
||||
private productHistoryPrice: Repository<ProductHistoryPrice>,
|
||||
@InjectRepository(ProductHistoryStatus)
|
||||
private productHistoryStatus: Repository<ProductHistoryStatus>,
|
||||
private productSubCategoriesService: ProductSubCategoriesService,
|
||||
private usersService: UsersService,
|
||||
private supplierService: SupplierService,
|
||||
private partnerService: PartnerService,
|
||||
@InjectRepository(Product)
|
||||
private productRepository: Repository<Product>,
|
||||
@InjectRepository(ProductHistoryPrice)
|
||||
private productHistoryPrice: Repository<ProductHistoryPrice>,
|
||||
@InjectRepository(ProductHistoryStatus)
|
||||
private productHistoryStatus: Repository<ProductHistoryStatus>,
|
||||
private productSubCategoriesService: ProductSubCategoriesService,
|
||||
private usersService: UsersService,
|
||||
private supplierService: SupplierService,
|
||||
private partnerService: PartnerService,
|
||||
) {}
|
||||
|
||||
async create(createProductDto: CreateProductDto) {
|
||||
const subCategories = await this.productSubCategoriesService.findOne(
|
||||
createProductDto.subCategoriesId,
|
||||
createProductDto.subCategoriesId,
|
||||
);
|
||||
|
||||
const result = await this.productRepository.insert({
|
||||
|
@ -66,7 +66,7 @@ export class ProductService {
|
|||
let productStatusPartner;
|
||||
|
||||
const subCategories =
|
||||
await this.productSubCategoriesService.findOneForCSVParser(it[2]);
|
||||
await this.productSubCategoriesService.findOneForCSVParser(it[2]);
|
||||
|
||||
if (!subCategories) {
|
||||
return;
|
||||
|
@ -193,10 +193,10 @@ export class ProductService {
|
|||
}
|
||||
|
||||
async findAll(
|
||||
page: number,
|
||||
supplier: string,
|
||||
subCategories: string,
|
||||
pageSize?: number,
|
||||
page: number,
|
||||
supplier: string,
|
||||
subCategories: string,
|
||||
pageSize?: number,
|
||||
) {
|
||||
let filterSupplier, filterSubCategories;
|
||||
|
||||
|
@ -213,40 +213,40 @@ export class ProductService {
|
|||
}
|
||||
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.leftJoin('sub_categories.category', 'category')
|
||||
.leftJoin('product.supplier', 'supplier')
|
||||
.where('supplier.status = :status', { status: true })
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.end_date is NULL',
|
||||
)
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentStatus',
|
||||
'product.statusHistory',
|
||||
'history_status',
|
||||
'history_status.deleted_at is NULL',
|
||||
)
|
||||
.select(['product.id'])
|
||||
.addSelect([
|
||||
'product.name',
|
||||
'product.code',
|
||||
'sub_categories.name',
|
||||
'supplier.name',
|
||||
'category.name',
|
||||
])
|
||||
.addSelect('history_status.status', 'status')
|
||||
.addSelect('current_price.price', 'price')
|
||||
.addSelect('current_price.partner_fee', 'partner_fee')
|
||||
.addSelect('current_price.admin_price', 'admin_price')
|
||||
.addSelect(
|
||||
'(current_price.price + current_price.mark_up_price) as mark_up_price',
|
||||
)
|
||||
.orderBy('product.code')
|
||||
.distinct();
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.leftJoin('sub_categories.category', 'category')
|
||||
.leftJoin('product.supplier', 'supplier')
|
||||
.where('supplier.status = :status', { status: true })
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.end_date is NULL',
|
||||
)
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentStatus',
|
||||
'product.statusHistory',
|
||||
'history_status',
|
||||
'history_status.deleted_at is NULL',
|
||||
)
|
||||
.select(['product.id'])
|
||||
.addSelect([
|
||||
'product.name',
|
||||
'product.code',
|
||||
'sub_categories.name',
|
||||
'supplier.name',
|
||||
'category.name',
|
||||
])
|
||||
.addSelect('history_status.status', 'status')
|
||||
.addSelect('current_price.price', 'price')
|
||||
.addSelect('current_price.partner_fee', 'partner_fee')
|
||||
.addSelect('current_price.admin_price', 'admin_price')
|
||||
.addSelect(
|
||||
'(current_price.price + current_price.mark_up_price) as mark_up_price',
|
||||
)
|
||||
.orderBy('product.code')
|
||||
.distinct();
|
||||
|
||||
if (subCategories && filterSubCategories.length > 0) {
|
||||
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||
|
@ -261,9 +261,9 @@ export class ProductService {
|
|||
}
|
||||
|
||||
const data = await baseQuery
|
||||
.offset(page * (pageSize || 10))
|
||||
.limit(pageSize || 10)
|
||||
.getRawMany();
|
||||
.offset(page * (pageSize || 10))
|
||||
.limit(pageSize || 10)
|
||||
.getRawMany();
|
||||
|
||||
const totalData = await baseQuery.getCount();
|
||||
|
||||
|
@ -275,26 +275,26 @@ export class ProductService {
|
|||
|
||||
async findAllByCategories(page, subCategories, supplier) {
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.where(
|
||||
'sub_categories.category_id = :id and product.supplier_id = :supplier_id',
|
||||
{
|
||||
id: subCategories,
|
||||
supplier_id: supplier,
|
||||
},
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id is null',
|
||||
);
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.where(
|
||||
'sub_categories.category_id = :id and product.supplier_id = :supplier_id',
|
||||
{
|
||||
id: subCategories,
|
||||
supplier_id: supplier,
|
||||
},
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id is null',
|
||||
);
|
||||
|
||||
const data = await baseQuery
|
||||
.skip(page * 10)
|
||||
.take(10)
|
||||
.getMany();
|
||||
.skip(page * 10)
|
||||
.take(10)
|
||||
.getMany();
|
||||
|
||||
const totalData = await baseQuery.getCount();
|
||||
|
||||
|
@ -312,18 +312,18 @@ export class ProductService {
|
|||
console.log(supplier, 'asldklaksd')
|
||||
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.leftJoin('product.supplier', 'supplier')
|
||||
|
||||
// .leftJoin('product.statusHistory', 'status_history')
|
||||
|
||||
.leftJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id is NULL and current_price.end_date is NULL',
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id is NULL and current_price.end_date is NULL',
|
||||
)
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentStatus',
|
||||
'product.statusHistory',
|
||||
|
@ -333,12 +333,12 @@ export class ProductService {
|
|||
status: 'ACTIVE',
|
||||
},
|
||||
)
|
||||
// .where(
|
||||
// `product.supplier_id = :supplier_id`,
|
||||
// {
|
||||
// supplier_id: supplier,
|
||||
// },
|
||||
// )
|
||||
// .where(
|
||||
// `product.supplier_id = :supplier_id`,
|
||||
// {
|
||||
// supplier_id: supplier,
|
||||
// },
|
||||
// )
|
||||
.where(
|
||||
`history_status.partner_id is NULL`,
|
||||
{
|
||||
|
@ -351,14 +351,14 @@ export class ProductService {
|
|||
status: true,
|
||||
},
|
||||
)
|
||||
.select(['product.id'])
|
||||
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
|
||||
.addSelect('(current_price.price + current_price.mark_up_price) as price')
|
||||
.select(['product.id'])
|
||||
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
|
||||
.addSelect('(current_price.price + current_price.mark_up_price) as price')
|
||||
.addSelect('product.supplier_id', 'supplier')
|
||||
.addSelect('supplier.status', 'status')
|
||||
.addSelect('history_status.partner_id', 'partner')
|
||||
.orderBy('price', 'ASC')
|
||||
.distinct();
|
||||
.distinct();
|
||||
|
||||
if (subCategories != 'null' && subCategories) {
|
||||
baseQuery.andWhere('product.sub_categories_id = :id', {
|
||||
|
@ -367,9 +367,9 @@ export class ProductService {
|
|||
}
|
||||
|
||||
const data = await baseQuery
|
||||
.offset(page * 1000)
|
||||
.limit(1000)
|
||||
.getRawMany();
|
||||
.offset(page * 1000)
|
||||
.limit(1000)
|
||||
.getRawMany();
|
||||
|
||||
const totalData = await baseQuery.getCount();
|
||||
|
||||
|
@ -380,10 +380,10 @@ export class ProductService {
|
|||
}
|
||||
|
||||
async findAllForPartner(
|
||||
page: number,
|
||||
pageSize: number,
|
||||
subCategories: string,
|
||||
username: string,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
subCategories: string,
|
||||
username: string,
|
||||
) {
|
||||
let filterSubCategories;
|
||||
const user = await this.usersService.findOneByUsername(username);
|
||||
|
@ -396,68 +396,68 @@ export class ProductService {
|
|||
|
||||
if (user.partner === null) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Partner id not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Partner id not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
const baseQuery = await this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.leftJoin('product.supplier', 'supplier')
|
||||
// .leftJoinAndSelect(
|
||||
// 'product.supplier',
|
||||
// 'supplier',
|
||||
// 'supplier.status = true',
|
||||
// {
|
||||
// status: true
|
||||
// }
|
||||
//
|
||||
// )
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id = :id_partner and current_price.end_date is NULL',
|
||||
{
|
||||
id_partner: user.partner.id,
|
||||
},
|
||||
)
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentStatus',
|
||||
'product.statusHistory',
|
||||
'history_status',
|
||||
'history_status.partner_id = :id_partner and history_status.deleted_at is NULL',
|
||||
{
|
||||
id_partner: user.partner.id,
|
||||
},
|
||||
)
|
||||
// .where(`history_status.partner_id = :id_partner`, {
|
||||
// partner: user.partner.id,
|
||||
// })
|
||||
.where(`history_status.status = 'ACTIVE'`, {
|
||||
status: 'ACTIVE',
|
||||
})
|
||||
// 'product.supplier',
|
||||
// 'supplier',
|
||||
// 'supplier.status = true',
|
||||
// {
|
||||
// status: true
|
||||
// }
|
||||
//
|
||||
// )
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id = :id_partner and current_price.end_date is NULL',
|
||||
{
|
||||
id_partner: user.partner.id,
|
||||
},
|
||||
)
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentStatus',
|
||||
'product.statusHistory',
|
||||
'history_status',
|
||||
'history_status.partner_id = :id_partner and history_status.deleted_at is NULL',
|
||||
{
|
||||
id_partner: user.partner.id,
|
||||
},
|
||||
)
|
||||
// .where(`history_status.partner_id = :id_partner`, {
|
||||
// partner: user.partner.id,
|
||||
// })
|
||||
.where(`history_status.status = 'ACTIVE'`, {
|
||||
status: 'ACTIVE',
|
||||
})
|
||||
.andWhere('supplier.status = TRUE', {
|
||||
status: true
|
||||
})
|
||||
.select(['product.id'])
|
||||
.addSelect([
|
||||
'product.name',
|
||||
'product.code',
|
||||
'product.type',
|
||||
'product.supplier_id',
|
||||
'sub_categories.name',
|
||||
'current_price.admin_price as admin_price',
|
||||
'current_price.mark_up_price as markup_price',
|
||||
'current_price.partner_fee as partner_fee',
|
||||
'current_price.price as price',
|
||||
])
|
||||
.addSelect('history_status.status', 'status')
|
||||
.distinct();
|
||||
.select(['product.id'])
|
||||
.addSelect([
|
||||
'product.name',
|
||||
'product.code',
|
||||
'product.type',
|
||||
'product.supplier_id',
|
||||
'sub_categories.name',
|
||||
'current_price.admin_price as admin_price',
|
||||
'current_price.mark_up_price as markup_price',
|
||||
'current_price.partner_fee as partner_fee',
|
||||
'current_price.price as price',
|
||||
])
|
||||
.addSelect('history_status.status', 'status')
|
||||
.distinct();
|
||||
// .addSelect(
|
||||
// '(current_price.price + current_price.mark_up_price) as price',
|
||||
// );
|
||||
|
@ -474,18 +474,18 @@ export class ProductService {
|
|||
|
||||
if (subCategories && filterSubCategories.length > 0) {
|
||||
baseQuery
|
||||
.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||
subCategoryId: filterSubCategories,
|
||||
})
|
||||
.andWhere(`history_status.status = 'ACTIVE'`);
|
||||
.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||
subCategoryId: filterSubCategories,
|
||||
})
|
||||
.andWhere(`history_status.status = 'ACTIVE'`);
|
||||
}
|
||||
|
||||
const newData = [];
|
||||
|
||||
const data = await baseQuery
|
||||
.offset(page * pageSize)
|
||||
.limit(pageSize)
|
||||
.getRawMany();
|
||||
.offset(page * pageSize)
|
||||
.limit(pageSize)
|
||||
.getRawMany();
|
||||
|
||||
data.map((dataa) => {
|
||||
let actualPrice = 0;
|
||||
|
@ -496,8 +496,8 @@ export class ProductService {
|
|||
|
||||
if (dataa.product_type === 'postpaid') {
|
||||
actualPrice =
|
||||
Number(dataa['admin_price']) -
|
||||
(Number(dataa['partner_fee']) + Number(dataa['markup_price']));
|
||||
Number(dataa['admin_price']) -
|
||||
(Number(dataa['partner_fee']) + Number(dataa['markup_price']));
|
||||
}
|
||||
|
||||
dataa.price = actualPrice;
|
||||
|
@ -515,22 +515,23 @@ export class ProductService {
|
|||
};
|
||||
}
|
||||
|
||||
async findOne(code: string, type: string) {
|
||||
async findOne(code: string, type: string, productId: string) {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
id: productId
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
|
@ -539,31 +540,31 @@ export class ProductService {
|
|||
}
|
||||
|
||||
async findOneActive(
|
||||
code: string,
|
||||
type: string,
|
||||
productId: string
|
||||
code: string,
|
||||
type: string,
|
||||
productId: string
|
||||
) {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
id: productId
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
id: productId
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -578,11 +579,11 @@ export class ProductService {
|
|||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
|
@ -596,11 +597,11 @@ export class ProductService {
|
|||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
|
@ -608,7 +609,7 @@ export class ProductService {
|
|||
}
|
||||
|
||||
const subCategories = await this.productSubCategoriesService.findOne(
|
||||
updateProductDto.subCategoriesId,
|
||||
updateProductDto.subCategoriesId,
|
||||
);
|
||||
|
||||
const dataStatus = await this.productHistoryStatus.findOne({
|
||||
|
@ -632,19 +633,19 @@ export class ProductService {
|
|||
}
|
||||
|
||||
async updatePrice(
|
||||
code: string,
|
||||
updatePriceProductDto: UpdatePriceProductDto,
|
||||
code: string,
|
||||
updatePriceProductDto: UpdatePriceProductDto,
|
||||
) {
|
||||
const product = await this.findOne(code, updatePriceProductDto.productType);
|
||||
// const product = await this.findOne(code, updatePriceProductDto.productType);
|
||||
|
||||
await this.productHistoryPrice.insert({
|
||||
product: product,
|
||||
type: updatePriceProductDto.type,
|
||||
price: updatePriceProductDto.price,
|
||||
mark_up_price: updatePriceProductDto.markUpPrice,
|
||||
startDate: updatePriceProductDto.startDate,
|
||||
endDate: updatePriceProductDto.endDate,
|
||||
});
|
||||
// await this.productHistoryPrice.insert({
|
||||
// product: product,
|
||||
// type: updatePriceProductDto.type,
|
||||
// price: updatePriceProductDto.price,
|
||||
// mark_up_price: updatePriceProductDto.markUpPrice,
|
||||
// startDate: updatePriceProductDto.startDate,
|
||||
// endDate: updatePriceProductDto.endDate,
|
||||
// });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -655,11 +656,11 @@ export class ProductService {
|
|||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Product not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user