mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Laravel Vapor - Created new resource files for Vue Polling Component
This commit is contained in:
@@ -23,15 +23,15 @@ class DeleteBulkInvoiceFilesV2CommandJob implements ShouldQueue
|
||||
$start = new Carbon();
|
||||
|
||||
$directories = [
|
||||
storage_path('app/bulk_invoice'),
|
||||
storage_path('app/bulk_whiteform'),
|
||||
storage_path('app/bulk_invoice'), //cief todo: should map to the equivalent in AWS S3 bucket
|
||||
storage_path('app/bulk_whiteform'), //cief todo: should map to the equivalent in AWS S3 bucket
|
||||
];
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
$start = new Carbon();
|
||||
Log::info(Carbon::now() . ' Start cleaning - ' . $directory);
|
||||
|
||||
if (File::isDirectory($directory)) {
|
||||
if (File::isDirectory($directory)) { //cief todo: should map to the equivalent in AWS S3 bucket
|
||||
File::cleanDirectory($directory);
|
||||
Log::info('All files have been deleted.');
|
||||
} else {
|
||||
|
||||
@@ -74,7 +74,7 @@ class DeleteOrderV2CommandJob implements ShouldQueue
|
||||
|
||||
Log::info(Carbon::now() . ' : ' . $text);
|
||||
|
||||
$filePath = storage_path('logs/delete-orders.log');
|
||||
$filePath = storage_path('logs/delete-orders.log'); //cief todo: should map to the equivalent in AWS S3 bucket
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $text . PHP_EOL;
|
||||
file_put_contents($filePath, $textToAppend, FILE_APPEND);
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class GenerateEmailVerificationAttemptProcessor
|
||||
|
||||
$attempt = $this->generatesEmailVerificationAttempt->execute($user);
|
||||
|
||||
// $this->emailVerificationAttemptExpiration::dispatch($attempt)->delay(now()->addHours(48)); //cief todo: changed to schedule task
|
||||
// $this->emailVerificationAttemptExpiration::dispatch($attempt)->delay(now()->addHours(48)); //cief todo: changed to schedule task (DONE)
|
||||
|
||||
$this->sendUserVerificationEmail::dispatch($user, $attempt);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Classes\Modules\Bookings\Services\ListsBookings;
|
||||
use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor;
|
||||
use App\Classes\General\Helper;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||
use App\Http\Resources\ListBookingJobResource;
|
||||
use App\Http\Resources\V2\ListBookingJobResource;
|
||||
|
||||
class ListBookingsJobProcessor
|
||||
{
|
||||
@@ -37,7 +37,7 @@ class ListBookingsJobProcessor
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
$query = $this->listsBookings->execute($this->listsBookings->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
foreach ($query->items() as &$item) {
|
||||
foreach ($query->items() as $item) {
|
||||
$item['userInfo'] = $listGenericJobObject->getUserInfo();
|
||||
}
|
||||
$resultCurrent = Helper::collectionResponse(ListBookingJobResource::collection($query));
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor;
|
||||
use App\Classes\General\Helper;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||
use App\Http\Resources\ListDocumentJobResource;
|
||||
use App\Http\Resources\V2\ListDocumentJobResource;
|
||||
|
||||
class ListDocumentsJobProcessor
|
||||
{
|
||||
@@ -37,7 +37,7 @@ class ListDocumentsJobProcessor
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
foreach ($query->items() as &$item) {
|
||||
foreach ($query->items() as $item) {
|
||||
$item['userInfo'] = $listGenericJobObject->getUserInfo();
|
||||
}
|
||||
$resultCurrent = Helper::collectionResponse(ListDocumentJobResource::collection($query));
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor;
|
||||
use App\Classes\General\Helper;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||
use App\Http\Resources\ListTransactionJobResource;
|
||||
use App\Http\Resources\V2\ListTransactionJobResource;
|
||||
|
||||
class ListTransactionsJobProcessor
|
||||
{
|
||||
@@ -37,7 +37,9 @@ class ListTransactionsJobProcessor
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
|
||||
foreach ($query->items() as $item) {
|
||||
$item['userInfo'] = $listGenericJobObject->getUserInfo();
|
||||
}
|
||||
$resultCurrent = Helper::collectionResponse(ListTransactionJobResource::collection($query));
|
||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingFloatingAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ListBookingJobResource extends JsonResource
|
||||
{
|
||||
private $userInfo;
|
||||
|
||||
public function __construct($resource, $userInfo = null)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
$this->userInfo = $userInfo ?? ($resource->userInfo ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company' => new CompanyResource($this->company, $this->userInfo),
|
||||
'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)),
|
||||
'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()),
|
||||
],
|
||||
'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()),
|
||||
'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]);
|
||||
})->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())
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -12,17 +12,10 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources as V1;
|
||||
use App\Http\Resources\V2 as V2;
|
||||
|
||||
class BookingV2Resource extends JsonResource
|
||||
{
|
||||
private $userInfo;
|
||||
|
||||
public function __construct($resource, $userInfo = null)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
$this->userInfo = $userInfo ?? ($resource->userInfo ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
@@ -32,9 +25,12 @@ class BookingV2Resource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if($this->userInfo){
|
||||
$this->company->userInfo = $this->userInfo;
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company' => new CompanyV2Resource($this->company, $this->userInfo),
|
||||
'company' => new V2\CompanyV2Resource($this->company),
|
||||
'bank' => new V1\BankResource($this->bank),
|
||||
'service' => new V1\ServiceTypeResource($this->service),
|
||||
'marking' => $this->marking,
|
||||
@@ -46,26 +42,26 @@ class BookingV2Resource extends JsonResource
|
||||
'convertible_currency' => new V1\CurrencyResource($this->convertibleCurrency),
|
||||
'conversion_currency' => new V1\CurrencyResource($this->conversionCurrency),
|
||||
'documents' => [
|
||||
'purchase_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()),
|
||||
'delivery_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()),
|
||||
'invoice' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()),
|
||||
'supplier_delivery_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()),
|
||||
'proforma_invoice' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()),
|
||||
'ecommerce_purchase_order' => new V1\DocumentResource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()),
|
||||
'purchase_order' => new V2\DocumentV2Resource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()),
|
||||
'delivery_order' => new V2\DocumentV2Resource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()),
|
||||
'invoice' => new V2\DocumentV2Resource($this->documents()->where('document_type', DocumentType::INVOICE)->first()),
|
||||
'supplier_delivery_order' => new V2\DocumentV2Resource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()),
|
||||
'proforma_invoice' => new V2\DocumentV2Resource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()),
|
||||
'ecommerce_purchase_order' => new V2\DocumentV2Resource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()),
|
||||
],
|
||||
'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 V1\TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()),
|
||||
'payment_attempts' => V1\TransactionResource::collection(
|
||||
'purchase_order' => new V2\TransactionV2Resource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()),
|
||||
'payment_attempts' => V2\TransactionV2Resource::collection(
|
||||
$this->transactions()
|
||||
->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
||||
->whereDate('expires_on', '>=', Carbon::now())
|
||||
->get()
|
||||
),
|
||||
'expired_payment_attempts' => V1\TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()),
|
||||
'payment_history' => V1\TransactionResource::collection($this->transactions()->where(function($query){
|
||||
'expired_payment_attempts' => V2\TransactionV2Resource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()),
|
||||
'payment_history' => V2\TransactionV2Resource::collection($this->transactions()->where(function($query){
|
||||
$query->where(function($query){
|
||||
$query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]);
|
||||
})->orWhere(function($query){
|
||||
|
||||
@@ -20,14 +20,6 @@ use App\Http\Resources as V1;
|
||||
|
||||
class CompanyV2Resource extends JsonResource
|
||||
{
|
||||
private $userInfo;
|
||||
|
||||
public function __construct($resource, $userInfo = null)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
$this->userInfo = $userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
@@ -47,12 +39,12 @@ class CompanyV2Resource extends JsonResource
|
||||
$userInfoEmail = $this->userInfo && isset($this->userInfo->email) ? $this->userInfo->email : null;
|
||||
$userInfoType = $this->userInfo && isset($this->userInfo->type) ? $this->userInfo->type : null;
|
||||
|
||||
if(!$userInfoEmail && Auth::user()){
|
||||
$userInfoEmail = Auth::user()->email;
|
||||
}
|
||||
if(!$userInfoType && Auth::user()){
|
||||
$userInfoType = Auth::user()->type;
|
||||
}
|
||||
// if(!$userInfoEmail && Auth::user()){
|
||||
// $userInfoEmail = Auth::user()->email;
|
||||
// }
|
||||
// if(!$userInfoType && Auth::user()){
|
||||
// $userInfoType = Auth::user()->type;
|
||||
// }
|
||||
|
||||
if(!is_null($userInfoEmail) && !is_null($userInfoType)){
|
||||
$userResource = new V1\UserResource($userInfoType === RoleTypes::USER ? $this->employees()->where('email', '=', $userInfoEmail)->first() : $this->employees()->orderBy('id', 'DESC')->first());
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DocumentV2Resource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'reference' => $this->reference,
|
||||
'status' => (int) $this->status,
|
||||
'document_type' => $this->document_type,
|
||||
'files' => FileV2Resource::collection($this->files),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FileV2Resource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'file' => $this->file,
|
||||
'type' => (int) $this->file_type,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingFloatingAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources as V1;
|
||||
|
||||
class ListBookingJobResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if($this->userInfo){
|
||||
$this->company->userInfo = $this->userInfo;
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company' => new CompanyV2Resource($this->company),
|
||||
'bank' => new V1\BankResource($this->bank),
|
||||
'service' => new V1\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)),
|
||||
'fixed_currency' => new V1\CurrencyResource($this->fixedCurrency),
|
||||
'convertible_currency' => new V1\CurrencyResource($this->convertibleCurrency),
|
||||
'conversion_currency' => new V1\CurrencyResource($this->conversionCurrency),
|
||||
'documents' => [
|
||||
'purchase_order' => new DocumentV2Resource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()),
|
||||
'delivery_order' => new DocumentV2Resource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()),
|
||||
'invoice' => new DocumentV2Resource($this->documents()->where('document_type', DocumentType::INVOICE)->first()),
|
||||
'supplier_delivery_order' => new DocumentV2Resource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()),
|
||||
'proforma_invoice' => new DocumentV2Resource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()),
|
||||
'ecommerce_purchase_order' => new DocumentV2Resource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()),
|
||||
],
|
||||
'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 V1\TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()),
|
||||
// 'payment_attempts' => V1\TransactionResource::collection(
|
||||
// $this->transactions()
|
||||
// ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
||||
// ->whereDate('expires_on', '>=', Carbon::now())
|
||||
// ->get()
|
||||
// ),
|
||||
// 'expired_payment_attempts' => V1\TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString())->get()),
|
||||
// 'payment_history' => V1\TransactionResource::collection($this->transactions()->where(function($query){
|
||||
// $query->where(function($query){
|
||||
// $query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]);
|
||||
// })->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())
|
||||
// ])
|
||||
];
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\V2\BookingV2Resource;
|
||||
use App\Http\Resources\V2\CompanyV2Resource;
|
||||
|
||||
|
||||
class ListDocumentJobResource extends JsonResource
|
||||
{
|
||||
@@ -18,13 +17,17 @@ class ListDocumentJobResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if($this->userInfo){
|
||||
$this->owner->userInfo = $this->userInfo;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'reference' => $this->reference,
|
||||
'status' => (int) $this->status,
|
||||
'document_type' => $this->document_type,
|
||||
'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingV2Resource($this->owner, $this->userInfo) : new CompanyV2Resource($this->owner, $this->userInfo)) : null,
|
||||
'files' => FileResource::collection($this->files),
|
||||
'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingV2Resource($this->owner) : new CompanyV2Resource($this->owner)) : null,
|
||||
'files' => FileV2Resource::collection($this->files),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
}
|
||||
+29
-10
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\V2\BookingV2Resource;
|
||||
use App\Http\Resources as V1;
|
||||
|
||||
class ListTransactionJobResource extends JsonResource
|
||||
{
|
||||
@@ -20,35 +22,52 @@ class ListTransactionJobResource extends JsonResource
|
||||
$booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner;
|
||||
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
|
||||
|
||||
$transactionBillQuery = $this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first());
|
||||
$transactionRefundsQuery = $this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get());
|
||||
|
||||
if($this->userInfo){
|
||||
$booking->userInfo = $this->userInfo;
|
||||
if ($transactionBillQuery) {
|
||||
$transactionBillQuery->userInfo = $this->userInfo;
|
||||
}
|
||||
if ($transactionRefundsQuery) {
|
||||
foreach ($transactionRefundsQuery as $item) {
|
||||
$item['userInfo'] = $this->userInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
$transactionBill = new TransactionV2Resource($transactionBillQuery);
|
||||
$transactionRefunds = TransactionV2Resource::collection($transactionRefundsQuery);
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'booking' => new BookingResource($booking),
|
||||
'booking' => new BookingV2Resource($booking),
|
||||
'type' => (int) $this->type,
|
||||
'bill_no' => $this->bill_no,
|
||||
'payment_reference' => $this->payment_reference,
|
||||
'payment_method' => (float) $this->payment_method,
|
||||
'recipient_bank_account' => new BankResource($booking->bank),
|
||||
'recipient_bank_account' => new V1\BankResource($booking->bank),
|
||||
'issuer_name' => $this->issuerCompany->name,
|
||||
'issuer_id' => $this->issuerCompany->id,
|
||||
'amount' => (double) $this->amount,
|
||||
'original_amount' => (double) $this->original_amount,
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'original_currency' => new CurrencyResource($this->original_currency),
|
||||
'currency' => new V1\CurrencyResource($this->currency),
|
||||
'original_currency' => new V1\CurrencyResource($this->original_currency),
|
||||
'service_charge' => (double) $this->service_charge,
|
||||
'tax' => (double) $this->tax,
|
||||
'currency_rate' => (double) $this->currency_rate,
|
||||
'status' => (int) $this->status,
|
||||
'details' => TransactionDetailResource::collection($this->transactionDetails),
|
||||
'documents' => new DocumentResource($this->documents()->first()),
|
||||
'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())),
|
||||
'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())),
|
||||
'details' => V1\TransactionDetailResource::collection($this->transactionDetails),
|
||||
'documents' => new DocumentV2Resource($this->documents()->first()),
|
||||
'transaction_bill' => $transactionBill,
|
||||
'transaction_refunds' => $transactionRefunds,
|
||||
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'),
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'),
|
||||
'interval' => [
|
||||
'value' => $days->gt(Carbon::now()) ? '+' : '-',
|
||||
'duration' => $days->diff(Carbon::now())->format('%d'),
|
||||
],
|
||||
'redemption' => new VoucherRedemptionResource($this->voucherRedemption)
|
||||
'redemption' => new V1\VoucherRedemptionResource($this->voucherRedemption)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources as V1;
|
||||
|
||||
class TransactionV2Resource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner;
|
||||
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
|
||||
$transactionBillQuery = $this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first());
|
||||
$transactionRefundsQuery = $this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get());
|
||||
|
||||
if($this->userInfo){
|
||||
$booking->userInfo = $this->userInfo;
|
||||
if ($transactionBillQuery) {
|
||||
$transactionBillQuery->userInfo = $this->userInfo;
|
||||
}
|
||||
if ($transactionRefundsQuery) {
|
||||
foreach ($transactionRefundsQuery as $item) {
|
||||
$item['userInfo'] = $this->userInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
$transactionBill = new TransactionV2Resource($transactionBillQuery);
|
||||
$transactionRefunds = TransactionV2Resource::collection($transactionRefundsQuery);
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'booking' => new BookingV2Resource($booking),
|
||||
'type' => (int) $this->type,
|
||||
'bill_no' => $this->bill_no,
|
||||
'payment_reference' => $this->payment_reference,
|
||||
'payment_method' => (float) $this->payment_method,
|
||||
'recipient_bank_account' => new V1\BankResource($booking->bank),
|
||||
'issuer_name' => $this->issuerCompany->name,
|
||||
'issuer_id' => $this->issuerCompany->id,
|
||||
'amount' => (double) $this->amount,
|
||||
'original_amount' => (double) $this->original_amount,
|
||||
'currency' => new V1\CurrencyResource($this->currency),
|
||||
'original_currency' => new V1\CurrencyResource($this->original_currency),
|
||||
'service_charge' => (double) $this->service_charge,
|
||||
'tax' => (double) $this->tax,
|
||||
'currency_rate' => (double) $this->currency_rate,
|
||||
'status' => (int) $this->status,
|
||||
'details' => V1\TransactionDetailResource::collection($this->transactionDetails),
|
||||
'documents' => new DocumentV2Resource($this->documents()->first()),
|
||||
'transaction_bill' => $transactionBill,
|
||||
'transaction_refunds' => $transactionRefunds,
|
||||
'refunded_amount' => $this->booking ? floatval((App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($this->resource, $this->booking->fix_currency_id)) : null,
|
||||
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'),
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'),
|
||||
'interval' => [
|
||||
'value' => $days->gt(Carbon::now()) ? '+' : '-',
|
||||
'duration' => $days->diff(Carbon::now())->format('%d'),
|
||||
],
|
||||
'redemption' => new V1\VoucherRedemptionResource($this->voucherRedemption)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'base_url' => env('PERFEXCRM_BASE_URL', 'http://192.168.1.101:8084'), //cief todo: Update crm api domain here
|
||||
'base_url' => env('PERFEXCRM_BASE_URL', 'http://192.168.1.101:8084'), //cief todo: Environment variables
|
||||
'api_key' => env('PERFEXCRM_API_KEY', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiZXhjaGFuZ2Utc2hpcHBpbmciLCJuYW1lIjoiRXhjaGFuZ2UgYW5kIFNoaXBwaW5nIFBvcnRhbCIsIkFQSV9USU1FIjoxNjc1MDg2Mzc4fQ.SGAHWl5stcxQwp55TBGeMRVTdlLeWQIbsvJh5glyVvs'),
|
||||
'is_enabled' => env('PERFEXCRM_IS_ENABLED', 'true'),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user