3 Commits
temp ... master

Author SHA1 Message Date
9845b01b0e Merge pull request 'feat(Basicdata): Update 'is_dalam_kota' column and add new branches' (#1) from shola into master
Reviewed-on: #1
2025-12-08 17:28:19 +07:00
Sholahuddin Al Ayubi
fec8dc083c feat(Basicdata): Update 'is_dalam_kota' column and add new branches
- Update 'is_dalam_kota' to true for existing branches based on suffix code
- Set 'is_dalam_kota' to false for branches not in the list
- Add new branches (ID0012005 - KORPORASI, ID0010172 - AMBON TUAL MALUKU)
- Seeder is idempotent and can be rerun safely

run this command:
php artisan module:seed Basicdata --class="UpdateBranchesIsDalamKotaSeeder"

php artisan module:seed --class="Modules\\Basicdata\\Database\\Seeders\\UpdateBranchesIsDalamKotaSeeder"
2025-12-08 17:19:12 +07:00
Daeng Deni Mardaeni
4c4a4a33a9 fix(export): tambahkan properti parent_id pada BranchExport
- Menambahkan properti `protected $parent_id` pada kelas **BranchExport**.
- Properti ini digunakan untuk menyimpan ID cabang induk yang akan dipakai sebagai filter saat melakukan ekspor data.
- Memastikan nilai `parent_id` diinisialisasi melalui constructor dan dideklarasikan sebagai properti kelas.
- Perbaikan ini memastikan filter berdasarkan cabang induk berfungsi dengan benar pada proses ekspor.
- Mendukung konsistensi data pada ekspor **Excel/CSV** dengan filter yang akurat.
- Meningkatkan keandalan fitur ekspor cabang dalam modul laporan.
- Mengoptimalkan integrasi antara fitur filter dan proses ekspor.
- Memperbaiki potensi bug yang muncul akibat properti tidak dideklarasikan.
- Menjamin proses ekspor lebih stabil dan sesuai dengan parameter yang diberikan.
2025-09-08 15:12:27 +07:00
5 changed files with 85 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
class BranchExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping class BranchExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
{ {
protected $search; protected $search;
protected $parent_id;
public function __construct($search = null, $parent_id = null) public function __construct($search = null, $parent_id = null)
{ {

View File

@@ -8,6 +8,7 @@
protected $fillable = [ protected $fillable = [
'code', 'code',
'name', 'name',
'is_dalam_kota',
'address', 'address',
'mnemonic', 'mnemonic',
'customer_company', 'customer_company',

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('branches', function (Blueprint $table) {
$table->boolean('is_dalam_kota')->default(true)->after('name');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('branches', function (Blueprint $table) {
$table->dropColumn('is_dalam_kota');
});
}
};

View File

@@ -59,7 +59,8 @@
['code' => 'PKR', 'name' => 'Pakistani Rupee', 'symbol' => '₨', 'decimal_places' => 2, 'status' => true, 'created_at' => $now, 'updated_at' => $now], ['code' => 'PKR', 'name' => 'Pakistani Rupee', 'symbol' => '₨', 'decimal_places' => 2, 'status' => true, 'created_at' => $now, 'updated_at' => $now],
]; ];
DB::table('currencies')->truncate(); // DB::table('currencies')->truncate();
DB::table('currencies')->delete();
DB::table('currencies')->insert($currencies); DB::table('currencies')->insert($currencies);
} }
} }

View File

@@ -0,0 +1,54 @@
<?php
namespace Modules\Basicdata\Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Basicdata\Models\Branch;
class UpdateBranchesIsDalamKotaSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$codes = [
'0005','0012','0250','0016','0018','0279','0092','0022','0251',
'0029','0270','0096','0109','0098','2005','0008','0028','0015',
'0006','0090','0009','0023','0020','0099','0003','0010','0002',
'0273','0011','0105',
];
Branch::query()->update(['is_dalam_kota' => false]);
foreach ($codes as $code) {
Branch::where('code', 'like', '%' . $code)
->update(['is_dalam_kota' => true]);
}
$newBranches = [
[
'code' => 'ID0012005',
'name' => 'KORPORASI',
'is_dalam_kota' => true,
],
[
'code' => 'ID0010172',
'name' => 'AMBON TUAL MALUKU',
'is_dalam_kota' => false,
],
];
foreach ($newBranches as $branch) {
Branch::firstOrCreate(
['code' => $branch['code']],
[
'name' => $branch['name'],
'is_dalam_kota' => $branch['is_dalam_kota'],
]
);
}
echo "Seeder update kolom is_dalam_kota + insert data baru selesai!\n";
}
}