Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const dataMasterPermohonanquery = knex('master_permohonan as mp')
- .select('mp.*', 'res.id_elevation', 'res.kode_aksi', 'ra.nama', 'res.tanggal_approve', 'res.pemutus', 'res.catatan as catatan', 'res.update_is_direksi')
- .leftJoin('ref_elevation_status as res', 'res.id_ref_status','mp.status')
- .leftJoin('ref_action as ra', 'ra.kode_aksi', 'res.kode_aksi')
- .where('mp.id', requestBody.idPermohonan)
- .where('res.kode_aksi', requestBody.kodeAksi)
- const dataMasterPermohonan = await dataMasterPermohonanquery
- .first()
- let update_catatan = dataMasterPermohonan.catatan
- let update_pemutus = dataMasterPermohonan.pemutus
- let tanggal_approve = dataMasterPermohonan.tanggal_approve
- if (dataMasterPermohonan.update_is_direksi === true) {
- if(dataMasterPermohonan.status === 15){
- dataMasterPermohonanquery.where('master_permohonan.is_direksi', knex.raw('ref_elevation_status.check_direksi'));
- const tes = await dataMasterPermohonanquery.first()
- console.log(tes)
- }
- await knex('master_permohonan')
- .where('id', '=', requestBody.idPermohonan)
- .update({
- status : dataMasterPermohonan.id_elevation,
- [update_catatan]: requestBody.catatan,
- [update_pemutus]: user.FullName,
- is_direksi:requestBody.isDireksi,
- [tanggal_approve] : currentDate
- });
- if (dataMasterPermohonan.id_elevation === 7) {
- const innerDataMasterPermohonan = await knex('master_permohonan as mp')
- .select(
- 'mp.id',
- 'mp.no_rekening',
- 'mp.nama_nasabah',
- 'mp.nominal',
- 'mp.eq',
- 'mp.nisbah',
- 'mp.tanggal',
- 'mp.idcabang',
- 'mp.idinduk',
- 'rj.jangka_waktu',
- 'rj.hari',
- 'rs.status',
- 'rs.id as idstatus',
- knex.raw(`
- case
- when mp.jenis_permohonan = 1
- then 'Penempatan Baru'
- else 'Perpanjangan'
- end as pengajuan
- `),
- knex.raw(`
- case
- when mp.jenis_kepemilikan = 1
- then 'Ritel'
- else 'Korporasi'
- end as pemilik
- `),
- knex.raw(`
- case
- when jenis_deposito = 1
- then 'Bagi Hasil'
- else 'Jualah'
- end as deposito
- `)
- )
- .leftJoin('ref_jangka as rj', 'rj.id', 'mp.idjangka')
- .leftJoin('ref_status as rs', 'rs.id', 'mp.status')
- .where('mp.id', '=', requestBody.idPermohonan)
- .first();
- const innerDataMasterEmail = await knex('master_email as me')
- .leftJoin('master_permohonan as mp', 'mp.id', 'me.id_pemohon')
- .where('me.id_pemohon', '=', requestBody.idPermohonan)
- .select('me.email')
- .first();
- console.log('innerDataMasterEmail.email : ', innerDataMasterEmail.email);
- const innerCcEmail = innerDataMasterEmail.email.split(',');
- console.log('innerccEmail : ', innerCcEmail);
- const htmlTemplate = `
- <html>
- <body>
- <p><i><strong> Assalamualaikum wr wb </strong></i></p>
- <p> Berikut data permohonan special nisbah : </p>
- </br>
- <p> Jenis Permohonan : ${innerDataMasterPermohonan.pengajuan} </p>
- <p> Segmentasi : ${innerDataMasterPermohonan.pemilik} </p>
- <p> Jenis Deposito : ${innerDataMasterPermohonan.deposito} </p>
- <p> Nama Nasabah : ${innerDataMasterPermohonan.nama_nasabah} </p>
- <p> Nominal : ${innerDataMasterPermohonan.nominal.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")} </p>
- <p> Jangka Waktu : ${innerDataMasterPermohonan.jangka_waktu} </p>
- <p> Nisbah : ${innerDataMasterPermohonan.nisbah} % </p>
- <p> Indikasi E.q rate dimohon : ${innerDataMasterPermohonan.eq} % </p>
- <p> Email ini dibuat secara otomatis. Mohon tidak mengirimkan balasan ke email ini. </p>
- </br>
- <p><i><strong> Wassalamualaikum wr wb </strong></i></p>
- <p> Bank BJB Syariah </p>
- </body>
- </html>
- `;
- await kirimEmail(
- innerCcEmail,
- innerCcEmail,
- 'SPECIAL NISBAH IB MASLAHAH',
- htmlTemplate
- );
- }
- }else{
- if(dataMasterPermohonan.kode_aksi === 'A'){
- await knex('master_permohonan')
- .where('id', '=', requestBody.idPermohonan)
- .update({
- status : dataMasterPermohonan.id_elevation,
- [update_catatan]: requestBody.catatan,
- [update_pemutus]: user.FullName,
- [tanggal_approve] : currentDate
- });
- }else{
- await knex('master_permohonan')
- .where('id', '=', requestBody.idPermohonan)
- .update({
- status : dataMasterPermohonan.id_elevation,
- [update_catatan]: requestBody.catatan,
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement