- fix when product not active can't order
This commit is contained in:
@@ -12,7 +12,8 @@ import { UsersModule } from 'src/users/users.module';
|
||||
import { ConfigurableModule } from '../configurable/configurable.module';
|
||||
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
||||
import { CallbackPartner } from './entities/callback-partner.entity';
|
||||
import {ProductHistoryPrice} from "../product/entities/product-history-price.entity";
|
||||
import { ProductHistoryPrice } from '../product/entities/product-history-price.entity';
|
||||
import { ProductHistoryStatus } from '../product/entities/product-history-status.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -23,6 +24,7 @@ import {ProductHistoryPrice} from "../product/entities/product-history-price.ent
|
||||
CheckBillHistory,
|
||||
CallbackPartner,
|
||||
ProductHistoryPrice,
|
||||
ProductHistoryStatus,
|
||||
]),
|
||||
ProductModule,
|
||||
ConfigurableModule,
|
||||
|
||||
@@ -37,6 +37,7 @@ import axios from 'axios';
|
||||
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
||||
import { CallbackPartner } from './entities/callback-partner.entity';
|
||||
import { doAuthorizeHemat } from '../helper/sihemat-authorization';
|
||||
import { ProductHistoryStatusService } from '../product/history-status/history-status.service';
|
||||
|
||||
@Injectable()
|
||||
export class TransactionService {
|
||||
@@ -58,6 +59,7 @@ export class TransactionService {
|
||||
private coaService: CoaService,
|
||||
private productService: ProductService,
|
||||
private productHistoryPriceService: ProductHistoryPriceService,
|
||||
private productHistoryStatusService: ProductHistoryStatusService,
|
||||
private userService: UsersService,
|
||||
private commissionService: CommissionService,
|
||||
private supplierService: SupplierService,
|
||||
@@ -520,6 +522,20 @@ export class TransactionService {
|
||||
product.supplier.code,
|
||||
);
|
||||
|
||||
const statusProduct = await this.productHistoryStatusService.findOneActive(
|
||||
product.id,
|
||||
userData.partner.id ? userData.partner.id : null,
|
||||
);
|
||||
|
||||
if (statusProduct.status == 'NOT ACTIVE') {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
error: `Transaction Failed because product is not active`,
|
||||
},
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
} else {
|
||||
console.log('userdatapartnerid', userData.partner?.id);
|
||||
|
||||
let product_price = await this.productHistoryPriceService.findOne(
|
||||
@@ -618,8 +634,8 @@ export class TransactionService {
|
||||
console.log('iniresponsupplier', hitSupplier.harga)
|
||||
console.log(supplier.code, 'sdkfjsd');
|
||||
console.log(product_price, 'price');
|
||||
|
||||
|
||||
|
||||
|
||||
if (supplier.code == 'metro') {
|
||||
const parsingResponse = hitSupplier.split(' ');
|
||||
console.log('parsingResponse', parsingResponse)
|
||||
@@ -651,7 +667,7 @@ export class TransactionService {
|
||||
}
|
||||
|
||||
console.log(hitSupplier, 'newhitSupplier');
|
||||
|
||||
|
||||
// const hitSupplier = {
|
||||
// harga: 2000,
|
||||
// success: true,
|
||||
@@ -768,7 +784,7 @@ export class TransactionService {
|
||||
amount: product_price.mark_up_price + product_price.price,
|
||||
status: status,
|
||||
};
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
async orderTransactionBillProd(
|
||||
|
||||
Reference in New Issue
Block a user