DONE: add accumulated amount display

This commit is contained in:
ISMAIL MASSERAN
2026-05-18 11:52:32 +08:00
parent e8d4f03627
commit fe9223cae1
11 changed files with 482 additions and 242 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
[x] hardcode on daftar kehadiran
[x] buang flow pengesahan
[x] tambah siapa yang bagi duit (activity log)
[ ] there is certain part/files that is hardcoded
[x] there is certain part/files that is hardcoded
Penambahan Untuk Sistem Mengundi
[x] Pendaftaran kehadiran (fizikal/maya)
@@ -51,8 +51,10 @@ class UpdateVoterPelaburanFromJson extends Command
continue;
}
$pelaburanRaw = $row['pelaburan'] ?? 0;
$map[$noAnggota] = $this->cleanNumber($pelaburanRaw);
$map[$noAnggota] = [
'pelaburan' => $this->cleanNumber($row['pelaburan'] ?? 0),
'accumulated_amount' => $this->cleanNumber($row['accumulated_amount'] ?? 0),
];
}
if (count($map) === 0) {
@@ -78,7 +80,7 @@ class UpdateVoterPelaburanFromJson extends Command
$bar->start();
DB::table('voter')
->select(['id', 'no_anggota', 'pelaburan'])
->select(['id', 'no_anggota', 'pelaburan', 'accumulated_amount'])
->where('election_id', $electionId)
->orderBy('id')
->chunkById(500, function ($chunk) use ($map, $dryRun, &$updated, &$matched, &$missingInJson, &$unchanged, $bar) {
@@ -92,11 +94,15 @@ class UpdateVoterPelaburanFromJson extends Command
}
$matched++;
$jsonRow = $map[$noAnggota];
$newPelaburan = $map[$noAnggota];
$oldPelaburan = $voter->pelaburan !== null ? (float) $voter->pelaburan : 0.0;
$oldAccumulated = $voter->accumulated_amount !== null ? (float) $voter->accumulated_amount : 0.0;
if (abs($oldPelaburan - $newPelaburan) < 0.00001) {
if (
abs($oldPelaburan - $jsonRow['pelaburan']) < 0.00001
&& abs($oldAccumulated - $jsonRow['accumulated_amount']) < 0.00001
) {
$unchanged++;
$bar->advance();
continue;
@@ -106,7 +112,8 @@ class UpdateVoterPelaburanFromJson extends Command
DB::table('voter')
->where('id', $voter->id)
->update([
'pelaburan' => $newPelaburan,
'pelaburan' => $jsonRow['pelaburan'],
'accumulated_amount' => $jsonRow['accumulated_amount'],
'updated_at' => now(),
]);
}
@@ -129,7 +136,6 @@ class UpdateVoterPelaburanFromJson extends Command
private function resolvePath(string $path): string
{
// absolute path
if (strpos($path, DIRECTORY_SEPARATOR) === 0) {
return $path;
}
@@ -155,4 +161,3 @@ class UpdateVoterPelaburanFromJson extends Command
return is_numeric($value) ? (float) $value : 0.0;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ class Voter extends Authenticatable
protected $table = 'voter';
protected $fillable = ['name', 'no_kp', 'no_anggota','unit', 'election_id', 'alamat', 'telefon', 'saham', 'yuran', 'kehadiran','status_penyata','persetujuan','tarikh_sah','cadangan','pelaburan','tergempar','barangan','peribadi','berjamin_yuran','roadtax','pelbagai'];
protected $fillable = ['name', 'no_kp', 'no_anggota','unit', 'election_id', 'alamat', 'telefon', 'saham', 'yuran', 'kehadiran','status_penyata','persetujuan','tarikh_sah','cadangan','pelaburan', 'accumulated_amount', 'tergempar','barangan','peribadi','berjamin_yuran','roadtax','pelbagai'];
protected $casts = [
'fizikal_registration_verified_at' => 'datetime',
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddAccumulatedAmountToVoterTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('voter', function (Blueprint $table) {
$table->decimal('accumulated_amount', 12, 2)->default(0)->after('pelaburan');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('voter', function (Blueprint $table) {
$table->dropColumn('accumulated_amount');
});
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -143,4 +143,4 @@ You can watch the System Demo [here](https://youtu.be/dsEoONiovdA).
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag=migrations
```
formula kiraan = ((Bulan masuk/12) * jumlah pelaburan) * 0.12
formula kiraan (purate) = ((Bulan masuk/12) * jumlah pelaburan) * 0.12
@@ -33,6 +33,17 @@
<input type="text" name="yuran" class="form-control" :value="data.voter.yuran" required />
</div>
<div class="form-group">
<label for="accumulated_amount">Jumlah Pelaburan (hingga Dis 2025)</label>
<input type="text" name="accumulated_amount" class="form-control"
:value="data.voter.accumulated_amount" required />
</div>
<div class="form-group">
<label for="pelaburan">Dividen Simpanan Khas (Tabung 1) Tahun 2025</label>
<input type="text" name="pelaburan" class="form-control" :value="data.voter.pelaburan" required />
</div>
<div class="form-group">
<input type="submit" value="Hantar" class="btn btn-success" />
<router-link :to="{ name: 'Manage Voter' }" class="btn btn-default">Kembali</router-link>
@@ -106,6 +106,8 @@ export default {
{ title: 'Unit', key: 'unit', sortable: true },
{ title: 'Saham', key: 'saham', sortable: true },
{ title: 'Yuran', key: 'yuran', sortable: true },
{ title: 'Jumlah Pelaburan (hingga Dis 2025)', key: 'accumulated_amount', sortable: true },
{ title: 'Dividen Simpanan Khas (Tabung 1) Tahun 2025', key: 'pelaburan', sortable: true },
{ title: 'Tindakan', key: 'actions', sortable: false }
]
}
@@ -393,6 +393,7 @@ export default {
{ icon: "fa-building", label: "Unit", value: u.unit || "—" },
{ icon: "fa-line-chart", label: "Saham", value: "RM " + fmt(u.saham) },
{ icon: "fa-money", label: "Yuran", value: "RM " + fmt(u.yuran) },
{ icon: "fa-bank", label: "Simpanan Khas (Tabung 1) - (Sehingga Dis 2025)", value: "RM " + fmt(u.accumulated_amount) },
{ icon: "fa-percent", label: "Dividen Simpanan Khas (Tabung 1) Tahun 2025", value: "RM " + fmt(u.pelaburan) }
];
}