@@ -374,16 +374,12 @@ export class PurchasingRepository implements IPurchasingRepo {
374
374
}
375
375
376
376
async pengajuanKontrakPks ( user_id ?: number , data ?: TypePengajuanKontrakPks ) : Promise < any > {
377
- let pricePoPks : number = data ?. price !
377
+
378
378
const resPurchasing = await this . purchasingDataSource . insert ( data )
379
379
const resPpn = await this . setupsDataSource . selectByNama ( process . env . PPN_NAME )
380
380
381
-
382
381
let jumlahPpn = Number ( 1 ) + Number ( resPpn . nilai ! )
383
-
384
- if ( data ?. ppn == 1 ) {
385
- pricePoPks = Number ( data ?. price ! ) / Number ( jumlahPpn )
386
- }
382
+ let pricePoPks : number = data ?. ppn == 1 ? Number ( data ?. price ! ) / Number ( jumlahPpn ) : data ?. price !
387
383
388
384
let dataPoPks : PoPksEntity = {
389
385
purchasing_id : resPurchasing [ 0 ] . insertId ,
@@ -415,24 +411,24 @@ export class PurchasingRepository implements IPurchasingRepo {
415
411
if ( tmpFreighCostId . length > 0 )
416
412
await Promise . all (
417
413
tmpFreighCostId . map ( async ( val : number , i : number ) => {
418
- let dataVendorKontrak : VendorKontrakEntity = { }
419
- let dataPurchasingFreightCost : PurchasingFreightCostEntity = { }
420
- dataVendorKontrak = {
414
+ let dataVendorKontrak = new Map < string , VendorKontrakEntity > ( )
415
+ let dataPurchasingFreightCost = new Map < string , PurchasingFreightCostEntity > ( )
416
+ dataVendorKontrak . set ( 'data' , {
421
417
freight_cost_id : val ,
422
418
po_pks_id : resPoPks [ 0 ] . insertId ,
423
419
stockpile_contract_id : 0 ,
424
420
quantity : data ?. quantity ,
425
421
entry_date : data ?. entry_date ,
426
422
entry_by : user_id ,
427
423
status : 1
428
- }
429
- dataPurchasingFreightCost = {
424
+ } )
425
+ dataPurchasingFreightCost . set ( 'data' , {
430
426
purchasing_id : resPurchasing [ 0 ] . insertId ,
431
427
freight_cost_id : val ,
432
428
entry_date : `${ format ( new Date ( ) , 'yyyy-MM-dd HH:mm:ss' ) } `
433
- }
434
- const resVendorKontrak = await this . vendorKontrakDataSource . insert ( dataVendorKontrak )
435
- const resPurchasingFreightCost = await this . purchasingFreightCostDataSource . insert ( dataPurchasingFreightCost )
429
+ } )
430
+ const resVendorKontrak = await this . vendorKontrakDataSource . insert ( dataVendorKontrak . get ( 'data' ) )
431
+ const resPurchasingFreightCost = await this . purchasingFreightCostDataSource . insert ( dataPurchasingFreightCost . get ( 'data' ) )
436
432
437
433
const dataHistoryLogVendorKontrak : HistoryLogEntity = {
438
434
tanggal : `${ format ( new Date ( ) , 'yyyy-MM-dd HH:mm:ss' ) } ` ,
@@ -474,25 +470,27 @@ export class PurchasingRepository implements IPurchasingRepo {
474
470
tanggal : `${ format ( new Date ( ) , 'yyyy-MM-dd HH:mm:ss' ) } ` ,
475
471
user_id : user_id
476
472
} )
477
- const dataHistoryLogPurchasing : HistoryLogEntity = {
473
+ const dataHistoryLogPurchasing = new Map < string , HistoryLogEntity > ( )
474
+ dataHistoryLogPurchasing . set ( 'data' , {
478
475
tanggal : `${ format ( new Date ( ) , 'yyyy-MM-dd HH:mm:ss' ) } ` ,
479
476
transaksi : `${ resPurchasing [ 0 ] . insertId } ` ,
480
477
cud : 'CREATE' ,
481
478
isitransaksi_baru : `MENGAJUKAN KONTRAK PKS ( table purchasing )` ,
482
479
user_id : user_id
483
- }
484
- const dataHistoryLogPoPks : HistoryLogEntity = {
480
+ } )
481
+ const dataHistoryLogPoPks = new Map < string , HistoryLogEntity > ( )
482
+ dataHistoryLogPoPks . set ( 'data' , {
485
483
tanggal : `${ format ( new Date ( ) , 'yyyy-MM-dd HH:mm:ss' ) } ` ,
486
484
transaksi : `${ resPoPks [ 0 ] . insertId } ` ,
487
485
cud : 'CREATE' ,
488
486
isitransaksi_baru : `MENGAJUKAN KONTRAK PKS ( table po pks)` ,
489
487
user_id : user_id
490
- }
488
+ } )
491
489
492
490
await Promise . all (
493
491
[
494
- this . historyLogDataSource . insert ( dataHistoryLogPurchasing ) ,
495
- this . historyLogDataSource . insert ( dataHistoryLogPoPks ) ,
492
+ this . historyLogDataSource . insert ( dataHistoryLogPurchasing . get ( 'data' ) ) ,
493
+ this . historyLogDataSource . insert ( dataHistoryLogPoPks . get ( 'data' ) ) ,
496
494
this . historyLogDataSource . insert ( dataLogPurchasingDetail . get ( 'data' ) )
497
495
]
498
496
)
@@ -640,7 +638,7 @@ export class PurchasingRepository implements IPurchasingRepo {
640
638
return insert
641
639
}
642
640
643
- async findOneDynamicPurchasingDetail ( conf ?: Pick < ParamsEntity , 'columnKey' | 'columnValue' > | undefined ) : Promise < PurchasingDetailEntity [ ] | [ ] > {
641
+ async findOneDynamicPurchasingDetail ( conf ?: Pick < ParamsEntity , 'columnKey' | 'columnValue' | 'options' > | undefined ) : Promise < PurchasingDetailEntity [ ] | [ ] > {
644
642
const res = await this . purchasingDetailDataSource . selectOneDynamic ( conf ! )
645
643
return res
646
644
}
0 commit comments