update module interest history

This commit is contained in:
daengdeni 2024-04-22 16:50:22 +07:00
parent 89922d1b7a
commit c7981a7c31
3 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?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::create('interest_histories', function (Blueprint $table) {
$table->id();
$table->string('nomor_pinjaman',20);
$table->string('periode_bunga',6);
$table->string('nilai_bunga_intra');
$table->string('nilai_bunga_extra');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('interest_histories');
}
};

View File

@ -0,0 +1,16 @@
<?php
namespace Modules\Writeoff\Entities;
class InterestHistory extends BaseModel
{
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'nomor_pinjaman',
'periode_bunga',
'nilai_bunga_intra',
'nilai_bunga_extra',
];
}

View File

@ -263,4 +263,15 @@
}
}
}
public function hitungBunga(){
$hapusbuku = HapusBuku::all();
foreach($hapusbuku as $key => $value){
$bunga = $value->suku_bunga / 100 * $value->baki_debet;
$value->jumlah_bunga = $bunga;
$value->save();
}
}
}