Merge branch 'feature/add-jumlah-div-terkumpul' into 'main'

DONE: add accumulated amount display

See merge request erahn/voting!17
This commit is contained in:
ISMAIL MASSERAN
2026-05-18 03:53:45 +00:00
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',
+1 -1
View File
@@ -1 +1 @@
*.sqlite
*.sqlite
@@ -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
@@ -1,49 +1,60 @@
<template>
<div class="panel panel-default">
<div class="panel-body">
<h4><b>Kemaskini Maklumat</b></h4>
<form @submit.prevent="edit()" id="edit-form">
<div class="form-group">
<label for="name">Nama</label>
<input type="text" name="name" class="form-control" :value="data.voter.name" required/>
</div>
<div class="panel panel-default">
<div class="panel-body">
<h4><b>Kemaskini Maklumat</b></h4>
<form @submit.prevent="edit()" id="edit-form">
<div class="form-group">
<label for="name">Nama</label>
<input type="text" name="name" class="form-control" :value="data.voter.name" required />
</div>
<div class="form-group">
<label for="no_kp">No. Kad Pengenalan</label>
<input type="text" name="no_kp" class="form-control" :value="data.voter.no_kp" required/>
</div>
<div class="form-group">
<label for="no_kp">No. Kad Pengenalan</label>
<input type="text" name="no_kp" class="form-control" :value="data.voter.no_kp" required />
</div>
<div class="form-group">
<label for="telefon">No. Telefon</label>
<input type="text" name="telefon" class="form-control" :value="data.voter.telefon" required/>
</div>
<div class="form-group">
<label for="telefon">No. Telefon</label>
<input type="text" name="telefon" class="form-control" :value="data.voter.telefon" required />
</div>
<div class="form-group">
<label for="Unit">Unit</label>
<input type="text" name="unit" class="form-control" :value="data.voter.unit" required/>
</div>
<div class="form-group">
<label for="Unit">Unit</label>
<input type="text" name="unit" class="form-control" :value="data.voter.unit" required />
</div>
<div class="form-group">
<label for="saham">Saham</label>
<input type="text" name="saham" class="form-control" :value="data.voter.saham" required/>
</div>
<div class="form-group">
<label for="saham">Saham</label>
<input type="text" name="saham" class="form-control" :value="data.voter.saham" required />
</div>
<div class="form-group">
<label for="yuran">Yuran</label>
<input type="text" name="yuran" class="form-control" :value="data.voter.yuran" required/>
</div>
<div class="form-group">
<label for="yuran">Yuran</label>
<input type="text" name="yuran" class="form-control" :value="data.voter.yuran" 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>
</div>
</form>
<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>
</div>
</form>
</div>
</div>
</div>
</template>
<script>
export default{
export default {
data: function () {
return {
loading: false
@@ -52,7 +63,7 @@ export default{
created: function () {
if (!this.data.voter.id) {
this.$router.push({name:'Manage Voter'});
this.$router.push({ name: 'Manage Voter' });
}
},
@@ -62,15 +73,15 @@ export default{
this.loading = true;
var vm = this;
this.util.notify('Updating voter', 'loading');
axios.put(config.API+'voter/'+this.data.voter.id, $('#edit-form').serialize())
.then(response=>{
axios.put(config.API + 'voter/' + this.data.voter.id, $('#edit-form').serialize())
.then(response => {
vm.loading = false;
$.notifyClose();
if (vm.util.showResult(response, 'success')) {
vm.$router.push({name:'Manage Voter'});
vm.$router.push({ name: 'Manage Voter' });
}
})
.catch(error=>{
.catch(error => {
$.notifyClose();
vm.loading = false;
vm.util.showResult(error);
@@ -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) }
];
}