30 lines
1.1 KiB
PHP
30 lines
1.1 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Migration_Add_depreciation_account_mapping extends CI_Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if (!$this->db->table_exists('system_account_mappings')) {
|
|
throw new RuntimeException('Jalankan migration accounting foundation terlebih dahulu.');
|
|
}
|
|
|
|
$exists = $this->db->where('mapping_key', 'depreciation_expense')->count_all_results('system_account_mappings') > 0;
|
|
$accountExists = $this->db->where('id', 54)->count_all_results('accounts') > 0;
|
|
if (!$exists && $accountExists) {
|
|
$this->db->insert('system_account_mappings', array(
|
|
'mapping_key' => 'depreciation_expense',
|
|
'account_id' => 54,
|
|
'description' => 'Beban penyusutan aset',
|
|
'is_active' => 1,
|
|
'created_at' => date('Y-m-d H:i:s')
|
|
));
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->db->where('mapping_key', 'depreciation_expense')->delete('system_account_mappings');
|
|
}
|
|
}
|