mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-26 16:04:05 +00:00
22 lines
830 B
PHP
22 lines
830 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Transactions\Services;
|
|
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use App\Models\BillGroup;
|
|
|
|
class CalculatesBillGroupPaymentAmount
|
|
{
|
|
public function execute(BillGroup $billGroup){
|
|
$floating_amount = floatval($billGroup->transactions()->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount'));
|
|
$paid_amount = floatval($billGroup->transactions()->where('status', ApprovalStatus::APPROVED)->sum('amount'));
|
|
$outstanding_amount = $billGroup->amount - $paid_amount - $floating_amount + $billGroup->service_charge;
|
|
|
|
return [
|
|
'floating_amount' => $floating_amount,
|
|
'paid_amount' => $paid_amount,
|
|
'outstanding_amount' => $outstanding_amount,
|
|
];
|
|
}
|
|
|
|
} |