mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
fix bill seeder
This commit is contained in:
@@ -57,11 +57,7 @@ class BookingResource extends JsonResource
|
||||
'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '<', Carbon::now())->get()),
|
||||
'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){
|
||||
$query->where(function($query){
|
||||
$query->where(function($query){
|
||||
$query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]);
|
||||
})->orWhere(function($query){
|
||||
$query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
});
|
||||
$query->payments();
|
||||
})->orWhere(function($query){
|
||||
$query->where(function($query){
|
||||
$query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]);
|
||||
|
||||
@@ -41,14 +41,7 @@ class TransactionResource extends JsonResource
|
||||
'interval' => [
|
||||
'value' => (Carbon::parse($this->created_at)->addDays(3)->gt(Carbon::now()) ) ? '+' : '-' ,
|
||||
'duration' => Carbon::parse($this->created_at)->addDays(3)->diff(Carbon::now())->format('%d'),
|
||||
],
|
||||
new TransactionResource($this->when((int) $this->type === TransactionType::BILL, function(){
|
||||
$key = 0;
|
||||
$bills = $this->booking->transactions()->bills()->where('original_amount', '=', $this->original_amount)->get();
|
||||
if(count($bills) > 1){ $key = $bills->search(function($bill){ return $bill->id === $this->id; }); }
|
||||
return $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->skip($key)->first();
|
||||
|
||||
}))
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user