mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
add route preview-unfinished-payment-orders
This commit is contained in:
@@ -15,4 +15,14 @@ class CalculatesBookingPaidAmount
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
+4
-5
@@ -1372,11 +1372,13 @@ Route::get('/maintenance', function () {
|
||||
});
|
||||
|
||||
Route::get('/preview-unfinished-payment-orders', function (Request $request) {
|
||||
$cutOffDate = $request->cut_off_date;
|
||||
$cutOffDate = $request->cut_off_date ?? null;
|
||||
|
||||
if ($cutOffDate) {
|
||||
echo 'Cut Off Date: ' . $cutOffDate;
|
||||
echo '<br><br>';
|
||||
|
||||
$cutOffDate = Carbon::parse($cutOffDate);
|
||||
}
|
||||
|
||||
echo '<table style="border-collapse: collapse; width: 100%;" border="1">';
|
||||
@@ -1389,9 +1391,6 @@ Route::get('/preview-unfinished-payment-orders', function (Request $request) {
|
||||
<th>Order Created Date</th>
|
||||
</tr></thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
$cutOffDate = Carbon::parse($cutOffDate);
|
||||
|
||||
$bookings = Booking::where('status', '<', ApprovalStatus::COMPLETED);
|
||||
if ($cutOffDate) {
|
||||
$bookings->where('created_at', '<=', $cutOffDate);
|
||||
@@ -1401,7 +1400,7 @@ Route::get('/preview-unfinished-payment-orders', function (Request $request) {
|
||||
$calculateBookingPaidAmount = new CalculatesBookingPaidAmount();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
$paid = $calculateBookingPaidAmount->execute($booking);
|
||||
$paid = $calculateBookingPaidAmount->executeUntilDate($booking, $cutOffDate);
|
||||
$outstanding = $booking->fix_amount - $paid;
|
||||
|
||||
if ($paid > 0 && $outstanding > 0) {
|
||||
|
||||
Reference in New Issue
Block a user