mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Merge branch 'master' into dillon/34.1-jenkins-vapor
This commit is contained in:
@@ -65,7 +65,7 @@ abstract class AbstractControllerLogic
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
if ($exception instanceof JobResourceNotFoundException) {
|
||||
Log::error(sprintf(
|
||||
Log::channel('vue_polling')->info(sprintf(
|
||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
||||
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
||||
$join->where('transactions.owner_type', '=', PackingList::class);
|
||||
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
||||
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
||||
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
||||
))');
|
||||
})->orderBy('transactions.updated_at', 'DESC');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PostcodeLike implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('postcode', 'LIKE', '%'.$value.'%');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WithContainersPackages implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
// Log::info('WithContainersPackages: '.$value);
|
||||
// return $builder->with(['containers', 'packages']);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ class ListPackingListsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/** @var ListGenericJobObject */
|
||||
private $listGenericJobObject;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = 0;
|
||||
$invoiceStatus = 0;
|
||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
|
||||
if(is_null($invoice)){
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||
@@ -55,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -145,7 +145,7 @@ class CallbackBillplzLogic
|
||||
$pL = $invoice->owner;
|
||||
$order = $pL->owner;
|
||||
if($order){
|
||||
$this->storageInvoiceTransactionProcessor->executeOrder($order, false); //original was set true here so that no group is soft deleted or billplz bill got deleted
|
||||
$this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@ use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Group;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
@@ -33,8 +32,8 @@ class CallbackBillplzProcessor
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var CreateStorageInvoiceDocTransactionProcessor */
|
||||
private $ceateStorageInvoiceDocTransactionProcessor;
|
||||
/** @var ReleaseGoodsToCustomerProcessor */
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/**
|
||||
* CreateUserProcessor constructor.
|
||||
@@ -43,16 +42,16 @@ class CallbackBillplzProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
* @param CreateStorageInvoiceDocTransactionProcessor $ceateStorageInvoiceDocTransactionProcessor
|
||||
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CreateStorageInvoiceDocTransactionProcessor $ceateStorageInvoiceDocTransactionProcessor)
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->ceateStorageInvoiceDocTransactionProcessor = $ceateStorageInvoiceDocTransactionProcessor;
|
||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,11 +81,11 @@ class CallbackBillplzProcessor
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
|
||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||
|
||||
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||
$pL = $invoice->owner;
|
||||
$this->processPackingListAndInvoice($pL, $invoice);
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +95,7 @@ class CallbackBillplzProcessor
|
||||
}
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
$this->processPackingListAndInvoice($packingList, $invoice);
|
||||
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -126,49 +125,4 @@ class CallbackBillplzProcessor
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function processPackingListAndInvoice($packingList, $invoice = null){
|
||||
$result = false;
|
||||
$totalInvoicesAmountPaid = 0.00;
|
||||
$totalInvoicesAmount = 0.00;
|
||||
$invoiceTransactions = $packingList->transactions()->where('status', [ApprovalStatus::APPROVED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
|
||||
//Part 1: Process each single invoice type and get the total of all invoices
|
||||
foreach($invoiceTransactions as $invoiceTransaction){
|
||||
|
||||
$totalInvoiceAmountPaid = $invoiceTransaction->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
if ($invoice && $invoice->type == $invoiceTransaction->type) {
|
||||
if(($invoice->amount - $totalInvoiceAmountPaid) < 0.01){
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
if($invoice->type == TransactionType::STORAGE_INVOICE){
|
||||
$this->ceateStorageInvoiceDocTransactionProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totalInvoicesAmount = $totalInvoicesAmount + $invoiceTransaction->amount;
|
||||
$totalInvoicesAmountPaid = $totalInvoicesAmountPaid + $totalInvoiceAmountPaid;
|
||||
}
|
||||
|
||||
Log::channel('storage_invoices')->info('Total invoice amount paid 1: '.$totalInvoicesAmount); //cief todo: to be removed
|
||||
Log::channel('storage_invoices')->info('Total invoice amount paid 2: '.$totalInvoicesAmountPaid); //cief todo: to be removed
|
||||
|
||||
//Part 2: Based on the collected info for all the total of all invoices
|
||||
if (($totalInvoicesAmount - $totalInvoicesAmountPaid) < 0.01) {
|
||||
Log::channel('storage_invoices')->info('Total invoice amount paid 3: '.$totalInvoicesAmountPaid); //cief todo: to be removed
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if (app()->environment('production')) {
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
$result = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Company Credit Term Status',
|
||||
'message' => 'You have successfully updated Company Credit Term Status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyModuleIsCreditTerm */
|
||||
private $updatesCompanyModuleIsCreditTerm;
|
||||
|
||||
/** @var CanUpdateCompanyModule */
|
||||
private $canUpdateCompanyModule;
|
||||
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
/** @var UpdatesTransactionIsWaived */
|
||||
private $updatesTransactionIsWaived;
|
||||
|
||||
/** @var CheckStorageInvoiceTransactionProcessor */
|
||||
private $storageInvoiceTransactionProcessor;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* UpdateCompanyCreditTermStatusLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm
|
||||
* @param CanUpdateCompanyModule $canUpdateCompanyModule
|
||||
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
||||
* @param ListsTransactions $listsTransactions
|
||||
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, UpdatesTransactionIsWaived $updatesTransactionIsWaived, ListsTransactions $listsTransactions, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm;
|
||||
$this->canUpdateCompanyModule = $canUpdateCompanyModule;
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
||||
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canUpdateCompanyModule->passes();
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$companyModule = $company->companyModules()->first();
|
||||
$isCreditTerm = $companyModule->connections()->first()->is_credit_term;
|
||||
|
||||
if ($isCreditTerm == 1) {
|
||||
$isCreditTerm = 0;
|
||||
} else {
|
||||
$isCreditTerm = 1;
|
||||
}
|
||||
|
||||
if($isCreditTerm === 1){
|
||||
//{"per_page":10,"order_by":{"column":"id","DESC":true},"status_in":[2],"receiver":190,"type_in":[1],"does_not_have_payment_status_in":[0,1],"does_not_have_groups":1,"check_for_storage_invoice":1}
|
||||
|
||||
$filters = [
|
||||
'status_in' => [2],
|
||||
'receiver' => $companyModule->id,
|
||||
'type_in' => [TransactionType::STORAGE_INVOICE]
|
||||
];
|
||||
|
||||
$transactions = $this->listsTransactions->execute($filters);
|
||||
foreach($transactions as $transaction){
|
||||
$this->updatesTransactionIsWaived->execute($transaction);
|
||||
$packingList = $transaction->owner()->first();
|
||||
if($packingList){
|
||||
$order = $packingList->owner()->first();
|
||||
if($order instanceof Order){
|
||||
$storages = $this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->updatesCompanyModuleIsCreditTerm->execute($company->companyModules()->first()->connections()->first(), $isCreditTerm);
|
||||
Log::info(Auth::user()->email." updated credit term status for customer with id: " .$request->route('id'). " to status " . $isCreditTerm);
|
||||
|
||||
$result = ['is_credit_term' => $isCreditTerm];
|
||||
return $this->response(['data' => $result]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
|
||||
class UpdatesCompanyModuleIsCreditTerm extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CompanyConnection $model
|
||||
* @param int $isCreditTerm
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $model, int $isCreditTerm)
|
||||
{
|
||||
$model->is_credit_term = $isCreditTerm;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class CanUpdateCompanyModule extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* CanUpdateCompanyModule constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
$user = Auth()->user();
|
||||
if($user){
|
||||
$roleToCheck = Auth()->user()->type;
|
||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Imports\Services;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
|
||||
|
||||
class GenericImport implements ToCollection, WithHeadingRow
|
||||
{
|
||||
function headingRow(): int { return 1; }
|
||||
|
||||
public $rows;
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function collection(Collection $collection)
|
||||
{
|
||||
$this->rows = $collection;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ class UpdateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function execute(PackingList $packingList) {
|
||||
Log::info('Trying to Call UpdateDoFromYDPortalProcessor');
|
||||
Log::channel('storage_invoices')->info('UpdateDoFromYDPortalProcessor: '.json_encode($packingList));
|
||||
|
||||
if(!app()->environment(['production'])){
|
||||
return;
|
||||
|
||||
@@ -75,7 +75,7 @@ class ListPackingListsJobLogic extends AbstractControllerLogic
|
||||
// ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('hellokitty2'); //cief todo: testing sqs
|
||||
// }
|
||||
// }
|
||||
ListPackingListsJob::dispatch($listGenericJobObject);
|
||||
ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('high_priority');
|
||||
|
||||
$result = [];
|
||||
$result['job_id'] = $jobId;
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
||||
use App\Http\Resources\PackingListNullOrderResource;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use App\Http\Resources\PackingListWithStorageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -54,7 +54,14 @@ class ListPackingListsLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(PackingListResource::collection($query));
|
||||
if($request->input('storages')){
|
||||
foreach ($query->items() as $item) {
|
||||
$item['storages'] = $request->input('storages');
|
||||
}
|
||||
return $this->collectionResponse(PackingListWithStorageResource::collection($query));
|
||||
}
|
||||
else{
|
||||
return $this->collectionResponse(PackingListResource::collection($query));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,11 @@ use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor;
|
||||
use App\Classes\General\Helper;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||
use App\Http\Middleware\CheckForStorageInvoiceByPackingLists;
|
||||
use App\Http\Resources\ListPackingListJobResource;
|
||||
use App\Http\Resources\ListPackingListDetailsJobResource;
|
||||
use App\Http\Resources\ListPackingListJobWithStorageResource;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ListPackingListsJobProcessor
|
||||
{
|
||||
@@ -18,15 +22,19 @@ class ListPackingListsJobProcessor
|
||||
/** @var UpdateJobResultProcessor */
|
||||
private $updateJobResultProcessor;
|
||||
|
||||
/** @var CheckForStorageInvoiceByPackingLists */
|
||||
private $checkForStorageInvoiceByPackingLists;
|
||||
|
||||
/**
|
||||
* ListPackingListsJobProcessor constructor.
|
||||
* @param ListsPackingLists $listsPackingLists
|
||||
* @param UpdateJobResultProcessor $updateJobResultProcessor
|
||||
*/
|
||||
public function __construct(ListsPackingLists $listsPackingLists, UpdateJobResultProcessor $updateJobResultProcessor)
|
||||
public function __construct(ListsPackingLists $listsPackingLists, UpdateJobResultProcessor $updateJobResultProcessor, CheckForStorageInvoiceByPackingLists $checkForStorageInvoiceByPackingLists)
|
||||
{
|
||||
$this->listsPackingLists = $listsPackingLists;
|
||||
$this->updateJobResultProcessor = $updateJobResultProcessor;
|
||||
$this->checkForStorageInvoiceByPackingLists = $checkForStorageInvoiceByPackingLists;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,12 +44,44 @@ class ListPackingListsJobProcessor
|
||||
* @throws \App\Classes\Exceptions\JobResourceNotFoundException
|
||||
*/
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
// $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]);
|
||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
// $query = $this->listsPackingLists->execute(array_merge($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]));
|
||||
|
||||
$filtersArray = json_decode($listGenericJobObject->getPayload()['filters'], true);
|
||||
|
||||
$storages = [];
|
||||
if(isset($filtersArray['check_for_storage_invoice']))
|
||||
{
|
||||
$myRequest = new \Illuminate\Http\Request();
|
||||
$myRequest->setMethod('POST');
|
||||
$myRequest->request->add($listGenericJobObject->getPayload());
|
||||
$next = function ($request) {
|
||||
return $request;
|
||||
};
|
||||
|
||||
$response = $this->checkForStorageInvoiceByPackingLists->handle($myRequest, $next);
|
||||
$storages = $response->input('storages');
|
||||
}
|
||||
|
||||
foreach ($query->items() as &$item) {
|
||||
$item['userInfo'] = $listGenericJobObject->getUserInfo();
|
||||
$item['storages'] = $storages;
|
||||
}
|
||||
|
||||
if(isset($filtersArray['does_not_have_transaction_type'])){ //For Payment and Billing page > Pending Invoice tab
|
||||
$resultCurrent = Helper::collectionResponse(ListPackingListDetailsJobResource::collection($query));
|
||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
||||
}
|
||||
else{
|
||||
if($storages){ //For Payment and Billing page > Pending Payment tab, Paid Invoice tab
|
||||
$resultCurrent = Helper::collectionResponse(ListPackingListJobWithStorageResource::collection($query));
|
||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
||||
}
|
||||
else{
|
||||
$resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query));
|
||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
||||
}
|
||||
}
|
||||
$resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query));
|
||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class FetchPerfexCRMInvoiceProcessor
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
$log['message'] = 'FetchPerfexCRMInvoiceProcessor failed for transaction > bill_no: '.$number;
|
||||
Helper::debugLogger($log);
|
||||
Log::channel('perfex_crm')->info($log);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -25,7 +25,7 @@ class ConvertsPerfexCRMLeadToCustomer
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('ConvertsPerfexCRMLeadToCustomer: '.$response);
|
||||
Log::channel('perfex_crm')->info('ConvertsPerfexCRMLeadToCustomer: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class CreatesPerfexCRMCustomer
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMCustomer: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMCustomer: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class CreatesPerfexCRMCustomerContact
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMCustomerContact: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMCustomerContact: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMCustomerProject
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMCustomerProject: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMCustomerProject: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class CreatesPerfexCRMInvoice
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMInvoice: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMInvoice: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMInvoicePayment
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMInvoicePayment: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMInvoicePayment: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class CreatesPerfexCRMLead
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMLead: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMLead: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class CreatesPerfexCRMMilestone
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMMilestone: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMMilestone: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMSupportTicket
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
Log::channel('perfex_crm')->info($response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class CreatesPerfexCRMTask
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMTask: '.$response);
|
||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMTask: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class FetchesPerfexCRMCustomer
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMCustomer: '.$response);
|
||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMCustomer: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class FetchesPerfexCRMInvoice
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMInvoice: '.$response);
|
||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMInvoice: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class FetchesPerfexCRMLead
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMLead: '.$response);
|
||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMLead: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class FetchesPerfexCRMMilestone
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMMilestone: '.$response);
|
||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMMilestone: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class FetchesPerfexCRMProject
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMProject: '.$response);
|
||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMProject: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class FetchesPerfexCRMTask
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Helper::debugLogger($response);
|
||||
Log::channel('perfex_crm')->info($response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class UpdatesPerfexCRMCustomer
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
// Helper::debugLogger($response);
|
||||
// Log::channel('perfex_crm')->info($response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class UpdatesPerfexCRMInvoice
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMInvoice: '.$response);
|
||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMInvoice: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class UpdatesPerfexCRMLead
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMLead: '.$response);
|
||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMLead: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class UpdatesPerfexCRMProject
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMProject: '.$response);
|
||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMProject: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class UpdatesPerfexCRMTask
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMTask: '.$response);
|
||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMTask: '.$response);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\GroupTransaction;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
|
||||
|
||||
class CreateGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -55,13 +57,18 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
/** @var CreatesGroup */
|
||||
private $createsGroup;
|
||||
|
||||
/** @var ReleaseGoodsToCustomerProcessor */
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreateWalletTopUpTransactionProcessor $createWalletTopUpTransactionProcessor,
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor,
|
||||
CreatesGroup $createsGroup
|
||||
CreatesGroup $createsGroup,
|
||||
ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -70,20 +77,40 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
$this->createWalletTopUpTransactionProcessor = $createWalletTopUpTransactionProcessor;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->createsGroup = $createsGroup;
|
||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
$groupPyamentStatus = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
// todo-new: check why is this not working
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
$isInvoicesApprove = $this->checkIfInvoicesAreApprove($invoices);
|
||||
if(!$isInvoicesApprove){
|
||||
$response = ['message' => 'One of the transactions might be suspended; please check if there are any disputes in progress.'];
|
||||
return $this->response(['data' => $response]);
|
||||
}
|
||||
else{
|
||||
$paymentMethodStr = $request->input('payment_method');
|
||||
$paymentMethod = PaymentMethodType::PAYMENT_METHODS[$paymentMethodStr];
|
||||
$amount = $request->input('amount');
|
||||
$bankCode = $request->input('bank_code');
|
||||
$result = $this->processInvoices($invoices, $paymentMethodStr, $amount, $bankCode);
|
||||
|
||||
if ($paymentMethod === PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
return $this->resourceResponse(new WalletTransactionResource($result));
|
||||
}
|
||||
}
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
private function processInvoices($invoices, $reqPaymentMethod, $reqAmount, $reqBankCode){
|
||||
$result = [];
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$reqPaymentMethod];
|
||||
$groupPyamentStatus = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
foreach ($invoices as $invoice) {
|
||||
$order = null;
|
||||
if ($invoice->owner instanceof Transaction) {
|
||||
@@ -110,7 +137,7 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
$wallet = Wallet::where('owner_id', $companyModuleId)->first();
|
||||
|
||||
// todo-new: verify currently checking wallet amount based on 'amount' value passed by frontend
|
||||
if((float) number_format(($wallet->amount - $request->input('amount')),2) < 0){
|
||||
if((float) number_format(($wallet->amount - $reqAmount),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
@@ -146,7 +173,12 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
if ($payment_method == PaymentMethodType::WALLET) {
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $request->input('bank_code'));
|
||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $reqBankCode, false);
|
||||
|
||||
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||
$pL = $invoice->owner;
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||
}
|
||||
}
|
||||
|
||||
$issuer = $invoice->issuer;
|
||||
@@ -168,11 +200,12 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
|
||||
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
||||
// create only one billplz payment for wallet top up
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$amount = floatval(str_replace(',', '', $reqAmount));
|
||||
$companyModuleId = $invoice->receiver;
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||
|
||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'), $payment_method, $billNumber, true);
|
||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $reqBankCode, $payment_method, $billNumber, true);
|
||||
$result = $topUpTransaction;
|
||||
}
|
||||
|
||||
$group->issuer = $issuer;
|
||||
@@ -188,11 +221,15 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
$group->status = $groupPyamentStatus;
|
||||
$group->save();
|
||||
|
||||
if ($payment_method === PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
return $this->resourceResponse(new WalletTransactionResource($topUpTransaction));
|
||||
return $result;
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->response([]);
|
||||
private function checkIfInvoicesAreApprove($invoices){
|
||||
foreach ($invoices as $invoice) {
|
||||
if($invoice->status !== ApprovalStatus::APPROVED && $invoice->status !== ApprovalStatus::COMPLETED){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-16
@@ -10,6 +10,8 @@ use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -30,13 +32,18 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var ReleaseGoodsToCustomerProcessor */
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor,
|
||||
ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
@@ -45,22 +52,20 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]);
|
||||
|
||||
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'));
|
||||
if($invoice_transaction->status === ApprovalStatus::APPROVED){
|
||||
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'), false);
|
||||
|
||||
//cief todo: at exchange there is a transition step - starts
|
||||
// if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){
|
||||
// $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION);
|
||||
// }
|
||||
if($payment_transaction && $payment_transaction->status === ApprovalStatus::APPROVED){
|
||||
$pL = $invoice_transaction->owner;
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice_transaction);
|
||||
}
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
}
|
||||
|
||||
// if(config('perfexcrm.is_enabled') == 'true'){
|
||||
// $this->transactionToPerfexCRMV2Processor->execute($transaction, $status);
|
||||
// }
|
||||
|
||||
//To use
|
||||
//ApprovalStatus::PENDING_VERIFICATION;
|
||||
//use this to trigger $this->transactionToPerfexCRMV2Processor->execute > defineTasks > defineTasks_handlePendingVerificationStatus > definePaymentTasks
|
||||
//cief todo: at exchange there is a transition step - ends
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
$response = ['message' => 'A transaction might be suspended; please check if there is any dispute in progress.'];
|
||||
return $this->response(['data' => $response]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class DeleteTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
|
||||
/**
|
||||
* SuspendTransactionLogic constructor.
|
||||
* DeleteTransactionLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Http\Resources\TransactionWithStorageResource;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -42,15 +43,18 @@ class ListTransactionsLogic extends AbstractControllerLogic
|
||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
||||
|
||||
if($request->input('storages')){
|
||||
foreach ($query->items() as &$item) {
|
||||
foreach ($query->items() as $item) {
|
||||
$transactionId = $item['id'];
|
||||
$filteredStorages = array_filter($request->input('storages'), function ($storage) use ($transactionId) {
|
||||
return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId;
|
||||
});
|
||||
$item['storages'] = $filteredStorages;
|
||||
}
|
||||
//return $this->collectionResponse(TransactionWithStorageResource::collection($query));
|
||||
}
|
||||
|
||||
return $this->collectionResponse(TransactionResource::collection($query));
|
||||
// else{
|
||||
// return $this->collectionResponse(TransactionResource::collection($query));
|
||||
//
|
||||
return $this->collectionResponse(TransactionWithStorageResource::collection($query));
|
||||
}
|
||||
}
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanRegenerateStorageInvoice;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RegenerateSingleStorageInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Regenerate Storage Invoice',
|
||||
'message' => 'You have successfully regenerated storage invoice'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var CreateStorageInvoiceDocTransactionFixProcessor */
|
||||
private $createStorageInvoiceDocTransactionProcessor;
|
||||
|
||||
/** @var CanRegenerateStorageInvoice */
|
||||
private $canRegenerateStorageInvoice;
|
||||
|
||||
/**
|
||||
* @param CreatesDocument $createsDocument
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, CreateStorageInvoiceDocTransactionFixProcessor $createStorageInvoiceDocTransactionProcessor, CanRegenerateStorageInvoice $canRegenerateStorageInvoice)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor;
|
||||
$this->canRegenerateStorageInvoice = $canRegenerateStorageInvoice;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canRegenerateStorageInvoice->passes();
|
||||
|
||||
$invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]);
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
$invoice->documents()->delete();
|
||||
}
|
||||
|
||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true);
|
||||
Log::info(Auth::user()->email." regenerate storage invoice for transaction with id ".$request->route('invoice_id'));
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanWaiveTransaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WaiveTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Waive Transaction',
|
||||
'message' => 'You have successfully waived the transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionIsWaived */
|
||||
private $updatesTransactionIsWaived;
|
||||
|
||||
/** @var CanWaiveTransaction */
|
||||
private $canWaiveTransaction;
|
||||
|
||||
|
||||
/**
|
||||
* WaiveTransactionLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
||||
* @param CanWaiveTransaction $canWaiveTransaction
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionIsWaived $updatesTransactionIsWaived, CanWaiveTransaction $canWaiveTransaction)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
||||
$this->canWaiveTransaction = $canWaiveTransaction;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type, $transaction->status);
|
||||
$this->canWaiveTransaction->passes($object);
|
||||
|
||||
$this->updatesTransactionIsWaived->execute($transaction);
|
||||
Log::info(Auth::user()->email." waive storage invoice charges with bill_no: ".$transaction->bill_no);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WaiveTransactionObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/** @var string */
|
||||
private $billNo;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
public function __construct(int $id, string $billNo, int $type, int $status)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->billNo = $billNo;
|
||||
$this->type = $type;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillNo(): string
|
||||
{
|
||||
return $this->billNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
+101
-29
@@ -24,7 +24,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Http\Resources\TransactionWithStorageResource;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
@@ -99,33 +99,38 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
return $this->executeOrder($order);
|
||||
}
|
||||
|
||||
public function executeOrder(Order $order, bool $isBackDoorCheck = false){
|
||||
public function executeOrder(Order $order){
|
||||
$results = [];
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$is_credit_term = $order->companyModule->inviters()->withPivot('is_credit_term')->first()->pivot->is_credit_term;
|
||||
if(!$is_credit_term){
|
||||
Log::channel('storage_invoices')->info('orderId: '.$order->id.', orderReference: '.$order->reference.', marking: '.$marking.', is_credit_term: '.$is_credit_term);
|
||||
$packingLists = $order->destinationWarehousePackages;
|
||||
Log::channel('storage_invoices')->info('orderId: '.$order->id.', orderReference: '.$order->reference.', marking: '.$marking.', is_credit_term: '.$is_credit_term);
|
||||
$packingLists = $order->destinationWarehousePackages;
|
||||
|
||||
foreach ($packingLists as $packingList){
|
||||
$arrivalDateAtChinaWarehouse = $this->getArrivalDateAtChinaWarehoue($packingList);
|
||||
Log::channel('storage_invoices')->info('arrivalDateAtChinaWarehouse: '.json_encode($arrivalDateAtChinaWarehouse));
|
||||
Log::channel('storage_invoices')->info('destinationWarehousePackage: '.json_encode($packingList));
|
||||
$eta = $this->getEtaFromPackingList($packingList);
|
||||
if($arrivalDateAtChinaWarehouse && $eta){
|
||||
$transactions = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
// $transactions = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->where('transactions.status', ApprovalStatus::APPROVED)->get();
|
||||
foreach ($packingLists as $packingList){
|
||||
$arrivalDateAtChinaWarehouse = $this->getArrivalDateAtChinaWarehoue($packingList);
|
||||
Log::channel('storage_invoices')->info('arrivalDateAtChinaWarehouse: '.json_encode($arrivalDateAtChinaWarehouse));
|
||||
Log::channel('storage_invoices')->info('destinationWarehousePackage: '.json_encode($packingList));
|
||||
$eta = $this->getEtaFromPackingList($packingList);
|
||||
if($arrivalDateAtChinaWarehouse && $eta){
|
||||
$transactions = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
// $transactions = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->where('transactions.status', ApprovalStatus::APPROVED)->get();
|
||||
|
||||
/** @var Transaction $invoice_transaction */
|
||||
foreach ($transactions as $invoice_transaction){
|
||||
$result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta, $isBackDoorCheck);
|
||||
if($result){
|
||||
$results[] = $result;
|
||||
}
|
||||
/** @var Transaction $invoice_transaction */
|
||||
foreach ($transactions as $invoice_transaction){
|
||||
$result = null;
|
||||
if(!$is_credit_term){
|
||||
$result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta);
|
||||
}
|
||||
else{
|
||||
$result = $this->isPaidOrWaivedStorageInvoiceExist($invoice_transaction, $packingList, $eta);
|
||||
}
|
||||
if($result){
|
||||
$results[] = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -167,7 +172,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
return null;
|
||||
}
|
||||
|
||||
private function processSingleTransactionOfTypeShippingInvoice($transaction, $destinationWarehousePackage, $company_module_id, $eta, $isBackDoorCheck){
|
||||
private function processSingleTransactionOfTypeShippingInvoice($transaction, $destinationWarehousePackage, $company_module_id, $eta){
|
||||
$pricePerCBM = 3;
|
||||
$resultNumberOfDaysFree = 10;
|
||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
||||
@@ -200,6 +205,11 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$this->createStorageInvoiceTransactionDetails($storageInvoice, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded);
|
||||
}
|
||||
else if($storageInvoice){
|
||||
//Additional handling for giving selected storage invoice a waiver
|
||||
if(isset($storageInvoice->is_waived) && $storageInvoice->is_waived){
|
||||
$pricePerCBM = 0;
|
||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
||||
}
|
||||
|
||||
//Additional handling for calculation of numberOfDaysExceeded in the event of the storage already paid
|
||||
$paymentStorageTransaction = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::APPROVED)->first();
|
||||
@@ -216,19 +226,26 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
Log::channel('storage_invoices')->info('Update $transaction->id: '.$transaction->id);
|
||||
Log::channel('storage_invoices')->info('$storageInvoice->status: '.$storageInvoice->status);
|
||||
Log::channel('storage_invoices')->info('price_cbm: '.$price_cbm."-".gettype($price_cbm));
|
||||
Log::channel('storage_invoices')->info('amount: '.$amount);
|
||||
|
||||
$proceedToUpdate = false;
|
||||
|
||||
if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED){
|
||||
$paymentTransactions = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
||||
|
||||
if(!$isBackDoorCheck){
|
||||
if(count($paymentTransactions) > 0){
|
||||
$this->updatePaymentTransactionViaNonGroupPayment($paymentTransactions);
|
||||
}
|
||||
else{
|
||||
$this->updatePaymentTransactionViaGroupPayment($storageInvoice);
|
||||
}
|
||||
// if(!$isBackDoorCheck){
|
||||
if(count($paymentTransactions) > 0){
|
||||
$this->updatePaymentTransactionViaNonGroupPayment($paymentTransactions);
|
||||
}
|
||||
else{
|
||||
$this->updatePaymentTransactionViaGroupPayment($storageInvoice);
|
||||
}
|
||||
//}
|
||||
|
||||
$proceedToUpdate = true;
|
||||
}
|
||||
|
||||
if($proceedToUpdate || ($pricePerCBM == 0 && $amount != 0)){
|
||||
Log::channel('storage_invoices')->info('proceedToUpdate');
|
||||
$storageInvoice = $this->updateStorageInvoiceTransaction($storageInvoice, $price_cbm);
|
||||
$invoiceTransactionDetails = $storageInvoice->transactionDetails()->first();
|
||||
$this->updateStorageInvoiceTransactionDetails($invoiceTransactionDetails, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded);
|
||||
@@ -247,13 +264,68 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
'currentDate' => $resultCurrentDate,
|
||||
'cbm' => $cbm,
|
||||
'pricePerCBM' => $pricePerCBM,
|
||||
'storageInvoice' => new TransactionResource($storageInvoice)
|
||||
'storageInvoice' => new TransactionWithStorageResource($storageInvoice)
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function isPaidOrWaivedStorageInvoiceExist($transaction, $packingList, $eta){
|
||||
$pricePerCBM = 3;
|
||||
$resultNumberOfDaysFree = 10;
|
||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
||||
$resultStartDate = $dt1->format('Y-m-d');
|
||||
$currentDatetime = Carbon::now();
|
||||
$dt2 = $currentDatetime->copy()->addDay()->startOfDay();
|
||||
$resultCurrentDate = $dt2->format('Y-m-d H:i:s');
|
||||
$interval = Carbon::parse($dt2)->diff($dt1);
|
||||
$resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree;
|
||||
$paidStorageInvoice = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('transactions.status', [ApprovalStatus::COMPLETED])->first();
|
||||
if($paidStorageInvoice){
|
||||
$storageInvoice = $paidStorageInvoice;
|
||||
}
|
||||
else{
|
||||
$waivedStorageInvoice = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->where('transactions.is_waived', 1)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->first();
|
||||
$storageInvoice = $waivedStorageInvoice;
|
||||
}
|
||||
|
||||
if($storageInvoice){
|
||||
$storageInvoiceId = $storageInvoice->id;
|
||||
|
||||
if(isset($storageInvoice->is_waived) && $storageInvoice->is_waived){
|
||||
$pricePerCBM = 0;
|
||||
}
|
||||
|
||||
$transactionDetailsItems = $transaction->transactionDetails()->get();
|
||||
$cbm = 0.00;
|
||||
foreach ($transactionDetailsItems as $tdItem){
|
||||
$quantity = $tdItem->quantity;
|
||||
if($tdItem->price < 0.00){
|
||||
$quantity = $quantity * -1;
|
||||
}
|
||||
$cbm = $cbm + $quantity;
|
||||
}
|
||||
|
||||
if($storageInvoiceId !== 0){
|
||||
$result = [
|
||||
'parentInvoiceId' => $transaction->id,
|
||||
'storageInvoiceId' => $storageInvoiceId,
|
||||
'numberOfDaysExceeded' => $resultNumberOfDaysExceeded,
|
||||
'numberOfDaysFree' => $resultNumberOfDaysFree,
|
||||
'startDate' => $resultStartDate,
|
||||
'currentDate' => $resultCurrentDate,
|
||||
'cbm' => $cbm,
|
||||
'pricePerCBM' => $pricePerCBM,
|
||||
'storageInvoice' => new TransactionWithStorageResource($storageInvoice)
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function updatePaymentTransactionViaGroupPayment($storageInvoice){
|
||||
Log::channel('storage_invoices')->info('updatePaymentTransactionViaGroupPayment');
|
||||
$groups = $storageInvoice->groups()->get();
|
||||
|
||||
@@ -85,7 +85,7 @@ class CreatePaymentTransactionProcessor
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $invoice, $payment_method, $bank_code)
|
||||
public function execute(Transaction $invoice, $payment_method, $bank_code, $run = true)
|
||||
{
|
||||
$amount = $invoice->amount;
|
||||
Log::info($invoice->owner);
|
||||
@@ -127,22 +127,26 @@ class CreatePaymentTransactionProcessor
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
// $packingList = $invoice->owner;
|
||||
// $order = $packingList->owner;
|
||||
// $packingList->status = ApprovalStatus::APPROVED;
|
||||
// $packingList->save();
|
||||
if($run)
|
||||
{
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
// if(app()->environment('production')){
|
||||
// $this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
// $this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
// }
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
// later use this variabke to create a approved payment transaction
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
// $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
if($run){
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
|
||||
class CreateStorageInvoiceDocTransactionFixProcessor
|
||||
{
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
|
||||
/**
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
/** @var Transaction $invoice_transaction */
|
||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED])->first();
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::STORAGE_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'storage_invoice'
|
||||
);
|
||||
|
||||
// $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first();
|
||||
// if(!$invouce_transaction_document){
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
// $user = $packingList->owner->companyModule->employees()->first();
|
||||
// if(app()->environment(['production'])) {
|
||||
// $user->notify(new InvoiceIssuedEmail($user, $packingList));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ReleaseGoodsToCustomerProcessor
|
||||
{
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor;
|
||||
|
||||
/** @var CreateStorageInvoiceDocTransactionProcessor */
|
||||
private $createStorageInvoiceDocTransactionProcessor;
|
||||
|
||||
/**
|
||||
* ReleaseGoodsToCustomerProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param CreateStorageInvoiceDocTransactionProcessor $createStorageInvoiceDocTransactionProcessor
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, CreateStorageInvoiceDocTransactionProcessor $createStorageInvoiceDocTransactionProcessor)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $packingList
|
||||
* @param $invoice
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($packingList, $invoice = null)
|
||||
{
|
||||
$result = false;
|
||||
$totalInvoicesAmountPaid = 0.00;
|
||||
$totalInvoicesAmount = 0.00;
|
||||
$invoiceTransactions = $packingList->transactions()->where('status', [ApprovalStatus::APPROVED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
|
||||
//Part 1: Process each single invoice type and get the total of all invoices
|
||||
foreach($invoiceTransactions as $invoiceTransaction){
|
||||
|
||||
$totalInvoiceAmountPaid = $invoiceTransaction->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
if ($invoice && $invoice->type == $invoiceTransaction->type) {
|
||||
if(($invoice->amount - $totalInvoiceAmountPaid) < 0.01){
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
if($invoice->type == TransactionType::STORAGE_INVOICE){
|
||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totalInvoicesAmount = $totalInvoicesAmount + $invoiceTransaction->amount;
|
||||
$totalInvoicesAmountPaid = $totalInvoicesAmountPaid + $totalInvoiceAmountPaid;
|
||||
}
|
||||
|
||||
Log::channel('storage_invoices')->info('Total invoice amount paid 1: '.$totalInvoicesAmount); //cief todo: to be removed
|
||||
Log::channel('storage_invoices')->info('Total invoice amount paid 2: '.$totalInvoicesAmountPaid); //cief todo: to be removed
|
||||
|
||||
//Part 2: Based on the collected info for all the total of all invoices
|
||||
if (($totalInvoicesAmount - $totalInvoicesAmountPaid) < 0.01 && $totalInvoicesAmountPaid > 0.01) {
|
||||
Log::channel('storage_invoices')->info('Total invoice amount paid 3: '.$totalInvoicesAmountPaid); //cief todo: to be removed
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if (app()->environment('production')) {
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
$result = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class UpdatesTransactionIsWaived extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Transaction $model
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $model)
|
||||
{
|
||||
$model->is_waived = 1;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class CanRegenerateStorageInvoice extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
$user = Auth()->user();
|
||||
if($user){
|
||||
$roleToCheck = Auth()->user()->type;
|
||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
||||
use App\Classes\Modules\Transactions\Standards\Validators\WaiveTransactionValidation;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class CanWaiveTransaction extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WaiveTransactionValidation */
|
||||
private $waiveTransactionValidation;
|
||||
|
||||
|
||||
public function __construct(WaiveTransactionValidation $waiveTransactionValidation)
|
||||
{
|
||||
$this->waiveTransactionValidation = $waiveTransactionValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
$user = Auth()->user();
|
||||
if($user){
|
||||
$roleToCheck = Auth()->user()->type;
|
||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WaiveTransactionObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->waiveTransactionValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Standards\Validators;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
class WaiveTransactionValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
/**
|
||||
* @param WaiveTransactionObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'id' => $object->getId(),
|
||||
'billNo' => $object->getBillNo(),
|
||||
'type' => $object->getType(),
|
||||
'status' => $object->getStatus(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'id' => 'required',
|
||||
'type' => ['required', 'numeric', 'in:'.TransactionType::STORAGE_INVOICE], //Only storage invoice (type 16) can be waived
|
||||
'status' => ['required', 'numeric', 'in:'.ApprovalStatus::APPROVED], //Approve storage invoice only, paid invoice stricly forbidden
|
||||
// 'billNo' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Notifications;
|
||||
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class PermitsReminderEmail extends AbstractEmail
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
private $reminders;
|
||||
|
||||
/**
|
||||
* SendResetPasswordEmail constructor.
|
||||
* @param User $user
|
||||
* @param PasswordReset $attempt
|
||||
*/
|
||||
public function __construct(User $user, $reminders)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->reminders = $reminders;
|
||||
}
|
||||
|
||||
public function toMail()
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject('Permits Renew Remidner Email')
|
||||
->view('emails.reminder.permits_reminder', ['user' => $this->user, 'reminders' => $this->reminders]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FixGroupPaymentProblem extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'fix-group-payment-problem';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This is a one time data patch for a problem result from Storage Invoice Implementation';
|
||||
|
||||
/** @var FetchesGroup */
|
||||
private $fetchesGroup;
|
||||
|
||||
/** @var ReleaseGoodsToCustomerProcessor */
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var CreateStorageInvoiceDocTransactionFixProcessor */
|
||||
private $createStorageInvoiceDocTransactionProcessor;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, FetchesOrder $fetchesOrder, CreateStorageInvoiceDocTransactionFixProcessor $createStorageInvoiceDocTransactionProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->fetchesGroup = $fetchesGroup;
|
||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ': Start data patch.');
|
||||
$start = new Carbon();
|
||||
|
||||
/*
|
||||
$group = $this->fetchesGroup->execute(['id' => 325]);
|
||||
$this->info('FixGroupPaymentProblem group: '.json_encode($group));
|
||||
if ($group) {
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->info('FixGroupPaymentProblem group: '.json_encode($invoice));
|
||||
$pL = $invoice->owner;
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$order = $this->fetchesOrder->execute(['reference' => '729251424']);
|
||||
$packingLists = $order->destinationWarehousePackages;
|
||||
|
||||
foreach ($packingLists as $packingList){
|
||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true);
|
||||
dd(json_encode($packingList));
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ': Done data patch. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class OneTimeTransactionFixBillplzFailedCallback extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'one-time-transaction-fix-billplz-failed-callback';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This is a one time fix billplz failed callback for transaction with id 15205';
|
||||
|
||||
protected $output = null;
|
||||
|
||||
protected $outputArray = [];
|
||||
|
||||
/** @var CallbackBillplzProcessor */
|
||||
private $callbackBillplzProcessor;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CallbackBillplzProcessor $callbackBillplzProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->outputArray = [];
|
||||
$start = new Carbon();
|
||||
|
||||
//This transaction, 15205 has approve payment but not its owner, shipping invoice
|
||||
$transaction = Transaction::whereIn('id', [15205])->first();
|
||||
$this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron started.');
|
||||
|
||||
if($transaction && $transaction->id == 15205){
|
||||
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
$this->callbackBillplzProcessor->execute($transaction, $status);
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
$this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron ended. ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Notifications\PermitsReminderEmail;
|
||||
use App\Models\PermitsReminder;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendPermitsReminderEmails extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'permitsReminder:send';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send Permits Reminders Email';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$currentDateTime = now();
|
||||
$startRange = $currentDateTime->subDays(3)->startOfDay();
|
||||
$endRange = $currentDateTime->copy()->addDays(6)->endOfDay();
|
||||
|
||||
$reminders = PermitsReminder::whereDate('reminder_date', '>=', $startRange)
|
||||
->whereDate('reminder_date', '<=', $endRange)
|
||||
->orWhere('reminder_date', '<', now())
|
||||
->pluck('model');
|
||||
|
||||
if ($reminders->isEmpty()) {
|
||||
$this->info('No reminders expiring within the specified range.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->info($this->getTimeStamp() . 'Reminders: ' . $reminders->toJson());
|
||||
|
||||
$users = User::whereIn('email', $this->getEmailList())->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$this->info($this->getTimeStamp() . 'Reminder email sent to ' . $user->email);
|
||||
if (app()->environment('production')) {
|
||||
$user->notify(new PermitsReminderEmail($user, $reminders));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTimeStamp()
|
||||
{
|
||||
return '[' . Carbon::now()->format('Y-m-d H:i:s') . '] - ';
|
||||
}
|
||||
|
||||
protected function getEmailList(): array
|
||||
{
|
||||
return [
|
||||
'edmond.wuiming2021@gmail.com',
|
||||
'anithagurl96@gmail.com'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,12 @@ class Kernel extends ConsoleKernel
|
||||
->dailyAt('0:01')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path().'/logs/check_storage_invoices.log');
|
||||
|
||||
//cief todo: command version 2
|
||||
$schedule->command('permitsReminder:send')
|
||||
->dailyAt('09:30')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path().'/logs/permits-reminder-send.log');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyCreditTermStatusLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyCreditTermStatusController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyCreditTermStatusLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCompanyCreditTermStatusLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\GenericImport;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\PermitsReminder;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
class ImportPermitsReminderController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
$file = json_decode($object->getFiles()[0])->file_info->original->file;
|
||||
$file = storage_path('app/documents/' . $file);
|
||||
|
||||
$import = new GenericImport();
|
||||
Excel::import($import, $file);
|
||||
$excelRows = $import->rows->toArray();
|
||||
$successRows = [];
|
||||
$returnArray = []; // Initialize the return array
|
||||
|
||||
foreach ($excelRows as $row) {
|
||||
if (is_null($row['expiry_date']) && is_null($row['reminder_date'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row['expiry_date'] = $this->changeExcelDate($row['expiry_date']);
|
||||
$row['reminder_date'] = $this->changeExcelDate($row['reminder_date']);
|
||||
|
||||
$validator = Validator::make($row, [
|
||||
'model' => 'required|unique:permits_reminders,model',
|
||||
'expiry_date' => 'required|date|after_or_equal:today',
|
||||
'reminder_date' => 'required|date|after_or_equal:today',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$row['status'] = 'failed';
|
||||
$row['message'] = $validator->errors()->all();
|
||||
|
||||
$returnArray[] = $row;
|
||||
} else {
|
||||
$row['created_at'] = Carbon::now();
|
||||
$row['updated_at'] = Carbon::now();
|
||||
$successRows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($successRows)) {
|
||||
PermitsReminder::insert($successRows); // Insert only if there are successful rows
|
||||
}
|
||||
|
||||
$successCount = count($successRows);
|
||||
|
||||
return response()->json([
|
||||
'completedRows' => $successCount,
|
||||
'failedRows' => count($returnArray),
|
||||
'remark' => "Successful Imported {$successCount} data.",
|
||||
'data' => $returnArray
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeExcelDate($date)
|
||||
{
|
||||
$formatedDate = DateTime::createFromFormat('d/m/Y', $date);
|
||||
if ($formatedDate instanceof DateTime) {
|
||||
return $formatedDate->format('Y-m-d');
|
||||
}
|
||||
|
||||
$unixTime = (($date - 25569) * 86400);
|
||||
|
||||
return (new DateTime("@$unixTime"))->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PermitsReminder;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Models\PermitsReminder;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class CreatePermitsReminderController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request): JsonResponse
|
||||
{
|
||||
// Define validation rules
|
||||
$rules = [
|
||||
'model' => 'required|unique:permits_reminders,model',
|
||||
'expiry_date' => 'required|date|after_or_equal:today',
|
||||
'reminder_date' => 'required|date|after_or_equal:today',
|
||||
];
|
||||
|
||||
// Perform validation
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
$validationError = implode("<br>", $validationErrors);
|
||||
|
||||
// Return validation error response
|
||||
return response()->json([
|
||||
'title' => 'Create Permits Reminder Failed',
|
||||
'message' => $validationError,
|
||||
"payload" => []
|
||||
], 422); // 422 Unprocessable Entity status code for validation errors
|
||||
}
|
||||
|
||||
// If validation passes, create the record
|
||||
$record = PermitsReminder::create([
|
||||
'expiry_date' => Carbon::parse($request->input('expiry_date'))->format('Y-m-d'),
|
||||
'reminder_date' => Carbon::parse($request->input('reminder_date'))->format('Y-m-d'),
|
||||
'model' => $request->input('model'),
|
||||
]);
|
||||
|
||||
$response = [
|
||||
"title" => "Create Permits Reminder Successful",
|
||||
"message" => "You have successfully created a Permits Reminder",
|
||||
"payload" => [
|
||||
"data" => $record
|
||||
]
|
||||
];
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PermitsReminder;
|
||||
|
||||
use App\Models\PermitsReminder;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeletePermitsReminderController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request): JsonResponse
|
||||
{
|
||||
$record = PermitsReminder::find($request->route('id'));
|
||||
$record->delete();
|
||||
|
||||
$response = [
|
||||
"title" => "Delete Permits Reminder Successful",
|
||||
"message" => "You have successfully deleted a Permits Reminder",
|
||||
"payload" => []
|
||||
];
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PermitsReminder;
|
||||
|
||||
use App\Models\PermitsReminder;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListPermitsReminderController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request): JsonResponse
|
||||
{
|
||||
$perPage = 10; // Number of items per page
|
||||
$page = $request->query('page', 1); // Get the current page from the request
|
||||
|
||||
// Paginate the PermitsReminder model
|
||||
$paginator = PermitsReminder::orderBy('reminder_date')->paginate($perPage, ['*'], 'page', $page);
|
||||
|
||||
// Get current date and time
|
||||
$currentDateTime = now();
|
||||
|
||||
// Define date range
|
||||
$startRange = $currentDateTime->subDays(3)->startOfDay();
|
||||
$endRange = $currentDateTime->copy()->addDays(6)->endOfDay();
|
||||
|
||||
// Process paginated items
|
||||
$data = $paginator->items();
|
||||
foreach ($data as &$item) {
|
||||
// Check if the reminder_date is within the date range or after the current date
|
||||
$reminderDate = Carbon::parse($item->reminder_date);
|
||||
$item->show_remind = $reminderDate->between($startRange, $endRange) || $reminderDate->isBefore($currentDateTime);
|
||||
}
|
||||
|
||||
// Create pagination links
|
||||
$links = [
|
||||
"first" => $paginator->url(1),
|
||||
"last" => $paginator->url($paginator->lastPage()),
|
||||
"prev" => $paginator->previousPageUrl(),
|
||||
"next" => $paginator->nextPageUrl(),
|
||||
];
|
||||
|
||||
// Prepare response
|
||||
$response = [
|
||||
"title" => "List Permits Reminder",
|
||||
"message" => "You have successfully retrieved a list of Permits Reminder",
|
||||
"payload" => [
|
||||
'data' => $data,
|
||||
"links" => $links,
|
||||
"meta" => [
|
||||
"current_page" => $paginator->currentPage(),
|
||||
"from" => $paginator->firstItem(),
|
||||
"last_page" => $paginator->lastPage(),
|
||||
"path" => $request->path(),
|
||||
"per_page" => $paginator->perPage(),
|
||||
"to" => $paginator->lastItem(),
|
||||
"total" => $paginator->total(),
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PermitsReminder;
|
||||
|
||||
use App\Models\PermitsReminder;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class UpdatePermitsReminderController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request): JsonResponse
|
||||
{
|
||||
$rules = [
|
||||
'model' => 'required|unique:permits_reminders,model,' . $request->route('id'),
|
||||
'expiry_date' => 'required|date|after_or_equal:today',
|
||||
'reminder_date' => 'required|date|after_or_equal:today',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
$validationError = implode("<br>", $validationErrors);
|
||||
|
||||
return response()->json([
|
||||
'title' => 'Update Permits Reminder Failed',
|
||||
'message' => $validationError,
|
||||
"payload" => []
|
||||
], 422);
|
||||
}
|
||||
|
||||
$record = PermitsReminder::findOrFail($request->route('id'));
|
||||
|
||||
$record->model = $request->input('model');
|
||||
$record->expiry_date = Carbon::parse($request->input('expiry_date'))->format('Y-m-d');
|
||||
$record->reminder_date = Carbon::parse($request->input('reminder_date'))->format('Y-m-d');
|
||||
$record->save();
|
||||
|
||||
return response()->json([
|
||||
'title' => 'Permits Reminder Updated',
|
||||
'message' => 'The permits reminder has been successfully updated.',
|
||||
"payload" => $record
|
||||
]);
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\RegenerateSingleStorageInvoiceTransactionLogic;
|
||||
|
||||
|
||||
class RegenerateSingleStorageInvoiceTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RegenerateShippingInvoiceTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function regenerate(Request $request, RegenerateSingleStorageInvoiceTransactionLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\WaiveTransactionLogic;
|
||||
|
||||
|
||||
class WaiveTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param WaiveTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function waive(Request $request, WaiveTransactionLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -73,5 +73,6 @@ class Kernel extends HttpKernel
|
||||
'storage.invoice.check.byorder' => \App\Http\Middleware\CheckForStorageInvoiceByOrderId::class,
|
||||
'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class,
|
||||
'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class,
|
||||
'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -29,7 +29,12 @@ class CheckForStorageInvoiceByOrderId
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$orderId = $request->route('id');
|
||||
$storages = $this->storageInvoiceTransactionProcessor->execute($orderId);
|
||||
$storages = [];
|
||||
try{
|
||||
$storages = $this->storageInvoiceTransactionProcessor->execute($orderId);
|
||||
} catch (\Exception $exception) {
|
||||
$storages = [];
|
||||
}
|
||||
$request->merge(['storages' => $storages]);
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CheckForStorageInvoiceByPackingLists
|
||||
{
|
||||
|
||||
/** @var CheckStorageInvoiceTransactionProcessor */
|
||||
private $storageInvoiceTransactionProcessor;
|
||||
|
||||
/** @var ListsPackingLists */
|
||||
private $listsPackingLists;
|
||||
|
||||
|
||||
public function __construct(CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor, ListsPackingLists $listsPackingLists)
|
||||
{
|
||||
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
||||
$this->listsPackingLists = $listsPackingLists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$results = [];
|
||||
$packinglists = null;
|
||||
|
||||
$filters = json_decode($request->input('filters'), true);
|
||||
// $filters['type_in'] = [TransactionType::SHIPPING_INVOICE];
|
||||
// if(json_encode($filters['order_by']) == '{"column":"id","DESC":true}'){
|
||||
// $filters['order_by_id_desc'] = true;
|
||||
// }
|
||||
|
||||
if(isset($filters['check_for_storage_invoice'])){
|
||||
unset($filters['order_by']);
|
||||
$packinglists = $this->listsPackingLists->execute($filters);
|
||||
foreach($packinglists as $packingList){
|
||||
if($packingList){
|
||||
$order = $packingList->owner()->first();
|
||||
if($order instanceof Order){
|
||||
$storages = $this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||
if($storages){
|
||||
$results = array_merge($results, $storages);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$request->merge(['storages' => $results]);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class CompanyResource extends JsonResource
|
||||
{
|
||||
$companyModule = $this->companyModules()->first();
|
||||
$companyTypeArray = CompanyType::COMPANY_TYPE_ID;
|
||||
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'hash_id' => Crypt::encryptString($this->id),
|
||||
@@ -33,6 +33,7 @@ class CompanyResource extends JsonResource
|
||||
'business_type' => (int) $this->business_type,
|
||||
'status' => (int) $this->status,
|
||||
'segments' => SegmentResource::collection($companyModule->connections()->first()->segments),
|
||||
'is_credit_term' => $companyModule->connections()->first()->is_credit_term,
|
||||
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
||||
'employee' => new UserResource($companyModule->employees()->first()),
|
||||
'company_module' => new CompanyModuleResource($companyModule),
|
||||
|
||||
@@ -23,17 +23,25 @@ class ContainerResource extends JsonResource
|
||||
'container_specification' => ContainerTypes::CONTAINER_SPECIFICATION[$this->container_type],
|
||||
'container_number' => $this->container_number,
|
||||
'seal_reference' => $this->seal_reference,
|
||||
'loading_date' => $this->loading_date ? $this->loading_date->format('d-m-Y') : $this->loading_date,
|
||||
'loading_date' => optional($this->loading_date)->format('d-m-Y'),
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'packages_count' => $this->packages()->where('packages.type', '!=', 2)->sum('quantity'),
|
||||
'total_cbm' => $this->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity')),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'status' => $this->status,
|
||||
'packing_lists' => $this->whenLoaded('packingLists', PackingListResource::collection($this->whenLoaded('packingLists', function(){
|
||||
return $this->packingLists()->get()->sortBy(function ($packingList) {
|
||||
return $packingList->owner->company_module_id;
|
||||
});
|
||||
})))
|
||||
'packing_lists' => $this->shouldIncludePackingListData($request) ? $this->getSortedPackingLists() : null,
|
||||
];
|
||||
}
|
||||
|
||||
protected function shouldIncludePackingListData($request)
|
||||
{
|
||||
return (isset($request->all()['with_packing_list_data']) && ($request->all()['with_packing_list_data'] == false)) ? false : true;
|
||||
}
|
||||
|
||||
protected function getSortedPackingLists()
|
||||
{
|
||||
return $this->whenLoaded('packingLists', PackingListResource::collection(
|
||||
$this->packingLists()->get()->sortBy(fn ($packingList) => $packingList->owner->company_module_id)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -17,6 +18,8 @@ class GroupForOrderV2Resource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$payment_transaction = Transaction::where('payment_reference', $this->reference)->first();
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'original_amount' => (float) $this->original_amount,
|
||||
@@ -33,7 +36,12 @@ class GroupForOrderV2Resource extends JsonResource
|
||||
'payment_method' => (int)$this->payment_method,
|
||||
'payment_method_name' => ucwords(PaymentMethodType::PAYMENT_METHODS_ID[$this->payment_method]),
|
||||
'payment_reference' => $this->reference,
|
||||
'transactions_ids' => GroupTransactionsForOrderV2Resource::collection($this->groupTransactions)
|
||||
'transactions_ids' => GroupTransactionsForOrderV2Resource::collection($this->groupTransactions),
|
||||
'payment_transaction' => $payment_transaction ? [
|
||||
'id' => $payment_transaction->id,
|
||||
'status' => $payment_transaction->status,
|
||||
'status_name' => ApprovalStatus::APPROVAL_STATUS_ID[$payment_transaction->status]
|
||||
] : []
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\V2\PackingListV2Resource;
|
||||
|
||||
class ListPackingListDetailsJobResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$exceptionUsers = in_array($this->userInfo ? $this->userInfo->type : Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
|
||||
$packages = !$this->packingLists()->exists() || $exceptionUsers ? $this->packages : $this->packingLists->first()->packages;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'claimant_id' => $this->claimant_id,
|
||||
'reference' => $this->reference,
|
||||
'status' => $this->status,
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'type' => $this->type,
|
||||
'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)),
|
||||
// 'packages' => PackageResource::collection($packages),
|
||||
// $this->mergeWhen($this->owner instanceof Order, [
|
||||
// 'order' => New OrderResource($this->owner)
|
||||
// ]),
|
||||
'container' => new ContainerResource($this->containers->first()),
|
||||
'packages' => PackageWithoutOrderResource::collection($packages),
|
||||
$this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]),
|
||||
'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
|
||||
'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
|
||||
// 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,14 @@ class ListPackingListJobResource extends JsonResource
|
||||
'status' => $this->status,
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'type' => $this->type,
|
||||
'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)),
|
||||
'packages' => PackageResource::collection($packages),
|
||||
$this->mergeWhen($this->owner instanceof Order, [
|
||||
'order' => New OrderResource($this->owner)
|
||||
]),
|
||||
// 'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)),
|
||||
// 'packages' => PackageResource::collection($packages),
|
||||
// $this->mergeWhen($this->owner instanceof Order, [
|
||||
// 'order' => New OrderResource($this->owner)
|
||||
// ]),
|
||||
'container' => new ContainerResource($this->containers->first()),
|
||||
'packages' => PackageWithoutOrderResource::collection($packages),
|
||||
$this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]),
|
||||
'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
|
||||
'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
|
||||
// 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ListPackingListJobWithStorageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$exceptionUsers = in_array($this->userInfo ? $this->userInfo->type : Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
|
||||
$packages = !$this->packingLists()->exists() || $exceptionUsers ? $this->packages : $this->packingLists->first()->packages;
|
||||
$shippingTransaction = $this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first();
|
||||
$transactions = $this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
$storages = [];
|
||||
|
||||
if($this->storages){
|
||||
$transactionId = $shippingTransaction->id;
|
||||
$filteredStorages = array_filter($this->storages, function ($storage) use ($transactionId) {
|
||||
return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId;
|
||||
});
|
||||
$storages = $filteredStorages;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'claimant_id' => $this->claimant_id,
|
||||
'reference' => $this->reference,
|
||||
'status' => $this->status,
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'type' => $this->type,
|
||||
// 'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)),
|
||||
// 'packages' => PackageResource::collection($packages),
|
||||
// $this->mergeWhen($this->owner instanceof Order, [
|
||||
// 'order' => New OrderResource($this->owner)
|
||||
// ]),
|
||||
'container' => new ContainerResource($this->containers->first()),
|
||||
'packages' => PackageWithoutOrderResource::collection($packages),
|
||||
$this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]),
|
||||
'shipping_transaction' => count($storages) == 0 ? new TransactionWithStorageResource($shippingTransaction): null,
|
||||
'storages' => $storages,
|
||||
'invoices' => TransactionWithStorageResource::collection($transactions),
|
||||
'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
|
||||
// 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ class MappableTransactionResource extends JsonResource
|
||||
'owner_type' => Transaction::class,
|
||||
'owner_id'=> $this->id,
|
||||
'owner_reference'=> $reference,
|
||||
'created_at'=> $this->created_at, // invoice date
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,16 +27,19 @@ class MappableTransactionWithDetailsResource extends JsonResource
|
||||
'order_reference' => null,
|
||||
'bill_no' => null,
|
||||
'marking' => null,
|
||||
'created_at' => null
|
||||
];
|
||||
|
||||
if ($this->type === TransactionType::PAYMENT) {
|
||||
$order = $this->owner->owner->owner;
|
||||
$data['order_reference'] = $order->reference;
|
||||
$data['debtor_code'] = $order->companyModule->company->debtor;
|
||||
$data['created_at'] = $this->owner->created_at; // invoice date
|
||||
} elseif (in_array($this->type, [TransactionType::GROUP_PAYMENT, TransactionType::TOP_UP])) {
|
||||
$connection = $this->owner->owner->inviters()->withPivot('invitee_reference')->first();
|
||||
$data['marking'] = $connection ? $connection->pivot->invitee_reference : '';
|
||||
$data['bill_no'] = $this->bill_no;
|
||||
$data['created_at'] = $this->created_at;
|
||||
} else {
|
||||
$payments = $this->transactions()
|
||||
->payments()->where('status', ApprovalStatus::APPROVED)
|
||||
@@ -54,6 +57,7 @@ class MappableTransactionWithDetailsResource extends JsonResource
|
||||
'type' => $payment->type,
|
||||
'marking' => null,
|
||||
'amount' => $payment->amount,
|
||||
'created_at' => $this->created_at
|
||||
];
|
||||
})->toArray();
|
||||
} else {
|
||||
@@ -61,6 +65,7 @@ class MappableTransactionWithDetailsResource extends JsonResource
|
||||
$data['amount'] = 'Transaction Type not allowed';
|
||||
$data['transaction_type'] = $this->type;
|
||||
$data['payment_transactions'] = null;
|
||||
$data['created_at'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class OrderV2Resource extends JsonResource
|
||||
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
|
||||
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
|
||||
'invoices' => $this->whenLoaded('packingLists', function() {
|
||||
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get());
|
||||
return TransactionWithStorageResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get());
|
||||
}),
|
||||
'storages' => $this->storages ? $this->storages : null, //from middleware
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PackageWithoutOrderResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'description' => $this->description,
|
||||
'width' => floatval($this->width),
|
||||
'height' => floatval($this->height),
|
||||
'length' => floatval($this->length),
|
||||
'weight' => $this->weight,
|
||||
'quantity' => $this->quantity,
|
||||
'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity,
|
||||
'reference' => $this->packingList->reference,
|
||||
'status' => $this->status,
|
||||
// $this->mergeWhen($originalPackingList->owner instanceof Order, [
|
||||
// 'order' => New OrderResource($originalPackingList->owner)
|
||||
// ]),
|
||||
// 'container' => new ContainerResource($originalPackingList->containers()->first()),
|
||||
// 'transport' => new TransportResource($originalPackingList->transports()->first())
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PackingListWithStorageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$exceptionUsers = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
|
||||
$packages = !$this->packingLists()->exists() || $exceptionUsers ? $this->packages : $this->packingLists->first()->packages;
|
||||
$shippingTransaction = $this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first();
|
||||
$transactions = $this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
$storages = [];
|
||||
|
||||
if($this->storages){
|
||||
$transactionId = $shippingTransaction->id;
|
||||
$filteredStorages = array_filter($this->storages, function ($storage) use ($transactionId) {
|
||||
return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId;
|
||||
});
|
||||
$storages = $filteredStorages;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'claimant_id' => $this->claimant_id,
|
||||
'reference' => $this->reference,
|
||||
'status' => $this->status,
|
||||
'transport' => new TransportResource($this->transports()->first()),
|
||||
'type' => $this->type,
|
||||
'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListResource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first())),
|
||||
'packages' => PackageResource::collection($packages),
|
||||
$this->mergeWhen($this->owner instanceof Order, [
|
||||
'order' => New OrderResource($this->owner)
|
||||
]),
|
||||
'shipping_transaction' => count($storages) == 0 ? new TransactionWithStorageResource($shippingTransaction): null,
|
||||
'storages' => $storages,
|
||||
'invoices' => TransactionWithStorageResource::collection($transactions),
|
||||
'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,15 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Group;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
|
||||
class TransactionResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
@@ -23,8 +24,6 @@ class TransactionResource extends JsonResource
|
||||
{
|
||||
$order = null;
|
||||
$groupTransactions = null;
|
||||
$group_payment_attempts = null;
|
||||
$group_payment_expired = null;
|
||||
|
||||
if ($this->owner instanceof Transaction) {
|
||||
if ($this->owner) {
|
||||
@@ -36,12 +35,6 @@ class TransactionResource extends JsonResource
|
||||
if ($this->owner) {
|
||||
$order = new OrderResource($this->owner->owner);
|
||||
}
|
||||
|
||||
if($this->groups){
|
||||
$group_payment_attempts = GroupForOrderV2Resource::collection($this->groups->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]));
|
||||
$group_payment_expired = GroupForOrderV2Resource::collection($this->groupsWithTrashed->whereIn('status', [ApprovalStatus::EXPIRED]));
|
||||
}
|
||||
|
||||
} else {
|
||||
$group = Group::where('reference', $this->payment_reference)->first();
|
||||
if ($group) {
|
||||
@@ -55,9 +48,7 @@ class TransactionResource extends JsonResource
|
||||
'owner_type' => $this->owner_type,
|
||||
'order' => $order,
|
||||
'group_transactions' => $groupTransactions,
|
||||
'group_reference' => $groupTransactions ? ($group ? $group->reference : null ) : null,
|
||||
'groups_payment_attempts' => $group_payment_attempts,
|
||||
'groups_payment_expired' => $group_payment_expired,
|
||||
'group_reference' => $groupTransactions ? ($group ? $group->reference : null ) : null,
|
||||
'documents' => $groupTransactions ? DocumentResource::collection($this->documents->where('status', ApprovalStatus::PENDING_VERIFICATION)) : DocumentResource::collection($this->documents),
|
||||
'type' => (int) $this->type,
|
||||
'bill_no' => $this->bill_no,
|
||||
@@ -80,11 +71,6 @@ class TransactionResource extends JsonResource
|
||||
->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
||||
->get()
|
||||
),
|
||||
'payments_expired' => TransactionResource::collection(
|
||||
$this->transactions()
|
||||
->payments()->where('status', ApprovalStatus::EXPIRED)
|
||||
->get()
|
||||
),
|
||||
'payment_history' => TransactionResource::collection(
|
||||
$this->transactions()
|
||||
->payments()
|
||||
@@ -92,7 +78,6 @@ class TransactionResource extends JsonResource
|
||||
->get()
|
||||
),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'storages' => $this->storages ? $this->storages : null, //from middleware
|
||||
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'),
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y')
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransactionWithStorageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$order = null;
|
||||
$groupTransactions = null;
|
||||
$group_payment_attempts = null;
|
||||
$groupPaymentAttemptsFiltered = [];
|
||||
$group_payment_expired = null;
|
||||
$group_payment_history = null;
|
||||
$groupTotalAmount = 0;
|
||||
|
||||
if ($this->owner instanceof Transaction) {
|
||||
if ($this->owner) {
|
||||
if ($this->owner->owner) {
|
||||
$order = new OrderResource($this->owner->owner->owner);
|
||||
}
|
||||
}
|
||||
} else if (!($this->owner instanceof Transaction) && !($this->owner instanceof Wallet)) {
|
||||
if ($this->owner) {
|
||||
$order = new OrderResource($this->owner->owner);
|
||||
}
|
||||
|
||||
if($this->groups){
|
||||
$group_payment_attempts = GroupForOrderV2Resource::collection($this->groups->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]));
|
||||
$group_payment_expired = GroupForOrderV2Resource::collection($this->groupsWithTrashed->whereIn('status', [ApprovalStatus::EXPIRED]));
|
||||
$group_payment_history = GroupForOrderV2Resource::collection($this->groups->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]));
|
||||
}
|
||||
|
||||
} else {
|
||||
$group = Group::where('reference', $this->payment_reference)->first();
|
||||
if ($group) {
|
||||
$groupTransactions = GroupTransactionResource::collection($group->groupTransactions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$ts = $this->groups->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION])->last();
|
||||
if ($ts) {
|
||||
$paymentTransaction = Transaction::where('payment_reference', $ts->reference)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
if($paymentTransaction){
|
||||
$groupTotalAmount = (double) $this->amount;
|
||||
|
||||
foreach ($group_payment_history as $key => $value) {
|
||||
if ($value->id === $ts->id && $value->reference === $ts->reference) {
|
||||
unset($group_payment_history[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($group_payment_attempts as $key => $value) {
|
||||
if ($value->id === $ts->id && $value->reference == $ts->reference) {
|
||||
$groupPaymentAttemptsFiltered[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'owner_type' => $this->owner_type,
|
||||
'order' => $order,
|
||||
'group_transactions' => $groupTransactions,
|
||||
'group_reference' => $groupTransactions ? ($group ? $group->reference : null ) : null,
|
||||
'groups_payment_attempts' => $groupPaymentAttemptsFiltered,
|
||||
'groups_payment_expired' => $group_payment_expired,
|
||||
'groups_payment_history' => $group_payment_history,
|
||||
'documents' => $groupTransactions ? DocumentResource::collection($this->documents->where('status', ApprovalStatus::PENDING_VERIFICATION)) : DocumentResource::collection($this->documents),
|
||||
'type' => (int) $this->type,
|
||||
'bill_no' => $this->bill_no,
|
||||
'amount' => (double) $this->amount,
|
||||
'payment_method' => (int) $this->payment_method,
|
||||
'payment_reference' => $this->payment_reference,
|
||||
'outstanding' => (double) $this->amount - ($this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount')),
|
||||
'floating' => $group_payment_attempts ? $groupTotalAmount : (double) $this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount'),
|
||||
'service_charge' => (double) $this->service_charge,
|
||||
'tax' => (double) $this->tax,
|
||||
'original_amount' => (double) $this->original_amount,
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'original_currency' => new CurrencyResource($this->original_currency),
|
||||
'currency_rate' => (double) $this->currency_rate,
|
||||
'status' => (int) $this->status,
|
||||
'details' => TransactionDetailResource::collection($this->transactionDetails),
|
||||
'transactions' => TransactionResource::collection($this->transactions),
|
||||
'payment_attempts' => TransactionResource::collection(
|
||||
$this->transactions()
|
||||
->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
||||
->get()
|
||||
),
|
||||
'payments_expired' => TransactionResource::collection(
|
||||
$this->transactions()
|
||||
->payments()->where('status', ApprovalStatus::EXPIRED)
|
||||
->get()
|
||||
),
|
||||
'payment_history' => TransactionResource::collection(
|
||||
$this->transactions()
|
||||
->payments()
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED])
|
||||
->get()
|
||||
),
|
||||
'remarks' => RemarkResource::collection($this->remarks),
|
||||
'storages' => $this->storages ? $this->storages : null, //from middleware
|
||||
'is_waived' => (int) $this->is_waived,
|
||||
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'),
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class PermitsReminder extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'permits_reminders';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = ['model', 'expiry_date', 'reminder_date'];
|
||||
|
||||
public function getExpiryDateAttribute($value)
|
||||
{
|
||||
return $this->attributes['expiry_date'] === null ? NULL : Carbon::parse($this->attributes['expiry_date'])->format('d-m-Y');
|
||||
}
|
||||
|
||||
public function getReminderDateAttribute($value)
|
||||
{
|
||||
return $this->attributes['reminder_date'] === null ? NULL : Carbon::parse($this->attributes['reminder_date'])->format('d-m-Y');
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute($value)
|
||||
{
|
||||
return $this->attributes['created_at'] === null ? NULL : Carbon::parse($this->attributes['created_at'])->format('d-m-Y');
|
||||
}
|
||||
}
|
||||
@@ -112,6 +112,18 @@ return [
|
||||
'path' => storage_path('logs/paymentUnknownOrderLog.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
|
||||
'vue_polling' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel_vue_plling.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
|
||||
'perfex_crm' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel_perfex_crm.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -34,6 +34,14 @@ return [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'high_priority' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'high_priority',
|
||||
'retry_after' => 3600,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePermitsRemindersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('permits_reminders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('model')->nullable();
|
||||
$table->timestamp('expiry_date')->nullable();
|
||||
$table->timestamp('reminder_date')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('permits_reminders');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIsWaivedToTransactionsLogsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('transaction_logs', function (Blueprint $table) {
|
||||
$table->boolean('is_waived')->nullable()->after('status')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('transaction_logs', function (Blueprint $table) {
|
||||
$table->dropColumn('is_waived');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIsWaivedToTransactionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->boolean('is_waived')->nullable()->after('status')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->dropColumn('is_waived');
|
||||
});
|
||||
}
|
||||
}
|
||||
Binary file not shown.
+1
-1
@@ -5,7 +5,7 @@
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h6 class="no-margin fs-12 text-black">{{item.street_one}} {{item.street_two}}, {{item.district.name}}, {{item.post_code}} {{item.state.name}}, {{item.country.name}}</h6>
|
||||
<h6 v-if="item" class="no-margin fs-12 text-black">{{item.street_one}} {{item.street_two}}, {{item.district.name}}, {{item.post_code}} {{item.state.name}}, {{item.country.name}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<change-customer-name-form-component :section="'customerProfileSection'" :data="item"></change-customer-name-form-component>
|
||||
</modal-component>
|
||||
<div class="font-heading fs-20 light">
|
||||
{{item.name}}
|
||||
{{item.name}}
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary bg-transparent" data-type="changeCustomerName" >
|
||||
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
|
||||
</div>
|
||||
@@ -35,6 +35,26 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="$store.getters.isAdmin">
|
||||
<div class="col">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto">
|
||||
<div v-if="item.is_credit_term === 1" class="font-heading fs-11 light">
|
||||
Credit term customer: YES
|
||||
</div>
|
||||
<div v-else class="font-heading fs-11 light">
|
||||
Credit term customer: NO
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary bg-transparent" data-type="changeCreditTermCustomerStatus">
|
||||
<i class="fa fa-edit pointer fa-fw fs-11 m-l-5"></i>
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeCreditTermCustomerStatus">
|
||||
<update-credit-term-status-form-component :section="'customerProfileSection'" :data="item" v-on:update="item.is_credit_term = $event.is_credit_term"></update-credit-term-status-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,13 +115,13 @@
|
||||
</div>
|
||||
<!-- <div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h6 class="no-margin fs-12">WeChat ID</h6>
|
||||
<h6 class="no-margin fs-12">WeChat ID</h6>
|
||||
<h6 class="no-margin">{{item.contact.wechat_id}}</h6>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h6 class="no-margin fs-12">Company Type </h6>
|
||||
<h6 class="no-margin fs-12">Company Type </h6>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeBusinessType">
|
||||
<change-business-type-form-component :section="'customerProfileSection'" :data="item"></change-business-type-form-component>
|
||||
</modal-component>
|
||||
@@ -216,4 +236,4 @@
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<div class="row" @keyup.enter="submitForm">
|
||||
<div class="col bg-white padding-40 b-rad-lg">
|
||||
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col text-center">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h5 class="all-caps">Update Credit Term Customer</h5>
|
||||
<div class="fs-11">Are you sure you want to update the credit term status for this company to <b>{{ data.is_credit_term === 1 ? 'NO' : 'YES' }}</b>?</div>
|
||||
<p class="fs-11 text-danger" v-if="data.is_credit_term === 0">All existing invoices for storage that have not yet been paid will be waived</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-danger w-100 btn-sm" @click="submit(route('api.company.update.creditterm.status', data.id), 'post', section, true, true)">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
methods: {
|
||||
successHandler(response){
|
||||
this.$emit('update', response.payload.data);
|
||||
this.closeModal();
|
||||
this.formHandler();
|
||||
},
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="row m-t-5">
|
||||
<div class="row m-t-5" @keyup.enter="submitForm">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.content">
|
||||
<input type="text" class="form-control fs-12" placeholder="Write your comments..." v-model.trim="parameters.content">
|
||||
@@ -42,7 +42,7 @@
|
||||
submitForm() {
|
||||
this.submit(this.data ? this.route('api.remark.update', this.data.id) : this.route('api.packing_list.container.remark.create', this.id), this.data ? 'put' : 'post', this.section, true, true);
|
||||
this.$emit('submit')
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="col bg-white padding-40 b-rad-lg">
|
||||
<div class="row m-b-10">
|
||||
<div class="col text-center">
|
||||
<p>Plese set the approximate dates of below.</p>
|
||||
<p>Please set the approximate dates of below.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -12,13 +12,13 @@
|
||||
<div class="col p-l-0 p-r-10">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.etd">
|
||||
<label class="text-primary">Etd</label>
|
||||
<date-picker-component :parameters="parameters" :value="'etd'"></date-picker-component>
|
||||
<date-picker-component v-model.lazy="parameters.etd"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col p-r-0 p-l-10">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.eta">
|
||||
<label class="text-primary">Eta</label>
|
||||
<date-picker-component :parameters="parameters" :value="'eta'"></date-picker-component>
|
||||
<date-picker-component v-model.lazy="parameters.eta"></date-picker-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -43,8 +43,8 @@
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
etd: this.etd,
|
||||
eta: this.eta,
|
||||
etd: this.data.transport.current_schedule.etd,
|
||||
eta: this.data.transport.current_schedule.eta,
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -57,4 +57,4 @@
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" v-if="container">
|
||||
<div class="col">
|
||||
<div class="row align-items-center m-t-10">
|
||||
<div class="col bg-master-lightest rounded padding-20 m-l-10 m-r-10">
|
||||
<div class="row d-flex justify-content-between align-items-center">
|
||||
<div class="col b-r">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="m-b-0 large-text normal m-b-10">Container Number</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="m-t-0 m-b-0 fs-20 bold">{{ container.container_reference }}</p>
|
||||
<p class="m-t-0 m-b-0 small-text">{{ container.container_number }}</p>
|
||||
<p class="m-t-0 m-b-0 small-text">seal number</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="fs-10 bold m-b-0">ETD</p>
|
||||
<p class="small-text m-t-0">{{ container.transport.current_schedule.etd }} <a class="b-rad-none all-caps requestModal" data-type="rescheduleDate"><i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="fs-10 bold m-b-0">ETA</p>
|
||||
<p class="small-text m-t-0">{{ container.transport.current_schedule.eta }} <a class="b-rad-none all-caps requestModal" data-type="rescheduleDate"><i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="fs-10 bold m-b-0">Location</p>
|
||||
<p class="small-text m-t-0">-tbc-</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="fs-10 bold m-b-0">Destination</p>
|
||||
<p class="small-text m-t-0">-tbc-</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="fs-10 bold m-b-0">Container Type</p>
|
||||
<p class="small-text m-t-0">{{ container.container_specification.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="fs-10 bold m-b-0">Owner</p>
|
||||
<p class="small-text m-t-0">-tbc-</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-10 m-b-50">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row h-100">
|
||||
<div class="col">
|
||||
<h5 class="m-b-5 large-text bold l-20">Tracking:</h5>
|
||||
<div class="row padding-10">
|
||||
<div class="col rounded bg-master-lighter padding-15">
|
||||
<li class="m-t-10">
|
||||
<a class="btn btn-sm btn-primary b-rad-none all-caps requestModal"
|
||||
data-type="containerDepature">Container Departure</a>
|
||||
</li>
|
||||
<li class="m-t-10">
|
||||
<a class="btn btn-sm btn-primary b-rad-none all-caps requestModal"
|
||||
data-type="containerArrival">Arrival Date</a>
|
||||
</li>
|
||||
<li class="m-t-10">
|
||||
<a class="btn btn-sm btn-primary b-rad-none all-caps requestModal"
|
||||
data-type="containerUnpacking">Date of Unpacking</a>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in"
|
||||
type="rescheduleDate">
|
||||
<reschedule-date-form-component :section="section"
|
||||
:data="container"></reschedule-date-form-component>
|
||||
</modal-component>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in"
|
||||
type="containerDepature">
|
||||
<container-depature-form-component :section="section"
|
||||
:data="container"></container-depature-form-component>
|
||||
</modal-component>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in"
|
||||
type="containerArrival">
|
||||
<container-arrival-form-component :section="section"
|
||||
:data="container"></container-arrival-form-component>
|
||||
</modal-component>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in"
|
||||
type="containerUnpacking">
|
||||
<container-unpacking-form-container :section="section"
|
||||
:data="container"></container-unpacking-form-container>
|
||||
</modal-component>
|
||||
|
||||
<div class="row m-t-10">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-auto padding-5 m-l-15 m-r-15 pointer" :class="[{ 'text-primary': tabShowing === 'Comments' }, { 'b-b': tabShowing === 'Comments' }]" @click="tabShowing = 'Comments'">
|
||||
<h5 class="large-text bold l-20" :class="[{ 'text-primary': tabShowing === 'Comments' }]"> Comments</h5>
|
||||
</div>
|
||||
<!-- <div class="col-auto padding-5 m-l-15 m-r-15 pointer" :class="[{ 'text-primary': tabShowing === 'Timeline' }, { 'b-b': tabShowing === 'Timeline' }]" @click="tabShowing = 'Timeline'">
|
||||
<h5 class="large-text bold l-20" :class="[{ 'text-primary': tabShowing === 'Timeline' }]"> Activity Timeline</h5>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="row p-l-10 p-r-10">
|
||||
<div class="col rounded padding-15">
|
||||
<div class="row" v-if="tabShowing === 'Comments'">
|
||||
<div class="col">
|
||||
<div class="row" v-for="remarks in container.remarks">
|
||||
<div class="col">
|
||||
<container-comment-component :section="section" :data="remarks"></container-comment-component>
|
||||
</div>
|
||||
</div>
|
||||
<container-comment-form-component :section="section" :id="container.id"></container-comment-form-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="tabShowing === 'Timeline'">
|
||||
<div class="col">
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-5 align-items-center justify-content-center hide">
|
||||
<div class="col">
|
||||
<small class="fs-9 muted all-caps font-lato" style="letter-spacing: 2px">There is no results found, Try adjusting your filters to find what you are looking for.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
section: 'containerPofileSection',
|
||||
isLoading: true,
|
||||
container: null,
|
||||
expanded: false,
|
||||
CBMcapacity: 30,
|
||||
// tabShowing: 'Timeline',
|
||||
tabShowing: 'Comments',
|
||||
selectAllPackingList: false,
|
||||
selectedPackageList: [],
|
||||
deleteCommentId: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
pendingQueue() {
|
||||
return this.$store.getters.isInCompleteQueue(this.section);
|
||||
},
|
||||
loadedCBM() {
|
||||
return (Math.ceil((this.container.packing_lists.reduce((total, obj) => total + obj.packages.reduce((total, obj) => obj.cbm + total, 0), 0)) * 1000) / 1000).toFixed(3)
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
pendingQueue(inComplete) {
|
||||
if (inComplete) {
|
||||
this.fetchCompany();
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('updateListQueue', { 'name': this.section });
|
||||
},
|
||||
methods: {
|
||||
fetchCompany() {
|
||||
this.isLoading = true;
|
||||
this.submit(route('api.packing_list.container.show', this.id) + '?with_packing_list_data=0', 'get', this.section, false, false)
|
||||
},
|
||||
successHandler(response) {
|
||||
this.$store.dispatch('completeList', { 'name': this.section, 'data': [] });
|
||||
this.isLoading = false;
|
||||
this.container = response.payload.data;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -76,6 +76,7 @@
|
||||
filters: this.options,
|
||||
pollingInterval: null,
|
||||
isPolling: false,
|
||||
isFetchingResult: false,
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
@@ -124,6 +125,7 @@
|
||||
this.isLoading = false;
|
||||
},
|
||||
errorHandler(error){
|
||||
this.isFetchingResult = false;
|
||||
this.isPolling = false;
|
||||
},
|
||||
startPolling(jobId, maxAttempts = 8) {
|
||||
@@ -135,7 +137,7 @@
|
||||
};
|
||||
|
||||
const pollJobResult = () => {
|
||||
if (this.isPolling) {
|
||||
if (this.isPolling || this.isFetchingResult) {
|
||||
return;
|
||||
}
|
||||
this.isPolling = true;
|
||||
@@ -168,6 +170,7 @@
|
||||
clearInterval(this.pollingInterval);
|
||||
this.pollingInterval = null;
|
||||
this.isPolling = false;
|
||||
this.isFetchingResult = false;
|
||||
},
|
||||
submitJob(url){
|
||||
try {
|
||||
@@ -187,6 +190,7 @@
|
||||
},
|
||||
fetchJobResult(jobId, isLastAttempt = false) {
|
||||
// console.log('fetchJobResult: ', jobId);
|
||||
this.isFetchingResult = true;
|
||||
try {
|
||||
let anotherEndpoint = route('api.job.fetch', jobId);
|
||||
if(isLastAttempt){
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-b b-grey p-b-20 align-items-center">
|
||||
<div class="row b-b b-grey p-b-20 align-items-center parentContainer">
|
||||
<div class="col">
|
||||
<div class="row m-b-5">
|
||||
<div class="col-auto">
|
||||
@@ -58,9 +58,48 @@
|
||||
<small class="fs-10 all-caps muted">Status</small>
|
||||
<p class="no-margin bold">{{item.container ? item.container.transport.schedule_complete && status === 'Shipping' ? 'Custom Clearance' : status : status}}</p>
|
||||
</div>
|
||||
<div class="col-auto" v-if="$store.getters.isAdmin">
|
||||
<small class="fs-10 all-caps muted">Container</small>
|
||||
<p class="no-margin bold">{{item.container ? item.container.container_reference : '-'}}</p>
|
||||
<div class="col" v-if="$store.getters.isAdmin">
|
||||
<div class="row h-100 justify-content-center align-items-center">
|
||||
<div class="col">
|
||||
<small class="fs-10 all-caps muted">Container</small>
|
||||
<p class="no-margin bold">{{ item.container ? item.container.container_reference : '-' }}</p>
|
||||
</div>
|
||||
<div class="col-auto" v-if="$store.getters.isAdmin && item.container">
|
||||
<i class="fa fa-comment fs-15 pointer requestModal" data-type="commentsModal"></i>
|
||||
<modal-component type="commentsModal" styleType="fill-in">
|
||||
<div class="row">
|
||||
<div class="col bg-white b-rad-lg p-t-10 p-t-10 p-l-40 p-r-40">
|
||||
<h4 class="m-b-20">Remarks</h4>
|
||||
<div class="row" v-if="item.container.remarks.length">
|
||||
<div class="col">
|
||||
<div class="row" v-for="remarks in item.container.remarks">
|
||||
<div class="col">
|
||||
<container-comment-component :section="section" :data="remarks"></container-comment-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-else>
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<h6 class="no-margin">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-auto pr-sm-0"><b>Delivery Address:</b> </div>
|
||||
<div class="col-12 col-sm-auto pl-sm-0">{{order.address.reference}} <i class="fa fa-info-circle m-l-10" v-tooltip:right="order.address.street_one+' '+(order.address.street_two ? order.address.street_two : '')+', '+ order.address.district.name+', '+order.address.post_code+' '+order.address.state.name+', '+order.address.country.name" ></i></div>
|
||||
<div class="col-12 col-sm-auto pl-sm-0">{{order.address.reference}} <i class="fa fa-info-circle m-l-10" v-tooltip:right="order.address.street_one + ' ' + (order.address.street_two ? order.address.street_two : '') + ', ' + (order.address.district ? order.address.district.name : '') + ', ' + order.address.post_code + ' ' + (order.address.state ? order.address.state.name : '') + ', ' + (order.address.country ? order.address.country.name : '')"></i></div>
|
||||
</div>
|
||||
</h6>
|
||||
</div>
|
||||
@@ -149,7 +149,7 @@
|
||||
</div>
|
||||
<div class="row bg-master-lightest p-t-15" v-for="invoice in order.invoices" v-if="invoice.type === 1">
|
||||
<div class="col" v-if="getMergedInvoices(invoice).length > 1">
|
||||
<customer-payments-billing-variant-2-component :data="getMergedInvoices(invoice)" :storage="getStorageInfo(invoice)" invoice_status="Pending Payment" :section="section"></customer-payments-billing-variant-2-component>
|
||||
<customer-payments-billing-with-storage-component :data="getMergedInvoices(invoice)" :storage="getStorageInfo(invoice)" invoice_status="Pending Payment" :section="section"></customer-payments-billing-with-storage-component>
|
||||
</div>
|
||||
<div class="col" v-else>
|
||||
<customer-payments-billing-component :data="invoice" invoice_status="Pending Payment" :section="section"></customer-payments-billing-component>
|
||||
@@ -215,6 +215,11 @@
|
||||
this.isLoading = false;
|
||||
this.order = response.payload.data;
|
||||
},
|
||||
errorHandler(error, status){
|
||||
if(status == 404){
|
||||
window.location.href = this.route('error.404');
|
||||
}
|
||||
},
|
||||
getStorageInfo(invoice) {
|
||||
const storageObject = this.findStorageInfoObject(invoice.id);
|
||||
return storageObject;
|
||||
|
||||
+4
-9
@@ -34,17 +34,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- CIEF TODO: For easy revert to old code -->
|
||||
<!-- <list-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list')" :options="options">
|
||||
<list-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list')" :options="options">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component>
|
||||
<single-parent-admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></single-parent-admin-payments-billing-component>
|
||||
<!-- <admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component> -->
|
||||
</template>
|
||||
</list-component> -->
|
||||
<list-polling-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list.job')" :options="options">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component>
|
||||
</template>
|
||||
</list-polling-component>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div class="row m-t-20" @keyup.enter="search">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md">
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<div class="form-group no-margin form-group-default b-rad-none">
|
||||
<label class="text-primary">Order Number Like</label>
|
||||
<input type="text" class="form-control" v-model="marking" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto p-l-0 p-r-0">
|
||||
<div class="btn btn-primary b-rad-none" @click="search">
|
||||
<i class="fa fa-search lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto p-l-0">
|
||||
<div class="btn btn-secondary b-rad-none" @click="reset">
|
||||
<i class="fa fa-remove lh-40"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md">
|
||||
<div class="row" v-if="with_export">
|
||||
<div class="col">
|
||||
<download-billing-with-dates-component :section="section"></download-billing-with-dates-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<list-polling-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list.job')" :options="options">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<!-- <single-admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></single-admin-payments-billing-component> -->
|
||||
<single-parent-admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></single-parent-admin-payments-billing-component>
|
||||
</template>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
invoice_status: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
options: {
|
||||
default () {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
section:{
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
with_export:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
marking: '',
|
||||
currentKey: 1,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
this.options['order_marking_in'] = this.marking;
|
||||
this.currentKey+=1;
|
||||
},
|
||||
reset() {
|
||||
this.marking = '';
|
||||
delete(this.options['order_marking_in']);
|
||||
this.currentKey+=1;
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user