Files
exchange-2.0/app/Classes/Modules/Bookings/Services/CalculatesBookingFloatingAmount.php
T
omair saleh 69eccb2d9c fixing bugs
2021-04-27 14:56:53 +08:00

18 lines
499 B
PHP

<?php
namespace App\Classes\Modules\Bookings\Services;
use App\Models\Booking;
class CalculatesBookingFloatingAmount
{
public function execute(Booking $booking, int $type){
return $type === 1 ?
$booking->transactions()->payments()->inComplete()
->selectRaw('sum(amount - service_charge - tax) as sub_total')
->get()->sum('sub_total')
: $booking->transactions()->payments()->inComplete()->get()->sum('original_amount');
}
}