mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
5fd2f6ef7f
-create refund and supplier refund if the request refund order is in white form
26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
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)
|
|
{
|
|
$bill_refund_amount = round(floatval($billGroup->billRefunds->sum('amount')), 7);
|
|
$floating_amount = round(floatval($billGroup->transactions()->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount')), 7);
|
|
$paid_amount = round(floatval($billGroup->transactions()->where('status', ApprovalStatus::APPROVED)->sum('amount')), 7);
|
|
$outstanding_amount = $billGroup->amount - $bill_refund_amount - $paid_amount - $floating_amount + $billGroup->service_charge;
|
|
$outstanding_amount = round($outstanding_amount, 7);
|
|
|
|
return [
|
|
'bill_refund_amount' => $bill_refund_amount,
|
|
'floating_amount' => $floating_amount,
|
|
'paid_amount' => $paid_amount,
|
|
'outstanding_amount' => $outstanding_amount,
|
|
];
|
|
}
|
|
}
|