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 | |
|---|---|---|---|
| 834ea52a4f |
+2
-4
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
|||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=shpping_portal
|
DB_DATABASE=laravel
|
||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=root
|
DB_PASSWORD=
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
@@ -55,5 +55,3 @@ EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
|||||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||||
|
|
||||||
YD_API_CODE=''
|
YD_API_CODE=''
|
||||||
|
|
||||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
+1
-2
@@ -2,8 +2,6 @@
|
|||||||
/public/hot
|
/public/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/tests/_output
|
|
||||||
/tests/_support
|
|
||||||
/vendor
|
/vendor
|
||||||
**/.idea/
|
**/.idea/
|
||||||
.env
|
.env
|
||||||
@@ -23,6 +21,7 @@ gox.iml
|
|||||||
rebuild_docker.sh
|
rebuild_docker.sh
|
||||||
docker/*
|
docker/*
|
||||||
db/*
|
db/*
|
||||||
|
docker-compose.yml
|
||||||
package-lock.json
|
package-lock.json
|
||||||
public/*
|
public/*
|
||||||
/public/*
|
/public/*
|
||||||
|
|||||||
-149
@@ -1,149 +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 =~ /.*/'
|
|
||||||
|
|
||||||
#unit test
|
|
||||||
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 =~ /.*/'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#acceptance tests
|
|
||||||
acceptance_test:
|
|
||||||
stage: acceptance_test
|
|
||||||
services:
|
|
||||||
- name: mysql:8.0
|
|
||||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
|
||||||
- selenium/standalone-chrome:latest
|
|
||||||
#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 serve &
|
|
||||||
- vendor/bin/codecept run
|
|
||||||
artifacts:
|
|
||||||
when: always
|
|
||||||
paths:
|
|
||||||
- tests/_output
|
|
||||||
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
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
- add running and setting selenium on all OS if possible
|
- [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).
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Models\Order;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderMarkingIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('owner', function($query) use ($value) {
|
|
||||||
$query->where('reference', 'LIKE', '%' . $value . '%');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OwnerType implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('owner_type', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class Receiver implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('receiver', '=', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatePerfexCRMCustomer implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var CreateLeadPerfexCRMObject */
|
|
||||||
private $createLeadPerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMCustomer constructor.
|
|
||||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->createLeadPerfexCRMObject = $createLeadPerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatePerfexCRMSingleTask implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMLead */
|
|
||||||
private $fetchesPerfexCRMLead;
|
|
||||||
|
|
||||||
/** @var CreateTaskPerfexCRMObject */
|
|
||||||
private $createTaskPerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMSingleTask constructor.
|
|
||||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->createTaskPerfexCRMObject = $createTaskPerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createTaskPerfexCRMObject->getEmail());
|
|
||||||
if(!is_null($lead))
|
|
||||||
{
|
|
||||||
$this->createTaskPerfexCRMObject->setLeadId($lead->id);
|
|
||||||
(App()->make(CreatePerfexCRMTaskProcessor::class))->execute($this->createTaskPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@@ -29,12 +25,8 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
|
||||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
|
||||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
|
||||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
|
||||||
|
|
||||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
|
||||||
|
|
||||||
class InitializePerfexCRM implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var InitialPerfexCRMObject */
|
|
||||||
private $initialPerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* InitializePerfexCRM constructor.
|
|
||||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(InitialPerfexCRMObject $initialPerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->initialPerfexCRMObject = $initialPerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
(App()->make(InitializePerfexCRMProcessor::class))->execute($this->initialPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
|
|
||||||
class UpdatePerfexCRM implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMObject */
|
|
||||||
private $updatePerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdatePerfexCRM constructor.
|
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
(App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,27 +8,23 @@ use App\Classes\General\Services\GeneratesInitials;
|
|||||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||||
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||||
|
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
|
||||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
|
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
|
|
||||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -84,9 +80,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
/** @var FetchesCompanyModule */
|
/** @var FetchesCompanyModule */
|
||||||
private $fetchesCompanyModule;
|
private $fetchesCompanyModule;
|
||||||
|
|
||||||
/** @var CreatePerfexCRMLeadProcessor */
|
|
||||||
private $createPerfexCRMLeadProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateCustomerLogic constructor.
|
* CreateCustomerLogic constructor.
|
||||||
* @param CreateUserProcessor $createUserProcessor
|
* @param CreateUserProcessor $createUserProcessor
|
||||||
@@ -100,9 +93,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
* @param AuthenticationProcessor $authenticationProcessor
|
* @param AuthenticationProcessor $authenticationProcessor
|
||||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
|
||||||
*/
|
*/
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
$this->createUserProcessor = $createUserProcessor;
|
$this->createUserProcessor = $createUserProcessor;
|
||||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||||
@@ -115,7 +107,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
$this->authenticationProcessor = $authenticationProcessor;
|
$this->authenticationProcessor = $authenticationProcessor;
|
||||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,17 +146,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||||
|
|
||||||
if(config('perfexcrm.is_enabled') == 'true'){
|
|
||||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
|
||||||
$createLeadPerfexCRMObject = new CreateLeadPerfexCRMObject(
|
|
||||||
$request->input('name'),
|
|
||||||
$request->input('email'),
|
|
||||||
$request->input('phone'),
|
|
||||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name')
|
|
||||||
);
|
|
||||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||||
|
|
||||||
return $this->response($this->authenticationProcessor->execute($request));
|
return $this->response($this->authenticationProcessor->execute($request));
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
|
||||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Http\Resources\AddressResource;
|
|
||||||
use App\Models\Address;
|
|
||||||
use App\Models\CompanyModule;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateBillingAddressLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Created Billing Address',
|
|
||||||
'message' => 'You have successfully created a new Billing Address'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CanCreateAddress */
|
|
||||||
private $canCreateAddress;
|
|
||||||
|
|
||||||
/** @var FetchesCompanyModule */
|
|
||||||
private $fetchesCompanyModule;
|
|
||||||
|
|
||||||
/** @var CreatesAddress */
|
|
||||||
private $createsAddress;
|
|
||||||
|
|
||||||
/** @var FetchesAddress */
|
|
||||||
private $fetchesAddress;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreateAddressLogic constructor.
|
|
||||||
* @param CanCreateAddress $canCreateAddress
|
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
|
||||||
* @param CreatesAddress $createsAddress
|
|
||||||
* @param FetchesAddress $fetchesAddress
|
|
||||||
*/
|
|
||||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress)
|
|
||||||
{
|
|
||||||
$this->canCreateAddress = $canCreateAddress;
|
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
|
||||||
$this->createsAddress = $createsAddress;
|
|
||||||
$this->fetchesAddress = $fetchesAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
{
|
|
||||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_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) {
|
|
||||||
// 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);
|
|
||||||
$this->canCreateAddress->passes($billingAddress);
|
|
||||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
|
||||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
|
||||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyDebtor;
|
|
||||||
use App\Http\Resources\CompanyResource;
|
|
||||||
use ErrorException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class UpdateCompanyNameAndDebtorLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Updated Company Name and Debtor',
|
|
||||||
'message' => 'You have successfully updated the Company'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CanUpdateCompany */
|
|
||||||
private $canUpdateCompany;
|
|
||||||
|
|
||||||
/** @var UpdatesCompany */
|
|
||||||
private $updatesCompany;
|
|
||||||
|
|
||||||
/** @var FetchesCompany */
|
|
||||||
private $fetchesCompany;
|
|
||||||
|
|
||||||
/** @var UpdatesCompanyDebtor */
|
|
||||||
private $updatesCompanyDebtor;
|
|
||||||
|
|
||||||
/** @var UpdatesCompanyModuleName */
|
|
||||||
private $updatesCompanyModuleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateCompanyControllersLogic constructor.
|
|
||||||
* @param CanUpdateCompany $canUpdateCompany
|
|
||||||
* @param UpdatesCompany $updatesCompany
|
|
||||||
* @param FetchesCompany $fetchesCompany
|
|
||||||
* @param UpdatesCompanyDebtor $updatesCompanyDebtor
|
|
||||||
* @param UpdatesCompanyModuleName $updatesCompanyModuleName
|
|
||||||
*/
|
|
||||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany, UpdatesCompanyDebtor $updatesCompanyDebtor, UpdatesCompanyModuleName $updatesCompanyModuleName)
|
|
||||||
{
|
|
||||||
$this->canUpdateCompany = $canUpdateCompany;
|
|
||||||
$this->updatesCompany = $updatesCompany;
|
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
|
||||||
$this->updatesCompanyDebtor = $updatesCompanyDebtor;
|
|
||||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
|
||||||
|
|
||||||
$this->canUpdateCompany->passes($object);
|
|
||||||
|
|
||||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
$this->updatesCompanyModuleName->execute($query->companyModules()->first(), $object->getName());
|
|
||||||
|
|
||||||
$query = $this->updatesCompany->execute($query, $object);
|
|
||||||
|
|
||||||
if ($request->input('debtor') || $query->first()->debtor !== null) {
|
|
||||||
$this->updatesCompanyDebtor->execute($query, $request->input('debtor'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->resourceResponse(new CompanyResource($query));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Companies\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
|
||||||
use App\Models\Company;
|
|
||||||
|
|
||||||
class UpdatesCompanyDebtor extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Company $model
|
|
||||||
* @param CompanyObject $object
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(Company $model, ?string $debtor)
|
|
||||||
{
|
|
||||||
$model->debtor = $debtor;
|
|
||||||
|
|
||||||
return $this->handler($model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Models\CompanyConnection;
|
|
||||||
use App\Models\Container;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\Package;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ExportsOrderSummaryByMarking implements FromCollection, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
||||||
{
|
|
||||||
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
protected $customerMarking;
|
|
||||||
protected $dateFrom;
|
|
||||||
protected $dateTo;
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Date',
|
|
||||||
'Container',
|
|
||||||
'Order Marking',
|
|
||||||
'Packing List Reference',
|
|
||||||
'Description',
|
|
||||||
'Quantity',
|
|
||||||
'L (cm)',
|
|
||||||
'H (cm)',
|
|
||||||
'W (cm)',
|
|
||||||
'CBM'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParameters($customerMarking, $dateFrom, $dateTo)
|
|
||||||
{
|
|
||||||
$this->customerMarking = $customerMarking;
|
|
||||||
$this->dateFrom = $dateFrom;
|
|
||||||
$this->dateTo = $dateTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function collection()
|
|
||||||
{
|
|
||||||
$connection = CompanyConnection::where('invitee_reference', $this->customerMarking)->first();
|
|
||||||
|
|
||||||
$company_id = $connection->invitee->company->id;
|
|
||||||
$company_module_id = $connection->invitee->id;
|
|
||||||
$packagesArray = collect();
|
|
||||||
$orders = Order::where('company_module_id', $company_module_id);
|
|
||||||
|
|
||||||
if (isset($this->dateFrom) && isset($this->dateTo)) {
|
|
||||||
$from = Carbon::createFromFormat('d-m-Y', $this->dateFrom);
|
|
||||||
$to = Carbon::createFromFormat('d-m-Y', $this->dateTo);
|
|
||||||
$orders = $orders->whereBetween('created_at', [$from, $to]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$orders = $orders->get();
|
|
||||||
|
|
||||||
foreach ($orders as $order){
|
|
||||||
$packingLists = $order->packingLists;
|
|
||||||
foreach ($packingLists as $packingList){
|
|
||||||
if($packingList->packingLists->first()){
|
|
||||||
$packingList = $packingList->packingLists->first();
|
|
||||||
}
|
|
||||||
$packages = $packingList->packages;
|
|
||||||
foreach ($packages as $package){
|
|
||||||
$packagesArray->push($package);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $packagesArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Package $package
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($package): array
|
|
||||||
{
|
|
||||||
$packinglist = ($package->packingList()->first()->owner->owner_type == Order::class) ? $package->packingList()->first(): $package->packingList->owner;
|
|
||||||
$order = $packinglist->owner;
|
|
||||||
|
|
||||||
return [
|
|
||||||
Carbon::parse($package->created_at)->format('d-m-Y'),
|
|
||||||
'',
|
|
||||||
$order->reference,
|
|
||||||
$package->packingList->reference,
|
|
||||||
$package->description,
|
|
||||||
$package->quantity,
|
|
||||||
$package->length,
|
|
||||||
$package->height,
|
|
||||||
$package->width,
|
|
||||||
((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -60,15 +60,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
|||||||
|
|
||||||
$query = Transaction::query();
|
$query = Transaction::query();
|
||||||
|
|
||||||
// paidInvoiceSection
|
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED]);
|
||||||
$approvalStatus = ApprovalStatus::COMPLETED;
|
|
||||||
|
|
||||||
if ($this->request->route('section') == 'pendingPaymentSection') {
|
|
||||||
// pendingPaymentSection
|
|
||||||
$approvalStatus = ApprovalStatus::APPROVED;
|
|
||||||
}
|
|
||||||
|
|
||||||
$query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [$approvalStatus]);
|
|
||||||
|
|
||||||
if($start_date && $end_date) {
|
if($start_date && $end_date) {
|
||||||
$query->whereBetween('updated_at', [
|
$query->whereBetween('updated_at', [
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
||||||
{
|
|
||||||
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Customer Marking',
|
|
||||||
'Order Number'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return Order::whereHas('addresses', function($address) {
|
|
||||||
$address->where('status', ApprovalStatus::APPROVED);
|
|
||||||
})->whereHas('packingLists', function($packingLists) {
|
|
||||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Order $order
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($order): array
|
|
||||||
{
|
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
|
||||||
|
|
||||||
return [
|
|
||||||
$marking,
|
|
||||||
$order->reference,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,19 +4,13 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
|||||||
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||||
use App\Http\Resources\OrderResource;
|
use App\Http\Resources\OrderResource;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
|
||||||
use App\Models\Address;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
@@ -45,12 +39,6 @@ class CreateOrderLogic extends AbstractControllerLogic
|
|||||||
/** @var GeneratesOrderNumber */
|
/** @var GeneratesOrderNumber */
|
||||||
private $generatesOrderNumber;
|
private $generatesOrderNumber;
|
||||||
|
|
||||||
/** @var CreatesAddress */
|
|
||||||
private $createsAddress;
|
|
||||||
|
|
||||||
/** @var CanCreateAddress */
|
|
||||||
private $canCreateAddress;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateOrderLogic constructor.
|
* CreateOrderLogic constructor.
|
||||||
* @param FetchesCompany $fetchesCompany
|
* @param FetchesCompany $fetchesCompany
|
||||||
@@ -58,18 +46,14 @@ class CreateOrderLogic extends AbstractControllerLogic
|
|||||||
* @param CreateOrderProcessor $createOrderProcessor
|
* @param CreateOrderProcessor $createOrderProcessor
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||||
* @param CreatesAddress $createsAddress
|
|
||||||
* @param CanCreateAddress $canCreateAddress
|
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, CreatesAddress $createsAddress, CanCreateAddress $canCreateAddress)
|
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber)
|
||||||
{
|
{
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
$this->fetchesAddress = $fetchesAddress;
|
$this->fetchesAddress = $fetchesAddress;
|
||||||
$this->createOrderProcessor = $createOrderProcessor;
|
$this->createOrderProcessor = $createOrderProcessor;
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||||
$this->createsAddress = $createsAddress;
|
|
||||||
$this->canCreateAddress = $canCreateAddress;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,21 +66,6 @@ class CreateOrderLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||||
|
|
||||||
if ($request->input('billing_address_id')) {
|
|
||||||
$companyModule = $company->companyModules->first();
|
|
||||||
$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) {
|
|
||||||
// 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);
|
|
||||||
$this->canCreateAddress->passes($billingAddress);
|
|
||||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
|
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
|
||||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
|
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ class FetchesDataFromYDPortal
|
|||||||
public function clientRequest(string $url, string $method, $body){
|
public function clientRequest(string $url, string $method, $body){
|
||||||
|
|
||||||
$client = new \GuzzleHttp\Client();
|
$client = new \GuzzleHttp\Client();
|
||||||
|
|
||||||
$body['apicode'] = env('YD_API_CODE');
|
$body['apicode'] = env('YD_API_CODE');
|
||||||
|
|
||||||
$request = $client->requestAsync($method, $url, ['query' => $body, 'timeout' => 15]);
|
$request = $client->requestAsync($method, $url, ['query' => $body]);
|
||||||
|
|
||||||
return $request->wait();
|
return $request->wait();
|
||||||
}
|
}
|
||||||
@@ -31,7 +32,6 @@ class FetchesDataFromYDPortal
|
|||||||
$content = $request->getBody()->getContents();
|
$content = $request->getBody()->getContents();
|
||||||
$content = str_replace("\r",'', $content);
|
$content = str_replace("\r",'', $content);
|
||||||
$content = str_replace("\n",'', $content);
|
$content = str_replace("\n",'', $content);
|
||||||
$content = str_replace("\t",'', $content);
|
|
||||||
return json_decode($content);
|
return json_decode($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ class CreatePackingListProcessor
|
|||||||
/** @var PackingList $packingList */
|
/** @var PackingList $packingList */
|
||||||
$packingList = $this->createsPackingList->execute($object, $packable);
|
$packingList = $this->createsPackingList->execute($object, $packable);
|
||||||
|
|
||||||
$appointee_id = $packingList->owner_id == 1 ? 2307 : $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
$appointee_id = $packingList->owner_id == 1 ? 2037 : $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||||
|
|
||||||
$type = $object->getType() === PackingListType::SHIPPING_PACKING_LIST ? PackingListType::SHIPPING_PACKING_LIST_REPLICA : PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA;
|
$type = $object->getType() === PackingListType::SHIPPING_PACKING_LIST ? PackingListType::SHIPPING_PACKING_LIST_REPLICA : PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA;
|
||||||
|
|
||||||
|
|||||||
@@ -1,160 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
|
||||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
|
||||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
|
||||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
|
||||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
|
||||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
|
||||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
|
||||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
|
||||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
|
||||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
|
||||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
|
||||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
|
||||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
|
||||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
|
||||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
|
||||||
use App\Models\Container;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transport;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class FetchContainersFromYdPortalProcessor
|
|
||||||
{
|
|
||||||
/** @var FetchesDataFromYDPortal */
|
|
||||||
private $fetchesDataFRomYDPortal;
|
|
||||||
|
|
||||||
/** @var CreatesTransport */
|
|
||||||
private $createsTransport;
|
|
||||||
|
|
||||||
/** @var CreatesSchedule */
|
|
||||||
private $createsSchedule;
|
|
||||||
|
|
||||||
/** @var FetchesContainer */
|
|
||||||
private $fetchesContainer;
|
|
||||||
|
|
||||||
/** @var CreateContainerProcessor */
|
|
||||||
private $createContainerProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
|
||||||
* @param CreatesTransport $createsTransport
|
|
||||||
* @param CreatesSchedule $createsSchedule
|
|
||||||
* @param FetchesContainer $fetchesContainer
|
|
||||||
* @param CreateContainerProcessor $createContainerProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, CreateContainerProcessor $createContainerProcessor)
|
|
||||||
{
|
|
||||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
|
||||||
$this->createsTransport = $createsTransport;
|
|
||||||
$this->createsSchedule = $createsSchedule;
|
|
||||||
$this->fetchesContainer = $fetchesContainer;
|
|
||||||
$this->createContainerProcessor = $createContainerProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
* @throws AccessForbiddenException
|
|
||||||
* @throws RequestValidationException
|
|
||||||
*/
|
|
||||||
public function execute()
|
|
||||||
{
|
|
||||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->doesntHave('containers')->get();
|
|
||||||
|
|
||||||
foreach ($packingLists as $packingList) {
|
|
||||||
$time_start = microtime(true);
|
|
||||||
|
|
||||||
$containerReference = null;
|
|
||||||
$loadingDate = null;
|
|
||||||
$etd = null;
|
|
||||||
$eta = null;
|
|
||||||
|
|
||||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
|
||||||
'trakingno' => $packingList->reference
|
|
||||||
]);
|
|
||||||
|
|
||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
|
||||||
|
|
||||||
if(!$rows->data){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
|
||||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
|
||||||
$tracking = explode(':', $trackingRow->tracking);
|
|
||||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
|
||||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
|
||||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($containerReference) {
|
|
||||||
try {
|
|
||||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
|
||||||
$container->packingLists()->detach($packingList);
|
|
||||||
$container->packingLists()->attach($packingList);
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
|
||||||
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
|
|
||||||
$originWarehouse = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
|
||||||
|
|
||||||
|
|
||||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
|
||||||
|
|
||||||
/** @var Container $container */
|
|
||||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
|
||||||
|
|
||||||
$container->packingLists()->detach($packingList);
|
|
||||||
$container->packingLists()->attach($packingList);
|
|
||||||
|
|
||||||
$transport = $container->transports()->first();
|
|
||||||
|
|
||||||
if(!$transport){
|
|
||||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$time_end = microtime(true);
|
|
||||||
|
|
||||||
$execution_time = ($time_end - $time_start)/60;
|
|
||||||
|
|
||||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-162
@@ -1,162 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
|
||||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
|
||||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
|
||||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Models\Container;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class FetchContainersUpdatesFromYdPortalProcessor
|
|
||||||
{
|
|
||||||
/** @var FetchesDataFromYDPortal */
|
|
||||||
private $fetchesDataFRomYDPortal;
|
|
||||||
|
|
||||||
/** @var UpdatesContractObligation */
|
|
||||||
private $updatesContractObligations;
|
|
||||||
|
|
||||||
/** @var CreatesSchedule */
|
|
||||||
private $createsSchedule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
|
||||||
* @param UpdatesContractObligation $updatesContractObligations
|
|
||||||
* @param CreatesSchedule $createsSchedule
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, UpdatesContractObligation $updatesContractObligations, CreatesSchedule $createsSchedule)
|
|
||||||
{
|
|
||||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
|
||||||
$this->updatesContractObligations = $updatesContractObligations;
|
|
||||||
$this->createsSchedule = $createsSchedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute()
|
|
||||||
{
|
|
||||||
$containers = Container::where('status', ApprovalStatus::PENDING_VERIFICATION)->get();
|
|
||||||
|
|
||||||
foreach ($containers as $container) {
|
|
||||||
$time_start = microtime(true);
|
|
||||||
|
|
||||||
$packingList = $container->packingLists()->random();
|
|
||||||
|
|
||||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
|
||||||
'trakingno' => $packingList->reference
|
|
||||||
]);
|
|
||||||
|
|
||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
|
||||||
|
|
||||||
if(!$rows->data){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$unstuffingDate = null;
|
|
||||||
$delayDate = null;
|
|
||||||
|
|
||||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
|
||||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
|
||||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
|
||||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
|
||||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
|
||||||
$dates = collect();
|
|
||||||
|
|
||||||
foreach($matches[0] as $date){
|
|
||||||
try {
|
|
||||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$rescheduleDate = $dates->sortDesc()->first();
|
|
||||||
|
|
||||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
|
||||||
/** @var Carbon $delayDate */
|
|
||||||
$delayDate = $rescheduleDate;
|
|
||||||
|
|
||||||
if($rescheduleETA === false && $delayDate) {
|
|
||||||
$delayDate = $delayDate->addDays('5');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '到港') {
|
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '已开船') {
|
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
|
||||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($delayDate){
|
|
||||||
$delayDate = $delayDate->addDays(2);
|
|
||||||
$transport = $container->transports()->first();
|
|
||||||
|
|
||||||
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
|
||||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
|
||||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
|
||||||
foreach ($container->packingLists as $packingList){
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
$user = $packingList->owner->companyModule->employees()->first();
|
|
||||||
if(app()->environment(['production'])) {
|
|
||||||
$user->notify(new ShipmentRescheduleEmail($user, $packingList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if($unstuffingDate){
|
|
||||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
|
||||||
foreach($container->packingLists as $packingList){
|
|
||||||
|
|
||||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
|
||||||
$packingList->status = ApprovalStatus::APPROVED;
|
|
||||||
$packingList->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
|
|
||||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
|
||||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
|
||||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
|
||||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$time_end = microtime(true);
|
|
||||||
|
|
||||||
$execution_time = ($time_end - $time_start)/60;
|
|
||||||
|
|
||||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-115
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
|
||||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
|
||||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
|
||||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
|
||||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
|
||||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
|
||||||
use App\Models\CompanyModule;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transport;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class FetchDeliveryUpdatesFromYdPortalProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var UpdatesContractObligation */
|
|
||||||
private $updatesContractObligations;
|
|
||||||
|
|
||||||
/** @var CreatesTransport */
|
|
||||||
private $createsTransport;
|
|
||||||
|
|
||||||
/** @var CreatesSchedule */
|
|
||||||
private $createsSchedule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param UpdatesContractObligation $updatesContractObligations
|
|
||||||
* @param CreatesTransport $createsTransport
|
|
||||||
* @param CreatesSchedule $createsSchedule
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatesContractObligation $updatesContractObligations, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
|
||||||
{
|
|
||||||
$this->updatesContractObligations = $updatesContractObligations;
|
|
||||||
$this->createsTransport = $createsTransport;
|
|
||||||
$this->createsSchedule = $createsSchedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
* @throws GuzzleException
|
|
||||||
*/
|
|
||||||
public function execute()
|
|
||||||
{
|
|
||||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereRaw('LENGTH(reference) > 12')->whereHas('containers', function ($container){
|
|
||||||
return $container->where('status', 3);
|
|
||||||
})->doesntHave('transports')->get()->reverse();
|
|
||||||
foreach ($packingLists->chunk(50) as $chunk) {
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($chunk as $packingList){
|
|
||||||
if(!$packingList->reference) continue;
|
|
||||||
$time_start = microtime(true);
|
|
||||||
|
|
||||||
$deliveryDate = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
|
||||||
|
|
||||||
$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) {
|
|
||||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
|
||||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
|
||||||
$deliveryDate = $trackingDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $exception){
|
|
||||||
dump($exception);
|
|
||||||
Log::debug('failed to fetch delivery tracking');
|
|
||||||
}
|
|
||||||
|
|
||||||
if($deliveryDate){
|
|
||||||
$packingList->status = ApprovalStatus::COMPLETED;
|
|
||||||
$packingList->save();
|
|
||||||
|
|
||||||
$deliveryDate = Carbon::parse($deliveryDate);
|
|
||||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
|
||||||
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
|
|
||||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
|
||||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
|
||||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
|
||||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$time_end = microtime(true);
|
|
||||||
|
|
||||||
$execution_time = ($time_end - $time_start)/60;
|
|
||||||
|
|
||||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+1
-1
@@ -264,7 +264,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
|||||||
//
|
//
|
||||||
// $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
// $this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||||
} else {
|
} else {
|
||||||
$appointee_id = 2307;
|
$appointee_id = 2037;
|
||||||
}
|
}
|
||||||
|
|
||||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, null);
|
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, null);
|
||||||
|
|||||||
+306
-330
@@ -139,360 +139,336 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
*/
|
*/
|
||||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||||
{
|
{
|
||||||
ini_set('max_execution_time', '900');
|
try {
|
||||||
// $missingOrders = ['M202302161513122', 'YW202302161027442', 'YW202302151637022', 'M202302151605025', 'M202302151527103', 'M202302151527356', 'M202302151556019', 'YW202302151520241', 'YW202302151445068', 'M202302151359169', 'YW202302151349223', 'YW202302151336520', 'M202302151334316', 'YW202302151148129', 'M202302151145379', 'M202302151142411', 'M202302151037036', 'M202302151036398', 'M202302150919406', 'M202302141535009', 'YW202302141532318', 'M202302141319463', 'M202302141319045', 'YW202302141405471', 'M202302141334494', 'YW202302141321569', 'YW202302141323005', 'M202302141309053', 'M202302140905116', 'M202302141039558', 'M202302141022333', 'YW202302140943182', 'YW202302140923485', 'YW202302131728233', 'YW202302131702040', 'M202302131649417', 'M202302131638056', 'YW202302131601110', 'YW202302131530436', 'YW202302131411338', 'YW202302131355161', 'YW202302131312526', 'M202302130859076', 'M202302111708070', 'M202302111455134', 'M202302111457501', 'M202302111444041', 'M202302111506514', 'M202302111440286', 'M202302111354585', 'M202302111055551', 'M202302110900216', 'YW202302101743112', 'M202302091559443', 'M202302101716374', 'M202302101700402', 'M202302101633570', 'M202302101612095', 'M202302101611408', 'M202302101542340', 'M202302101408370', 'M202302101323341', 'M202302101129532', 'M202302101025109', 'M202302101006595', 'M202302091706357', 'YW202302091255022', 'YW202302091448196', 'YW202302091446431', 'M202302091138154', 'M202302091129396', 'YW202302091028175', 'M202302091006545', 'YW202302090942033', 'YW202302081743094', 'M202302081530599', 'M202302081531210', 'M202302081508571', 'YW202302081530492', 'M202302081500361', 'M202302081253105', 'M202302081303370', 'M202302071636303', 'M202302071741187', 'YW202302071735407', 'M202302071706323', 'M202302071537501', 'M202302071538092', 'YW202302071516453', 'M202302071311314', 'M202302071148154', 'YW202302071136018', 'M202302071036027', 'M202302071008010', 'M202302061742178', 'M202302061615198', 'M202302061502093', 'M202302061458532', 'M202302061552141', 'M202302061548431', 'M202302061555033', 'YW202302061404567', 'M202302061322463', 'M202302061042556', 'M202302061021277', 'M202302060917276', 'M202302041551570', 'M202302041552382', 'YW202302041515257', 'M202302041405502', 'M202302041030185', 'YW202302041215576', 'YW202302041058469', 'YW202302041024459', 'YW202302040939568', 'M202302031701053', 'M202302031700316', 'M202302031430562', 'M202302031431535', 'M202302031147213', 'YW202302031406529', 'YW202302031322256', 'M202302021718554', 'M202302021417415', 'YW202302021404542', 'M202302021055324', 'YW202302021037462', 'M202302011613381', 'M202302011347586', 'M202302011348245', 'M202301151635132', 'M202301141803516', 'YW202301141653536', 'M202301131504477', 'M202301131538220', 'M202301121327453', 'YW202301111153183', 'M202301091649543', 'M202212311641071', 'YW202212211532191', 'YW202212191605226'];
|
$start = $start ? $start : Carbon::today()->subDays(30);
|
||||||
|
|
||||||
$from = $end ? Carbon::today()->diff($end)->days : 0;
|
$startLimit = Carbon::parse('01-12-2021');
|
||||||
$to = $start ? Carbon::today()->diff($start)->days : 10;
|
|
||||||
|
|
||||||
for ($x = $from; $x <= $to; $x++) {
|
if($start->isBefore($startLimit)){
|
||||||
try {
|
$start = $startLimit;
|
||||||
$startDate = Carbon::today()->subDays($x);
|
}
|
||||||
|
|
||||||
$startLimit = Carbon::parse('01-12-2021');
|
$end = $end ? $end : Carbon::today()->addDay();
|
||||||
|
|
||||||
if($startDate->isBefore($startLimit)){
|
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||||
$startDate = $startLimit;
|
'begintime' => $start->timestamp,
|
||||||
}
|
'endtime' => $end->timestamp,
|
||||||
|
]);
|
||||||
|
|
||||||
$endDate = Carbon::today()->subDays($x - 1);
|
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||||
|
|
||||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
foreach($rows->data as $row){
|
||||||
'begintime' => $startDate->timestamp,
|
|
||||||
'endtime' => $endDate->timestamp,
|
$containerReference = null;
|
||||||
|
$loadingDate = null;
|
||||||
|
$unstuffingDate = null;
|
||||||
|
$deliveryDate = null;
|
||||||
|
$etd = null;
|
||||||
|
$eta = null;
|
||||||
|
$delayDate = null;
|
||||||
|
|
||||||
|
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||||
|
'trakingno' => $row->expressno
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||||
|
|
||||||
if(!$rows->data) continue;
|
if(!$rows){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($rows->data as $row){
|
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||||
$time_start = microtime(true);
|
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
||||||
|
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
$containerReference = null;
|
|
||||||
$loadingDate = null;
|
|
||||||
$unstuffingDate = null;
|
|
||||||
$deliveryDate = null;
|
|
||||||
$etd = null;
|
|
||||||
$eta = null;
|
|
||||||
$delayDate = null;
|
|
||||||
$status = $row->status;
|
|
||||||
|
|
||||||
if($status >= 3){
|
|
||||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
|
||||||
'trakingno' => $row->expressno
|
|
||||||
]);
|
|
||||||
|
|
||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
|
||||||
|
|
||||||
if(!$rows){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
|
||||||
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
|
||||||
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
|
||||||
$tracking = explode(':', $trackingRow->tracking);
|
|
||||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
|
||||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
|
||||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
|
||||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
|
||||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
|
||||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
|
||||||
$dates = collect();
|
|
||||||
|
|
||||||
foreach($matches[0] as $date){
|
|
||||||
try {
|
|
||||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$rescheduleDate = $dates->sortDesc()->first();
|
|
||||||
|
|
||||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
|
||||||
/** @var Carbon $delayDate */
|
|
||||||
$delayDate = $rescheduleDate;
|
|
||||||
|
|
||||||
if($rescheduleETA === false && $delayDate) {
|
|
||||||
$delayDate = $delayDate->addDays('5');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '到港') {
|
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '已开船') {
|
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
|
||||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) {
|
|
||||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($status >= 5){
|
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
||||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
$tracking = explode(':', $trackingRow->tracking);
|
||||||
|
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||||
try {
|
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$row->expressno.'&sOrgId=sti');
|
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
$eta = Carbon::parse($tracking[2])->addDays(2);
|
||||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
|
||||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
|
||||||
if (Str::contains($trackingRow->PublicDescription, ['accepted/picked'])){
|
|
||||||
$unstuffingDate = $trackingDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
|
||||||
$deliveryDate = $trackingDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $exception){
|
|
||||||
Log::debug('failed to fetch delivery tracking');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||||
|
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
||||||
|
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
||||||
|
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
||||||
|
$dates = collect();
|
||||||
|
|
||||||
$orderNumber = $customerno[array_key_last($customerno)];
|
foreach($matches[0] as $date){
|
||||||
$allow_contract = true;
|
try {
|
||||||
|
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$rescheduleDate = $dates->sortDesc()->first();
|
||||||
|
|
||||||
|
if(!$delayDate || $rescheduleDate > $delayDate){
|
||||||
|
/** @var Carbon $delayDate */
|
||||||
|
$delayDate = $rescheduleDate;
|
||||||
|
|
||||||
|
if($rescheduleETA === false && $delayDate) {
|
||||||
|
$delayDate = $delayDate->addDays('5');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($trackingRow->tracking === '到港') {
|
||||||
|
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($trackingRow->tracking === '已开船') {
|
||||||
|
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||||
|
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) {
|
||||||
|
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$row->expressno.'&sOrgId=sti');
|
||||||
|
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||||
|
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||||
|
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
||||||
|
if (Str::contains($trackingRow->PublicDescription, ['accepted/picked'])){
|
||||||
|
$unstuffingDate = $trackingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
||||||
|
$deliveryDate = $trackingDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Exception $exception){
|
||||||
|
Log::debug('failed to fetch delivery tracking');
|
||||||
|
}
|
||||||
|
|
||||||
|
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||||
|
|
||||||
|
$orderNumber = $customerno[array_key_last($customerno)];
|
||||||
|
$allow_contract = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||||
|
} catch (ResourceNotFoundException $exception) {
|
||||||
try {
|
try {
|
||||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
||||||
} catch (ResourceNotFoundException $exception) {
|
} catch (ResourceNotFoundException $exception) {
|
||||||
try {
|
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
$allow_contract = false;
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
|
||||||
$allow_contract = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$packingListReference = $row->expressno;
|
|
||||||
|
|
||||||
try{
|
|
||||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
|
||||||
|
|
||||||
$packingList->packages()->delete();
|
|
||||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
|
||||||
if($replica) $replica->packages()->delete();
|
|
||||||
|
|
||||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
|
||||||
$warehouseReceiveList->packages()->delete();
|
|
||||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
|
||||||
if($replica) $replica->packages()->delete();
|
|
||||||
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
|
|
||||||
if (!$allow_contract) {
|
|
||||||
$appointee_id = 2307;
|
|
||||||
} else {
|
|
||||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
|
||||||
|
|
||||||
/** @var PackingList $warehouseReceiveList */
|
|
||||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
|
||||||
|
|
||||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
|
||||||
|
|
||||||
if ($allow_contract) {
|
|
||||||
|
|
||||||
$contract = $this->unityCreateContract->execute();
|
|
||||||
|
|
||||||
$contractReference = $contract->hash_id;
|
|
||||||
$contractObligations = $contract->contract_obligation_list;
|
|
||||||
|
|
||||||
$this->unityActivateContract->execute($contractReference);
|
|
||||||
|
|
||||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
|
||||||
|
|
||||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
|
||||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
|
||||||
|
|
||||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
|
||||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
|
||||||
|
|
||||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
|
||||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
|
||||||
|
|
||||||
if ($allow_contract) {
|
|
||||||
foreach ($contractObligations as $obligation) {
|
|
||||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
|
||||||
$this->createsStep->execute($packingList, $stepObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($row->deliverysize as $package) {
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!count($row->deliverysize)){
|
|
||||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
$weightCbm = (float) $row->weight / 500;
|
|
||||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
|
||||||
|
|
||||||
if($overWeightCbm > 0){
|
|
||||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
|
||||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($order instanceof Order){
|
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
|
||||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
|
||||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
|
||||||
'expressno' => $row->expressno
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($containerReference) {
|
|
||||||
try {
|
|
||||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
|
||||||
$container->packingLists()->detach($packingList);
|
|
||||||
$container->packingLists()->attach($packingList);
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
|
||||||
|
|
||||||
if (!$allow_contract) {
|
|
||||||
$appointee_id = 2307;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $appointee_id]);
|
|
||||||
|
|
||||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
|
||||||
/** @var Container $container */
|
|
||||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
|
||||||
|
|
||||||
$container->packingLists()->detach($packingList);
|
|
||||||
$container->packingLists()->attach($packingList);
|
|
||||||
|
|
||||||
$transport = $container->transports()->first();
|
|
||||||
|
|
||||||
if(!$transport){
|
|
||||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($delayDate){
|
|
||||||
$delayDate = $delayDate->addDays(2);
|
|
||||||
$transport = $container->transports()->first();
|
|
||||||
|
|
||||||
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
|
||||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
|
||||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
|
||||||
foreach ($container->packingLists as $packingList){
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
$user = $packingList->owner->companyModule->employees()->first();
|
|
||||||
if(app()->environment(['production'])) {
|
|
||||||
$user->notify(new ShipmentRescheduleEmail($user, $packingList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){
|
|
||||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
|
||||||
foreach($container->packingLists as $packingList){
|
|
||||||
|
|
||||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
|
||||||
$packingList->status = ApprovalStatus::APPROVED;
|
|
||||||
$packingList->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($allow_contract) {
|
|
||||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
|
||||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
|
||||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
|
||||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($deliveryDate && !$packingList->transports()->exists()){
|
|
||||||
$packingList->status = ApprovalStatus::COMPLETED;
|
|
||||||
$packingList->save();
|
|
||||||
|
|
||||||
$deliveryDate = Carbon::parse($deliveryDate);
|
|
||||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
|
||||||
/** @var Transport $transport */
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
|
||||||
|
|
||||||
|
|
||||||
if ($allow_contract) {
|
|
||||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
|
||||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
|
||||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
|
||||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$time_end = microtime(true);
|
|
||||||
|
|
||||||
$execution_time = ($time_end - $time_start)/60;
|
|
||||||
|
|
||||||
echo '<b>Total Execution Time:</b> '.$execution_time.' Mins';
|
|
||||||
echo 'successful';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $exception) {
|
$packingListReference = $row->expressno;
|
||||||
Log::debug($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try{
|
||||||
|
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||||
|
|
||||||
|
$packingList->packages()->delete();
|
||||||
|
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||||
|
if($replica) $replica->packages()->delete();
|
||||||
|
|
||||||
|
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
||||||
|
$warehouseReceiveList->packages()->delete();
|
||||||
|
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||||
|
if($replica) $replica->packages()->delete();
|
||||||
|
|
||||||
|
} catch (ResourceNotFoundException $exception) {
|
||||||
|
|
||||||
|
if (!$allow_contract) {
|
||||||
|
$appointee_id = 2037;
|
||||||
|
} else {
|
||||||
|
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||||
|
|
||||||
|
/** @var PackingList $warehouseReceiveList */
|
||||||
|
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||||
|
|
||||||
|
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||||
|
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||||
|
|
||||||
|
if ($allow_contract) {
|
||||||
|
|
||||||
|
$contract = $this->unityCreateContract->execute();
|
||||||
|
|
||||||
|
$contractReference = $contract->hash_id;
|
||||||
|
$contractObligations = $contract->contract_obligation_list;
|
||||||
|
|
||||||
|
$this->unityActivateContract->execute($contractReference);
|
||||||
|
|
||||||
|
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||||
|
|
||||||
|
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||||
|
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||||
|
|
||||||
|
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||||
|
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||||
|
|
||||||
|
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||||
|
}
|
||||||
|
|
||||||
|
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
||||||
|
|
||||||
|
/** @var PackingList $packingList */
|
||||||
|
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||||
|
|
||||||
|
if ($allow_contract) {
|
||||||
|
foreach ($contractObligations as $obligation) {
|
||||||
|
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||||
|
$this->createsStep->execute($packingList, $stepObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($row->deliverysize as $package) {
|
||||||
|
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
||||||
|
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||||
|
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!count($row->deliverysize)){
|
||||||
|
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
||||||
|
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
||||||
|
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||||
|
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||||
|
}
|
||||||
|
|
||||||
|
$weightCbm = (float) $row->weight / 500;
|
||||||
|
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||||
|
|
||||||
|
if($overWeightCbm > 0){
|
||||||
|
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
||||||
|
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
||||||
|
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($order instanceof Order){
|
||||||
|
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||||
|
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
||||||
|
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||||
|
'expressno' => $row->expressno
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($containerReference) {
|
||||||
|
try {
|
||||||
|
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||||
|
$container->packingLists()->detach($packingList);
|
||||||
|
$container->packingLists()->attach($packingList);
|
||||||
|
} catch (ResourceNotFoundException $exception){
|
||||||
|
|
||||||
|
if (!$allow_contract) {
|
||||||
|
$appointee_id = 2037;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $appointee_id]);
|
||||||
|
|
||||||
|
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||||
|
/** @var Container $container */
|
||||||
|
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||||
|
|
||||||
|
$container->packingLists()->detach($packingList);
|
||||||
|
$container->packingLists()->attach($packingList);
|
||||||
|
|
||||||
|
$transport = $container->transports()->first();
|
||||||
|
|
||||||
|
if(!$transport){
|
||||||
|
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
||||||
|
/** @var Transport $transport */
|
||||||
|
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||||
|
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($delayDate){
|
||||||
|
$delayDate = $delayDate->addDays(2);
|
||||||
|
$transport = $container->transports()->first();
|
||||||
|
|
||||||
|
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
||||||
|
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||||
|
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||||
|
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||||
|
foreach ($container->packingLists as $packingList){
|
||||||
|
if(!($packingList->owner instanceof Order)) continue;
|
||||||
|
$user = $packingList->owner->companyModule->employees()->first();
|
||||||
|
if(app()->environment(['production'])) {
|
||||||
|
$user->notify(new ShipmentRescheduleEmail($user, $packingList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){
|
||||||
|
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||||
|
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
||||||
|
|
||||||
|
/** @var PackingList $packingList */
|
||||||
|
foreach($container->packingLists as $packingList){
|
||||||
|
|
||||||
|
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||||
|
$packingList->status = ApprovalStatus::APPROVED;
|
||||||
|
$packingList->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($allow_contract) {
|
||||||
|
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||||
|
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||||
|
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||||
|
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($deliveryDate && !$packingList->transports()->exists()){
|
||||||
|
$packingList->status = ApprovalStatus::COMPLETED;
|
||||||
|
$packingList->save();
|
||||||
|
|
||||||
|
$deliveryDate = Carbon::parse($deliveryDate);
|
||||||
|
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||||
|
/** @var Transport $transport */
|
||||||
|
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||||
|
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||||
|
|
||||||
|
|
||||||
|
if ($allow_contract) {
|
||||||
|
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||||
|
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||||
|
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||||
|
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo 'successful';
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
Log::debug($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class FetchPackingListFromVTPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (GuzzleException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
|
dd($exception);
|
||||||
Log::error($exception);
|
Log::error($exception);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
-267
@@ -1,267 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
|
||||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
|
||||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
|
||||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
|
||||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
|
||||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
|
||||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
|
||||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
|
||||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchPackingListsFromYdPortalProcessor
|
|
||||||
{
|
|
||||||
/** @var FetchesDataFromYDPortal */
|
|
||||||
private $fetchesDataFRomYDPortal;
|
|
||||||
|
|
||||||
/** @var FetchesOrder */
|
|
||||||
private $fetchesOrder;
|
|
||||||
|
|
||||||
/** @var CreatePackingListProcessor */
|
|
||||||
private $createPackingListProcessor;
|
|
||||||
|
|
||||||
/** @var CreatePackageProcessor */
|
|
||||||
private $createPackageProcessor;
|
|
||||||
|
|
||||||
/** @var CreatesTransport */
|
|
||||||
private $createsTransport;
|
|
||||||
|
|
||||||
/** @var FetchesPackingList */
|
|
||||||
private $fetchesPackingList;
|
|
||||||
|
|
||||||
/** @var FetchesCompanyModule */
|
|
||||||
|
|
||||||
private $fetchesCompanyModule;
|
|
||||||
/** @var CreatesContract */
|
|
||||||
private $unityCreateContract;
|
|
||||||
|
|
||||||
/** @var AssignContractEntityProcessor */
|
|
||||||
private $unityAssignContractEntity;
|
|
||||||
|
|
||||||
/** @var CreateContractEntityProcessor */
|
|
||||||
private $unityCreateContractEntity;
|
|
||||||
|
|
||||||
/** @var CreatesStep */
|
|
||||||
private $createsStep;
|
|
||||||
|
|
||||||
/** @var ActivateContractProcessor */
|
|
||||||
private $unityActivateContract;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
|
||||||
* @param FetchesOrder $fetchesOrder
|
|
||||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
|
||||||
* @param CreatePackageProcessor $createPackageProcessor
|
|
||||||
* @param CreatesTransport $createsTransport
|
|
||||||
* @param FetchesPackingList $fetchesPackingList
|
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
|
||||||
* @param CreatesContract $unityCreateContract
|
|
||||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
|
||||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
|
||||||
* @param CreatesStep $createsStep
|
|
||||||
* @param ActivateContractProcessor $unityActivateContract
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesOrder $fetchesOrder, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
|
||||||
{
|
|
||||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
|
||||||
$this->fetchesOrder = $fetchesOrder;
|
|
||||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
|
||||||
$this->createPackageProcessor = $createPackageProcessor;
|
|
||||||
$this->createsTransport = $createsTransport;
|
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
|
||||||
$this->unityCreateContract = $unityCreateContract;
|
|
||||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
|
||||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
|
||||||
$this->createsStep = $createsStep;
|
|
||||||
$this->unityActivateContract = $unityActivateContract;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon|null $start
|
|
||||||
* @param Carbon|null $end
|
|
||||||
* @return void
|
|
||||||
* @throws GuzzleException
|
|
||||||
*/
|
|
||||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
|
||||||
{
|
|
||||||
$from = $end ? Carbon::today()->diff($end)->days : 0;
|
|
||||||
$to = $start ? Carbon::today()->diff($start)->days : 10;
|
|
||||||
|
|
||||||
for ($x = $from; $x <= $to; $x++) {
|
|
||||||
try {
|
|
||||||
$startDate = Carbon::today()->subDays($x);
|
|
||||||
|
|
||||||
$startLimit = Carbon::parse('01-12-2021');
|
|
||||||
|
|
||||||
if($startDate->isBefore($startLimit)){
|
|
||||||
$startDate = $startLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$endDate = Carbon::today()->subDays($x - 1);
|
|
||||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
|
||||||
'begintime' => $startDate->timestamp,
|
|
||||||
'endtime' => $endDate->timestamp,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
|
||||||
|
|
||||||
if(!$rows->data) continue;
|
|
||||||
|
|
||||||
foreach($rows->data as $row){
|
|
||||||
|
|
||||||
$time_start = microtime(true);
|
|
||||||
|
|
||||||
$receiveDate = Carbon::parse(substr(preg_replace("/[^0-9]/", "", $row->expressno), 0, 8));
|
|
||||||
|
|
||||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
|
||||||
|
|
||||||
$orderNumber = $customerno[array_key_last($customerno)];
|
|
||||||
$allow_contract = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
try {
|
|
||||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
|
||||||
$allow_contract = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingListReference = $row->expressno;
|
|
||||||
|
|
||||||
try{
|
|
||||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
|
||||||
|
|
||||||
$packingList->packages()->delete();
|
|
||||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
|
||||||
if($replica) $replica->packages()->delete();
|
|
||||||
|
|
||||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
|
||||||
$warehouseReceiveList->packages()->delete();
|
|
||||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
|
||||||
if($replica) $replica->packages()->delete();
|
|
||||||
|
|
||||||
} catch (ResourceNotFoundException $exception) {
|
|
||||||
|
|
||||||
if (!$allow_contract) {
|
|
||||||
$appointee_id = 2307;
|
|
||||||
} else {
|
|
||||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
|
||||||
|
|
||||||
/** @var PackingList $warehouseReceiveList */
|
|
||||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
|
||||||
|
|
||||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
|
||||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
|
||||||
|
|
||||||
if ($allow_contract) {
|
|
||||||
|
|
||||||
$contract = $this->unityCreateContract->execute();
|
|
||||||
|
|
||||||
$contractReference = $contract->hash_id;
|
|
||||||
$contractObligations = $contract->contract_obligation_list;
|
|
||||||
|
|
||||||
$this->unityActivateContract->execute($contractReference);
|
|
||||||
|
|
||||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
|
||||||
|
|
||||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
|
||||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
|
||||||
|
|
||||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
|
||||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
|
||||||
|
|
||||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
|
||||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
|
||||||
|
|
||||||
if ($allow_contract) {
|
|
||||||
foreach ($contractObligations as $obligation) {
|
|
||||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
|
||||||
$this->createsStep->execute($packingList, $stepObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($row->deliverysize as $package) {
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!count($row->deliverysize)){
|
|
||||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
$weightCbm = (float) $row->weight / 500;
|
|
||||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
|
||||||
|
|
||||||
if($overWeightCbm > 0){
|
|
||||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
|
||||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($order instanceof Order){
|
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
|
||||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
|
||||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
|
||||||
'expressno' => $row->expressno
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$time_end = microtime(true);
|
|
||||||
|
|
||||||
$execution_time = ($time_end - $time_start)/60;
|
|
||||||
|
|
||||||
echo 'successful => <b>Total Execution Time:</b> '.$execution_time.' Mins<br>';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
Log::debug($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+1
-1
@@ -152,7 +152,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
|||||||
} catch (ResourceNotFoundException $exception) {
|
} catch (ResourceNotFoundException $exception) {
|
||||||
$allow_contract = false;
|
$allow_contract = false;
|
||||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||||
$appointee_id = 2307;
|
$appointee_id = 2037;
|
||||||
}
|
}
|
||||||
|
|
||||||
$packingListReference = $parcel[0];
|
$packingListReference = $parcel[0];
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class CreateLeadPerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $name;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $email;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $phone;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $companyName;
|
|
||||||
|
|
||||||
public function __construct(string $name, string $email, string $phone, string $companyName)
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->name = $name;
|
|
||||||
$this->email = $email;
|
|
||||||
$this->phone = $phone;
|
|
||||||
$this->companyName = $companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getEmail(): string
|
|
||||||
{
|
|
||||||
return $this->email;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPhone(): string
|
|
||||||
{
|
|
||||||
return $this->phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCompanyName(): string
|
|
||||||
{
|
|
||||||
return $this->companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class CreateTaskPerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $email;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $name;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $description;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $leadId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $milestoneId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $projectId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $reference;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $onTaskCompletion;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $status;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status)
|
|
||||||
{
|
|
||||||
$this->email = $email;
|
|
||||||
$this->name = $name;
|
|
||||||
$this->description = $description;
|
|
||||||
$this->leadId = $leadId;
|
|
||||||
$this->projectId = $projectId;
|
|
||||||
$this->milestoneId = $milestoneId;
|
|
||||||
$this->reference = $reference;
|
|
||||||
$this->onTaskCompletion = $onTaskCompletion;
|
|
||||||
$this->status = $status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getEmail(): string
|
|
||||||
{
|
|
||||||
return $this->email;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getLeadId(): string
|
|
||||||
{
|
|
||||||
return $this->leadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLeadId(string $leadId)
|
|
||||||
{
|
|
||||||
$this->leadId = $leadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getProjectId(): string
|
|
||||||
{
|
|
||||||
return $this->projectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMilestoneId(): string
|
|
||||||
{
|
|
||||||
return $this->milestoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getReference(): string
|
|
||||||
{
|
|
||||||
return $this->reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getOnTaskCompletion(): string
|
|
||||||
{
|
|
||||||
return $this->onTaskCompletion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getStatus(): string
|
|
||||||
{
|
|
||||||
return $this->status;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class CustomerContactObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var int */
|
|
||||||
private $customerId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $firstname;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $lastname;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $email;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $password;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $isPrimary;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $sendSetPasswordEmail;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $customerId, string $firstname, string $lastname, string $email, string $password, string $isPrimary, string $sendSetPasswordEmail)
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->customerId = $customerId;
|
|
||||||
$this->firstname = $firstname;
|
|
||||||
$this->lastname = $lastname;
|
|
||||||
$this->email = $email;
|
|
||||||
$this->password = $password;
|
|
||||||
$this->isPrimary = $isPrimary;
|
|
||||||
$this->sendSetPasswordEmail = $sendSetPasswordEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getCustomerId(): int
|
|
||||||
{
|
|
||||||
return $this->customerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getFirstName(): string
|
|
||||||
{
|
|
||||||
return $this->firstname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getLastName(): string
|
|
||||||
{
|
|
||||||
return $this->lastname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getEmail(): string
|
|
||||||
{
|
|
||||||
return $this->email;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPassword(): string
|
|
||||||
{
|
|
||||||
return $this->password;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getIsPrimary(): string
|
|
||||||
{
|
|
||||||
return $this->isPrimary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getSendSetPasswordEmail(): string
|
|
||||||
{
|
|
||||||
return $this->sendSetPasswordEmail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class InitialPerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $companyName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $companyReference;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $contactName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $contactEmail;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $bookingMarking;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $projectName;
|
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
private $milestoneNames;
|
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
private $taskNames;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, array $milestoneNames, array $taskNames)
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->companyName = $companyName;
|
|
||||||
$this->companyReference = $companyReference;
|
|
||||||
$this->contactName = $contactName;
|
|
||||||
$this->contactEmail = $contactEmail;
|
|
||||||
$this->bookingMarking = $bookingMarking;
|
|
||||||
$this->projectName = $projectName;
|
|
||||||
$this->milestoneNames = $milestoneNames;
|
|
||||||
$this->taskNames = $taskNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCompanyName(): string
|
|
||||||
{
|
|
||||||
return $this->companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCompanyReference(): string
|
|
||||||
{
|
|
||||||
return $this->companyReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getContactName(): string
|
|
||||||
{
|
|
||||||
return $this->contactName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getContactEmail(): string
|
|
||||||
{
|
|
||||||
return $this->contactEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBookingMarking(): string
|
|
||||||
{
|
|
||||||
return $this->bookingMarking;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getProjectName(): string
|
|
||||||
{
|
|
||||||
return $this->projectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getMilestoneNames(): array
|
|
||||||
{
|
|
||||||
return $this->milestoneNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTaskNames(): array
|
|
||||||
{
|
|
||||||
return $this->taskNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class InvoicePaymentPerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var int */
|
|
||||||
private $invoiceId;
|
|
||||||
|
|
||||||
/** @var float */
|
|
||||||
private $amount;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $date;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $paymentMode;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $transactionId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $note;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(int $invoiceId, float $amount, string $date, int $paymentMode, string $transactionId, string $note)
|
|
||||||
{
|
|
||||||
$this->invoiceId = $invoiceId;
|
|
||||||
$this->amount = $amount;
|
|
||||||
$this->date = $date;
|
|
||||||
$this->paymentMode = $paymentMode;
|
|
||||||
$this->transactionId = $transactionId;
|
|
||||||
$this->note = $note;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getInvoiceId(): int
|
|
||||||
{
|
|
||||||
return $this->invoiceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getAmount(): float
|
|
||||||
{
|
|
||||||
return $this->amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDate(): string
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getPaymentMode(): int
|
|
||||||
{
|
|
||||||
return $this->paymentMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTransactionId(): string
|
|
||||||
{
|
|
||||||
return $this->transactionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getNote(): string
|
|
||||||
{
|
|
||||||
return $this->note;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class InvoicePerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var int */
|
|
||||||
private $clientId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $number;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $date;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $dueDate;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $currency;
|
|
||||||
|
|
||||||
/** @var float */
|
|
||||||
private $subTotal;
|
|
||||||
|
|
||||||
/** @var float */
|
|
||||||
private $total;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $billingStreet;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $projectId;
|
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
private $allowedPaymentModes;
|
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
private $invoiceItems;
|
|
||||||
|
|
||||||
public function __construct(string $clientId, string $number, string $date, string $dueDate, string $currency, float $subTotal, float $total, string $billingStreet, string $projectId, array $allowedPaymentModes, array $invoiceItems)
|
|
||||||
{
|
|
||||||
$this->clientId = $clientId;
|
|
||||||
$this->number = $number;
|
|
||||||
$this->date = $date;
|
|
||||||
$this->dueDate = $dueDate;
|
|
||||||
$this->currency = $currency;
|
|
||||||
$this->subTotal = $subTotal;
|
|
||||||
$this->total = $total;
|
|
||||||
$this->billingStreet = $billingStreet;
|
|
||||||
$this->projectId = $projectId;
|
|
||||||
$this->allowedPaymentModes = $allowedPaymentModes;
|
|
||||||
$this->invoiceItems = $invoiceItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getClientId(): int
|
|
||||||
{
|
|
||||||
return $this->clientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getNumber(): string
|
|
||||||
{
|
|
||||||
return $this->number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDate(): string
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDueDate(): string
|
|
||||||
{
|
|
||||||
return $this->dueDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCurrency(): string
|
|
||||||
{
|
|
||||||
return $this->currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getSubTotal(): float
|
|
||||||
{
|
|
||||||
return $this->subTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getTotal(): float
|
|
||||||
{
|
|
||||||
return $this->total;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBillingStreet(): string
|
|
||||||
{
|
|
||||||
return $this->billingStreet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getProjectId(): string
|
|
||||||
{
|
|
||||||
return $this->projectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getAllowedPaymentModes(): array
|
|
||||||
{
|
|
||||||
return $this->allowedPaymentModes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getInvoiceItems(): array
|
|
||||||
{
|
|
||||||
return $this->invoiceItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-86
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class InvoiceSingleItemPerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $description;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $longDescription;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $qty;
|
|
||||||
|
|
||||||
/** @var float */
|
|
||||||
public $rate;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $order;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $unit;
|
|
||||||
|
|
||||||
public function __construct(string $description, string $longDescription, int $qty, float $rate, int $order, string $unit)
|
|
||||||
{
|
|
||||||
$this->description = $description;
|
|
||||||
$this->longDescription = $longDescription;
|
|
||||||
$this->qty = $qty;
|
|
||||||
$this->rate = $rate;
|
|
||||||
$this->order = $order;
|
|
||||||
$this->unit = $unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getLongDescription(): string
|
|
||||||
{
|
|
||||||
return $this->longDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getQty(): int
|
|
||||||
{
|
|
||||||
return $this->qty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getRate(): float
|
|
||||||
{
|
|
||||||
return $this->rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getOrder(): int
|
|
||||||
{
|
|
||||||
return $this->order;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getUnit(): string
|
|
||||||
{
|
|
||||||
return $this->unit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class UpdatePerfexCRMObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $companyName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $companyReference;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $contactEmail;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $bookingMarking;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $projectName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $milestoneName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $taskName;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $companyName, string $companyReference, string $contactEmail, string $bookingMarking, string $projectName, string $milestoneName, string $taskName)
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->companyName = $companyName;
|
|
||||||
$this->companyReference = $companyReference;
|
|
||||||
$this->contactEmail = $contactEmail;
|
|
||||||
$this->bookingMarking = $bookingMarking;
|
|
||||||
$this->projectName = $projectName;
|
|
||||||
$this->milestoneName = $milestoneName;
|
|
||||||
$this->taskName = $taskName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCompanyName(): string
|
|
||||||
{
|
|
||||||
return $this->companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCompanyReference(): string
|
|
||||||
{
|
|
||||||
return $this->companyReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getContactEmail(): string
|
|
||||||
{
|
|
||||||
return $this->contactEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBookingMarking(): string
|
|
||||||
{
|
|
||||||
return $this->bookingMarking;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getProjectName(): string
|
|
||||||
{
|
|
||||||
return $this->projectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMilestoneName(): string
|
|
||||||
{
|
|
||||||
return $this->milestoneName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTaskName(): string
|
|
||||||
{
|
|
||||||
return $this->taskName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
// use App\Classes\Modules\PerfexCRM\DataTransferObjects\ContactObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoice;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoiceSingleItemPerfexCRMObject;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class CreatePerfexCRMInvoiceProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMInvoice */
|
|
||||||
private $createsPerfexCRMInvoice;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMInvoicePayment */
|
|
||||||
private $createsPerfexCRMInvoicePayment;
|
|
||||||
|
|
||||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
|
||||||
private $convertsPerfexCRMLeadToCustomer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMInvoiceProcessor constructor.
|
|
||||||
* @param CreatesPerfexCRMInvoice $createsPerfexCRMInvoice
|
|
||||||
*/
|
|
||||||
public function __construct(CreatesPerfexCRMInvoice $createsPerfexCRMInvoice,
|
|
||||||
CreatesPerfexCRMInvoicePayment $createsPerfexCRMInvoicePayment,
|
|
||||||
ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer)
|
|
||||||
{
|
|
||||||
$this->createsPerfexCRMInvoice = $createsPerfexCRMInvoice;
|
|
||||||
$this->createsPerfexCRMInvoicePayment = $createsPerfexCRMInvoicePayment;
|
|
||||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $transaction
|
|
||||||
* @param $purchaseOrder
|
|
||||||
* @param $supplier
|
|
||||||
* @return null|object
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute($transaction, $purchaseOrder, $supplier) {
|
|
||||||
$clientId = "";
|
|
||||||
$number = $transaction->bill_no;
|
|
||||||
$prefix = "INV-";
|
|
||||||
if (substr($number, 0, strlen($prefix)) == $prefix) {
|
|
||||||
$number = substr($number, strlen($prefix));
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = Carbon::parse($transaction->booking->created_at)->format('Y-m-d');
|
|
||||||
$dueDate = Carbon::parse($transaction->booking->created_at)->format('Y-m-d');
|
|
||||||
$currency = 1; //cief TODO: To look into Malaysia and Chinese currency
|
|
||||||
$subTotal = 0.00;
|
|
||||||
$total = 0.00;
|
|
||||||
|
|
||||||
$billingStreet = "";
|
|
||||||
$addresses = $supplier->addresses()->where('billing', '=', true)->first();
|
|
||||||
|
|
||||||
$billingStreet = $billingStreet.$addresses->street_one;
|
|
||||||
$billingStreet = $billingStreet.$addresses->street_two.',';
|
|
||||||
$billingStreet = $billingStreet.$addresses->district()->first()->name.',';
|
|
||||||
$billingStreet = $billingStreet.$addresses->postcode;
|
|
||||||
$billingStreet = $billingStreet.$addresses->state()->first()->name.',';
|
|
||||||
$billingStreet = $billingStreet.$addresses->country()->first()->name;
|
|
||||||
|
|
||||||
$projectId = "";
|
|
||||||
$allowedPaymentModes = [];
|
|
||||||
$invoiceItems = [];
|
|
||||||
|
|
||||||
$email = $supplier->employees()->first()->email;
|
|
||||||
$email = 'dillon37@yahoo.com'; //cief TODO: To be updated to user actual email address
|
|
||||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($email);
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$clientId = $result->payload['client_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
//newitems
|
|
||||||
foreach ($purchaseOrder->transactionDetails as $key => $transaction_detail){
|
|
||||||
$order = $key + 1;
|
|
||||||
$stockCode = $transaction_detail->product_code;
|
|
||||||
$description = $transaction_detail->product_name;
|
|
||||||
$quantity = $transaction_detail->quantity;
|
|
||||||
$unitPrice = 0.00;
|
|
||||||
if($transaction->booking()->first()->fix_currency_id !== 1)
|
|
||||||
$unitPrice = (1/$transaction->currency_rate) * $transaction_detail->price;
|
|
||||||
else
|
|
||||||
$unitPrice = $transaction_detail->price;
|
|
||||||
|
|
||||||
//$totalAmount = 0.00;
|
|
||||||
if($transaction->booking()->first()->fix_currency_id !== 1){
|
|
||||||
|
|
||||||
//$totalAmount = (float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity;
|
|
||||||
$subTotal += (1/$transaction->currency_rate) * $transaction_detail->price * $transaction_detail->quantity;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//$totalAmount = (float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity;
|
|
||||||
$subTotal += $transaction_detail->price * $transaction_detail->quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
//string $description, string $longDescription, int $qty, int $rate, int $order, string $unit
|
|
||||||
$invoiceSingleItem = new InvoiceSingleItemPerfexCRMObject(
|
|
||||||
$description,
|
|
||||||
"",
|
|
||||||
$quantity,
|
|
||||||
$unitPrice,
|
|
||||||
$order,
|
|
||||||
""
|
|
||||||
);
|
|
||||||
array_push($invoiceItems, $invoiceSingleItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($transaction->booking()->first()->fix_currency_id !== 1){
|
|
||||||
$total = ((1/$transaction->currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$total = $transaction->amount + $transaction->service_charge + $transaction->tax;
|
|
||||||
}
|
|
||||||
|
|
||||||
//cief TODO: To be updated, temporarily hardcoded allow payment modes
|
|
||||||
array_push($allowedPaymentModes, 1, 2);
|
|
||||||
|
|
||||||
$invoicePerfexCRMObject = new InvoicePerfexCRMObject(
|
|
||||||
$clientId,
|
|
||||||
$number,
|
|
||||||
$date,
|
|
||||||
$dueDate,
|
|
||||||
$currency,
|
|
||||||
$subTotal,
|
|
||||||
$total,
|
|
||||||
$billingStreet,
|
|
||||||
$projectId,
|
|
||||||
$allowedPaymentModes,
|
|
||||||
$invoiceItems
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = $this->createsPerfexCRMInvoice->execute($invoicePerfexCRMObject);
|
|
||||||
|
|
||||||
//If there is a checking whether an payment to an invoice need to be generated, do it here
|
|
||||||
if(true && $result->payload['id']){
|
|
||||||
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
|
||||||
$result->payload['id'],
|
|
||||||
$total,
|
|
||||||
$date,
|
|
||||||
1,
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
);
|
|
||||||
$this->createsPerfexCRMInvoicePayment->execute($invoicePaymentPerfexCRMObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
// use App\Classes\Modules\PerfexCRM\DataTransferObjects\ContactObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMLead;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatePerfexCRMLeadProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMLead */
|
|
||||||
private $createsPerfexCRMLead;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMLeadProcessor constructor.
|
|
||||||
* @param CreatesPerfexCRMLead $createsPerfexCRMLead
|
|
||||||
*/
|
|
||||||
public function __construct(CreatesPerfexCRMLead $createsPerfexCRMLead)
|
|
||||||
{
|
|
||||||
$this->createsPerfexCRMLead = $createsPerfexCRMLead;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject) {
|
|
||||||
return $this->createsPerfexCRMLead->execute($createLeadPerfexCRMObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatePerfexCRMTaskProcessor
|
|
||||||
{
|
|
||||||
/** @var CreatesPerfexCRMTask */
|
|
||||||
private $createsPerfexCRMTask;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
|
||||||
*/
|
|
||||||
public function __construct(CreatesPerfexCRMTask $createsPerfexCRMTask)
|
|
||||||
{
|
|
||||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
|
||||||
* @return true
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
|
|
||||||
$this->createsPerfexCRMTask->execute(
|
|
||||||
$createTaskPerfexCRMObject->getName(),
|
|
||||||
$createTaskPerfexCRMObject->getDescription(),
|
|
||||||
$createTaskPerfexCRMObject->getLeadId(),
|
|
||||||
$createTaskPerfexCRMObject->getMilestoneId(),
|
|
||||||
$createTaskPerfexCRMObject->getProjectId(),
|
|
||||||
$createTaskPerfexCRMObject->getReference(),
|
|
||||||
$createTaskPerfexCRMObject->getOnTaskCompletion(),
|
|
||||||
$createTaskPerfexCRMObject->getStatus(),
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMMilestone;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMMilestone;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMTask;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerContact;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMMilestones;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMStatus;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class InitializePerfexCRMProcessor
|
|
||||||
{
|
|
||||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
|
||||||
private $convertsPerfexCRMLeadToCustomer;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMCustomerProject */
|
|
||||||
private $createsPerfexCRMCustomerProject;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMMilestone */
|
|
||||||
private $createsPerfexCRMMilestone;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMTask */
|
|
||||||
private $createsPerfexCRMTask;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMProject */
|
|
||||||
private $fetchesPerfexCRMProject;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMMilestone */
|
|
||||||
private $fetchesPerfexCRMMilestone;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMTask */
|
|
||||||
private $fetchesPerfexCRMTask;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMCustomer */
|
|
||||||
private $createsPerfexCRMCustomer;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMCustomerContact */
|
|
||||||
private $createsPerfexCRMCustomerContact;
|
|
||||||
|
|
||||||
/** @var UpdatesPerfexCRM */
|
|
||||||
private $updatePerfexCRM;
|
|
||||||
|
|
||||||
/** @var UpdatesPerfexCRMCustomer */
|
|
||||||
private $updatesPerfexCRMCustomer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer
|
|
||||||
* @param CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject
|
|
||||||
* @param CreatesPerfexCRMMilestone $createsPerfexCRMMilestone
|
|
||||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
|
||||||
* @param FetchesPerfexCRMProject $fetchesPerfexCRMProject
|
|
||||||
* @param FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone
|
|
||||||
* @param FetchesPerfexCRMTask $fetchesPerfexCRMTask
|
|
||||||
* @param CreatesPerfexCRMCustomer $createsPerfexCRMCustomer
|
|
||||||
* @param CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact
|
|
||||||
* @param UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer
|
|
||||||
*/
|
|
||||||
public function __construct(ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
|
||||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
|
||||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
|
||||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
|
||||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
|
||||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
|
||||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
|
||||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
|
||||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
|
||||||
UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer)
|
|
||||||
{
|
|
||||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
|
||||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
|
||||||
$this->createsPerfexCRMMilestone = $createsPerfexCRMMilestone;
|
|
||||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
|
||||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
|
||||||
$this->fetchesPerfexCRMMilestone = $fetchesPerfexCRMMilestone;
|
|
||||||
$this->fetchesPerfexCRMTask = $fetchesPerfexCRMTask;
|
|
||||||
$this->createsPerfexCRMCustomer = $createsPerfexCRMCustomer;
|
|
||||||
$this->createsPerfexCRMCustomerContact = $createsPerfexCRMCustomerContact;
|
|
||||||
$this->updatesPerfexCRMCustomer = $updatesPerfexCRMCustomer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(InitialPerfexCRMObject $initialPerfexCRMObject) {
|
|
||||||
|
|
||||||
// Customer has to exist first before Project can appear under it
|
|
||||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
|
||||||
$crmCompany = $initialPerfexCRMObject->getCompanyName();
|
|
||||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($initialPerfexCRMObject->getContactEmail());
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$crmClientId = $result->payload['client_id'];
|
|
||||||
if (isset($result->payload['company'])) {
|
|
||||||
$crmCompany = $result->payload['company'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//if reach this point, this means this user is not a official customer nor is a lead in crm
|
|
||||||
//Create Customer has 2 parts: Create Company (client), Create Contact
|
|
||||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
|
||||||
if(is_null($result)){
|
|
||||||
$crmCompany = $crmCompany." 2";
|
|
||||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
|
||||||
}
|
|
||||||
|
|
||||||
$crmClientId = $result->payload['clientId'];
|
|
||||||
|
|
||||||
$customerContactObject = new CustomerContactObject(
|
|
||||||
$crmClientId,
|
|
||||||
$initialPerfexCRMObject->getContactName(),
|
|
||||||
$initialPerfexCRMObject->getContactName(),
|
|
||||||
$initialPerfexCRMObject->getContactEmail(),
|
|
||||||
"pU^T@sC#9Q",
|
|
||||||
"on",
|
|
||||||
"on"
|
|
||||||
);
|
|
||||||
$result = $this->createsPerfexCRMCustomerContact->execute($customerContactObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Update custom fields to identify company reference from exchange or shipping portal
|
|
||||||
$value_exists = false;
|
|
||||||
if (isset($result->payload['customfields'])) {
|
|
||||||
foreach ($result->payload['customfields'] as $element) {
|
|
||||||
if ($element['value'] === $initialPerfexCRMObject->getCompanyReference()) {
|
|
||||||
$value_exists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!$value_exists);
|
|
||||||
{
|
|
||||||
$result = $this->updatesPerfexCRMCustomer->execute($crmClientId, $crmCompany, $initialPerfexCRMObject->getCompanyReference());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
|
||||||
$result = $this->createsPerfexCRMCustomerProject->execute($initialPerfexCRMObject->getProjectName(), $crmClientId);
|
|
||||||
if(isset($result->payload)){ //Here means project creation successful
|
|
||||||
$projectId = $result->payload['project_id'];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$projectId = $this->fetchesPerfexCRMProject->execute($initialPerfexCRMObject->getProjectName(), $crmClientId)->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($result)){
|
|
||||||
$tasks = $initialPerfexCRMObject->getTaskNames();
|
|
||||||
|
|
||||||
//Create tasks with milestone
|
|
||||||
for($count=0; $count < count($tasks); $count++) {
|
|
||||||
$milestoneId = 0; //By default milestoneId is 0, having this set at individual task is optional
|
|
||||||
if($tasks[$count]['milestone'] != "") //Create milestone only if it is defined
|
|
||||||
{
|
|
||||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
|
||||||
$result = $this->createsPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId, $count);
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$milestoneId = $result->payload['milestone_id'];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$milestone = $this->fetchesPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId);
|
|
||||||
$array = json_decode(json_encode($milestone), true);
|
|
||||||
$milestoneId = $array[0]['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$taskStatus = PerfexCRMStatus::NOT_STARTED;
|
|
||||||
if($tasks[$count]['status'] != ''){
|
|
||||||
$taskStatus = $tasks[$count]['status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get existing or create task
|
|
||||||
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'], $taskStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMStatus;
|
|
||||||
use App\Classes\Jobs\CreatePerfexCRMSingleTask;
|
|
||||||
|
|
||||||
class NewLeadTaskToPerfexCRMProcessor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param None
|
|
||||||
* @return true
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute()
|
|
||||||
{
|
|
||||||
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
|
|
||||||
"dillontest1@gmail.com",
|
|
||||||
"test is the name of the task",
|
|
||||||
"this is the description of the task",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
PerfexCRMStatus::NOT_STARTED
|
|
||||||
);
|
|
||||||
|
|
||||||
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\Init;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMMilestones;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\Jobs\InitializePerfexCRM;
|
|
||||||
use App\Classes\Jobs\UpdatePerfexCRM;
|
|
||||||
|
|
||||||
class TransactionToPerfexCRMProcessor
|
|
||||||
{
|
|
||||||
/** @var FetchesCompany */
|
|
||||||
private $fetchesCompany;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMProcessor */
|
|
||||||
private $updatePerfexCRMProcessor;
|
|
||||||
|
|
||||||
/** @var InitializePerfexCRMProcessor */
|
|
||||||
private $initializePerfexCRMProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TransactionToPerfexCRMProcessor constructor.
|
|
||||||
* @param UpdatePerfexCRMProcessor $updatePerfexCRMProcessor
|
|
||||||
* @param InitializePerfexCRMProcessor $initializePerfexCRMProcessor
|
|
||||||
* @param FetchesCompany $fetchesCompany
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatePerfexCRMProcessor $updatePerfexCRMProcessor, InitializePerfexCRMProcessor $initializePerfexCRMProcessor, FetchesCompany $fetchesCompany)
|
|
||||||
{
|
|
||||||
$this->updatePerfexCRMProcessor = $updatePerfexCRMProcessor;
|
|
||||||
$this->initializePerfexCRMProcessor = $initializePerfexCRMProcessor;
|
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Transaction $model
|
|
||||||
* @param int $status
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(Transaction $model, int $status)
|
|
||||||
{
|
|
||||||
if($model->owner instanceof \App\Models\Transaction && $status == ApprovalStatus::APPROVED){
|
|
||||||
//dd(json_encode($packingList->owner()->first()->companyModule()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference));
|
|
||||||
//dd(json_encode($model->owner->owner->owner()->first()->companyModule()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference));
|
|
||||||
$companyModule = $model->owner->owner->owner()->first()->companyModule()->first();
|
|
||||||
$companyName = $companyModule->name;
|
|
||||||
$companyReference = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
|
||||||
$employee = $companyModule->employees()->first();
|
|
||||||
$contactEmail = $employee->email;
|
|
||||||
$contactName = $employee->name;
|
|
||||||
|
|
||||||
$orderReference = $model->owner->owner->owner()->first()->reference;
|
|
||||||
$packingListReference = $model->owner->owner->reference;
|
|
||||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
|
||||||
|
|
||||||
$bookingMarking = $model->owner->owner->id."-".$model->owner->owner->owner->id;
|
|
||||||
$initialPerfexCRMObject = new InitialPerfexCRMObject(
|
|
||||||
$companyName,
|
|
||||||
$companyReference,
|
|
||||||
$contactName,
|
|
||||||
$contactEmail,
|
|
||||||
$bookingMarking,
|
|
||||||
$projectName,
|
|
||||||
[],
|
|
||||||
[
|
|
||||||
PerfexCRMTasks::TASK_1,
|
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_1,
|
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_2,
|
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_3,
|
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_4,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
//$this->initializePerfexCRMProcessor->execute($initialPerfexCRMObject);
|
|
||||||
InitializePerfexCRM::dispatch($initialPerfexCRMObject);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMMilestone;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMMilestone;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMTask;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerContact;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMTask;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMStatus;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class UpdatePerfexCRMProcessor
|
|
||||||
{
|
|
||||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
|
||||||
private $convertsPerfexCRMLeadToCustomer;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMCustomerProject */
|
|
||||||
private $createsPerfexCRMCustomerProject;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMMilestone */
|
|
||||||
private $createsPerfexCRMMilestone;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMTask */
|
|
||||||
private $createsPerfexCRMTask;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMProject */
|
|
||||||
private $fetchesPerfexCRMProject;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMMilestone */
|
|
||||||
private $fetchesPerfexCRMMilestone;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMTask */
|
|
||||||
private $fetchesPerfexCRMTask;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMCustomer */
|
|
||||||
private $createsPerfexCRMCustomer;
|
|
||||||
|
|
||||||
/** @var CreatesPerfexCRMCustomerContact */
|
|
||||||
private $createsPerfexCRMCustomerContact;
|
|
||||||
|
|
||||||
/** @var UpdatesPerfexCRMTask */
|
|
||||||
private $updatesPerfexCRMTask;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer
|
|
||||||
* @param CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject
|
|
||||||
* @param CreatesPerfexCRMMilestone $createsPerfexCRMMilestone
|
|
||||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
|
||||||
* @param FetchesPerfexCRMProject $fetchesPerfexCRMProject
|
|
||||||
* @param FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone
|
|
||||||
* @param FetchesPerfexCRMTask $fetchesPerfexCRMTask
|
|
||||||
* @param CreatesPerfexCRMCustomer $createsPerfexCRMCustomer
|
|
||||||
* @param CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact
|
|
||||||
* @param UpdatesPerfexCRMTask $updatesPerfexCRMTask
|
|
||||||
*/
|
|
||||||
public function __construct(ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
|
||||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
|
||||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
|
||||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
|
||||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
|
||||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
|
||||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
|
||||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
|
||||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
|
||||||
UpdatesPerfexCRMTask $updatesPerfexCRMTask)
|
|
||||||
{
|
|
||||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
|
||||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
|
||||||
$this->createsPerfexCRMMilestone = $createsPerfexCRMMilestone;
|
|
||||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
|
||||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
|
||||||
$this->fetchesPerfexCRMMilestone = $fetchesPerfexCRMMilestone;
|
|
||||||
$this->fetchesPerfexCRMTask = $fetchesPerfexCRMTask;
|
|
||||||
$this->createsPerfexCRMCustomer = $createsPerfexCRMCustomer;
|
|
||||||
$this->createsPerfexCRMCustomerContact = $createsPerfexCRMCustomerContact;
|
|
||||||
$this->updatesPerfexCRMTask = $updatesPerfexCRMTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PerfexCRMObject $perfexCRMObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(UpdatePerfexCRMObject $updatePerfexCRMObject) {
|
|
||||||
|
|
||||||
// Customer has to exist first before Project can appear under it
|
|
||||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
|
||||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($updatePerfexCRMObject->getContactEmail());
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$crmClientId = $result->payload['client_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
|
||||||
$result = $this->createsPerfexCRMCustomerProject->execute($updatePerfexCRMObject->getProjectName(), $crmClientId);
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$projectId = $result->payload['project_id'];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$projectId = $this->fetchesPerfexCRMProject->execute($updatePerfexCRMObject->getProjectName(), $crmClientId)->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
|
||||||
$result = $this->createsPerfexCRMMilestone->execute($updatePerfexCRMObject->getMilestoneName(), $projectId);
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$milestoneId = $result->payload['milestone_id'];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$milestone = $this->fetchesPerfexCRMMilestone->execute($updatePerfexCRMObject->getMilestoneName(), $projectId);
|
|
||||||
$array = json_decode(json_encode($milestone), true);
|
|
||||||
$milestoneId = $array[0]['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get existing or create task
|
|
||||||
$result = $this->createsPerfexCRMTask->execute($updatePerfexCRMObject->getTaskName(), $milestoneId, $projectId);
|
|
||||||
if(isset($result->payload)){
|
|
||||||
$taskId = $result->payload['task_id'];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$taskId = $this->fetchesPerfexCRMTask->execute($updatePerfexCRMObject->getTaskName(), $milestoneId)->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->updatesPerfexCRMTask->execute($taskId, $updatePerfexCRMObject->getTaskName(), $milestoneId, $projectId, PerfexCRMStatus::COMPLETED);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ConvertsPerfexCRMLeadToCustomer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $email
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $email) {
|
|
||||||
try{
|
|
||||||
$response = Http::withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key'),])
|
|
||||||
->get(config('perfexcrm.base_url').'/api/leads/convertocustomer/'.$email);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMCustomer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $companyName
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $companyName) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'company' => $companyName
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/customers',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMCustomerContact
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param CustomerContactObject $customerContactObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(CustomerContactObject $customerContactObject) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'customer_id' => $customerContactObject->getCustomerId(),
|
|
||||||
'firstname' => $customerContactObject->getFirstName(),
|
|
||||||
'lastname' => $customerContactObject->getLastName(),
|
|
||||||
'email' => $customerContactObject->getEmail(), //$email
|
|
||||||
'password' => $customerContactObject->getPassword(),
|
|
||||||
'is_primary' => $customerContactObject->getIsPrimary(),
|
|
||||||
//'send_set_password_email' => $customerContactObject->getSendSetPasswordEmail(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/contacts',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMCustomerProject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $projectName
|
|
||||||
* @param string $clientId
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $projectName, string $clientId) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'name' => $projectName,
|
|
||||||
'rel_type' => 'customer',
|
|
||||||
'billing_type' => 1,
|
|
||||||
'clientid' => $clientId,
|
|
||||||
'start_date' => date('Y-m-d'),
|
|
||||||
'status' => 1
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/projects',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMInvoice
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param InvoicePerfexCRMObject $invoicePerfexCRMObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(InvoicePerfexCRMObject $invoicePerfexCRMObject) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'clientid' => $invoicePerfexCRMObject->getClientId(),
|
|
||||||
'number' => $invoicePerfexCRMObject->getNumber(),
|
|
||||||
'date' => $invoicePerfexCRMObject->getDate(),
|
|
||||||
'duedate' => $invoicePerfexCRMObject->getDueDate(),
|
|
||||||
'currency' => $invoicePerfexCRMObject->getCurrency(),
|
|
||||||
'subtotal' => $invoicePerfexCRMObject->getSubTotal(),
|
|
||||||
'total' => $invoicePerfexCRMObject->getTotal(),
|
|
||||||
'billing_street' => $invoicePerfexCRMObject->getBillingStreet(),
|
|
||||||
'project_id' => $invoicePerfexCRMObject->getProjectId(),
|
|
||||||
'allowed_payment_modes[0]' => 1,
|
|
||||||
'allowed_payment_modes[1]' => 2,
|
|
||||||
];
|
|
||||||
|
|
||||||
for($count=0; $count < count($invoicePerfexCRMObject->getInvoiceItems()); $count++) {
|
|
||||||
$oneItem = [
|
|
||||||
"newitems[".$count."][description]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->description,
|
|
||||||
"newitems[".$count."][long_description]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->longDescription,
|
|
||||||
"newitems[".$count."][qty]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->qty,
|
|
||||||
"newitems[".$count."][rate]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->rate,
|
|
||||||
"newitems[".$count."][order]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->order,
|
|
||||||
"newitems[".$count."][unit]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->unit,
|
|
||||||
];
|
|
||||||
$data = array_merge($data, $oneItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/invoices',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMInvoicePayment
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param InvoicePaymentPerfexCRMObject $invoicePaymentPerfexCRMObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(InvoicePaymentPerfexCRMObject $invoicePaymentPerfexCRMObject) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'invoiceid' => $invoicePaymentPerfexCRMObject->getInvoiceId(),
|
|
||||||
'amount' => $invoicePaymentPerfexCRMObject->getAmount(),
|
|
||||||
'date' => $invoicePaymentPerfexCRMObject->getDate(),
|
|
||||||
'paymentmode' => $invoicePaymentPerfexCRMObject->getPaymentMode(),
|
|
||||||
'transactionid' => $invoicePaymentPerfexCRMObject->getTransactionId(),
|
|
||||||
'note' => $invoicePaymentPerfexCRMObject->getNote(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/invoices/recordpayment',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMLead
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'name' => $createLeadPerfexCRMObject->getName(),
|
|
||||||
'email' => $createLeadPerfexCRMObject->getEmail(),
|
|
||||||
'phonenumber' => $createLeadPerfexCRMObject->getPhone(),
|
|
||||||
'company' => $createLeadPerfexCRMObject->getCompanyName(),
|
|
||||||
'source' => 2, //1: Exchange, 2: Shipping Portal
|
|
||||||
'status' => 2 //2: Lead, 1: Customer
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/leads/byemail',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMMilestone
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $$milestoneName
|
|
||||||
* @param string $projectId
|
|
||||||
* @param string $milestoneOrder
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $milestoneName, string $projectId, string $milestoneOrder = "") {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'name' => $milestoneName,
|
|
||||||
'project_id' => $projectId,
|
|
||||||
'due_date' => date('Y-m-d'),
|
|
||||||
'start_date' => date('Y-m-d')
|
|
||||||
];
|
|
||||||
|
|
||||||
if($milestoneOrder != ""){
|
|
||||||
$data['milestone_order'] = $milestoneOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/milestones',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreatesPerfexCRMTask
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $taskName
|
|
||||||
* @param string $taskDescription
|
|
||||||
* @param string $leadId
|
|
||||||
* @param string $milestoneId
|
|
||||||
* @param string $projectId
|
|
||||||
* @param string $reference, default: ''
|
|
||||||
* @param string $on_task_completion, default: ''
|
|
||||||
* @param string $status, default: 1
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $taskName, string $taskDescription, string $leadId, string $milestoneId, string $projectId, string $reference = '', string $on_task_completion = '', string $status = "1") {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'name' => $taskName,
|
|
||||||
'description' => $taskDescription,
|
|
||||||
'milestone' => $milestoneId,
|
|
||||||
'startdate' => date('Y-m-d'),
|
|
||||||
'rel_type' => 'project',
|
|
||||||
'rel_id' => $projectId,
|
|
||||||
'status' => $status,
|
|
||||||
'is_system_created' => 1,
|
|
||||||
'reference' => $reference,
|
|
||||||
'on_task_completion' => $on_task_completion
|
|
||||||
];
|
|
||||||
|
|
||||||
if($leadId != '') {
|
|
||||||
$data = [
|
|
||||||
'name' => $taskName,
|
|
||||||
'description' => $taskDescription,
|
|
||||||
'milestone' => $milestoneId,
|
|
||||||
'startdate' => date('Y-m-d'),
|
|
||||||
'rel_type' => 'lead',
|
|
||||||
'rel_id' => $leadId,
|
|
||||||
'status' => $status,
|
|
||||||
'is_system_created' => 1,
|
|
||||||
'reference' => $reference,
|
|
||||||
'on_task_completion' => $on_task_completion
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/tasks',$data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchesPerfexCRMLead
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $email
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $email) {
|
|
||||||
try{
|
|
||||||
$response = Http::withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key'),])
|
|
||||||
->get(config('perfexcrm.base_url').'/api/leads/byemail/'.$email);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchesPerfexCRMMilestone
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $milestoneName
|
|
||||||
* @param string $projectId
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $milestoneName, string $projectId) {
|
|
||||||
try{
|
|
||||||
$response = Http::withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key'),])
|
|
||||||
->get(config('perfexcrm.base_url').'/api/milestones/bynameandprojectid/'.rawurlencode($milestoneName).'/'.$projectId);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchesPerfexCRMProject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $projectName
|
|
||||||
* @param string $clientId
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $projectName, string $clientId) {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'name' => $projectName,
|
|
||||||
'clientid' => $clientId,
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asForm()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->post(config('perfexcrm.base_url').'/api/projects/bynameandclientid', $data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchesPerfexCRMTask
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $taskName
|
|
||||||
* @param string $milestoneId
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $taskName, string $milestoneId) {
|
|
||||||
try{
|
|
||||||
$response = Http::withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key'),])
|
|
||||||
->get(config('perfexcrm.base_url').'/api/tasks/bynameandmilestoneid/'.rawurlencode($taskName).'/'.$milestoneId);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class UpdatesPerfexCRMCustomer
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $customerId
|
|
||||||
* @param string $companyReference
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $customerId, string $companyName, string $companyReference) {
|
|
||||||
try{
|
|
||||||
$custom_fields = [
|
|
||||||
"customers" => [
|
|
||||||
2 => $companyReference
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'company' => $companyName,
|
|
||||||
'custom_fields' => $custom_fields
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asJson()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->put(config('perfexcrm.base_url').'/api/customers/'.$customerId, $data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class UpdatesPerfexCRMTask
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $taskName
|
|
||||||
* @param string $milestoneId
|
|
||||||
* @param string $projectId
|
|
||||||
* @param string $status, default: 1
|
|
||||||
* @return null|object
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $taskId, string $taskName, string $milestoneId, string $projectId, string $status = "1") {
|
|
||||||
try{
|
|
||||||
$data = [
|
|
||||||
'name' => $taskName,
|
|
||||||
'milestone' => $milestoneId,
|
|
||||||
'startdate' => date('Y-m-d'),
|
|
||||||
'duedate' => date('Y-m-d'),
|
|
||||||
'rel_type' => 'project',
|
|
||||||
'rel_id' => $projectId,
|
|
||||||
'status' => $status,
|
|
||||||
'repeat_every' => '',
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::asJson()->withHeaders([
|
|
||||||
'authtoken' => config('perfexcrm.api_key')])
|
|
||||||
->put(config('perfexcrm.base_url').'/api/tasks/'.$taskId, $data);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
Log::error($response);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+40
-8
@@ -3,13 +3,12 @@
|
|||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
@@ -37,17 +36,29 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
/** @var FetchesPackingList */
|
/** @var FetchesPackingList */
|
||||||
private $fetchesPackingList;
|
private $fetchesPackingList;
|
||||||
|
|
||||||
/** @var ApproveShippingInvoiceTransactionProcessor */
|
/** @var UpdatesTransactionStatus */
|
||||||
private $approveShippingInvoiceTransactionProcessor;
|
private $updatesTransactionStatus;
|
||||||
|
|
||||||
|
/** @var CreatesDocument */
|
||||||
|
private $createsDocument;
|
||||||
|
|
||||||
|
/** @var CreatesFiles */
|
||||||
|
private $createsFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ApprovePaymentVerificationLogic constructor.
|
||||||
* @param FetchesPackingList $fetchesPackingList
|
* @param FetchesPackingList $fetchesPackingList
|
||||||
* @param ApproveShippingInvoiceTransactionProcessor $approveShippingInvoiceTransactionProcessor
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
|
* @param CreatesDocument $createsDocument
|
||||||
|
* @param CreatesFiles $createsFiles
|
||||||
|
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesPackingList $fetchesPackingList, ApproveShippingInvoiceTransactionProcessor $approveShippingInvoiceTransactionProcessor)
|
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||||
{
|
{
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
$this->fetchesPackingList = $fetchesPackingList;
|
||||||
$this->approveShippingInvoiceTransactionProcessor = $approveShippingInvoiceTransactionProcessor;
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
|
$this->createsDocument = $createsDocument;
|
||||||
|
$this->createsFiles = $createsFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,8 +69,29 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||||
$this->approveShippingInvoiceTransactionProcessor->execute($packing_list);
|
|
||||||
|
|
||||||
|
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||||
|
|
||||||
|
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||||
|
|
||||||
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||||
|
|
||||||
|
$document_object = new DocumentObject(
|
||||||
|
DocumentType::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([]);
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ use Illuminate\Http\JsonResponse;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
|
||||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
|
|||||||
+226
-12
@@ -5,15 +5,41 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
||||||
|
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||||
|
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||||
|
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||||
|
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||||
|
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||||
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||||
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||||
|
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
|
use App\Classes\ValueObjects\Constants\PackageType;
|
||||||
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||||
|
|
||||||
|
use App\Models\CompanyModule;
|
||||||
|
use App\Models\Document;
|
||||||
|
use App\Models\PackingList;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
|
||||||
class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -27,26 +53,214 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
/** @var FetchesPackingList */
|
/** @var FetchesPackingList */
|
||||||
private $fetchesPackingList;
|
private $fetchesPackingList;
|
||||||
|
|
||||||
/** @var CreateInvoiceTransactionProcessor */
|
/** @var FetchesSegmentConstant */
|
||||||
private $createInvoiceTransactionProcessor;
|
private $fetchesSegmentConstant;
|
||||||
|
|
||||||
/**
|
/** @var GeneratesTransactionBillNumber */
|
||||||
* @param FetchesPackingList $fetchesPackingList
|
private $generatesTransactionBillNumber;
|
||||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
|
||||||
*/
|
/** @var CreatesTransaction */
|
||||||
public function __construct(FetchesPackingList $fetchesPackingList, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor)
|
private $createsTransaction;
|
||||||
|
|
||||||
|
/** @var CreatesTransactionDetail */
|
||||||
|
private $createsTransactionDetail;
|
||||||
|
|
||||||
|
/** @var CreatesDocument */
|
||||||
|
private $createsDocument;
|
||||||
|
|
||||||
|
/** @var CreatesFiles */
|
||||||
|
private $createsFile;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
FetchesPackingList $fetchesPackingList,
|
||||||
|
FetchesSegmentConstant $fetchesSegmentConstant,
|
||||||
|
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||||
|
CreatesTransaction $createsTransaction,
|
||||||
|
CreatesTransactionDetail $createsTransactionDetail,
|
||||||
|
CreatesDocument $createsDocument,
|
||||||
|
CreatesFiles $createsFile
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
$this->fetchesPackingList = $fetchesPackingList;
|
||||||
$this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor;
|
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||||
|
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||||
|
$this->createsTransaction = $createsTransaction;
|
||||||
|
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||||
|
$this->createsDocument = $createsDocument;
|
||||||
|
$this->createsFile = $createsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||||
$this->createInvoiceTransactionProcessor->execute($packing_list);
|
$packing_list = PackingList::where('reference', $packing_list->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
||||||
|
|
||||||
|
$billable_packing_list = $packing_list->packingLists()->first();
|
||||||
|
|
||||||
|
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packing_list;
|
||||||
|
|
||||||
|
$cbm = round($billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||||
|
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||||
|
}), 3);
|
||||||
|
|
||||||
|
$over_weight_cbm = round($billable_packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||||
|
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||||
|
}), 3);
|
||||||
|
|
||||||
|
$order = $packing_list->owner;
|
||||||
|
$companyModule = $order->companyModule;
|
||||||
|
$connection = $companyModule->connections()->first();
|
||||||
|
$address = $order->addresses()->first();
|
||||||
|
|
||||||
|
$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]);
|
||||||
|
$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]);
|
||||||
|
|
||||||
|
$noMinimumCharge = $connection->segments()->where('segments.id', 2)->first();
|
||||||
|
|
||||||
|
$minimum_cbm = 0.3;
|
||||||
|
$state_select = '';
|
||||||
|
|
||||||
|
$segment_price = $connection->segments()->whereHas('constants', function($query){
|
||||||
|
return $query->where('reference', SegmentConstants::CUSTOM_PRICE);
|
||||||
|
})->get()->map(function($segment){
|
||||||
|
return (float) $segment->constants()->first()->value[0];
|
||||||
|
})->sort()->first();
|
||||||
|
$segment_price = $segment_price ? $segment_price : 0;
|
||||||
|
|
||||||
|
$packing_list_drop_date = PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first()->drop_date->format('Y-m-d');
|
||||||
|
$base_price = $this->getConstantByKey($base_price_constant, $packing_list_drop_date);
|
||||||
|
|
||||||
|
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
||||||
|
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
|
||||||
|
$warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0;
|
||||||
|
|
||||||
|
$stateId = $address->state_id;
|
||||||
|
$state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId);
|
||||||
|
|
||||||
|
// get $state_rate
|
||||||
|
$postcode = $address->postcode;
|
||||||
|
$this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ;
|
||||||
|
$this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ;
|
||||||
|
$state_rate_constant = (array)$state_rate_constant;
|
||||||
|
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
||||||
|
|
||||||
|
$container = $packing_list->containers()->first();
|
||||||
|
$containerPackingLists = collect();
|
||||||
|
$hasMinimumCharge = null;
|
||||||
|
|
||||||
|
foreach ($container->packingLists as $packingList){
|
||||||
|
if($packingList->owner instanceof CompanyModule) continue;
|
||||||
|
if($packingList->owner->companyModule->id !== $companyModule->id) continue;
|
||||||
|
$containerPackingLists->push($packingList);
|
||||||
|
|
||||||
|
if(!$hasMinimumCharge) {
|
||||||
|
$hasMinimumCharge = $packingList->transactions()->whereHas('transactionDetails', function ($query){
|
||||||
|
$query->where('reference', 'MIN_CBM_CHARGES');
|
||||||
|
})->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalContainerCbm = $containerPackingLists->sum(function($packingList){
|
||||||
|
$billable_packing_list = $packingList->packingLists()->first();
|
||||||
|
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packingList;
|
||||||
|
return $billable_packing_list->packages->sum(function($package) {
|
||||||
|
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$minimum_charge = $minimum_cbm - $totalContainerCbm;
|
||||||
|
$minimum_charge = ($minimum_charge < 0) ? 0 : $minimum_charge;
|
||||||
|
$minimum_charge = $noMinimumCharge ? 0 : $minimum_charge;
|
||||||
|
|
||||||
|
$minimum_charge = $noMinimumCharge ? 0 : round($minimum_charge, 3);
|
||||||
|
|
||||||
|
|
||||||
|
if($hasMinimumCharge) {
|
||||||
|
$minimum_charge = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
||||||
|
|
||||||
|
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
||||||
|
|
||||||
|
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||||
|
|
||||||
|
$object = new TransactionObject(
|
||||||
|
$billNumber,
|
||||||
|
TransactionType::SHIPPING_INVOICE,
|
||||||
|
1,
|
||||||
|
$order->company_module_id,
|
||||||
|
1,
|
||||||
|
PaymentMethodType::CASH,
|
||||||
|
$total_cbm,
|
||||||
|
$total_cbm,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
ApprovalStatus::PENDING_SUBMISSION
|
||||||
|
);
|
||||||
|
|
||||||
|
/** @var Transaction $invoice_transaction */
|
||||||
|
$invoice_transaction = $this->createsTransaction->execute($packing_list, $object);
|
||||||
|
|
||||||
|
$object_detail = new TransactionDetailObject(
|
||||||
|
'SHIPPING_FEE',
|
||||||
|
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||||
|
$cbm,
|
||||||
|
$price_cbm
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
|
|
||||||
|
if ($over_weight_cbm > 0) {
|
||||||
|
$object_detail = new TransactionDetailObject(
|
||||||
|
'OVER_WEIGHT_CHARGES',
|
||||||
|
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
||||||
|
$over_weight_cbm,
|
||||||
|
$price_cbm
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($minimum_charge > 0) {
|
||||||
|
$object_detail = new TransactionDetailObject(
|
||||||
|
'MIN_CBM_CHARGES',
|
||||||
|
TransactionDetailType::MIN_CBM_CHARGES,
|
||||||
|
$minimum_charge,
|
||||||
|
$price_cbm
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->response([]);
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getConstantByKey($segmentConstantObject, $key) {
|
||||||
|
if ($segmentConstantObject) {
|
||||||
|
$base_rate = (array) $segmentConstantObject->value;
|
||||||
|
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
|
||||||
|
|
||||||
|
return $base_rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPostcodeExistInConstant($segmentConstantObject, $postcode) {
|
||||||
|
$segmentConstantObject = $segmentConstantObject->value;
|
||||||
|
if (!empty($segmentConstantObject)) {
|
||||||
|
return in_array($postcode, $segmentConstantObject);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf;
|
use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
|
||||||
class CreateSupplierTransactionLogic extends AbstractControllerLogic
|
class CreateSupplierTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ use App\Models\Transaction;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
|||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Processors;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
|
||||||
use App\Models\Document;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
|
||||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|
||||||
|
|
||||||
class ApproveShippingInvoiceTransactionProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var UpdatesTransactionStatus */
|
|
||||||
private $updatesTransactionStatus;
|
|
||||||
|
|
||||||
/** @var CreatesDocument */
|
|
||||||
private $createsDocument;
|
|
||||||
|
|
||||||
/** @var CreatesFiles */
|
|
||||||
private $createsFiles;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
|
||||||
* @param CreatesDocument $createsDocument
|
|
||||||
* @param CreatesFiles $createsFiles
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
|
||||||
{
|
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
|
||||||
$this->createsDocument = $createsDocument;
|
|
||||||
$this->createsFiles = $createsFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PackingList $packingList
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(PackingList $packingList)
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var Transaction $invoice_transaction */
|
|
||||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
|
||||||
|
|
||||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
|
||||||
DocumentType::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 = $packingList->owner->companyModule->employees()->first();
|
|
||||||
if(app()->environment(['production'])) {
|
|
||||||
$user->notify(new InvoiceIssuedEmail($user, $packingList));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+177
-195
@@ -1,247 +1,229 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Processors;
|
namespace App\Classes\Modules\Transactions\Processors;
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
use App\Classes\Modules\Bookings\Services\CalculatesBookingTransferredAmount;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations;
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
|
||||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
|
||||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||||
|
use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount;
|
||||||
|
use App\Classes\Modules\Bookings\Services\CalculatesBookingCurrencyAverageRate;
|
||||||
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||||
|
use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus;
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\Booking;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\PackingList;
|
use App\Models\SegmentConstant;
|
||||||
use App\Models\Transaction;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
|
|
||||||
class CreateInvoiceTransactionProcessor
|
class CreateInvoiceTransactionProcessor
|
||||||
{
|
{
|
||||||
|
/** @var ListsTransactions */
|
||||||
/** @var FetchesPackingList */
|
private $listsTransactions;
|
||||||
private $fetchesPackingList;
|
|
||||||
|
|
||||||
/** @var FetchesSegmentConstant */
|
|
||||||
private $fetchesSegmentConstant;
|
|
||||||
|
|
||||||
/** @var GeneratesTransactionBillNumber */
|
|
||||||
private $generatesTransactionBillNumber;
|
|
||||||
|
|
||||||
/** @var CreatesTransaction */
|
/** @var CreatesTransaction */
|
||||||
private $createsTransaction;
|
private $createsTransaction;
|
||||||
|
|
||||||
/** @var CreatesTransactionDetail */
|
/** @var GeneratesTransactionBillNumber */
|
||||||
private $createsTransactionDetail;
|
private $generatesTransactionBillNumber;
|
||||||
|
|
||||||
|
/** @var CalculatesBookingPaidAmount */
|
||||||
|
private $calculatesBookingPaidAmount;
|
||||||
|
|
||||||
|
/** @var CalculatesBookingTransferredAmount */
|
||||||
|
private $calculatesBookingTransferredAmount;
|
||||||
|
|
||||||
|
/** @var FetchesServiceConfigurations */
|
||||||
|
private $fetchesServiceConfigurations;
|
||||||
|
|
||||||
|
/** @var CalculatesBookingCurrencyAverageRate */
|
||||||
|
private $calculatesBookingCurrencyAverageRate;
|
||||||
|
|
||||||
|
/** @var FetchesCompany */
|
||||||
|
private $fetchesCompany;
|
||||||
|
|
||||||
|
/** @var CreatesDocument */
|
||||||
|
private $createsDocument;
|
||||||
|
|
||||||
|
/** @var CreatesFiles */
|
||||||
|
private $createsFile;
|
||||||
|
|
||||||
|
/** @var UpdatesBookingStatus */
|
||||||
|
private $updatesBookingStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FetchesPackingList $fetchesPackingList
|
* CreateInvoiceTransactionProcessor constructor.
|
||||||
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
* @param ListsTransactions $listsTransactions
|
||||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
|
||||||
* @param CreatesTransaction $createsTransaction
|
* @param CreatesTransaction $createsTransaction
|
||||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||||
|
* @param CalculatesBookingPaidAmount $calculatesBookingPaidAmount
|
||||||
|
* @param CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount
|
||||||
|
* @param FetchesServiceConfigurations $fetchesServiceConfigurations
|
||||||
|
* @param CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate
|
||||||
|
* @param FetchesCompany $fetchesCompany
|
||||||
|
* @param CreatesDocument $createsDocument
|
||||||
|
* @param CreatesFiles $createsFile
|
||||||
|
* @param UpdatesBookingStatus $updatesBookingStatus
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesPackingList $fetchesPackingList, FetchesSegmentConstant $fetchesSegmentConstant, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CreatesTransactionDetail $createsTransactionDetail)
|
public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingTransferredAmount $calculatesBookingTransferredAmount, FetchesServiceConfigurations $fetchesServiceConfigurations, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus)
|
||||||
{
|
{
|
||||||
$this->fetchesPackingList = $fetchesPackingList;
|
$this->listsTransactions = $listsTransactions;
|
||||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
|
||||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
|
||||||
$this->createsTransaction = $createsTransaction;
|
$this->createsTransaction = $createsTransaction;
|
||||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||||
|
$this->calculatesBookingPaidAmount = $calculatesBookingPaidAmount;
|
||||||
|
$this->calculatesBookingTransferredAmount = $calculatesBookingTransferredAmount;
|
||||||
|
$this->fetchesServiceConfigurations = $fetchesServiceConfigurations;
|
||||||
|
$this->calculatesBookingCurrencyAverageRate = $calculatesBookingCurrencyAverageRate;
|
||||||
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
|
$this->createsDocument = $createsDocument;
|
||||||
|
$this->createsFile = $createsFile;
|
||||||
|
$this->updatesBookingStatus = $updatesBookingStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws MalformedRequestException
|
* @param Booking $booking
|
||||||
|
* @return void
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(PackingList $packingList)
|
public function execute(Booking $booking)
|
||||||
{
|
{
|
||||||
$packing_list = PackingList::where('reference', $packingList->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
$payment_amount = $this->calculatesBookingTransferredAmount->execute($booking, $booking->fix_currency_id);
|
||||||
|
$booking_amount = $booking->fix_amount;
|
||||||
$billable_packing_list = $packing_list->packingLists()->first();
|
|
||||||
|
|
||||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packing_list;
|
|
||||||
|
|
||||||
$cbm = round($billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
|
||||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
|
||||||
}), 3);
|
|
||||||
|
|
||||||
$over_weight_cbm = round($billable_packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
|
||||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
|
||||||
}), 3);
|
|
||||||
|
|
||||||
$order = $packing_list->owner;
|
|
||||||
$companyModule = $order->companyModule;
|
|
||||||
$connection = $companyModule->connections()->first();
|
|
||||||
$address = $order->addresses()->first();
|
|
||||||
|
|
||||||
$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]);
|
|
||||||
$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]);
|
|
||||||
|
|
||||||
$noMinimumCharge = $connection->segments()->where('segments.id', 2)->first();
|
|
||||||
|
|
||||||
$minimum_cbm = 0.3;
|
|
||||||
$state_select = '';
|
|
||||||
|
|
||||||
$segment_price = $connection->segments()->whereHas('constants', function($query){
|
|
||||||
return $query->where('reference', SegmentConstants::CUSTOM_PRICE);
|
|
||||||
})->get()->map(function($segment){
|
|
||||||
return (float) $segment->constants()->first()->value[0];
|
|
||||||
})->sort()->first();
|
|
||||||
$segment_price = $segment_price ? $segment_price : 0;
|
|
||||||
|
|
||||||
$arrivalTransport = PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first();
|
|
||||||
if(!$arrivalTransport) {
|
|
||||||
throw new MalformedRequestException('Arrival date is unknow can\'t generate invoice');
|
|
||||||
}
|
|
||||||
$packing_list_drop_date = $arrivalTransport->drop_date->format('Y-m-d');
|
|
||||||
$base_price = $this->getConstantByKey($base_price_constant, $packing_list_drop_date);
|
|
||||||
|
|
||||||
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
|
||||||
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
|
|
||||||
$warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0;
|
|
||||||
|
|
||||||
$stateId = $address->state_id;
|
|
||||||
$state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId);
|
|
||||||
|
|
||||||
// get $state_rate
|
|
||||||
$postcode = $address->postcode;
|
|
||||||
$this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ;
|
|
||||||
$this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ;
|
|
||||||
$state_rate_constant = (array)$state_rate_constant;
|
|
||||||
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
|
||||||
|
|
||||||
$container = $packing_list->containers()->first();
|
|
||||||
$containerPackingLists = collect();
|
|
||||||
$hasMinimumCharge = null;
|
|
||||||
|
|
||||||
foreach ($container->packingLists as $packingList){
|
|
||||||
if($packingList->owner instanceof CompanyModule) continue;
|
|
||||||
if($packingList->owner->companyModule->id !== $companyModule->id) continue;
|
|
||||||
$containerPackingLists->push($packingList);
|
|
||||||
|
|
||||||
if(!$hasMinimumCharge) {
|
|
||||||
$hasMinimumCharge = $packingList->transactions()->whereHas('transactionDetails', function ($query){
|
|
||||||
$query->where('reference', 'MIN_CBM_CHARGES');
|
|
||||||
})->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ((float) $booking_amount !== (float) $payment_amount) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalContainerCbm = $containerPackingLists->sum(function($packingList){
|
$po_order_transaction = $booking->transactions()
|
||||||
$billable_packing_list = $packingList->packingLists()->first();
|
->where('type', TransactionType::PURCHASE_ORDER)
|
||||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packingList;
|
->complete()
|
||||||
return $billable_packing_list->packages->sum(function($package) {
|
->first();
|
||||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$minimum_charge = $minimum_cbm - $totalContainerCbm;
|
$constants = SegmentConstant::where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->id', $booking->service->id)->first();
|
||||||
$minimum_charge = ($minimum_charge < 0) ? 0 : $minimum_charge;
|
|
||||||
$minimum_charge = $noMinimumCharge ? 0 : $minimum_charge;
|
|
||||||
|
|
||||||
$minimum_charge = $noMinimumCharge ? 0 : round($minimum_charge, 3);
|
if($constants->detail->is_billable && !$po_order_transaction) {
|
||||||
|
return;
|
||||||
|
|
||||||
if($hasMinimumCharge) {
|
|
||||||
$minimum_charge = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
$transaction = $booking->transactions()
|
||||||
|
->where('type', TransactionType::PAYMENT)
|
||||||
|
->first();
|
||||||
|
|
||||||
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
$billNumber = $this->generatesTransactionBillNumber->execute('INV-');
|
||||||
|
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
$booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT);
|
||||||
|
|
||||||
$object = new TransactionObject(
|
$total_service_charge = $booking->transactions()
|
||||||
|
->where('type', TransactionType::PAYMENT)
|
||||||
|
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||||
|
->sum('service_charge');
|
||||||
|
|
||||||
|
$total_tax = $booking->transactions()
|
||||||
|
->where('type', TransactionType::PAYMENT)
|
||||||
|
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||||
|
->sum('tax');
|
||||||
|
|
||||||
|
$transaction_object = new TransactionObject(
|
||||||
$billNumber,
|
$billNumber,
|
||||||
TransactionType::SHIPPING_INVOICE,
|
TransactionType::INVOICE,
|
||||||
1,
|
$transaction->issuer,
|
||||||
$order->company_module_id,
|
$transaction->receiver,
|
||||||
1,
|
$transaction->recipient_bank_account_id,
|
||||||
PaymentMethodType::CASH,
|
$transaction->payment_method,
|
||||||
$total_cbm,
|
$payment_amount,
|
||||||
$total_cbm,
|
$booking_amount,
|
||||||
1,
|
$transaction->currency_id,
|
||||||
1,
|
$transaction->original_currency_id,
|
||||||
0,
|
$booking_currency_average_rate,
|
||||||
0,
|
$total_tax,
|
||||||
0,
|
$total_service_charge,
|
||||||
null,
|
null,
|
||||||
ApprovalStatus::PENDING_SUBMISSION
|
ApprovalStatus::APPROVED
|
||||||
|
);
|
||||||
|
$invoice_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||||
|
|
||||||
|
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||||
|
|
||||||
|
$purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.purchase_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||||
|
$document_object = new DocumentObject(
|
||||||
|
DocumentType::PURCHASE_ORDER,
|
||||||
|
[chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))],
|
||||||
|
'',
|
||||||
|
ApprovalStatus::COMPLETED,
|
||||||
|
'purchase_orders'
|
||||||
|
);
|
||||||
|
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||||
|
$this->createsFile->execute($document, $document_object);
|
||||||
|
|
||||||
|
$deliver_order_pdf = LaravelMpdf::loadView('pages.pdfs.deliver_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||||
|
$document_object = new DocumentObject(
|
||||||
|
DocumentType::DELIVER_ORDER,
|
||||||
|
[chunk_split('data:application/pdf;base64,'.base64_encode($deliver_order_pdf->output()))],
|
||||||
|
'',
|
||||||
|
ApprovalStatus::COMPLETED,
|
||||||
|
'delivery_orders'
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var Transaction $invoice_transaction */
|
/** @var Document $document */
|
||||||
$invoice_transaction = $this->createsTransaction->execute($packing_list, $object);
|
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||||
|
$this->createsFile->execute($document, $document_object);
|
||||||
|
|
||||||
$object_detail = new TransactionDetailObject(
|
|
||||||
'SHIPPING_FEE',
|
$invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
$document_object = new DocumentObject(
|
||||||
$cbm,
|
DocumentType::INVOICE,
|
||||||
$price_cbm
|
[chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))],
|
||||||
|
'',
|
||||||
|
ApprovalStatus::COMPLETED,
|
||||||
|
'invoices'
|
||||||
);
|
);
|
||||||
|
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||||
|
$this->createsFile->execute($document, $document_object);
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$billNumber = $this->generatesTransactionBillNumber->execute('SPDO-');
|
||||||
|
|
||||||
if ($over_weight_cbm > 0) {
|
$booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL);
|
||||||
$object_detail = new TransactionDetailObject(
|
|
||||||
'OVER_WEIGHT_CHARGES',
|
|
||||||
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
|
||||||
$over_weight_cbm,
|
|
||||||
$price_cbm
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$transaction_object = new TransactionObject(
|
||||||
}
|
$billNumber,
|
||||||
|
TransactionType::SUPPLIER_DELIVER,
|
||||||
|
$transaction->issuer,
|
||||||
|
$transaction->receiver,
|
||||||
|
$transaction->recipient_bank_account_id,
|
||||||
|
$transaction->payment_method,
|
||||||
|
$payment_amount,
|
||||||
|
$booking_amount,
|
||||||
|
$transaction->currency_id,
|
||||||
|
$transaction->original_currency_id,
|
||||||
|
$booking_currency_average_rate,
|
||||||
|
$total_tax,
|
||||||
|
$total_service_charge,
|
||||||
|
null,
|
||||||
|
ApprovalStatus::APPROVED
|
||||||
|
);
|
||||||
|
$supplier_deliver_order_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||||
|
|
||||||
if ($minimum_charge > 0) {
|
$supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||||
$object_detail = new TransactionDetailObject(
|
$document_object = new DocumentObject(
|
||||||
'MIN_CBM_CHARGES',
|
DocumentType::SUPPLIER_DELIVER_ORDER,
|
||||||
TransactionDetailType::MIN_CBM_CHARGES,
|
[chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))],
|
||||||
$minimum_charge,
|
'',
|
||||||
$price_cbm
|
ApprovalStatus::COMPLETED,
|
||||||
);
|
'supplier_delivery_orders'
|
||||||
|
);
|
||||||
|
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||||
|
$this->createsFile->execute($document, $document_object);
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$this->updatesBookingStatus->execute($booking, ApprovalStatus::COMPLETED);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConstantByKey($segmentConstantObject, $key) {
|
|
||||||
if ($segmentConstantObject) {
|
|
||||||
$base_rate = (array) $segmentConstantObject->value;
|
|
||||||
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
|
|
||||||
|
|
||||||
return $base_rate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkPostcodeExistInConstant($segmentConstantObject, $postcode) {
|
|
||||||
$segmentConstantObject = $segmentConstantObject->value;
|
|
||||||
if (!empty($segmentConstantObject)) {
|
|
||||||
return in_array($postcode, $segmentConstantObject);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,27 +4,9 @@ namespace App\Classes\Modules\Transactions\Services;
|
|||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\TransactionToPerfexCRMProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
|
||||||
|
|
||||||
class UpdatesTransactionStatus extends AbstractUpdateRecord
|
class UpdatesTransactionStatus extends AbstractUpdateRecord
|
||||||
{
|
{
|
||||||
/** @var TransactionToPerfexCRMProcessor */
|
|
||||||
private $transactionToPerfexCRMProcessor;
|
|
||||||
|
|
||||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
|
||||||
private $newLeadTaskToPerfexCRMProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdatesTransactionStatus constructor.
|
|
||||||
* @param TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor
|
|
||||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
|
||||||
{
|
|
||||||
$this->transactionToPerfexCRMProcessor = $transactionToPerfexCRMProcessor;
|
|
||||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Transaction $model
|
* @param Transaction $model
|
||||||
@@ -34,10 +16,6 @@ class UpdatesTransactionStatus extends AbstractUpdateRecord
|
|||||||
*/
|
*/
|
||||||
public function execute(Transaction $model, int $status)
|
public function execute(Transaction $model, int $status)
|
||||||
{
|
{
|
||||||
if(config('perfexcrm.is_enabled') == 'true'){
|
|
||||||
$this->transactionToPerfexCRMProcessor->execute($model, $status);
|
|
||||||
// $this->newLeadTaskToPerfexCRMProcessor->execute();
|
|
||||||
}
|
|
||||||
$model->status = $status;
|
$model->status = $status;
|
||||||
return $this->handler($model);
|
return $this->handler($model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,4 @@ final class ApprovalStatus {
|
|||||||
|
|
||||||
public const EXPIRED = 6;
|
public const EXPIRED = 6;
|
||||||
|
|
||||||
public const APPROVAL_STATUS_ID = [
|
|
||||||
self::PENDING_SUBMISSION => "Pending Submission",
|
|
||||||
self::PENDING_VERIFICATION => "Pending Verification",
|
|
||||||
self::APPROVED => "Approved",
|
|
||||||
self::COMPLETED => "Completed",
|
|
||||||
self::REJECTED => "Rejected",
|
|
||||||
self::SUSPENDED => "Suspended",
|
|
||||||
self::EXPIRED => "Expired",
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\ValueObjects\Constants;
|
|
||||||
|
|
||||||
class PerfexCRMMilestones
|
|
||||||
{
|
|
||||||
public const MILESTONE_1 = 'MILESTONE 1 - Customer Paid';
|
|
||||||
public const MILESTONE_2 = 'MILESTONE 2 - Order Placed';
|
|
||||||
public const MILESTONE_3 = 'MILESTONE 3 - Purchase Order Approved';
|
|
||||||
public const MILESTONE_4 = 'MILESTONE 4';
|
|
||||||
public const MILESTONE_5 = 'MILESTONE 5';
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\ValueObjects\Constants;
|
|
||||||
|
|
||||||
final class PerfexCRMStatus {
|
|
||||||
|
|
||||||
public const NOT_STARTED = 1;
|
|
||||||
|
|
||||||
public const AWAITING_FEEDBACK = 2;
|
|
||||||
|
|
||||||
public const TESTING = 3;
|
|
||||||
|
|
||||||
public const IN_PROGRESS = 4;
|
|
||||||
|
|
||||||
public const COMPLETED = 5;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\ValueObjects\Constants;
|
|
||||||
|
|
||||||
class PerfexCRMTasks
|
|
||||||
{
|
|
||||||
public const TASK_1 = [
|
|
||||||
'name' => 'Customer Paid',
|
|
||||||
'description' => '',
|
|
||||||
'milestone' => 'MILESTONE 1 - Customer Paid',
|
|
||||||
'reference' => '',
|
|
||||||
'on_task_completion' => '',
|
|
||||||
'status' => PerfexCRMStatus::COMPLETED
|
|
||||||
];
|
|
||||||
|
|
||||||
public const TASK_POST_PAYMENT_1 = [
|
|
||||||
'name' => 'Map Bank Transaction Record',
|
|
||||||
'description' => '○ Purpose: To map a transaction to bank transaction in the bank statement<br>
|
|
||||||
○ Initial Status: In Progress<br>
|
|
||||||
○ Deadline: Same day<br>
|
|
||||||
○ Responsible department: Accounts<br>
|
|
||||||
○ Next step: Change the status of the Approve payment status to "In Progress" upon successful completion of the operation.<br>
|
|
||||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
|
||||||
○ Dependencies: None<br>
|
|
||||||
○ Outcomes: Bank transaction is mapped successfully, allowing the next steps in the process to be initiated.<br>',
|
|
||||||
'milestone' => '',
|
|
||||||
'reference' => 'TASK_POST_PAYMENT_1',
|
|
||||||
'on_task_completion' => 'TASK_POST_PAYMENT_2',
|
|
||||||
'status' => PerfexCRMStatus::IN_PROGRESS
|
|
||||||
];
|
|
||||||
public const TASK_POST_PAYMENT_2 = [
|
|
||||||
'name' => 'Approve Payment',
|
|
||||||
'description' => '○ Purpose: To verify and approve the customer\'s payment on IZYIM<br>
|
|
||||||
○ Initial Status: Not Started<br>
|
|
||||||
○ Deadline:Same day<br>
|
|
||||||
○ Responsible department: Accounts<br>
|
|
||||||
○ Next step: Change the status of the Issue Shipping Autocount Invoice operation to "In Progress"<br>
|
|
||||||
○ Additional details: When the payment method is FPX or Wallet this task is performed automatically by the system.<br>
|
|
||||||
○ Dependencies: Map Transaction operation must be completed before this operation can begin.<br>
|
|
||||||
○ Outcomes: The payment will be approved in IZYIM, which will release the customer’s goods for delivery.<br>',
|
|
||||||
'milestone' => '',
|
|
||||||
'reference' => 'TASK_POST_PAYMENT_2',
|
|
||||||
'on_task_completion' => 'TASK_POST_PAYMENT_3',
|
|
||||||
'status' => ''
|
|
||||||
];
|
|
||||||
public const TASK_POST_PAYMENT_3 = [
|
|
||||||
'name' => 'Issue Shipping Autocount Invoince',
|
|
||||||
'description' => '○ Purpose: To issue an invoice for the customer\'s payment in accounting software.<br>
|
|
||||||
○ Initial Status: Not Started<br>
|
|
||||||
○ Deadline: Next day<br>
|
|
||||||
○ Responsible department: Accounts<br>
|
|
||||||
○ Next step: Change the status of the Knockoff Invoice operation to "In Progress" upon successful completion.<br>
|
|
||||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
|
||||||
○ Dependencies: Approve Payment operation must be completed before this operation can begin.<br>
|
|
||||||
○ Outcomes: An invoice will be issued in accounting software for the customer\'s payment.<br>',
|
|
||||||
'milestone' => '',
|
|
||||||
'reference' => 'TASK_POST_PAYMENT_3',
|
|
||||||
'on_task_completion' => 'TASK_POST_PAYMENT_4',
|
|
||||||
'status' => ''
|
|
||||||
];
|
|
||||||
public const TASK_POST_PAYMENT_4 = [
|
|
||||||
'name' => 'Knockoff Invoice',
|
|
||||||
'description' => '○ Purpose: The purpose of this operation is to issue the official receipt and knockoff with invoice for the customer\'s payment.<br>
|
|
||||||
○ Initial Status: Not Started<br>
|
|
||||||
○ Deadline: Next day.<br>
|
|
||||||
○ Responsible Department: Accounts<br>
|
|
||||||
○ Next Step: None<br>
|
|
||||||
○ Additional Details: ** Any specific requirements or notes for the operation.**<br>
|
|
||||||
○ Dependencies: Issue Shipping Autocount Invoice operation must be completed before this operation can begin.<br>
|
|
||||||
○ Outcomes: The customer’s payment is applied to the accounting software invoice and invoice is marked as paid.<br>',
|
|
||||||
'milestone' => '',
|
|
||||||
'reference' => 'TASK_POST_PAYMENT_4',
|
|
||||||
'on_task_completion' => '',
|
|
||||||
'status' => ''
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\ValueObjects\Constants;
|
|
||||||
|
|
||||||
final class RouteType {
|
|
||||||
|
|
||||||
public const WEB = 1;
|
|
||||||
|
|
||||||
public const API = 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
class AutoGenerateInvoice extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'invoice:generate';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Auto generate invoice';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
|
||||||
|
|
||||||
if (count($packingLists)) {
|
|
||||||
$this->info(Carbon::now() . ' : Auto generate invoice cron started.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
foreach ($packingLists as $packingList) {
|
|
||||||
$order = $packingList->owner;
|
|
||||||
if (!($order instanceof Order)) {
|
|
||||||
$this->info('Failed to generate invoice for reference' . $order->reference . '. It is not an instance of Order.');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$companyModule = $order->companyModule;
|
|
||||||
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
|
||||||
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
|
||||||
|
|
||||||
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
|
||||||
|
|
||||||
if (!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())) {
|
|
||||||
try {
|
|
||||||
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
|
||||||
$this->info('Invoice generated for reference ' . $order->reference . '.');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
$this->info('Failed to generate invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->info('Failed to generate invoice for reference ' . $order->reference . '. Billing Address is not defined / Postcode area is not defined.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
|
|
||||||
$this->info(Carbon::now() . ' : Done generating invoice. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\CompanyConnection;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
|
|
||||||
class FixInvoice extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'invoice:fix {--marking=}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Fix Invoice By Company Module Marking';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$connection = CompanyConnection::where('invitee_reference', $this->option('marking'))->first();
|
|
||||||
$company_module_id = $connection->invitee->id;
|
|
||||||
|
|
||||||
$orders = Order::where('company_module_id', $company_module_id)->get();
|
|
||||||
|
|
||||||
foreach ($orders as $order){
|
|
||||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
|
||||||
foreach ($invoices as $invoice){
|
|
||||||
|
|
||||||
dump($invoice->id);
|
|
||||||
|
|
||||||
$invoice->documents()->delete();
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
|
||||||
|
|
||||||
$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 = (App()->make(CreatesDocument::class))->execute($invoice, $document_object);
|
|
||||||
|
|
||||||
(App()->make(CreatesFiles::class))->execute($document, $document_object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
class approveInvoice extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'approve:invoice';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Command description';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
|
||||||
$packingList = $invoice->owner;
|
|
||||||
$order = $packingList->owner;
|
|
||||||
|
|
||||||
try {
|
|
||||||
(App()->make(ApproveShippingInvoiceTransactionProcessor::class))->execute($packingList);
|
|
||||||
$this->info('Invoice Approved for reference ' . $order->reference . '.');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
$this->info('Failed to Approve invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+13
-21
@@ -28,30 +28,22 @@ class Kernel extends ConsoleKernel
|
|||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
|
|
||||||
// $schedule->command('command:curlVTCommand')
|
$schedule->command('command:curlVTCommand')
|
||||||
// ->cron('0 8 * * *')
|
->cron('0 8 * * *')
|
||||||
// ->withoutOverlapping()
|
|
||||||
// ->appendOutputTo (storage_path().'/logs/curlvt.log');
|
|
||||||
|
|
||||||
// $schedule->command('command:curlYdOrderListCommand')
|
|
||||||
// ->cron('30 9-18/3 * * *')
|
|
||||||
// ->withoutOverlapping()
|
|
||||||
// ->appendOutputTo (storage_path().'/logs/curlyd.log');
|
|
||||||
|
|
||||||
// $schedule->command('command:curlYdOrderListCommand')
|
|
||||||
// ->cron('0 9 * * *')
|
|
||||||
// ->withoutOverlapping()
|
|
||||||
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
|
|
||||||
|
|
||||||
$schedule->command('invoice:generate')
|
|
||||||
->hourly()
|
|
||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
|
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||||
|
|
||||||
$schedule->command('approve:invoice')
|
$schedule->command('command:curlYdOrderListCommand')
|
||||||
->hourly()
|
->cron('30 9-18/3 * * *')
|
||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->appendOutputTo (storage_path().'/logs/approve_invoice.log');
|
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||||
|
|
||||||
|
$schedule->command('command:curlYdOrderListCommand')
|
||||||
|
->cron('0 9 * * *')
|
||||||
|
->withoutOverlapping()
|
||||||
|
->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Addresses;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Addresses\ControllersLogic\CreateBillingAddressLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateBillingAddressController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param CreateBillingAddressLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function create(Request $request, CreateBillingAddressLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Companies;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyNameAndDebtorLogic;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class UpdateCompanyNameAndDebtorController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param UpdateCompanyLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(Request $request, UpdateCompanyNameAndDebtorLogic $logic): JsonResponse
|
|
||||||
{
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Exports;
|
|||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
||||||
use App\Classes\Modules\Exports\Services\ExportsParcel;
|
use App\Classes\Modules\Exports\Services\ExportsParcel;
|
||||||
use App\Classes\Modules\Exports\Services\ExportsWarehousePackingList;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -35,11 +34,4 @@ class ExportArrivedParcelController
|
|||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function guangZhou2ToJohor(Request $request) {
|
|
||||||
$exportsWarehousePackingList = new ExportsWarehousePackingList();
|
|
||||||
$response = $exportsWarehousePackingList->download('guangzhou2-to-johor-summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers\Exports;
|
namespace App\Http\Controllers\Exports;
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsCompanyModuleSummary;
|
use App\Classes\Modules\Exports\Services\ExportsCompanyModuleSummary;
|
||||||
use App\Classes\Modules\Exports\Services\ExportsOrderSummaryByMarking;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -28,13 +27,4 @@ class ExportCompanyModuleSummaryController
|
|||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportOrderSummaryByMarking(Request $request) {
|
|
||||||
$exportsOrderSummaryByMarking = new ExportsOrderSummaryByMarking($request);
|
|
||||||
$customer_marking = $request->route('marking');
|
|
||||||
$exportsOrderSummaryByMarking->setParameters($customer_marking, $request->input('dateFrom'), $request->input('dateTo'));
|
|
||||||
$response = $exportsOrderSummaryByMarking->download($customer_marking . '_order_summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|||||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
|
||||||
class DownloadOrderQrPdfController
|
class DownloadOrderQrPdfController
|
||||||
{
|
{
|
||||||
@@ -51,12 +51,9 @@ class DownloadOrderQrPdfController
|
|||||||
if(strtolower($deliveryAddress->state->name) === 'sarawak' && !in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
if(strtolower($deliveryAddress->state->name) === 'sarawak' && !in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
||||||
$warehousePrefix = 'KU/';
|
$warehousePrefix = 'KU/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtolower($deliveryAddress->state->name) === 'johor') {
|
|
||||||
$warehousePrefix = 'NX/';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'marking' => $warehousePrefix.$deliveryPrefix.'CIEF/'.$customerMarking,
|
'marking' => $warehousePrefix.$deliveryPrefix.'CIEF/'.$customerMarking,
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\PackingLists\Containers;
|
namespace App\Http\Controllers\PackingLists\Packages;
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\ControllersLogic\Containers\InboundCustomClearedLogic;
|
use App\Classes\Modules\PackingLists\ControllersLogic\Containers\InboundCustomClearedLogic;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -6,7 +6,7 @@ use Auth;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
|
||||||
class TestController extends Controller
|
class TestController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Transactions;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\ControllersLogic\CreateCombinedInvoicesLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateCombinedInvoicesController
|
|
||||||
{
|
|
||||||
|
|
||||||
public function combine(Request $request, CreateCombinedInvoicesLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,13 +38,11 @@ class Kernel extends HttpKernel
|
|||||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
// \App\Http\Middleware\WebRouteLogs::class,
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
'throttle:300,1',
|
'throttle:300,1',
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
// \App\Http\Middleware\ApiRouteLogs::class,
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\RouteLog;
|
|
||||||
use App\Classes\ValueObjects\Constants\RouteType;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiRouteLogs
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle an incoming request.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
|
||||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function handle(Request $request, Closure $next)
|
|
||||||
{
|
|
||||||
$ip_address = getenv('REMOTE_ADDR') == '::1' ? '127.0.0.1' : getenv('REMOTE_ADDR');
|
|
||||||
$url = urldecode($request->fullUrl());
|
|
||||||
$request_method = $request->method();
|
|
||||||
$platform = $request->header('sec-ch-ua-platform');
|
|
||||||
$browser = Str::after($request->header('sec-ch-ua'), 'Not?A_Brand";v="8", "Chromium";v="108", "');
|
|
||||||
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$ip_address"));
|
|
||||||
$longitude = $geo["geoplugin_longitude"];
|
|
||||||
$latitude = $geo["geoplugin_latitude"];
|
|
||||||
$last_page = url()->previous();
|
|
||||||
$countryName = $geo["geoplugin_countryName"];
|
|
||||||
|
|
||||||
$user_id = Auth::user() ? Auth::user()->id : 0;
|
|
||||||
|
|
||||||
// if ($user_id != 0) {
|
|
||||||
// // $ip_address
|
|
||||||
// $webRouteLogWithSameIp = RouteLog::where('ip_address', $ip_address)->where('user_id', 0)->get();
|
|
||||||
// dd($webRouteLogWithSameIp);
|
|
||||||
// foreach($webRouteLogWithSameIp as $result){
|
|
||||||
// $result
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
$route_log = [
|
|
||||||
'user_id' => $user_id,
|
|
||||||
// 'ip_address' => $request->ip(),
|
|
||||||
'ip_address' => $ip_address,
|
|
||||||
'url' => $url,
|
|
||||||
'request_method' => $request_method,
|
|
||||||
'browser' => $browser,
|
|
||||||
'platform' => $platform,
|
|
||||||
'longitude' => $longitude,
|
|
||||||
'latitude' => $latitude,
|
|
||||||
'last_page' => $last_page,
|
|
||||||
'countryname' => $countryName,
|
|
||||||
'route_type' => RouteType::API,
|
|
||||||
];
|
|
||||||
|
|
||||||
RouteLog::create($route_log);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\RouteLog;
|
|
||||||
use App\Classes\ValueObjects\Constants\RouteType;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class WebRouteLogs
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle an incoming request.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
|
||||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function handle(Request $request, Closure $next)
|
|
||||||
{
|
|
||||||
$ip_address = getenv('REMOTE_ADDR') == '::1' ? '127.0.0.1' : getenv('REMOTE_ADDR');
|
|
||||||
$url = $request->fullUrl();
|
|
||||||
$request_method = $request->method();
|
|
||||||
$platform = $request->header('sec-ch-ua-platform');
|
|
||||||
$browser = Str::after($request->header('sec-ch-ua'), 'Not?A_Brand";v="8", "Chromium";v="108", "');
|
|
||||||
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$ip_address"));
|
|
||||||
$longitude = $geo["geoplugin_longitude"];
|
|
||||||
$latitude = $geo["geoplugin_latitude"];
|
|
||||||
$last_page = url()->previous();
|
|
||||||
$countryName = $geo["geoplugin_countryName"];
|
|
||||||
|
|
||||||
$route_log = [
|
|
||||||
'user_id' => Auth::user() ? Auth::user()->id : 0,
|
|
||||||
// 'ip_address' => $request->ip(),
|
|
||||||
'ip_address' => $ip_address,
|
|
||||||
'url' => $url,
|
|
||||||
'request_method' => $request_method,
|
|
||||||
'browser' => $browser,
|
|
||||||
'platform' => $platform,
|
|
||||||
'longitude' => $longitude,
|
|
||||||
'latitude' => $latitude,
|
|
||||||
'last_page' => $last_page,
|
|
||||||
'countryname' => $countryName,
|
|
||||||
'route_type' => RouteType::WEB,
|
|
||||||
];
|
|
||||||
|
|
||||||
// dd($route_log);
|
|
||||||
|
|
||||||
RouteLog::create($route_log);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,6 @@ class CompanyResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'hash_id' => Crypt::encryptString($this->id),
|
'hash_id' => Crypt::encryptString($this->id),
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'debtor' => $this->debtor,
|
|
||||||
'reference' => $this->reference,
|
'reference' => $this->reference,
|
||||||
'type' => (int) $this->type,
|
'type' => (int) $this->type,
|
||||||
'business_type' => (int) $this->business_type,
|
'business_type' => (int) $this->business_type,
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class RouteLog extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'user_id',
|
|
||||||
'ip_address',
|
|
||||||
'url',
|
|
||||||
'request_method',
|
|
||||||
'browser',
|
|
||||||
'platform',
|
|
||||||
'longitude',
|
|
||||||
'latitude',
|
|
||||||
'last_page',
|
|
||||||
'countryname',
|
|
||||||
'route_type'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
+1
-2
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
@@ -26,7 +25,7 @@ class User extends AbstractModel implements
|
|||||||
AuthorizableContract,
|
AuthorizableContract,
|
||||||
CanResetPasswordContract
|
CanResetPasswordContract
|
||||||
{
|
{
|
||||||
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes, HasFactory;
|
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes;
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
paths:
|
|
||||||
tests: tests
|
|
||||||
output: tests/_output
|
|
||||||
data: tests/_data
|
|
||||||
support: tests/_support
|
|
||||||
envs: tests/_envs
|
|
||||||
actor_suffix: Tester
|
|
||||||
extensions:
|
|
||||||
enabled:
|
|
||||||
- Codeception\Extension\RunFailed
|
|
||||||
params:
|
|
||||||
- .env.testing
|
|
||||||
+2
-13
@@ -2,24 +2,20 @@
|
|||||||
"name": "laravel/laravel",
|
"name": "laravel/laravel",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "The Laravel Framework.",
|
"description": "The Laravel Framework.",
|
||||||
"keywords": [
|
"keywords": ["framework", "laravel"],
|
||||||
"framework",
|
|
||||||
"laravel"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3",
|
"php": "^7.3",
|
||||||
"ext-fileinfo": "^7.3",
|
"ext-fileinfo": "^7.3",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"barryvdh/laravel-dompdf": "^0.9.0",
|
"barryvdh/laravel-dompdf": "^0.9.0",
|
||||||
"carlos-meneses/laravel-mpdf": "*",
|
"carlos-meneses/laravel-mpdf": "^2.1",
|
||||||
"doctrine/dbal": "^3.1",
|
"doctrine/dbal": "^3.1",
|
||||||
"fideloper/proxy": "^4.4",
|
"fideloper/proxy": "^4.4",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"intervention/image": "^2.5",
|
"intervention/image": "^2.5",
|
||||||
"laravel/framework": "^8.40",
|
"laravel/framework": "^8.40",
|
||||||
"laravel/legacy-factories": "^1.3",
|
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"maatwebsite/excel": "^3.1",
|
"maatwebsite/excel": "^3.1",
|
||||||
"rinvex/countries": "^6.1",
|
"rinvex/countries": "^6.1",
|
||||||
@@ -29,13 +25,6 @@
|
|||||||
"tymon/jwt-auth": "^1.0"
|
"tymon/jwt-auth": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-ide-helper": "^2.12",
|
|
||||||
"codeception/codeception": "^4.2",
|
|
||||||
"codeception/module-asserts": "^2.0",
|
|
||||||
"codeception/module-laravel": "^2.3",
|
|
||||||
"codeception/module-phpbrowser": "^2.0",
|
|
||||||
"codeception/module-rest": "^2.0",
|
|
||||||
"codeception/module-webdriver": "^2.0",
|
|
||||||
"facade/ignition": "^2.5",
|
"facade/ignition": "^2.5",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
"laravel/sail": "^1.0.1",
|
"laravel/sail": "^1.0.1",
|
||||||
|
|||||||
+2
-2
@@ -178,7 +178,7 @@ return [
|
|||||||
// Third Parties
|
// Third Parties
|
||||||
Spatie\Permission\PermissionServiceProvider::class,
|
Spatie\Permission\PermissionServiceProvider::class,
|
||||||
Barryvdh\DomPDF\ServiceProvider::class,
|
Barryvdh\DomPDF\ServiceProvider::class,
|
||||||
Mccarlosen\LaravelMpdf\LaravelMpdfServiceProvider::class,
|
Meneses\LaravelMpdf\LaravelMpdfServiceProvider::class,
|
||||||
Maatwebsite\Excel\ExcelServiceProvider::class,
|
Maatwebsite\Excel\ExcelServiceProvider::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ return [
|
|||||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
'View' => Illuminate\Support\Facades\View::class,
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
'PDF' => Barryvdh\DomPDF\Facade::class,
|
'PDF' => Barryvdh\DomPDF\Facade::class,
|
||||||
'MPDF' => Mccarlosen\LaravelMpdf\Facades\LaravelMpdf::class,
|
'MPDF' => Meneses\LaravelMpdf\Facades\LaravelMpdf::class,
|
||||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'base_url' => env('PERFEXCRM_BASE_URL', 'http://192.168.1.100:8084'), //cief todo: Update crm api domain here
|
|
||||||
'api_key' => env('PERFEXCRM_API_KEY', ''),
|
|
||||||
'is_enabled' => env('PERFEXCRM_IS_ENABLED', 'true'),
|
|
||||||
];
|
|
||||||
@@ -25,9 +25,23 @@ class UserFactory extends Factory
|
|||||||
return [
|
return [
|
||||||
'name' => $this->faker->name(),
|
'name' => $this->faker->name(),
|
||||||
'email' => $this->faker->unique()->safeEmail(),
|
'email' => $this->faker->unique()->safeEmail(),
|
||||||
|
'email_verified_at' => now(),
|
||||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||||
'remember_token' => Str::random(10),
|
'remember_token' => Str::random(10),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model's email address should be unverified.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||||
|
*/
|
||||||
|
public function unverified()
|
||||||
|
{
|
||||||
|
return $this->state(function (array $attributes) {
|
||||||
|
return [
|
||||||
|
'email_verified_at' => null,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateRouteLogsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('route_logs', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->foreignId('user_id')->unsigned();
|
|
||||||
$table->string('ip_address');
|
|
||||||
$table->string('url', 255);
|
|
||||||
$table->string('request_method');
|
|
||||||
$table->string('browser')->nullable();
|
|
||||||
$table->string('platform')->nullable();
|
|
||||||
$table->string('longitude')->nullable();
|
|
||||||
$table->string('latitude')->nullable();
|
|
||||||
$table->string('last_page')->nullable();
|
|
||||||
$table->string('countryname')->nullable();
|
|
||||||
$table->integer('route_type');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('route_logs');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
PHP_VERSION: 7.4
|
|
||||||
ports:
|
|
||||||
- "9000:9000"
|
|
||||||
db:
|
|
||||||
image: mysql:5.7
|
|
||||||
environment:
|
|
||||||
MYSQL_DATABASE: laravel
|
|
||||||
MYSQL_USER: laravel
|
|
||||||
MYSQL_PASSWORD: secret
|
|
||||||
MYSQL_ROOT_PASSWORD: secret
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
tests:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
PHP_VERSION: 7.4
|
|
||||||
command: bash -c "composer install && php artisan migrate --seed && vendor/bin/phpunit"
|
|
||||||
links:
|
|
||||||
- db
|
|
||||||
- redis
|
|
||||||
acceptance:
|
|
||||||
image: node:14
|
|
||||||
working_dir: /app
|
|
||||||
volumes:
|
|
||||||
- ./:/app
|
|
||||||
command: bash -c "npm install && gulp build"
|
|
||||||
links:
|
|
||||||
- web
|
|
||||||
- redis
|
|
||||||
redis:
|
|
||||||
image: redis:6.0
|
|
||||||
ports:
|
|
||||||
- "6379:6379"
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user