mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 735d14eef6 |
+2
-8
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -56,16 +56,10 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
WEPOST_BASE_URL=https://wepost-uat.90warehouse.com/api/router
|
||||
WEPOST_CLIENT_ID=1234
|
||||
WEPOST_CLIENT_SECRET=cief-secret-temp
|
||||
WEPOST_IS_ENABLED=false
|
||||
|
||||
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
||||
SST_START_DATE="2024-04-01 00:00:00"
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=P@ssw0rd
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
@@ -2,8 +2,6 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- service_build
|
||||
- node
|
||||
- building_assets
|
||||
- database
|
||||
- unit_test
|
||||
- acceptance_test
|
||||
- code_quality
|
||||
|
||||
# Variables
|
||||
variables:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: mysql_password
|
||||
MYSQL_PASSWORD: mysql_password
|
||||
MYSQL_DATABASE: shpping_portal
|
||||
DB_HOST: mysql
|
||||
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
#install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install MySQL client
|
||||
- apt-get install -y default-mysql-client
|
||||
|
||||
#install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
#install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
|
||||
|
||||
#jobs
|
||||
|
||||
#buld the backend
|
||||
composer_php:
|
||||
stage: service_build
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#build the UI
|
||||
#node installation
|
||||
npm:
|
||||
stage: node
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#building assets
|
||||
building_assets:
|
||||
stage: building_assets
|
||||
# dependencies:
|
||||
# - npm
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
database:
|
||||
stage: database
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - composer_php
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
#unit_test:
|
||||
# stage: unit_test
|
||||
# services:
|
||||
# - name: mysql:8.0
|
||||
# command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - database
|
||||
# script:
|
||||
# - npm install # Install npm dependencies
|
||||
# - gulp build # Build assets
|
||||
# - composer install
|
||||
# - cp .env.example .env
|
||||
# - php artisan key:generate
|
||||
# - php artisan migrate:fresh
|
||||
# - php artisan db:seed
|
||||
# - php artisan test
|
||||
# rules:
|
||||
# - if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +1,62 @@
|
||||
## Shipping portal documentation
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
||||
|
||||
simple documentation on how to install, run, test, commit and deploy application
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## creating and running unit tests
|
||||
## About Laravel
|
||||
|
||||
Required Tools
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- Chromium Driver / selenium
|
||||
- add running and setting selenium on all OS if possible
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Required Packages :
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
- laravel/legacy-factories
|
||||
## Learning Laravel
|
||||
|
||||
- codeception/codeception
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
Or Simply Run
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
``Composer install``
|
||||
## Laravel Sponsors
|
||||
|
||||
To create a unit test
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
|
||||
``php artisan make test: Test Example --unit``
|
||||
### Premium Partners
|
||||
|
||||
Running the tests :
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
|
||||
Running a single Test
|
||||
## Contributing
|
||||
|
||||
`` php artisan test --filter Example``
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
Running Unit tests -
|
||||
## Code of Conduct
|
||||
|
||||
`` php artisan test ``
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
Running Codeception tests -
|
||||
## Security Vulnerabilities
|
||||
|
||||
``vendor/bin/codecept run``
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
@@ -64,28 +64,22 @@ abstract class AbstractControllerLogic
|
||||
return $response;
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
if ($request->has('isApiPub')) {
|
||||
Log::error($exception);
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', "Server Error",
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
|
||||
} else {
|
||||
if ($exception instanceof JobResourceNotFoundException) {
|
||||
Log::channel('vue_polling')->info(sprintf(
|
||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
$exception->getTrace()[0]['file'],
|
||||
$exception->getTrace()[0]['line']
|
||||
));
|
||||
}
|
||||
else{
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
if ($exception instanceof JobResourceNotFoundException) {
|
||||
Log::channel('vue_polling')->info(sprintf(
|
||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
$exception->getTrace()[0]['file'],
|
||||
$exception->getTrace()[0]['line']
|
||||
));
|
||||
}
|
||||
else{
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class MarkingIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
||||
$module->whereHas('connections', function ($connection) use ($value) {
|
||||
$connection->whereIn('invitee_reference', $value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface KeyValueInterface
|
||||
{
|
||||
|
||||
public function attributes(): morphMany;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General;
|
||||
|
||||
|
||||
class WePostHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $clientId
|
||||
* @param string $clientSecrent
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
static function generateSignature(string $clientId, string $clientSecrent, string $type){
|
||||
// public parameters
|
||||
$timestamp = 1234; //time();
|
||||
|
||||
$params = [
|
||||
'client_id' => $clientId,
|
||||
'type' => $type,
|
||||
'timestamp' => $timestamp
|
||||
];
|
||||
|
||||
// $businessParams = [
|
||||
// 'test1' => '1',
|
||||
// ];
|
||||
|
||||
ksort($params);
|
||||
$str = '';
|
||||
foreach ($params as $key => $value) {
|
||||
if(is_array($value)) {
|
||||
$str .= $key.json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
continue;
|
||||
}
|
||||
$str .= $key. $value;
|
||||
}
|
||||
$str = $clientSecrent.$str.$clientSecrent;
|
||||
$signature = strtoupper(md5($str));
|
||||
return $signature;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
{
|
||||
@@ -30,17 +29,12 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info('FetchOrdersFromYDPortalJob starts');
|
||||
Log::info('FetchPackingListsFromYdPortalProcessor starts');
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchContainersFromYdPortalProcessor starts');
|
||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchContainersUpdatesFromYdPortalProcessor starts');
|
||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor starts');
|
||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchOrdersFromYDPortalJob ends');
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,16 +11,14 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
@@ -28,8 +28,7 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
||||
use App\Classes\Modules\Accounts\Processors\RegisterOnExchangeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
@@ -37,8 +36,6 @@ use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateCustomerLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -90,12 +87,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var CreatePerfexCRMLeadProcessor */
|
||||
private $createPerfexCRMLeadProcessor;
|
||||
|
||||
/** @var RegisterOnExchangeProcessor */
|
||||
private $registerOnExchangeProcessor;
|
||||
|
||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
||||
private $connectCompanyModuleToExchangeCompany;
|
||||
|
||||
/**
|
||||
* CreateCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
@@ -110,10 +101,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
||||
* @param RegisterOnExchangeProcessor $registerOnExchangeProcessor
|
||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, RegisterOnExchangeProcessor $registerOnExchangeProcessor, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
@@ -127,8 +116,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
||||
$this->registerOnExchangeProcessor = $registerOnExchangeProcessor;
|
||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +153,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
// $this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
||||
@@ -180,34 +167,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
||||
}
|
||||
|
||||
if(app()->environment(['production'])){
|
||||
// call wac webhook
|
||||
$url = config('wagWebhookUrl.account_registration_url');
|
||||
$payload = [
|
||||
'name' => $request->input('name'),
|
||||
'email' => $request->input('email'),
|
||||
'phone' => $request->input('phone'),
|
||||
'portal' => 'izyim'
|
||||
];
|
||||
$response = Http::post($url, $payload);
|
||||
Log::channel('wac_webhook')->info('Register Account: ' . json_encode($response));
|
||||
}
|
||||
|
||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
$exchangeCompanyId = null;
|
||||
if ($request->input('exchange_company_id')) {
|
||||
$exchangeCompanyId = $request->input('exchange_company_id');
|
||||
} else {
|
||||
// register account on exchange portal if this registration not coming from exchange
|
||||
$exchangeCompanyId = $this->registerOnExchangeProcessor->execute($request, $companyModule->id);
|
||||
}
|
||||
|
||||
if ($exchangeCompanyId) {
|
||||
// create exchange company connection
|
||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $exchangeCompanyId);
|
||||
}
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationTokenWithExchangeBookingId;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoginThroughExchangeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Authentication',
|
||||
'message' => 'You have successfully logged in to your account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var AuthenticationProcessor */
|
||||
private $authenticationProcessor;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var GeneratesAuthenticationTokenWithExchangeBookingId */
|
||||
private $generatesAuthenticationTokenWithExchangeBookingId;
|
||||
|
||||
|
||||
/**
|
||||
* LoginThroughExchangeLogic constructor.
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId
|
||||
*/
|
||||
public function __construct(GeneratesAuthenticationToken $generatesAuthenticationToken, GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId)
|
||||
{
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->generatesAuthenticationTokenWithExchangeBookingId = $generatesAuthenticationTokenWithExchangeBookingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
$token = explode('.', $request->input("exchangeToken"))[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$exchangeCompanyId = $exchangeUser['company_id'];
|
||||
$connection = ExchangeCompanyConnection::where("exchange_company_id", $exchangeCompanyId)->first();
|
||||
if (!$connection) {
|
||||
throw new AccessUnauthorisedException('These credentials do not match our records.');
|
||||
}
|
||||
$companyModule = $connection->companyModule;
|
||||
$user = $companyModule->employees->last();
|
||||
|
||||
$exchangeBookingId = null;
|
||||
if (isset($exchangeUser['booking_id']) && $exchangeUser['booking_id']) {
|
||||
$exchangeBookingId = $exchangeUser['booking_id'];
|
||||
$token = $this->generatesAuthenticationTokenWithExchangeBookingId->execute($user, $exchangeBookingId);
|
||||
|
||||
return $this->response(['access_token' => $token, 'redirect_url' => route('dashboard') . "?createOrder=true"]);
|
||||
} else {
|
||||
$token = $this->generatesAuthenticationToken->execute($user);
|
||||
$order = Order::where('id', $request->input("orderId"))->first();
|
||||
|
||||
return $this->response(['access_token' => $token, 'redirect_url' => route('order.show' , $order->reference)]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class KeyValuePairObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $key;
|
||||
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
|
||||
/**
|
||||
* KeyValuePairObject constructor.
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct(string $key, string $value)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RegisterOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = 'https://exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = 'http://127.0.0.1:8000/api/v1/account/registration/registration';
|
||||
} else {
|
||||
$url = 'https://dev.exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$formParams = $request->toArray();
|
||||
$formParams['shipping_company_module_id'] = $companyModuleId;
|
||||
$response = $client->request('POST', $url, ['form_params' => $formParams]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
$payload = $contents['payload'];
|
||||
$token = explode('.', $payload['access_token'])[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
|
||||
return $exchangeUser['company_id'];
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\KeyValueInterface;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Models\KeyValuePair;
|
||||
|
||||
class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param KeyValueInterface $kv
|
||||
* @param KeyValuePairObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
|
||||
public function execute(KeyValueInterface $kv, KeyValuePairObject $object) {
|
||||
$model = new KeyValuePair();
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($kv->attributes(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Company;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\JWT;
|
||||
|
||||
class GeneratesAuthenticationTokenWithExchangeBookingId {
|
||||
|
||||
/** @var JWT */
|
||||
private $builder;
|
||||
|
||||
|
||||
/**
|
||||
* GeneratesAuthenticationTokenWithExchangeBookingId constructor.
|
||||
* @param JWT $builder
|
||||
*/
|
||||
public function __construct(JWT $builder) {
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param bool $rememberUser
|
||||
* @return string
|
||||
*/
|
||||
public function execute(User $user, $bookingId): string {
|
||||
|
||||
$this->builder->manager()->setBlacklistEnabled(false);
|
||||
|
||||
// generate token for the customer
|
||||
$this->builder->factory()->setTTL(Carbon::now()->addDay()->timestamp);
|
||||
|
||||
// set the claim based on the object
|
||||
$this->setTokenClaims($user, $bookingId);
|
||||
|
||||
return $this->builder->fromUser($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
private function setTokenClaims(User $user, $bookingId): void {
|
||||
|
||||
$claims = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'type' => $user->type,
|
||||
'status' => $user->status
|
||||
];
|
||||
|
||||
if($user->type === RoleTypes::USER) {
|
||||
|
||||
/** @var Company $companyModule */
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$claims = array_merge($claims, [
|
||||
'company_id' => $companyModule->company_id,
|
||||
'company_module_id' => $companyModule->id,
|
||||
'company_module_type' => $companyModule->type,
|
||||
'company_name' => $companyModule->name,
|
||||
'company_marking' => $companyModule->type !== 8 ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'HWT',
|
||||
'exchange_booking_id' => $bookingId
|
||||
]);
|
||||
}
|
||||
|
||||
$this->builder->factory()->customClaims(['user' => $claims]);
|
||||
|
||||
|
||||
$this->builder->factory()->buildClaimsCollection();
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,6 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
@@ -18,10 +15,8 @@ use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -32,8 +27,7 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Address',
|
||||
'message' => 'You have successfully created a new Address'
|
||||
@@ -80,11 +74,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
@@ -96,31 +90,16 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||
|
||||
if ($request->input('phone')) {
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if ($request->input('remark')) {
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
$addressExtraFields = [
|
||||
'property_type' => $request->input('property_type'),
|
||||
'tools_required_unload' => $request->input('tools_required_unload'),
|
||||
'pickup_time_from' => $request->input('pickup_time_from'),
|
||||
'pickup_time_to' => $request->input('pickup_time_to'),
|
||||
];
|
||||
|
||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
||||
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
@@ -17,7 +14,6 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -27,8 +23,7 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Billing Address',
|
||||
'message' => 'You have successfully created a new Billing Address'
|
||||
@@ -65,35 +60,27 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create new billing addrress
|
||||
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
|
||||
// create addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
|
||||
//load address with only owner address
|
||||
|
||||
/* return fractal()
|
||||
->item($billingAddressInputed, new AddressTransformer())
|
||||
->parseIncludes('Owner_address')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||
@@ -19,8 +17,7 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Address',
|
||||
'message' => 'You have successfully retrieved a Address'
|
||||
@@ -48,22 +45,15 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchAddress->passes();
|
||||
|
||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,10 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +17,7 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
@@ -50,25 +45,17 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAddresses->passes();
|
||||
|
||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||
|
||||
//a collection of addresses with all incluides
|
||||
/* return fractal()
|
||||
->collection($query, new AddressTransformer)
|
||||
->parseIncludes('Owner_address')
|
||||
->parseIncludes('remark')
|
||||
->parseIncludes('contact')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(AddressResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\DistrictResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -9,7 +9,6 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -34,7 +33,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
/** @var ResetsAddressesDefault */
|
||||
private $resetsAddressesDefault;
|
||||
|
||||
/** @var SetsAddressToDefault */
|
||||
/** @var SetsAddressToDefault*/
|
||||
private $setsAddressToDefault;
|
||||
|
||||
|
||||
@@ -65,15 +64,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
|
||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||
|
||||
|
||||
$setAddress = $this->setsAddressToDefault->execute($address);
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($setAddress, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,10 @@ use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -29,8 +26,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Address',
|
||||
'message' => 'You have successfully updated the Address'
|
||||
@@ -81,7 +77,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
@@ -94,44 +90,18 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete();
|
||||
$address->remarks()->delete();
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
|
||||
if ($request->input('phone')) {
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if ($request->input('remark')) {
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
//only remark relationship needed
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
if ($request->input('pickup_time_to') <= $request->input('pickup_time_from')) {
|
||||
$pickupTimeFrom = Carbon::parse($request->input('pickup_time_from'));
|
||||
$request->merge([
|
||||
'pickup_time_to' => $pickupTimeFrom->addHour()->format('H:i') // Format to hh:mm
|
||||
]);
|
||||
}
|
||||
|
||||
$addressExtraFields = [
|
||||
'property_type' => $request->input('property_type'),
|
||||
'additional_request' => $request->input('additional_request'),
|
||||
'receive_goods_working_hours' => $request->input('receive_goods_working_hours'),
|
||||
'receive_goods_after_hours' => $request->input('receive_goods_after_hours'),
|
||||
'receive_goods_on_saturday' => $request->input('receive_goods_on_saturday'),
|
||||
];
|
||||
|
||||
$address->addressExtraFields()->delete();
|
||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
||||
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$announcement->segments()->attach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Group;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
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;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
//Date: 20240817
|
||||
//This Processor is used for one time data patching with OneTimeTransactionFixBillplzFailedCallback.php
|
||||
class CallbackBillplzDataPatchProcessor
|
||||
{
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var ReleaseGoodsToCustomerProcessor */
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzDataPatchProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||
*/
|
||||
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->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $status)
|
||||
{
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
|
||||
$proceed = $this->checkForGroupPayment($transaction);
|
||||
if(!$proceed) return false;
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
Log::info('CallbackBillplzDataPatchProcessor 1');
|
||||
|
||||
// check if is wallet top up
|
||||
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||
|
||||
Log::info('CallbackBillplzDataPatchProcessor 2');
|
||||
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
|
||||
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||
|
||||
// check if is group payment
|
||||
if ($group) {
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
Log::info('CallbackBillplzDataPatchProcessor 3: '.json_encode($invoice));
|
||||
|
||||
//if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||
// $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||
|
||||
// if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||
$pL = $invoice->owner;
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice, true);
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
Log::info('CallbackBillplzDataPatchProcessor 3');
|
||||
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkForGroupPayment($transaction){
|
||||
//This check is targetting group payment that expired and soft deleted
|
||||
//command:check-storage-invoices must already run for this part of the code to work properly
|
||||
$group = Group::withTrashed()->where('reference', $transaction->payment_reference)->first();
|
||||
if ($group) {
|
||||
$totalAmountToBePaid = 0;
|
||||
$actualAmountPaid = $transaction->amount;
|
||||
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||
$totalAmountToBePaid += $invoice->amount;
|
||||
}
|
||||
}
|
||||
|
||||
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
||||
|
||||
}
|
||||
else{
|
||||
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed
|
||||
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class CallbackBillplzProcessor
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzProcessor constructor.
|
||||
* CreateUserProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
|
||||
+4
-23
@@ -10,18 +10,16 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\ApproveIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -57,9 +55,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var CreateNotificationProcessor */
|
||||
private $createNotificationProcessor;
|
||||
|
||||
/** @var ApproveIdentificationDocumentOnExchangeProcessor */
|
||||
private $approveIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
/**
|
||||
* ApproveIdentificationDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
@@ -69,9 +64,8 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||
* @param ApproveIdentificationDocumentOnExchangeProcessor $approveIdentificationDocumentOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor, ApproveIdentificationDocumentOnExchangeProcessor $approveIdentificationDocumentOnExchangeProcessor)
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||
{
|
||||
$this->canApproveDocument = $canApproveDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
@@ -80,7 +74,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||
$this->approveIdentificationDocumentOnExchangeProcessor = $approveIdentificationDocumentOnExchangeProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,18 +85,11 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$documentId = $request->route('document_id');
|
||||
|
||||
if ($request->route('exchange_company_id')) {
|
||||
$companyModule = ExchangeCompanyConnection::where('exchange_company_id', $request->route('exchange_company_id'))->first()->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$documentId = $company->documents()->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->where('status', ApprovalStatus::PENDING_VERIFICATION)->first()->id;
|
||||
}
|
||||
|
||||
$status = $request->route('status');
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->fetchesDocument->execute(['id' => $documentId]);
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('document_id')]);
|
||||
|
||||
$this->canApproveDocument->passes();
|
||||
|
||||
@@ -125,11 +111,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
// if this request is not calling from exchange portal, then approve the document on exchange portal for this user
|
||||
$companyModule = $document->owner->companyModules()->first();
|
||||
if (!$request->route('exchange_company_id') && $companyModule->exchangeCompanyConnection()->first()) {
|
||||
$this->approveIdentificationDocumentOnExchangeProcessor->execute($request, $companyModule->id, $status);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document));
|
||||
|
||||
|
||||
+2
-22
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\CreateIdentificationDocumentOnExchangeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
@@ -15,7 +14,6 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Company;
|
||||
use App\Models\Document;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -44,9 +42,6 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesCompanyStatus */
|
||||
private $updatesCompanyStatus;
|
||||
|
||||
/** @var CreateIdentificationDocumentOnExchangeProcessor */
|
||||
private $createIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateIdentificationDocumentLogic constructor.
|
||||
@@ -54,15 +49,13 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param CreateIdentificationDocumentOnExchangeProcessor $createIdentificationDocumentOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesCompanyStatus $updatesCompanyStatus, CreateIdentificationDocumentOnExchangeProcessor $createIdentificationDocumentOnExchangeProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesCompanyStatus $updatesCompanyStatus)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->createIdentificationDocumentOnExchangeProcessor = $createIdentificationDocumentOnExchangeProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,15 +66,8 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
if ($request->route('exchange_company_id')) {
|
||||
$companyModule = ExchangeCompanyConnection::where('exchange_company_id', $request->route('exchange_company_id'))->first()->companyModule;
|
||||
$companyId = $companyModule->company_id;
|
||||
} else {
|
||||
$companyId = $request->route('id');
|
||||
}
|
||||
|
||||
/** @var Company $company */
|
||||
$company = $this->fetchesCompany->execute(['id' => $companyId]);
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$object = new DocumentObject($company->type === CompanyType::COMPANY_BUSINESS ?
|
||||
DocumentType::SSM_REGISTRATION : DocumentType::IDENTITY_CARD, $request->input('files'),
|
||||
$request->input('identification_no'), ApprovalStatus::PENDING_VERIFICATION, 'identifications');
|
||||
@@ -92,12 +78,6 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->updatesCompanyStatus->execute($company, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
// create identification on exchange if this request not coming from exchange
|
||||
$companyModule = $company->companyModules()->first();
|
||||
if (!$request->route('exchange_company_id') && $companyModule->exchangeCompanyConnection()->first()) {
|
||||
$this->createIdentificationDocumentOnExchangeProcessor->execute($request, $companyModule->id);
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\LinkExchangeCompanyProcessor;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkExchangeCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Connect Exchange with Izyim Account',
|
||||
'message' => 'You have successfully connect your exchange account to Izyim Account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var LinkExchangeCompanyProcessor */
|
||||
private $linkExchangeCompanyProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* LinkExchangeCompanyLogic constructor.
|
||||
* @param LinkExchangeCompanyProcessor $linkExchangeCompanyProcessor
|
||||
*/
|
||||
public function __construct(LinkExchangeCompanyProcessor $linkExchangeCompanyProcessor)
|
||||
{
|
||||
$this->linkExchangeCompanyProcessor = $linkExchangeCompanyProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
return $this->response($this->linkExchangeCompanyProcessor->execute($request));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,14 +3,10 @@
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +17,7 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
@@ -50,26 +45,15 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||
|
||||
/*include all relationships*/
|
||||
/* return fractal()
|
||||
->collection($query, new CompanyTransformer)
|
||||
->parseIncludes('company')
|
||||
->parseIncludes('contact')
|
||||
->parseIncludes('remarks')
|
||||
->parseIncludes('address')
|
||||
->parseIncludes('billingAddress')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApproveIdentificationDocumentOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId, $status) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('PUT', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateIdentificationDocumentOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('POST', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticationRedirect;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanAuthenticateUser;
|
||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkExchangeCompanyProcessor
|
||||
{
|
||||
|
||||
/** @var CanAuthenticateUser */
|
||||
private $canAuthenticateUser;
|
||||
|
||||
/** @var AuthenticatesUser */
|
||||
private $authenticatesUser;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var AuthenticationRedirect */
|
||||
private $authenticationRedirect;
|
||||
|
||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
||||
private $connectCompanyModuleToExchangeCompany;
|
||||
|
||||
/**
|
||||
* AuthenticationProcessor constructor.
|
||||
* @param CanAuthenticateUser $canAuthenticateUser
|
||||
* @param AuthenticatesUser $authenticatesUser
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param AuthenticationRedirect $authenticationRedirect
|
||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
||||
*/
|
||||
public function __construct(CanAuthenticateUser $canAuthenticateUser, AuthenticatesUser $authenticatesUser, GeneratesAuthenticationToken $generatesAuthenticationToken, FetchesUser $fetchesUser, AuthenticationRedirect $authenticationRedirect, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
||||
{
|
||||
$this->canAuthenticateUser = $canAuthenticateUser;
|
||||
$this->authenticatesUser = $authenticatesUser;
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->authenticationRedirect = $authenticationRedirect;
|
||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request): array {
|
||||
|
||||
$object = new AuthenticationCredentialsObject($request->input('email'), $request->input('password'));
|
||||
|
||||
$this->canAuthenticateUser->passes($object);
|
||||
|
||||
$this->authenticatesUser->execute($object);
|
||||
|
||||
$user = $this->fetchesUser->execute(['email' => $object->getEmail()]);
|
||||
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $request->route('exchange_company_id'));
|
||||
|
||||
return ['shipping_company_module_id' => $companyModule->id];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -20,7 +20,7 @@ class AssignsCompanyConnectionToConnectionSegment extends AbstractUpdateRecord
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$companyConnection->segments()->attach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class AssignsCompanyToSegment extends AbstractUpdateRecord
|
||||
try {
|
||||
$companyModule = $company->companyModules()->where('type', BusinessType::IMPORTER)->first();
|
||||
$connection = $companyModule->connections()->where('inviter_reference', 'CIEF');
|
||||
$connection->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$connection->segments()->attach($segment);
|
||||
|
||||
return $company;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class AssignsEmployee extends AbstractUpdateRecord
|
||||
{
|
||||
try {
|
||||
|
||||
$object->getCompanyModule()->employees()->attach($object->getUser(), ['status' => $object->getStatus(), 'role_id' => $object->getRoleId(), 'created_at' => now(), 'updated_at' => now()]);
|
||||
$object->getCompanyModule()->employees()->attach($object->getUser(), ['status' => $object->getStatus(),'role_id' => $object->getRoleId()]);
|
||||
|
||||
return $object->getCompanyModule();
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
|
||||
class ConnectCompanyModuleToExchangeCompany extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Company $company
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $companyModule, $exchangeCompanyId)
|
||||
{
|
||||
$model = new ExchangeCompanyConnection();
|
||||
$model->company_module_id = $companyModule->id;
|
||||
$model->exchange_company_id = $exchangeCompanyId;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Transformers\ContactTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -64,13 +63,6 @@ class UpdateContactLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContact->execute($query, $object);
|
||||
|
||||
/*uniformity*/
|
||||
/* return fractal()
|
||||
->item($query, new ContactTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new ContactResource($query));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Order;
|
||||
use App\Transformers\DeliveryOrderTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -53,14 +52,6 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$order = $this->cancelsOrder->execute($order);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||
|
||||
}
|
||||
|
||||
@@ -172,12 +172,6 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||
$this->createsPackage->execute($packageObject, $packingList);
|
||||
|
||||
//add relationship to order
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||
|
||||
}
|
||||
|
||||
@@ -48,12 +48,6 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new DeliveryOrderTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,13 +7,9 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use League\Fractal;
|
||||
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -62,11 +58,6 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
/* return fractal()
|
||||
->collection($query, new DocumentTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Documents\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApprovesDocument extends AbstractUpdateRecord
|
||||
@@ -18,19 +17,8 @@ class ApprovesDocument extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
// if auth user is null, then this services is calling from exchange
|
||||
if (!$user) {
|
||||
$token = explode('.', request()->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$user = User::where('email', $exchangeUser['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::find(1);
|
||||
}
|
||||
}
|
||||
$model->status = ApprovalStatus::APPROVED;
|
||||
$model->approver = $user->id;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
@@ -5,10 +5,7 @@ namespace App\Classes\Modules\Documents\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RejectsDocument extends AbstractUpdateRecord
|
||||
{
|
||||
@@ -20,19 +17,8 @@ class RejectsDocument extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
// if auth user is null, then this services is calling from exchange
|
||||
if (!$user) {
|
||||
$token = explode('.', request()->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$user = User::where('email', $exchangeUser['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::find(1);
|
||||
}
|
||||
}
|
||||
$model->status = ApprovalStatus::REJECTED;
|
||||
$model->approver = $user->id;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
@@ -24,8 +24,8 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
{
|
||||
$this->filters = [
|
||||
"has_invoice_status_in" => [2],
|
||||
// "packing_list_ordered_by_invoice_date" => true,
|
||||
// "with_aging_column" => true
|
||||
"packing_list_ordered_by_invoice_date" => true,
|
||||
"with_aging_column" => true
|
||||
];
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
'Invoice Date',
|
||||
'Days',
|
||||
'Amount',
|
||||
'Credit Term Customer',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -56,16 +55,9 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
$invDate = 'n/a';
|
||||
$invNo = 'n/a';
|
||||
$days = 'n/a';
|
||||
$isCreditTermCustomer = false;
|
||||
|
||||
if ($list->owner instanceof Order) {
|
||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
$companyModule = $list->owner->companyModule;
|
||||
|
||||
$segment = $companyModule->connections()->first()->segments()->where('name', 'Credit Term Customer')->first();
|
||||
if ($segment) {
|
||||
$isCreditTermCustomer = true;
|
||||
}
|
||||
|
||||
if ($inviterPivotInviteeReference) {
|
||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
||||
@@ -95,7 +87,6 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
$invDate,
|
||||
$days,
|
||||
$amt,
|
||||
$isCreditTermCustomer ? 'TRUE' : 'FALSE',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsGroupTransactions implements
|
||||
FromQuery,
|
||||
WithHeadings,
|
||||
WithHeadingRow,
|
||||
WithMapping,
|
||||
ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'PaymentDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
'AccNo',
|
||||
'DetailDescription',
|
||||
'FurtherDescription',
|
||||
'ProjNo',
|
||||
'DeptNo',
|
||||
'Qty',
|
||||
'UnitPrice',
|
||||
'TaxType',
|
||||
'TaxableAmt',
|
||||
'TaxRate'
|
||||
];
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
$start_date = $this->parseDate($this->request->input('startDate'));
|
||||
$end_date = $this->parseDate($this->request->input('endDate'));
|
||||
|
||||
return Group::when($start_date && $end_date, function ($query) use ($start_date, $end_date) {
|
||||
$query->whereBetween('created_at', [
|
||||
$start_date->startOfDay(),
|
||||
$end_date->endOfDay()
|
||||
]);
|
||||
})
|
||||
->when($start_date && !$end_date, function ($query) use ($start_date) {
|
||||
$query->where('created_at', '>=', $start_date->startOfDay());
|
||||
})
|
||||
->when(!$start_date && $end_date, function ($query) use ($end_date) {
|
||||
$query->where('created_at', '<=', $end_date->endOfDay());
|
||||
});
|
||||
}
|
||||
|
||||
private function parseDate($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->startOfDay() : null;
|
||||
}
|
||||
|
||||
public function map($transaction): array
|
||||
{
|
||||
$company = $transaction->receiverCompany;
|
||||
return [
|
||||
'<<New>>', //'DocNo',
|
||||
'', //'DocDate',
|
||||
$transaction->created_at->format('m/d/Y H:m'), //'PaymentDate',
|
||||
$company->debtor, //'DebtorCode',
|
||||
$company->referece, //'Ref',
|
||||
$company->referece, //'ShipInfo',
|
||||
'500-0000', //'AccNo',
|
||||
'X1 Freight Service Charge', //'DetailDescription',
|
||||
'FurtherDescription', //'FurtherDescription',
|
||||
'M3', //'ProjNo',
|
||||
'CIEF', //'DeptNo',
|
||||
'', //'Qty',
|
||||
'', //'UnitPrice',
|
||||
'', //'TaxType',
|
||||
floatval($transaction->tax) > 0 ? number_format($transaction->tax, 2) : '0.00', //'TaxableAmt',
|
||||
'', //'TaxRate'
|
||||
];
|
||||
}
|
||||
|
||||
private function getTaxType($tax_percentage)
|
||||
{
|
||||
return floatval($tax_percentage) > 0 ? 'SV-6' : '';
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
return [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'PaymentDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
@@ -60,12 +59,12 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
{
|
||||
$start_date = $this->request->input('startDate', null);
|
||||
if ($start_date) {
|
||||
$start_date = Carbon::parse($start_date)->startOfDay();
|
||||
$start_date = Carbon::parse($this->request->input('startDate'))->format('Y-m-d');
|
||||
}
|
||||
|
||||
$end_date = $this->request->input('endDate', null);
|
||||
if ($end_date) {
|
||||
$end_date = Carbon::parse($end_date)->endOfDay();
|
||||
$end_date = Carbon::parse($this->request->input('endDate'))->format('Y-m-d');
|
||||
}
|
||||
|
||||
$query = Transaction::query();
|
||||
@@ -78,31 +77,30 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
// Adjusted the query to include both types and status
|
||||
$query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])
|
||||
->where('status', $approvalStatus);
|
||||
// $query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [$approvalStatus]);
|
||||
$query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->whereIn('status', [$approvalStatus]);
|
||||
|
||||
if ($start_date && $end_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($start_date, $end_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)
|
||||
->whereBetween('updated_at', [$start_date, $end_date]);
|
||||
});
|
||||
} elseif ($start_date) {
|
||||
if($start_date && $end_date) {
|
||||
$query->whereBetween('updated_at', [
|
||||
Carbon::parse($start_date)->format('Y-m-d 0:00:00'),
|
||||
Carbon::parse($end_date)->format('Y-m-d 23:59:59')
|
||||
]);
|
||||
}
|
||||
elseif($start_date && !$end_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($start_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)
|
||||
->where('updated_at', '>=', $start_date);
|
||||
$transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00'));
|
||||
});
|
||||
} elseif ($end_date) {
|
||||
|
||||
}
|
||||
elseif(!$start_date && $end_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($end_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)
|
||||
->where('updated_at', '<=', $end_date);
|
||||
$transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($end_date)->format('Y-m-d 0:00:00'));
|
||||
});
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function map($transaction): array
|
||||
{
|
||||
$container = $transaction->owner->containers()->first();
|
||||
@@ -144,7 +142,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$rows[] = [
|
||||
$firstItem ? '<<New>>' : '',
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$transaction->transactions()->where('type', TransactionType::PAYMENT)->first()->updated_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
$order->reference,
|
||||
@@ -156,7 +153,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$detail->quantity,
|
||||
$detail->price,
|
||||
floatval($detail->tax_percentage) > 0 ? 'SV-6' : '',
|
||||
floatval($detail->tax_percentage) > 0 ? number_format($detail->amount, 2) : '0.00',
|
||||
floatval($detail->tax_percentage) > 0 ? $detail->amount : '0',
|
||||
$detail->tax_percentage,
|
||||
];
|
||||
|
||||
@@ -169,7 +166,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
$transaction->transactions()->where('type', TransactionType::PAYMENT)->first()->updated_at->format('m/d/Y H:m'),
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
$order->reference,
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -31,8 +32,10 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -40,12 +39,6 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,25 +4,14 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\ConnectOrderToExchangeBookingOnExchangeProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\ConnectOrderToExchangeBooking;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Models\Address;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -52,25 +41,8 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
/** @var ConnectOrderToExchangeBooking */
|
||||
private $connectOrderToExchangeBooking;
|
||||
|
||||
/** @var ConnectOrderToExchangeBookingOnExchangeProcessor */
|
||||
private $connectOrderToExchangeBookingOnExchangeProcessor;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -79,10 +51,8 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
* @param ConnectOrderToExchangeBooking $connectOrderToExchangeBooking
|
||||
* @param ConnectOrderToExchangeBookingOnExchangeProcessor $connectOrderToExchangeBookingOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor, ConnectOrderToExchangeBooking $connectOrderToExchangeBooking, ConnectOrderToExchangeBookingOnExchangeProcessor $connectOrderToExchangeBookingOnExchangeProcessor, CreatesKeyValuePair $createsKeyValuePair)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
@@ -90,18 +60,12 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
$this->connectOrderToExchangeBooking = $connectOrderToExchangeBooking;
|
||||
$this->connectOrderToExchangeBookingOnExchangeProcessor = $connectOrderToExchangeBookingOnExchangeProcessor;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$isTermsAgreed = $request->input('is_terms_agree');
|
||||
if(!$isTermsAgreed){
|
||||
throw new RequestValidationException('You must read and agree to our terms and conditions to proceed');
|
||||
}
|
||||
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
@@ -127,32 +91,12 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
|
||||
}
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
"TERMS_AND_CONDITIONS",
|
||||
$isTermsAgreed
|
||||
);
|
||||
$this->createsKeyValuePair->execute($order, $keyValuePairObject);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->newLeadTaskToPerfexCRMProcessor->execute($company);
|
||||
}
|
||||
|
||||
$token = explode('.', $request->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$exchangeBookingId = null;
|
||||
if (isset($exchangeUser['exchange_booking_id']) && $exchangeUser['exchange_booking_id']) {
|
||||
$exchangeBookingId = $exchangeUser['exchange_booking_id'];
|
||||
}
|
||||
|
||||
if ($exchangeBookingId) {
|
||||
$this->connectOrderToExchangeBooking->execute($order, $exchangeBookingId);
|
||||
$this->connectOrderToExchangeBookingOnExchangeProcessor->execute($request, $order->id, $exchangeBookingId);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
}
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ConnectOrderToExchangeBookingOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $orderId, $exchangeBookingId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/order/{$orderId}/booking/{$exchangeBookingId}/connect";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/order/{$orderId}/booking/{$exchangeBookingId}/connect";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/order/{$orderId}/booking/{$exchangeBookingId}/connect";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('POST', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class CreateOrderProcessor
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Address $address
|
||||
* @param int|null $orderNumber
|
||||
* @return Order
|
||||
* @return Addressable
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\ExchangeBookingOrder;
|
||||
use App\Models\Order;
|
||||
|
||||
class ConnectOrderToExchangeBooking extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Order $order
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Order $order, $exchangeBookingId)
|
||||
{
|
||||
$model = new ExchangeBookingOrder();
|
||||
$model->order_id = $order->id;
|
||||
$model->exchange_booking_id = $exchangeBookingId;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+1
-9
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -54,16 +53,9 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
|
||||
foreach ($packing_list as $key => $row) {
|
||||
$packing_list_item = $this->fetchesPackingList->execute(['id' => $row]);
|
||||
$container->packingLists()->attach($packing_list_item, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
}
|
||||
|
||||
//only return with packing list relationship
|
||||
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseInclude(['packingLists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
+2
-10
@@ -8,7 +8,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,8 +19,7 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -53,16 +51,10 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -71,11 +70,6 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -8,7 +8,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -19,8 +18,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
@@ -52,7 +50,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -61,12 +59,6 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
//load with remarks only
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['remarks'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
}
|
||||
|
||||
+17
-25
@@ -17,7 +17,6 @@ use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -29,8 +28,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
@@ -43,7 +41,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
@@ -56,12 +54,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
@@ -79,11 +77,11 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -94,27 +92,21 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//include transport
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['transport'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,8 +17,7 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Container',
|
||||
'message' => 'You have successfully retrieved a Container'
|
||||
@@ -50,18 +48,12 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
//load with packing lists
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->parseIncludes(['packing_lists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+2
-9
@@ -9,7 +9,6 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,8 +19,7 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -54,16 +52,11 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
//no relations required
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+5
-16
@@ -3,14 +3,10 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +17,7 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -50,22 +45,16 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
//load with no filters, a details page to be added to load one with all related data
|
||||
/* return fractal()
|
||||
->collection($query, new ContainerTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+2
-4
@@ -10,7 +10,6 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +20,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
@@ -56,7 +54,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
+10
-21
@@ -3,16 +3,12 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -23,8 +19,7 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -57,19 +52,19 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
@@ -79,12 +74,6 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContainer->execute($container, $object);
|
||||
|
||||
//no relationships
|
||||
/*
|
||||
return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+2
-11
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,8 +17,7 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
@@ -51,18 +49,11 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
|
||||
|
||||
//no relationships queried
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,8 +17,7 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
@@ -51,17 +49,11 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+5
-13
@@ -14,7 +14,6 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use App\Transformers\DeliverPackingListTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -25,8 +24,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
@@ -62,7 +60,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
@@ -70,9 +68,9 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
@@ -84,12 +82,6 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
//no relationships required
|
||||
/* return fractal()
|
||||
->item($deliverPackingList, new DeliverPackingListTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ class FetchContainersFromYdPortalProcessor
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
@@ -143,7 +143,7 @@ class FetchContainersFromYdPortalProcessor
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::LOAD_CONTAINER);
|
||||
|
||||
+1
-2
@@ -76,7 +76,6 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||
|
||||
Log::info('Delivery tracking sTrackingNo: '. $packingList->reference);
|
||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$packingList->reference.'&sOrgId=sti', ['timeout' => 3]);
|
||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||
@@ -120,7 +119,7 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
}
|
||||
|
||||
}
|
||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor ends');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
}
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$container->packingLists()->attach($packingList);
|
||||
$packingList->packages()->delete();
|
||||
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if (!$allow_contract) {
|
||||
|
||||
+1
-10
@@ -129,25 +129,16 @@ class FetchPackingListsFromYdPortalProcessor
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
|
||||
dump('Row Count: ' . count($rows->data));
|
||||
|
||||
if(!$rows->data) continue;
|
||||
|
||||
foreach($rows->data as $row){
|
||||
dump($row);
|
||||
if(!is_numeric($row->goodcount)) continue;
|
||||
|
||||
$time_start = microtime(true);
|
||||
|
||||
$receiveDate = Carbon::parse(substr(preg_replace("/[^0-9]/", "", $row->expressno), 0, 8));
|
||||
|
||||
$customerno = $row->customerno;
|
||||
// Check if $customerno contains '正确唛头YD' and extract the part after it
|
||||
if (strpos($customerno, '正确唛头YD') !== false) {
|
||||
$customerno = explode('正确唛头YD', $customerno)[1];
|
||||
}
|
||||
|
||||
$customerno = preg_split('/[-()\/]/', $customerno);
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
@@ -13,14 +13,10 @@ class RemarkObject implements DataTransferObject
|
||||
/** @var string*/
|
||||
private $content;
|
||||
|
||||
/** @var int|null */
|
||||
private $type;
|
||||
|
||||
public function __construct(string $content, int $commenterID, int $type = null)
|
||||
public function __construct(string $content, int $commenterID)
|
||||
{
|
||||
$this->commenterID = $commenterID;
|
||||
$this->content = $content;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,12 +35,4 @@ class RemarkObject implements DataTransferObject
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getType(): ?int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ class CreatesRemark extends AbstractUpdateRelationshipRecord
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($remarkable->remarks(), $model);
|
||||
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Meneses\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\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\Document;
|
||||
|
||||
class CreateCombinedInvoicesLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Shipping Invoice Status',
|
||||
'message' => 'You have successfully updated multiple shipping invoices status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$items = $request->input('ids');
|
||||
$invoice_transactions=array();
|
||||
foreach($items as $item){
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $item['id']]);
|
||||
|
||||
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
array_push($invoice_transactions, $invoice_transaction);
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $invoice_transactions]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
$user = $packing_list->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ use App\Models\GroupTransaction;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class CreateGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -200,9 +200,7 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
|
||||
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
||||
// create only one billplz payment for wallet top up
|
||||
$amount2 = floatval(str_replace(',', '', $reqAmount));
|
||||
Log::channel('storage_invoices')->info('CreateGroupsLogic reqAmount from client: ' .$amount2);
|
||||
Log::channel('storage_invoices')->info('CreateGroupsLogic amount from backend: ' .$amount); //the real amount should always be from backend
|
||||
$amount = floatval(str_replace(',', '', $reqAmount));
|
||||
$companyModuleId = $invoice->receiver;
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -23,8 +22,7 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Groups',
|
||||
'message' => 'You have successfully retrieved a list of groups'
|
||||
@@ -34,15 +32,10 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/** @var ListsGroups */
|
||||
private $listsGroups;
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->listsGroups->execute($this->listsGroups->deserializeFilters($request->input('filters')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(GroupResource::collection($query));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Group Transaction',
|
||||
'message' => 'You have successfully updated this Group Transaction'
|
||||
@@ -87,7 +86,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -101,7 +100,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
|
||||
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
foreach($transactions as $transaction) {
|
||||
|
||||
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
|
||||
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
||||
@@ -170,7 +169,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'currency_vendor_order'
|
||||
@@ -180,11 +179,6 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
$document = $this->createsDocument->execute($group, $object);
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
|
||||
+5
-23
@@ -4,7 +4,6 @@
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\Filters\PaymentMethodType as FiltersPaymentMethodType;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
@@ -124,7 +123,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta);
|
||||
}
|
||||
else{
|
||||
$result = $this->isExistPaidOrWaivedStorageInvoice($invoice_transaction, $packingList, $eta);
|
||||
$result = $this->isPaidOrWaivedStorageInvoiceExist($invoice_transaction, $packingList, $eta);
|
||||
}
|
||||
if($result){
|
||||
$results[] = $result;
|
||||
@@ -206,9 +205,8 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
|
||||
|
||||
Log::channel('storage_invoices')->info('dateToCompare: '.json_encode($dateToCompare));
|
||||
if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status !== ApprovalStatus::COMPLETED){
|
||||
if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status != ApprovalStatus::COMPLETED){
|
||||
Log::channel('storage_invoices')->info('Created $transaction->id: '.$transaction->id);
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('STOR-');
|
||||
|
||||
@@ -254,7 +252,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
|
||||
$proceedToUpdate = false;
|
||||
|
||||
if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED && !$this->isExistPendingVerificationManualPayment($storageInvoice)){
|
||||
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){
|
||||
@@ -296,7 +294,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
|
||||
}
|
||||
|
||||
private function isExistPaidOrWaivedStorageInvoice($transaction, $packingList, $eta){
|
||||
private function isPaidOrWaivedStorageInvoiceExist($transaction, $packingList, $eta){
|
||||
$pricePerCBM = 3;
|
||||
$resultNumberOfDaysFree = 10;
|
||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
||||
@@ -351,21 +349,6 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
return [];
|
||||
}
|
||||
|
||||
private function isExistPendingVerificationManualPayment($storageInvoice){
|
||||
$g = $storageInvoice->groups()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])->where('payment_method', PaymentMethodType::CASH)->latest('updated_at')->first();
|
||||
Log::channel('storage_invoices')->info('group: ' .json_encode($g));
|
||||
if($g){
|
||||
$gr = $g->reference;
|
||||
$manualPaymentTransaction =Transaction::where('payment_reference', $gr)->first();
|
||||
Log::channel('storage_invoices')->info('manualPaymentTransaction: ' .json_encode($manualPaymentTransaction));
|
||||
if($manualPaymentTransaction->status === ApprovalStatus::PENDING_SUBMISSION || $manualPaymentTransaction->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
Log::channel('storage_invoices')->info('isExistPendingVerificationManualPayment');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function updatePaymentTransactionViaGroupPayment($storageInvoice){
|
||||
Log::channel('storage_invoices')->info('updatePaymentTransactionViaGroupPayment');
|
||||
$groups = $storageInvoice->groups()->whereNotIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])->get();
|
||||
@@ -379,8 +362,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$this->updatesTransactionStatus->execute($walletTransaction, ApprovalStatus::EXPIRED);
|
||||
if($walletTransaction->payment_reference){
|
||||
$deletedBillplzBill = $this->deletesBillplzBill->execute($walletTransaction->payment_reference);
|
||||
Log::channel('storage_invoices')->info('deletedBillplzBill with reference: '.$walletTransaction->payment_reference);
|
||||
Log::channel('storage_invoices')->info('deletedBillplzBill return response: '.json_encode($deletedBillplzBill));
|
||||
Log::channel('storage_invoices')->info('deletedBillplzBill TransactionType::WALLET: '.json_encode($deletedBillplzBill));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CreateInvoiceTransactionProcessor
|
||||
{
|
||||
@@ -75,18 +74,6 @@ class CreateInvoiceTransactionProcessor
|
||||
*/
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
$ori_packing_list = $packingList;
|
||||
// call wac webhook
|
||||
$hasInvoiceCreated = Transaction::withTrashed()
|
||||
->where('type', TransactionType::SHIPPING_INVOICE)
|
||||
->where('owner_type', PackingList::class)
|
||||
->where('owner_id', $ori_packing_list->id)
|
||||
->exists();
|
||||
|
||||
if ($hasInvoiceCreated) {
|
||||
Log::channel('wac_webhook')->info('Regenerating Invoice for PackingList: ' . $ori_packing_list->id . '. No call wac api.');
|
||||
}
|
||||
|
||||
$packing_list = PackingList::where('reference', $packingList->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
||||
|
||||
$billable_packing_list = $packing_list->packingLists()->first();
|
||||
@@ -109,7 +96,6 @@ class CreateInvoiceTransactionProcessor
|
||||
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
||||
$warehouse_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::WAREHOUSE_RATE]);
|
||||
$state_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::STATE_RATE]);
|
||||
Log::channel('priceCbmLog')->info(json_encode($state_rate_constant));
|
||||
$center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]);
|
||||
$outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]);
|
||||
|
||||
@@ -137,18 +123,13 @@ class CreateInvoiceTransactionProcessor
|
||||
$warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0;
|
||||
|
||||
$stateId = $address->state_id;
|
||||
Log::channel('priceCbmLog')->info('stateId: ' . $stateId);
|
||||
$state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId);
|
||||
Log::channel('priceCbmLog')->info('state_rate_constant: ' . json_encode($state_rate_constant));
|
||||
|
||||
// get $state_rate
|
||||
$postcode = $address->postcode;
|
||||
$this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ;
|
||||
Log::channel('priceCbmLog')->info('state_select: ' . $state_select);
|
||||
$this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ;
|
||||
Log::channel('priceCbmLog')->info('state_select: ' . $state_select);
|
||||
$state_rate_constant = (array)$state_rate_constant;
|
||||
Log::channel('priceCbmLog')->info('state_rate_constant: ' . json_encode($state_rate_constant));
|
||||
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
||||
|
||||
$container = $packing_list->containers()->first();
|
||||
@@ -187,13 +168,7 @@ class CreateInvoiceTransactionProcessor
|
||||
$minimum_charge = 0;
|
||||
}
|
||||
|
||||
Log::channel('priceCbmLog')->info('$base_price: ' . $base_price);
|
||||
Log::channel('priceCbmLog')->info('$segment_price: ' . $segment_price);
|
||||
Log::channel('priceCbmLog')->info('$warehouse_rate: ' . $warehouse_rate);
|
||||
Log::channel('priceCbmLog')->info('$state_rate: ' . $state_rate);
|
||||
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
||||
Log::channel('priceCbmLog')->info('$price_cbm: ' . $price_cbm);
|
||||
Log::channel('priceCbmLog')->info('');
|
||||
|
||||
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
||||
|
||||
@@ -263,32 +238,6 @@ class CreateInvoiceTransactionProcessor
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
if (app()->environment('production') && !$hasInvoiceCreated) {
|
||||
$order = $ori_packing_list->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$companyContact = $company->contacts()->first();
|
||||
$employee = $companyModule->employees()->first();
|
||||
|
||||
$invoiceCount = Transaction::where('type', TransactionType::SHIPPING_INVOICE)
|
||||
->where('receiver', $companyModule->id)
|
||||
->where('status', ApprovalStatus::APPROVED)
|
||||
->count();
|
||||
|
||||
$payload = [
|
||||
'name' => $employee->name,
|
||||
'email' => $employee->email,
|
||||
'phone' => $companyContact->phone,
|
||||
'order_reference' => $order->reference,
|
||||
'portal' => 'izyim',
|
||||
'invoice_count' => $invoiceCount,
|
||||
];
|
||||
|
||||
Log::channel('wac_webhook')->info('Attempt to send wac_webhook - Invoice Created: ' . json_encode($payload));
|
||||
$response = Http::post(config('wagWebhookUrl.invoice_created_url'), $payload);
|
||||
Log::channel('wac_webhook')->info('Invoice Created: ' . json_encode($response));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
//DATE: 20240616
|
||||
//THIS IS A ONE TIME FIX PROCESSOR MEANT TO FIX A GROUP PAYMENT THAT GOT STUCK: https://izyim.cief-malaysia.com/customer/943GCC/payment-and-billing
|
||||
//TRNASACTION WITH ID: 16803
|
||||
//GROUP WITH ID: 609
|
||||
|
||||
class CreatePaymentTransactionOneTimeFixProcessor
|
||||
{
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
/**
|
||||
* @param FetchesTransaction $fetchesTransaction,
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
* @param CreatesPaymentTransaction $createsPaymentTransaction
|
||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
||||
* @param CreatesBillplzBill $createsBillplzBil
|
||||
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $invoice, $payment_method, $bank_code, $date, $run = true)
|
||||
{
|
||||
$amount = $invoice->amount;
|
||||
Log::info($invoice->owner);
|
||||
$company_module = $invoice->owner->owner->companyModule()->first();
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $billNumber,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$bank_code,
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
|
||||
// if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
// throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
// }
|
||||
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
$transaction->created_at = $date;
|
||||
$transaction->updated_at = $date;
|
||||
$transaction->save();
|
||||
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// later use this variabke to create a approved payment transaction
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
if($run){
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
|
||||
|
||||
return $payment_transaction;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
|
||||
class CreatePaymentTransactionProcessor
|
||||
{
|
||||
@@ -50,9 +49,6 @@ class CreatePaymentTransactionProcessor
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
/** @var CreditWalletProcessor */
|
||||
private $creditWalletProcessor ;
|
||||
|
||||
/**
|
||||
* @param FetchesTransaction $fetchesTransaction,
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
@@ -64,7 +60,6 @@ class CreatePaymentTransactionProcessor
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreditWalletProcessor $creditWalletProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
@@ -74,7 +69,6 @@ class CreatePaymentTransactionProcessor
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
CreditWalletProcessor $creditWalletProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
@@ -85,7 +79,6 @@ class CreatePaymentTransactionProcessor
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->creditWalletProcessor = $creditWalletProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
@@ -121,7 +114,7 @@ class CreatePaymentTransactionProcessor
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < -0.01){
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
@@ -181,11 +174,6 @@ class CreatePaymentTransactionProcessor
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
|
||||
|
||||
// cief coins
|
||||
if ($approvalStatus == ApprovalStatus::APPROVED) {
|
||||
$wallet = $this->creditWalletProcessor->execute($company_module, transactionType::CIEF_COINS_CREDIT, $amount, 'Cief Coins Credit', 3); // TODO-cief-coins: pls confirm the reference
|
||||
}
|
||||
|
||||
return $payment_transaction;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,33 +44,24 @@ class ReleaseGoodsToCustomerProcessor
|
||||
/**
|
||||
* @param $packingList
|
||||
* @param $invoice
|
||||
* @param $processCompletedInvoices
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($packingList, $invoice = null, $processCompletedInvoices = false)
|
||||
public function execute($packingList, $invoice = null)
|
||||
{
|
||||
$result = false;
|
||||
$totalInvoicesAmountPaid = 0.00;
|
||||
$totalInvoicesAmount = 0.00;
|
||||
if($processCompletedInvoices){
|
||||
//processCompletedInvoices, for manual processing of invoices, e.g. incomplete payment gateway finish with storage invoice
|
||||
$invoiceTransactions = $packingList->transactions()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
}
|
||||
else{
|
||||
$invoiceTransactions = $packingList->transactions()->where('status', ApprovalStatus::APPROVED)->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
}
|
||||
$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 (STORAGE + SHIPPING)
|
||||
//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){
|
||||
Log::channel('storage_invoices')->info('ReleaseGoodsToCustomerProcessor updatesTransactionStatus');
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
//cief todo: remove the following if block
|
||||
if($invoice->type === TransactionType::STORAGE_INVOICE){
|
||||
Log::channel('storage_invoices')->info('ReleaseGoodsToCustomerProcessor createStorageInvoiceDocTransactionProcessor');
|
||||
if($invoice->type == TransactionType::STORAGE_INVOICE){
|
||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wac\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\HelpMenu\Standards\Rules\CanFetchHelpMenuQuestion;
|
||||
use App\Classes\Modules\HelpMenu\Processors\FetchFirstQuestionQAProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\HelpMenuQuestionResource;
|
||||
use App\Models\User;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class RegisterExchangeEmailLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Register Exchange Email',
|
||||
'message' => 'You have successfully registered an exchange email address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var CreatesUser */
|
||||
private $createsUser;
|
||||
|
||||
/**
|
||||
* RegisterEmailLogic constructor.
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
*/
|
||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, CreatesUser $createsUser)
|
||||
{
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->createsUser = $createsUser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
// Validate the request inputs
|
||||
$validator = Validator::make(
|
||||
$request->all(),
|
||||
[
|
||||
'izyim_email' => 'email|required',
|
||||
'exchange_email' => 'email|required',
|
||||
]
|
||||
);
|
||||
|
||||
if ($validator->fails()) {
|
||||
throw new RequestValidationException($validator->messages()->first());
|
||||
}
|
||||
|
||||
// Retrieve the validated emails from the request
|
||||
$izyimEmail = $request->input('izyim_email');
|
||||
$exchangeEmail = $request->input('exchange_email');
|
||||
|
||||
// Check if both emails are the same
|
||||
if ($izyimEmail === $exchangeEmail) {
|
||||
return response()->json([
|
||||
'message' => 'Both emails are the same.',
|
||||
'status' => 'ok',
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Check if the exchange email already exists in the system
|
||||
$existingUser = User::where('email', $exchangeEmail)->first();
|
||||
if ($existingUser) {
|
||||
return response()->json([
|
||||
'message' => 'The Exchange email already exists in the system.',
|
||||
'status' => 'error',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Retrieve the izyim user
|
||||
$izyimUser = User::where('email', $izyimEmail)->first();
|
||||
if (!$izyimUser) {
|
||||
return response()->json([
|
||||
'message' => 'The Izyim email not found in system.',
|
||||
'status' => 'error',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$newUser = new User();
|
||||
$newUser->name = $izyimUser->name;
|
||||
$newUser->email = $exchangeEmail;
|
||||
$newUser->password = $izyimUser->password;
|
||||
$newUser->type = RoleTypes::USER;
|
||||
$newUser->status = ApprovalStatus::APPROVED;
|
||||
$newUser->save();
|
||||
|
||||
Log::channel('wac_webhook')->info('Wac created user: ' . $exchangeEmail);
|
||||
|
||||
$companyModule = $izyimUser->companyModule->first();
|
||||
$Object = new EmploymentObject($companyModule, $newUser);
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Exchange email registered successfully.',
|
||||
'status' => 'success',
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,16 @@
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallets;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ListWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -22,8 +26,8 @@ class ListWalletLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsWallets */
|
||||
private $listsWallets;
|
||||
/** @var ListWallet */
|
||||
private $listsWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
@@ -34,10 +38,10 @@ class ListWalletLogic extends AbstractControllerLogic
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanListWallet $canListWallet, ListsWallets $listsWallets)
|
||||
public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
|
||||
{
|
||||
$this->canListWallet = $canListWallet;
|
||||
$this->listsWallets = $listsWallets;
|
||||
$this->listsWallet = $listsWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +53,7 @@ class ListWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
//$this->canListWallet->passes();
|
||||
|
||||
$query = $this->listsWallets->execute($this->listsWallets->deserializeFilters($request->input('filters')));
|
||||
$query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(WalletResource::collection($query));
|
||||
}
|
||||
|
||||
@@ -79,40 +79,19 @@ class CreditWalletProcessor
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $companyModule, int $transactionType, float $amount, string $reference, ?int $currencyId = 1)
|
||||
public function execute(CompanyModule $companyModule, int $transactionType, float $amount, string $reference)
|
||||
{
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $companyModule->wallets()->where('currency_id', $currencyId)->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($companyModule->id, $currencyId, $this->generatesWalletCode->execute());
|
||||
if (!$companyModule->wallets()->first()) {
|
||||
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
|
||||
$this->createsWallet->execute($object, $companyModule);
|
||||
$wallet = $companyModule->wallets()->where('currency_id', $currencyId)->first();
|
||||
}
|
||||
|
||||
$billNumberPrefix = null;
|
||||
$transaction_object_transaction_type = $transactionType;
|
||||
switch ($transactionType) {
|
||||
case TransactionType::PAYMENT:
|
||||
$billNumberPrefix = 'DEBIT-NOTE-';
|
||||
$transaction_object_transaction_type = TransactionType::DEBIT_NOTE;
|
||||
break;
|
||||
case TransactionType::CIEF_COINS_CREDIT:
|
||||
$billNumberPrefix = 'COINS-CREDIT-'; // TODO-cief-coins: pls confirm the prefix
|
||||
break;
|
||||
case TransactionType::CIEF_COINS_DEBIT:
|
||||
$billNumberPrefix = 'COINS-DEBIT-'; // TODO-cief-coins: pls confirm the prefix
|
||||
break;
|
||||
default:
|
||||
$billNumberPrefix = 'CREDIT-NOTE-';
|
||||
$transaction_object_transaction_type = TransactionType::CREDIT_NOTE;
|
||||
break;
|
||||
}
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $companyModule->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute($billNumberPrefix);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, $transaction_object_transaction_type, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, $transaction->amount);
|
||||
|
||||
+6
-9
@@ -2,31 +2,28 @@
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class ListsWallets extends AbstractListRecord
|
||||
class ListsWallet extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Wallet */
|
||||
/** @var Booking */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Wallet constructor.
|
||||
* @param Wallet $repository
|
||||
* ListsBookings constructor.
|
||||
* @param Booking $repository
|
||||
*/
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
@@ -27,15 +27,11 @@ class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
|
||||
foreach ($model->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::GROUP_PAYMENT) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
|
||||
// cief coins
|
||||
if ((int) $transaction->type === TransactionType::CIEF_COINS_CREDIT) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::CIEF_COINS_DEBIT) $debit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::GROUP_PAYMENT) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\WePostHelper;
|
||||
use App\Classes\Modules\WePost\Services\CreatesWePostNotification;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostNotificationObject;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostProcessNotificationObject;
|
||||
use App\Classes\Modules\WePost\Standards\Rules\CanProcessWePostNotification;
|
||||
use App\Http\Resources\WePostNotificationResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProcessWePostNotificationLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Process WePost Notification',
|
||||
'message' => 'Payload proccessed'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWePostNotification */
|
||||
private $createsWePostNotification;
|
||||
|
||||
/** @var CanProcessWePostNotification */
|
||||
private $canProcessWePostNotification;
|
||||
|
||||
/**
|
||||
* ProcessWePostNotificationLogic constructor.
|
||||
* @param CreatesWePostNotification $createsWePostNotification
|
||||
* @param CanProcessWePostNotification $canProcessWePostNotification
|
||||
*/
|
||||
public function __construct(
|
||||
CreatesWePostNotification $createsWePostNotification, CanProcessWePostNotification $canProcessWePostNotification)
|
||||
{
|
||||
$this->createsWePostNotification = $createsWePostNotification;
|
||||
$this->canProcessWePostNotification = $canProcessWePostNotification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$request->merge([
|
||||
'isApiPub' => true,
|
||||
]);
|
||||
|
||||
$object = new WePostProcessNotificationObject($request->query('api-key'));
|
||||
$this->canProcessWePostNotification->passes($object);
|
||||
|
||||
$result = null;
|
||||
$code = 0;
|
||||
|
||||
$logisticsOrderCode = "";
|
||||
$executeTime = "";
|
||||
$timeZone = "";
|
||||
$status = "";
|
||||
$packageInfo = [];
|
||||
$clientId = "";
|
||||
$type = "";
|
||||
$timestamp = 0;
|
||||
$sign = "";
|
||||
$orderCode = "";
|
||||
$bizAction = "";
|
||||
$bizActionDesc= "";
|
||||
$segmentCode = "";
|
||||
$isSplitOut = "";
|
||||
$packageInfos = [];
|
||||
|
||||
|
||||
if($request->has('type')){
|
||||
$type = $request->input('type');
|
||||
if($type === 'wepost.service.conso.inbound'){
|
||||
$logisticsOrderCode = $request->input('logisticsOrderCode');
|
||||
$executeTime = $request->input('executeTime');
|
||||
$timeZone = $request->input('timeZone');
|
||||
$status = $request->input('status');
|
||||
$packageInfo = $request->input('packageInfo');
|
||||
$clientId = $request->input('client_id');
|
||||
$type = $request->input('type');
|
||||
$timestamp = $request->input('timestamp');
|
||||
$sign = $request->input('sign');
|
||||
}
|
||||
else if($type === 'wepost.service.conso.co.biz.action.notify'){
|
||||
$executeTime = $request->input('executeTime');
|
||||
$timeZone = $request->input('timeZone');
|
||||
$clientId = $request->input('client_id');
|
||||
$type = $request->input('type');
|
||||
$timestamp = $request->input('timestamp');
|
||||
$sign = $request->input('sign');
|
||||
$orderCode = $request->input('orderCode');
|
||||
$bizAction = $request->input('bizAction');
|
||||
$bizActionDesc = $request->input('bizActionDesc');
|
||||
}
|
||||
else if($type === 'wepost.service.conso.outbound'){
|
||||
$executeTime = $request->input('executeTime');
|
||||
$timeZone = $request->input('timeZone');
|
||||
$clientId = $request->input('client_id');
|
||||
$type = $request->input('type');
|
||||
$timestamp = $request->input('timestamp');
|
||||
$sign = $request->input('sign');
|
||||
$orderCode = $request->input('orderCode');
|
||||
$segmentCode = $request->input('segmentCode');
|
||||
$isSplitOut = $request->input('isSplitOut');
|
||||
$packageInfos = $request->input('packageInfos');
|
||||
}
|
||||
else{
|
||||
$code = 1202; //Missing required fields
|
||||
}
|
||||
}
|
||||
else{
|
||||
$code = 1202; //Missing required fields
|
||||
}
|
||||
|
||||
if(!$sign){
|
||||
$code = 1100; //Signature is empty
|
||||
}
|
||||
|
||||
if($code == 0){
|
||||
if($this->verifySignature($type, $sign)){
|
||||
$object = new WePostNotificationObject(
|
||||
$logisticsOrderCode, $executeTime, $timeZone, $status,$packageInfo,
|
||||
$clientId, $type, $timestamp, $sign,
|
||||
$orderCode, $segmentCode, $bizAction, $bizActionDesc, $isSplitOut, $packageInfos);
|
||||
$result = $this->createsWePostNotification->execute($object);
|
||||
}
|
||||
else{
|
||||
$code = 1101; //Signature verification failed
|
||||
}
|
||||
}
|
||||
|
||||
if($code != 0){
|
||||
$request->merge([
|
||||
'code' => $code,
|
||||
]);
|
||||
}
|
||||
// $result = [];
|
||||
// $result['logisticsOrderCode'] = $notification->logistics_order_code;
|
||||
// return $this->collectionResponse(OrderItemResource::collection($order->orderItems));
|
||||
// return $this->resourceResponse(new OrderResource($order));
|
||||
//return $this->response(['data' => $result]);
|
||||
|
||||
return $this->resourceResponse(new WePostNotificationResource($result));
|
||||
}
|
||||
|
||||
private function verifySignature($type, $sign){
|
||||
$result = false;
|
||||
|
||||
$signToCompare = WePostHelper::generateSignature(config('wepost.client_id'), config('wepost.client_secret'), $type);
|
||||
// dd($signToCompare);
|
||||
|
||||
if($sign == $signToCompare){
|
||||
$result = true;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
|
||||
class WePostNotificationObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private string $logisticsOrderCode;
|
||||
|
||||
/** @var string */
|
||||
private string $executeTime;
|
||||
|
||||
/** @var string */
|
||||
private string $timeZone;
|
||||
|
||||
/** @var string */
|
||||
private string $status;
|
||||
|
||||
/** @var array */
|
||||
private array $packageInfo;
|
||||
|
||||
/** @var string */
|
||||
private string $clientId;
|
||||
|
||||
/** @var string */
|
||||
private string $type;
|
||||
|
||||
/** @var int */
|
||||
private int $timestamp;
|
||||
|
||||
/** @var string */
|
||||
private string $sign;
|
||||
|
||||
/** @var string */
|
||||
private string $orderCode;
|
||||
|
||||
/** @var string */
|
||||
private string $bizAction;
|
||||
|
||||
/** @var string */
|
||||
private string $bizActionDesc;
|
||||
|
||||
/** @var string */
|
||||
private string $segmentCode;
|
||||
|
||||
/** @var string */
|
||||
private string $isSplitOut;
|
||||
|
||||
/** @var array */
|
||||
private array $packageInfos;
|
||||
|
||||
/**
|
||||
* WePostNotificationObject constructor.
|
||||
* @param string $logisticsOrderCode
|
||||
* @param string $executeTime,
|
||||
* @param string $timeZone,
|
||||
* @param string $status,
|
||||
* @param array $packageInfo,
|
||||
* @param string $clientId,
|
||||
* @param string $type,
|
||||
* @param int $timestamp,
|
||||
* @param string $sign
|
||||
* @param string $orderCode
|
||||
* @param string $bizAction
|
||||
* @param string $bizActionDesc
|
||||
* @param string $segmentCode
|
||||
* @param string $isSplitOut
|
||||
* @param array $packageInfos
|
||||
*/
|
||||
public function __construct(
|
||||
string $logisticsOrderCode,
|
||||
string $executeTime,
|
||||
string $timeZone,
|
||||
string $status,
|
||||
array $packageInfo,
|
||||
string $clientId,
|
||||
string $type,
|
||||
int $timestamp,
|
||||
string $sign,
|
||||
string $orderCode = "",
|
||||
string $bizAction = "",
|
||||
string $bizActionDesc = "",
|
||||
string $segmentCode = "",
|
||||
string $isSplitOut = "",
|
||||
array $packageInfos = []
|
||||
) {
|
||||
$this->logisticsOrderCode = $logisticsOrderCode;
|
||||
$this->executeTime = $executeTime;
|
||||
$this->timeZone = $timeZone;
|
||||
$this->status = $status;
|
||||
$this->packageInfo = $packageInfo;
|
||||
$this->clientId = $clientId;
|
||||
$this->type = $type;
|
||||
$this->timestamp = $timestamp;
|
||||
$this->sign = $sign;
|
||||
$this->orderCode = $orderCode;
|
||||
$this->bizAction = $bizAction;
|
||||
$this->bizActionDesc = $bizActionDesc;
|
||||
$this->segmentCode = $segmentCode;
|
||||
$this->isSplitOut = $isSplitOut;
|
||||
$this->packageInfos = $packageInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogisticsOrderCode(): string
|
||||
{
|
||||
return $this->logisticsOrderCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExecuteTime(): string
|
||||
{
|
||||
return $this->executeTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTimeZone(): string
|
||||
{
|
||||
return $this->timeZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPackageInfo(): array
|
||||
{
|
||||
return $this->packageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClientId(): string
|
||||
{
|
||||
return $this->clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTimestamp(): int
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSign(): string
|
||||
{
|
||||
return $this->sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrderCode(): string
|
||||
{
|
||||
return $this->orderCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBizAction(): string
|
||||
{
|
||||
return $this->bizAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBizActionDesc(): string
|
||||
{
|
||||
return $this->bizActionDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSegmentCode(): string
|
||||
{
|
||||
return $this->segmentCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIsSplitOut(): string
|
||||
{
|
||||
return $this->isSplitOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPackageInfos(): string
|
||||
{
|
||||
return json_encode($this->packageInfos);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
|
||||
class WePostProcessNotificationObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private string $token;
|
||||
|
||||
/**
|
||||
* WePostProcessNotificationObject constructor.
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(
|
||||
string $token
|
||||
) {
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToken(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostNotificationObject;
|
||||
use App\Models\WePostNotification;
|
||||
|
||||
|
||||
class CreatesWePostNotification extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WePostNotificationObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WePostNotificationObject $object)
|
||||
{
|
||||
$model = new WePostNotification();
|
||||
$model->logistics_order_code = $object->getLogisticsOrderCode();
|
||||
$model->execute_time = $object->getExecuteTime();
|
||||
$model->timezone = $object->getTimeZone();
|
||||
$model->status = $object->getStatus();
|
||||
$model->package_info = $object->getPackageInfo();
|
||||
$model->client_id = $object->getClientId();
|
||||
$model->type = $object->getType();
|
||||
$model->timestamp = $object->getTimestamp();
|
||||
$model->sign = $object->getSign();
|
||||
$model->order_code = $object->getOrderCode();
|
||||
$model->biz_action = $object->getBizAction();
|
||||
$model->biz_action_desc = $object->getBizActionDesc();
|
||||
$model->segment_code = $object->getSegmentCode();
|
||||
$model->is_split_out = $object->getIsSplitOut();
|
||||
$model->package_infos = $object->getPackageInfos();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Models\PersonalAccessTokens;
|
||||
|
||||
class CanProcessWePostNotification extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
$personalAccessToken = PersonalAccessTokens::where('token', $object->getToken())->first();
|
||||
if($personalAccessToken){
|
||||
$abilities = json_decode($personalAccessToken->abilities, true);
|
||||
if (in_array('process notification', $abilities)|| in_array('*', $abilities)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,4 @@ final class RemarkTypes
|
||||
|
||||
public const EXTERNAL = 1;
|
||||
|
||||
public const ADDRESS_EXTRA_COLUMNS = 2;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class RouteType {
|
||||
|
||||
public const WEB = 1;
|
||||
|
||||
public const API = 2;
|
||||
|
||||
}
|
||||
@@ -42,9 +42,4 @@ final class TransactionType {
|
||||
];
|
||||
|
||||
public const STORAGE_INVOICE = 16;
|
||||
|
||||
public const CIEF_COINS_DEBIT = 17;
|
||||
|
||||
public const CIEF_COINS_CREDIT = 18;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Group;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class FixApprovedPaymentFailedGroup extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'fix-approved-payment-failed-group';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fix all payment is approved or completed but group failed to be updated';
|
||||
|
||||
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();
|
||||
|
||||
$groups = Group::whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->whereHas('payment', function ($query) {
|
||||
$query->whereIn('status', [2, 3]);
|
||||
})->get();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$transaction = $group->payment;
|
||||
|
||||
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->get(config('billplz.base_url') . '/api/v3/bills/' . $transaction->payment_reference);
|
||||
|
||||
dump($transaction->payment_reference);
|
||||
|
||||
if ($response->successful()) {
|
||||
$data = $response->json();
|
||||
if ($data['paid']) {
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if ($data['state'] === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
$this->info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference);
|
||||
$this->callbackBillplzProcessor->execute($transaction, $status);
|
||||
}
|
||||
} else {
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
if ($groups) {
|
||||
$this->info(Carbon::now() . ' : Done . ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FixMissingPackingList extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'fix-missing-packinglist';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fix Missing Packinglist';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$start_date = '2024-05-05';
|
||||
$end_date = '2024-05-05';
|
||||
|
||||
$start = $start_date ? Carbon::parse($start_date) : null;
|
||||
$end = $end_date ? Carbon::parse($end_date) : null;
|
||||
|
||||
if (!$start || !$end) {
|
||||
return;
|
||||
}
|
||||
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Console\Commands;
|
||||
|
||||
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzDataPatchProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
@@ -33,19 +32,15 @@ class OneTimeTransactionFixBillplzFailedCallback extends Command
|
||||
/** @var CallbackBillplzProcessor */
|
||||
private $callbackBillplzProcessor;
|
||||
|
||||
/** @var CallbackBillplzDataPatchProcessor */
|
||||
private $callbackBillplzDataPatchProcessor;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CallbackBillplzProcessor $callbackBillplzProcessor, CallbackBillplzDataPatchProcessor $callbackBillplzDataPatchProcessor)
|
||||
public function __construct(CallbackBillplzProcessor $callbackBillplzProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||
$this->callbackBillplzDataPatchProcessor = $callbackBillplzDataPatchProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,22 +55,19 @@ class OneTimeTransactionFixBillplzFailedCallback extends Command
|
||||
$this->outputArray = [];
|
||||
$start = new Carbon();
|
||||
|
||||
//Transaction fix with this one time fix command: 15205, 16803, 17310
|
||||
//This transaction, 16803 has approve payment but not its owner, shipping invoice
|
||||
$transaction = Transaction::whereIn('id', [17310])->first();
|
||||
$this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 17310 cron started.');
|
||||
//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 == 17310){
|
||||
if($transaction && $transaction->id == 15205){
|
||||
|
||||
$this->info(Carbon::now() . ' : 17310.');
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
// $this->callbackBillplzProcessor->execute($transaction, $status);
|
||||
$this->callbackBillplzDataPatchProcessor->execute($transaction, $status);
|
||||
$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 17310 cron ended. ElapsedTime: ' . $elapsedTime);
|
||||
$this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron ended. ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user