Update besar apk finance

This commit is contained in:
Wian Drs
2026-09-11 16:03:00 +07:00
parent d42483b350
commit 4ef15c22ae
897 changed files with 98056 additions and 15979 deletions
+34 -23
View File
@@ -7,11 +7,12 @@ class Cronjob extends CI_Controller {
{
parent::__construct();
$this->load->database();
$this->load->library('AccountMappingService');
$this->load->library('PostingService');
// ONLY CLI ACCESS
// if (!$this->input->is_cli_request()) {
// exit('No direct access allowed');
// }
if (!$this->input->is_cli_request()) {
show_error('Cronjob hanya dapat dijalankan melalui CLI.', 403, 'Akses ditolak');
}
}
public function generate_insight()
@@ -358,9 +359,24 @@ class Cronjob extends CI_Controller {
// =====================================================
public function depreciation_asset()
{
// Tahap 8: satu-satunya jalur penyusutan memakai subledger yang
// idempotent, row-lock, dan pemeriksaan periode akuntansi.
$this->load->library('FixedAssetService');
$assets = $this->db->select('id')->where('lifecycle_status', 'active')->get('assets')->result();
$result = array();
foreach ($assets as $asset) {
try {
$result[$asset->id] = $this->fixedassetservice->depreciate($asset->id, date('Y-m-d'), 1, true);
} catch (Throwable $e) {
$result[$asset->id] = array('error' => $e->getMessage());
}
}
return $this->output->set_content_type('application/json')->set_output(json_encode(array('status'=>true,'assets'=>$result)));
/* Legacy engine retained below for historical reference; unreachable. */
$period = date('Y-m');
$runDate = date('Y-m-d');
$akun_beban_penyusutan = 54;
$akun_beban_penyusutan = $this->accountmappingservice->get('depreciation_expense');
$assets = $this->db
->select('id, nama_asset, nilai_perolehan, nilai_buku, nilai_residu, penyusutan_per_bulan, masa_manfaat, tanggal_perolehan, akumulasi_penyusutan, account_debit_id')
@@ -576,30 +592,25 @@ class Cronjob extends CI_Controller {
]);
$no_ref = 'DEP-' . date('YmdHis') . '-' . $a->id . '-' . str_replace('-', '', $iterMonth);
$this->db->insert('journals', [
$this->postingservice->post([
'tanggal' => $dueDateThisMonth,
'no_ref' => $no_ref,
'keterangan' => 'Penyusutan Asset ' . $a->nama_asset . ' periode ' . $iterMonth,
'ref_type' => 'assets',
'ref_id' => $a->id,
'created_by' => 1
]);
$jid = $this->db->insert_id();
$this->db->insert('journal_details', [
'journal_id' => $jid,
'account_id' => $akun_beban_penyusutan,
'debit' => $susut,
'kredit' => 0
]);
$this->db->insert('journal_details', [
'journal_id' => $jid,
'account_id' => $akun_akumulasi_penyusutan,
'debit' => 0,
'kredit' => $susut
]);
], [
[
'account_id' => $akun_beban_penyusutan,
'debit' => $susut,
'kredit' => 0
],
[
'account_id' => $akun_akumulasi_penyusutan,
'debit' => 0,
'kredit' => $susut
]
], false, false);
$success++;
$assetHasSuccess = true;