Merge pull request #7 from alealien666/manualPay
update service and model manual payment
This commit is contained in:
commit
783f8830b2
|
@ -14,7 +14,7 @@ class PaymentController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index() {}
|
public function index() {}
|
||||||
|
|
||||||
public function manualPayment()
|
public function indexManualPayment()
|
||||||
{
|
{
|
||||||
$santri = Santri::with('payments', 'payments.detailPayments', 'payments.detailPayments.paymentType')->get();
|
$santri = Santri::with('payments', 'payments.detailPayments', 'payments.detailPayments.paymentType')->get();
|
||||||
|
|
||||||
|
@ -22,56 +22,12 @@ public function manualPayment()
|
||||||
'santri' => $santri,
|
'santri' => $santri,
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'nis' => 'text',
|
'nis' => 'text',
|
||||||
|
'nama' => 'text',
|
||||||
|
'status_santri' => 'text',
|
||||||
|
'role_santri' => 'text',
|
||||||
|
'penalty' => 'text',
|
||||||
|
'amount' => 'text'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for creating a new resource.
|
|
||||||
*/
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*/
|
|
||||||
public function store(Request $request)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the specified resource.
|
|
||||||
*/
|
|
||||||
public function show(Payment $payment)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for editing the specified resource.
|
|
||||||
*/
|
|
||||||
public function edit(Payment $payment)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*/
|
|
||||||
public function update(Request $request, Payment $payment)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*/
|
|
||||||
public function destroy(Payment $payment)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,10 @@ class DetailPayment extends Model
|
||||||
|
|
||||||
public static function cekTunggakan($santri_id)
|
public static function cekTunggakan($santri_id)
|
||||||
{
|
{
|
||||||
return self::where('status', 'belum bayar')
|
|
||||||
->whereHas('payment', function ($query) use ($santri_id) {
|
return self::where('status', 'unpaid')->whereHas('payment', function ($query) use ($santri_id) {
|
||||||
$query->where('santri_id', $santri_id);
|
$query->where('santri_id', $santri_id);
|
||||||
})->orderBy('tahun_pembayaran', 'asc')
|
})->orderBy('payment_year', 'asc')->orderBy('payment_month')->get();
|
||||||
->orderBy('bulan_pembayaran', 'asc')->first();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment()
|
public function payment()
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\DetailPayment;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
class CekDenda
|
||||||
|
{
|
||||||
|
public function cekDenda()
|
||||||
|
{
|
||||||
|
$prevMonth = Carbon::now()->subMonth()->month;
|
||||||
|
$prevYear = Carbon::now()->subMonth()->year;
|
||||||
|
$now = Carbon::now()->day;
|
||||||
|
|
||||||
|
if ($now >= 10) {
|
||||||
|
$arrears = DetailPayment::where('status', 'unpaid')
|
||||||
|
->where('payment_month', $prevMonth)
|
||||||
|
->where('payment_year', $prevYear)->get();
|
||||||
|
|
||||||
|
foreach ($arrears as $arrear) {
|
||||||
|
$arrear->update([
|
||||||
|
'penalty' => 20000
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['message' => 'Berhasil'];
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ public function up(): void
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('nis');
|
$table->string('nis');
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->string('role');
|
$table->string('level');
|
||||||
$table->foreignId('santri_id')->constrained('santris')->onDelete('cascade');
|
$table->foreignId('santri_id')->constrained('santris')->onDelete('cascade');
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
|
@ -14,11 +14,11 @@ public function up(): void
|
||||||
Schema::create('detail_payments', function (Blueprint $table) {
|
Schema::create('detail_payments', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('payment_id')->constrained('payments')->onDelete('cascade');
|
$table->foreignId('payment_id')->constrained('payments')->onDelete('cascade');
|
||||||
$table->enum('status', ['bayar', 'belum bayar']);
|
$table->enum('status', ['paid', 'unpaid']);
|
||||||
$table->float('amount');
|
$table->float('amount');
|
||||||
$table->float('penalty')->nullable();
|
$table->float('penalty')->nullable();
|
||||||
$table->integer('bulan_pembayaran');
|
$table->integer('payment_month');
|
||||||
$table->integer('tahun_pembayaran');
|
$table->integer('payment_year');
|
||||||
$table->foreignId('type_id')->constrained('payment_types')->onDelete('cascade');
|
$table->foreignId('type_id')->constrained('payment_types')->onDelete('cascade');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue