mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-30 09:53:58 +00:00
23 lines
814 B
PHP
23 lines
814 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, int $type){
|
|
return $type === 1 ?
|
|
$booking->transactions()->selectRaw('sum(amount - service_charge - tax) as sub_total')
|
|
->where('type', TransactionType::PAYMENT)
|
|
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get()->sum('sub_total') :
|
|
$booking->transactions()->where('type', TransactionType::PAYMENT)
|
|
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('original_amount');
|
|
}
|
|
|
|
} |