mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 14:33:59 +00:00
28 lines
698 B
PHP
28 lines
698 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Bookings\Services;
|
|
|
|
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
use App\Models\Booking;
|
|
use Carbon\Carbon;
|
|
|
|
class CalculatesBookingPaidAmount
|
|
{
|
|
|
|
public function execute(Booking $booking){
|
|
return $booking->transactions()->payments()->complete()->sum('original_amount');
|
|
}
|
|
|
|
public function executeUntilDate(Booking $booking, Carbon $cutOffDate = null){
|
|
$amount = $booking->transactions()->payments()->complete();
|
|
|
|
if($cutOffDate){
|
|
$amount->where('created_at', '<=', $cutOffDate);
|
|
}
|
|
|
|
return $amount->sum('original_amount');
|
|
}
|
|
|
|
} |