Update besar apk finance
This commit is contained in:
@@ -34,9 +34,10 @@
|
||||
<th>No</th>
|
||||
<th>Tanggal</th>
|
||||
<th>No Ref</th>
|
||||
<th>Keterangan</th>
|
||||
<th style="max-width: 600px">Keterangan</th>
|
||||
<th class="text-end">Debit</th>
|
||||
<th class="text-end">Kredit</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -46,7 +47,7 @@
|
||||
<td colspan="4" class="text-end">TOTAL</td>
|
||||
<td class="text-end" id="totalDebitTable">0</td>
|
||||
<td class="text-end" id="totalKreditTable">0</td>
|
||||
<td></td>
|
||||
<td></td><td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -71,8 +72,8 @@
|
||||
<!-- MODE -->
|
||||
<div class="mb-3">
|
||||
<div class="btn-group w-100">
|
||||
<button class="btn btn-warning active" id="modeAuto">Otomatis</button>
|
||||
<button class="btn btn-outline-secondary" id="modeManual">Manual</button>
|
||||
<button type="button" class="btn btn-warning active" id="modeManual">Jurnal Manual</button>
|
||||
<button type="button" class="btn btn-outline-secondary" id="modeAuto">Template Jurnal</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -138,7 +139,8 @@
|
||||
<strong>Tanggal:</strong> <span id="d_tanggal"></span><br>
|
||||
<strong>No Ref:</strong> <span id="d_noref"></span><br>
|
||||
<strong>Keterangan:</strong> <span id="d_keterangan"></span><br>
|
||||
<strong>Dibuat oleh:</strong> <span id="d_createdby"></span>
|
||||
<strong>Dibuat oleh:</strong> <span id="d_createdby"></span><br>
|
||||
<strong>Status:</strong> <span id="d_status"></span>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered">
|
||||
@@ -160,6 +162,9 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<h6 class="mt-3">Riwayat Status</h6>
|
||||
<div id="statusHistory" class="small text-muted"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -177,7 +182,7 @@
|
||||
$(function(){
|
||||
|
||||
let accounts = [];
|
||||
let mode = 'auto';
|
||||
let mode = 'manual';
|
||||
|
||||
// ================= LOAD ACCOUNTS
|
||||
function loadAccounts(){
|
||||
@@ -282,7 +287,7 @@ $('#modeAuto').click(function(){
|
||||
|
||||
mode = 'auto';
|
||||
|
||||
$(this).addClass('btn-warning active').removeClass('btn-outline-warning');
|
||||
$(this).addClass('btn-warning active').removeClass('btn-outline-secondary');
|
||||
$('#modeManual').removeClass('btn-warning active').addClass('btn-outline-secondary');
|
||||
|
||||
$('#autoSection').show();
|
||||
@@ -305,7 +310,7 @@ $('#modeManual').click(function(){
|
||||
mode = 'manual';
|
||||
|
||||
$(this).addClass('btn-warning active').removeClass('btn-outline-secondary');
|
||||
$('#modeAuto').removeClass('btn-warning active').addClass('btn-outline-warning');
|
||||
$('#modeAuto').removeClass('btn-warning active').addClass('btn-outline-secondary');
|
||||
|
||||
$('#autoSection').hide();
|
||||
$('#tableDetail tbody').html('');
|
||||
@@ -313,6 +318,7 @@ $('#modeManual').click(function(){
|
||||
$('.btn-add-row').show(); // ⬅️ tampilkan lagi
|
||||
|
||||
addRow();
|
||||
addRow();
|
||||
});
|
||||
|
||||
// ================= PILIH TEMPLATE
|
||||
@@ -342,8 +348,8 @@ $('#modeManual').click(function(){
|
||||
let td=0, tk=0;
|
||||
|
||||
$('#tableDetail tbody tr').each(function(){
|
||||
td += parseFloat($(this).find('.debit').val()) || 0;
|
||||
tk += parseFloat($(this).find('.kredit').val()) || 0;
|
||||
td += window.parseMoney($(this).find('.debit').val());
|
||||
tk += window.parseMoney($(this).find('.kredit').val());
|
||||
});
|
||||
|
||||
$('#formTotalDebit').text(td.toLocaleString('id-ID'));
|
||||
@@ -367,7 +373,7 @@ $('.btn-add').click(async function(){
|
||||
$('#formTotalDebit').text('0');
|
||||
$('#formTotalKredit').text('0');
|
||||
|
||||
$('#modeAuto').click(); // default
|
||||
$('#modeManual').click(); // default jurnal manual dengan dua akun
|
||||
});
|
||||
|
||||
$('#btnSimpan').click(function(){
|
||||
@@ -381,8 +387,10 @@ $('#btnSimpan').click(function(){
|
||||
|
||||
$('#tableDetail tbody tr').each(function(){
|
||||
|
||||
let d = parseFloat($(this).find('.debit').val()) || 0;
|
||||
let k = parseFloat($(this).find('.kredit').val()) || 0;
|
||||
let d = window.parseMoney($(this).find('.debit').val());
|
||||
let k = window.parseMoney($(this).find('.kredit').val());
|
||||
|
||||
if(d <= 0 && k <= 0) return;
|
||||
|
||||
account_id.push($(this).find('.account_id').val());
|
||||
debit.push(d);
|
||||
@@ -393,13 +401,18 @@ $('#btnSimpan').click(function(){
|
||||
});
|
||||
|
||||
// ✅ VALIDASI DI SINI
|
||||
if(totalDebit !== totalKredit){
|
||||
if(Math.abs(totalDebit - totalKredit) > 0.009){
|
||||
Swal.fire('Warning','Total Debit dan Kredit harus sama!','warning');
|
||||
return;
|
||||
}
|
||||
|
||||
if(totalDebit === 0 && totalKredit === 0){
|
||||
Swal.fire('Warning','Harap Isi Semua Kolom!','warning'); // ✅ FIX add all collumn must be filled
|
||||
Swal.fire('Warning','Minimal satu pasangan debit dan kredit harus diisi.','warning');
|
||||
return;
|
||||
}
|
||||
|
||||
if(account_id.length < 2 || account_id.some(id => !id)){
|
||||
Swal.fire('Warning','Setiap baris yang memiliki nominal wajib memilih akun.','warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -412,7 +425,6 @@ $('#btnSimpan').click(function(){
|
||||
Swal.fire('Warning','Tanggal tidak boleh kosong!','warning');
|
||||
return;
|
||||
}
|
||||
|
||||
// lanjut simpan
|
||||
$.post("<?= base_url('jurnal/save'); ?>", {
|
||||
tanggal: $('#tanggal').val(),
|
||||
@@ -474,13 +486,37 @@ let table = $('#tableJurnal').DataTable({
|
||||
showCancelButton:true
|
||||
}).then(r=>{
|
||||
if(r.isConfirmed){
|
||||
$.get("<?= base_url('jurnal/delete/'); ?>"+id,function(){
|
||||
table.ajax.reload(null,false);
|
||||
});
|
||||
$.post("<?= base_url('jurnal/delete/'); ?>"+id,{},function(res){
|
||||
if(res.status){ table.ajax.reload(null,false); Swal.fire('Sukses',res.message,'success'); }
|
||||
else Swal.fire('Error',res.message,'error');
|
||||
},'json');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function workflowPost(endpoint, id, data, confirmation){
|
||||
Swal.fire({title:confirmation,icon:'question',showCancelButton:true}).then(function(result){
|
||||
if(!result.isConfirmed) return;
|
||||
$.post("<?= base_url('jurnal/'); ?>"+endpoint+'/'+id, data || {}, function(res){
|
||||
if(res.status){ table.ajax.reload(null,false); Swal.fire('Sukses',res.message,'success'); }
|
||||
else Swal.fire('Error',res.message,'error');
|
||||
},'json').fail(function(xhr){
|
||||
Swal.fire('Error', xhr.responseJSON?.message || 'Proses workflow gagal.','error');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click','.btn-submit',function(){ workflowPost('submit',$(this).data('id'),{},'Ajukan jurnal ini?'); });
|
||||
$(document).on('click','.btn-approve',function(){ workflowPost('approve',$(this).data('id'),{},'Setujui jurnal ini?'); });
|
||||
$(document).on('click','.btn-reject',async function(){
|
||||
const result=await Swal.fire({title:'Tolak jurnal',input:'textarea',inputLabel:'Alasan',showCancelButton:true,inputValidator:v=>!v?'Alasan wajib diisi':undefined});
|
||||
if(result.isConfirmed) workflowPost('reject',$(this).data('id'),{reason:result.value},'Konfirmasi penolakan jurnal?');
|
||||
});
|
||||
$(document).on('click','.btn-reverse',async function(){
|
||||
const result=await Swal.fire({title:'Reversal jurnal',html:'<input type="date" id="reverseDate" class="swal2-input" value="<?= date('Y-m-d') ?>"><textarea id="reverseReason" class="swal2-textarea" placeholder="Alasan reversal"></textarea>',showCancelButton:true,preConfirm:()=>{const date=$('#reverseDate').val(),reason=$('#reverseReason').val().trim();if(!date||!reason){Swal.showValidationMessage('Tanggal dan alasan wajib diisi');return false;}return {date,reason};}});
|
||||
if(result.isConfirmed) workflowPost('reverse',$(this).data('id'),result.value,'Buat jurnal reversal?');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// DETAIL
|
||||
@@ -493,7 +529,10 @@ $(document).on('click','.btn-detail',function(){
|
||||
$('#d_tanggal').text(res.header.tanggal);
|
||||
$('#d_noref').text(res.header.no_ref);
|
||||
$('#d_keterangan').text(res.header.keterangan);
|
||||
$('#d_createdby').text(res.user.nama);
|
||||
$('#d_createdby').text(res.user ? res.user.nama : '-');
|
||||
$('#d_status').text(String(res.header.status || '').toUpperCase());
|
||||
let history=(res.history||[]).map(h=>`${h.from_status||'-'} → ${h.to_status} oleh ${h.changed_by_name||'-'} (${h.changed_at})${h.notes?' — '+h.notes:''}`).join('<br>');
|
||||
$('#statusHistory').html(history || 'Belum ada perubahan status.');
|
||||
|
||||
let html = '';
|
||||
let totalDebit = 0;
|
||||
@@ -524,4 +563,4 @@ $(document).on('click','.btn-detail',function(){
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user