diff --git a/app/Http/Resources/BookingForTransactionUrgentResource.php b/app/Http/Resources/BookingForTransactionUrgentResource.php new file mode 100644 index 00000000..73d83dc3 --- /dev/null +++ b/app/Http/Resources/BookingForTransactionUrgentResource.php @@ -0,0 +1,73 @@ + $this->id, + 'company' => new CompanyResource($this->company), + 'bank' => new BankResource($this->bank), + 'service' => new ServiceTypeResource($this->service), + 'marking' => $this->marking, + // 'amount' => $this->fix_amount, + // 'floating_amount' => floatval((App()->make(CalculatesBookingFloatingAmount::class))->execute($this->resource, $this->fix_currency_id)), + // 'paid_amount' => floatval((App()->make(CalculatesBookingPayableAmount::class))->execute($this->resource, $this->fix_currency_id)) - floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), + // // 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)) + floatval((App()->make(CalculatesBookingRefundAmount::class))->execute($this->resource, $this->fix_currency_id)), + // 'outstanding_amount' => floatval((App()->make(CalculatesBookingOutstanding::class))->execute($this->resource)), + // 'fixed_currency' => new CurrencyResource($this->fixedCurrency), + // 'convertible_currency' => new CurrencyResource($this->convertibleCurrency), + // 'conversion_currency' => new CurrencyResource($this->conversionCurrency), + // 'documents' => [ + // 'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()), + // 'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), + // 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), + // 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), + // 'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()), + // 'ecommerce_purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()), + // ], + // 'order_reference_no' => $this->modelAttributes()->where('name', BookingAttributeNames::ORDER_REFERENCE_NO)->get()->map(function ($attr) { + // return [ + // 'id' => $attr->id, + // 'value' => $attr->value + // ]; + // }), + // 'status' => $this->status, + // 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), + // 'created_at_with_time' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), + // $this->mergeWhen($this->relationLoaded('transactions'), [ + // 'purchase_order' => new TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), + // 'payment_attempts' => TransactionResource::collection( + // $this->transactions() + // ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION) + // ->whereDate('expires_on', '>=', Carbon::now()) + // ->get() + // ), + // // 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()), + // 'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::EXPIRED)->get()), + // 'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){ + // $query->where(function($query){ + // $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED, ApprovalStatus::REFUNDED]); + // })->orWhere(function($query){ + // $query->where(function($query){ + // $query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]); + // })->orWhere(function($query){ + // $query->where('type', TransactionType::CREDIT_NOTE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + // }); + // }); + // })->latest()->get()) + // ]) + ]; + } +} diff --git a/app/Http/Resources/TransactionUrgentResource.php b/app/Http/Resources/TransactionUrgentResource.php index 8b795fe8..c36b8de8 100644 --- a/app/Http/Resources/TransactionUrgentResource.php +++ b/app/Http/Resources/TransactionUrgentResource.php @@ -35,7 +35,7 @@ class TransactionUrgentResource extends JsonResource return [ 'id' => $this->id, - 'booking' => new BookingResource($booking), + 'booking' => new BookingForTransactionUrgentResource($booking), // 'type' => (int) $this->type, // 'bill_no' => $this->bill_no, // 'payment_reference' => $this->payment_reference,