mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
229 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c109d625c | |||
| a9910c5a12 | |||
| 4bee415d2d | |||
| 02f7adb1e9 | |||
| 039a6155ca | |||
| c8d806a51d | |||
| 4dbaf6a5dc | |||
| fcc0135843 | |||
| 4a922ac340 | |||
| c4d421db76 | |||
| 2816e80bee | |||
| 466e90a0af | |||
| 5e6ae2a905 | |||
| 3378d37ffb | |||
| fff3d948d0 | |||
| c181882145 | |||
| 2a333f7d19 | |||
| 8f8622aa10 | |||
| f88936c873 | |||
| 20f3004e22 | |||
| fd4bbe5d4f | |||
| a630b49867 | |||
| 75ce5bd752 | |||
| abb7bc2e4c | |||
| 857003b25b | |||
| 551119e313 | |||
| b567f50711 | |||
| 395b15af90 | |||
| 833ffdab8d | |||
| 2f6a30a512 | |||
| 4c433f74f1 | |||
| 852da05e24 | |||
| 1658b65484 | |||
| 8e9ff0cad5 | |||
| acee1a7884 | |||
| 0079d745ba | |||
| 0bd3464184 | |||
| 7ec1bc65a5 | |||
| c401d1e0d5 | |||
| a2983ec9f1 | |||
| 2421640c0a | |||
| 7dae2228f6 | |||
| 75039466ab | |||
| f3df5fbe9f | |||
| 362e47aaa0 | |||
| ba26cda598 | |||
| 8995a567d5 | |||
| 5eeec7806b | |||
| fd46a4fb7f | |||
| 1100267316 | |||
| e133f1fab8 | |||
| 5d5892ce07 | |||
| b26700ea6f | |||
| 589c2e01d9 | |||
| 9cf6058a65 | |||
| ff4d81966c | |||
| a4891aa0de | |||
| 05ba0ba6fd | |||
| 9217970237 | |||
| 828f424cfd | |||
| 057ca8480b | |||
| d07901f31b | |||
| c22638b29e | |||
| c292bfd1e0 | |||
| 85942eff1d | |||
| d69896f807 | |||
| 2c5c97488f | |||
| 99e38b96ce | |||
| 81a00a8195 | |||
| dbab7a9f8c | |||
| 046676d174 | |||
| 2b4f1ad570 | |||
| bcb78f2392 | |||
| 345a62fec6 | |||
| 6257b11a6e | |||
| 4b124ca96d | |||
| 4b25764fb3 | |||
| 422a0af465 | |||
| c73d65343b | |||
| 9e5784b6ec | |||
| 9a863e2143 | |||
| 8024865d5d | |||
| 66abe81e73 | |||
| ca178e1b31 | |||
| e52a27aedb | |||
| 6c2c28fb31 | |||
| 049da351ef | |||
| 0ce8709f70 | |||
| 1e5609bb1b | |||
| 8e7970a925 | |||
| 06b2c5166d | |||
| 6ba3b873a2 | |||
| 623fb1609b | |||
| 24be20a60d | |||
| 3535201481 | |||
| cdefd48d26 | |||
| 45fbcf1447 | |||
| 53805f3608 | |||
| 99e90ad357 | |||
| 5edb9b5cfe | |||
| 86a5a3b2d9 | |||
| a6590e3b81 | |||
| b1bb2b9f33 | |||
| 9318e7471f | |||
| e19ba1c9f3 | |||
| 8cffae079b | |||
| 594b25b71b | |||
| d142a86683 | |||
| 935f3e9bf5 | |||
| dedd6464f4 | |||
| 38aba65178 | |||
| 091119c244 | |||
| 4d095b5459 | |||
| 1c50181132 | |||
| 9e26c470f5 | |||
| 4c0bf164a0 | |||
| 8ab7f72e90 | |||
| 5772e30575 | |||
| 4b2daa62d7 | |||
| 2bd8700a61 | |||
| ad7e77c169 | |||
| e95c41bd3e | |||
| 903269e714 | |||
| 4120a50559 | |||
| 88b31f2d3f | |||
| a2f9bf83ce | |||
| dd2ac4c966 | |||
| c88f6890d6 | |||
| bf4b3fa97f | |||
| 6bcea5a8f1 | |||
| 2704ec1665 | |||
| 0c636d2156 | |||
| 1270ba3f43 | |||
| f2c32c5024 | |||
| ccb3bde260 | |||
| a7eb14c2b7 | |||
| abac96b1e5 | |||
| ecb48c8897 | |||
| 2686229a0f | |||
| 558fa7ae52 | |||
| 88e2136c07 | |||
| 70cdcded9b | |||
| 4022b640f9 | |||
| 0d780074b8 | |||
| 078f675a7f | |||
| 2b48a86f98 | |||
| 19f3aa18fc | |||
| 2b4c932fc8 | |||
| 89f0ca651a | |||
| c9fc5938c6 | |||
| 2ad8235c1b | |||
| dbf8301cb9 | |||
| 7d582c6bca | |||
| 3c4b6afcb2 | |||
| e4bc56d188 | |||
| 9a448d5a3d | |||
| 5c1074b244 | |||
| 49fcdfd89e | |||
| c900759234 | |||
| cd3b47ab1a | |||
| c5f95cdf61 | |||
| cc428a92b8 | |||
| 97bac45612 | |||
| 8048396a88 | |||
| 400ec31235 | |||
| 4d9346c62c | |||
| 94fd2069e8 | |||
| 1f401eb347 | |||
| 80e282bda0 | |||
| 65cd6aae3c | |||
| eba2a30024 | |||
| c103deb2a7 | |||
| dcef782587 | |||
| 10e7da4673 | |||
| faff35f241 | |||
| e2c1562f19 | |||
| df35ceb798 | |||
| cdb81a0bf4 | |||
| f1b1955190 | |||
| 860632b7a3 | |||
| bde7a61fb4 | |||
| b6600c5168 | |||
| 25f38ef7fe | |||
| ddeb44b920 | |||
| 02be710203 | |||
| 2ffbfc9f1c | |||
| 7b34f8116c | |||
| 8a9b6df255 | |||
| c881dd44d6 | |||
| 1cfaeaf8bb | |||
| 914f29184d | |||
| f510d57463 | |||
| 7833c17938 | |||
| 97fdffe6eb | |||
| b1f2900f1c | |||
| ddf015dc71 | |||
| 2a9d4fd212 | |||
| 2cacc23a38 | |||
| a7fd5a038e | |||
| 626b31084f | |||
| 4f3c25d5bd | |||
| 8da942e41e | |||
| b599c8a151 | |||
| d41f796825 | |||
| dd612e2660 | |||
| c503b5e677 | |||
| 0b433cfa18 | |||
| 75aba8c4ac | |||
| 81c65874a3 | |||
| 79d29d9c7b | |||
| 1e558b93af | |||
| 6d3d52639e | |||
| a1d460aa6c | |||
| 5a0bc7aaea | |||
| c7962b4231 | |||
| d14bb39ae8 | |||
| 5cc2f51c02 | |||
| a185f73e8a | |||
| f9a9598210 | |||
| 9976ccec41 | |||
| 8bfb2d749a | |||
| 7bf9a570a1 | |||
| b38df170e8 | |||
| bf38ace70c | |||
| 66c008f97e | |||
| 0298eb946f | |||
| 70fb35e37c | |||
| 1a30877ca9 | |||
| 569a22c0db |
+4
-2
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
DB_PASSWORD=root
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -56,6 +56,8 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=P@ssw0rd
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
@@ -2,6 +2,8 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- service_build
|
||||
- node
|
||||
- building_assets
|
||||
- database
|
||||
- unit_test
|
||||
- acceptance_test
|
||||
- code_quality
|
||||
|
||||
# Variables
|
||||
variables:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: mysql_password
|
||||
MYSQL_PASSWORD: mysql_password
|
||||
MYSQL_DATABASE: shpping_portal
|
||||
DB_HOST: mysql
|
||||
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
#install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install MySQL client
|
||||
- apt-get install -y default-mysql-client
|
||||
|
||||
#install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
#install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
|
||||
|
||||
#jobs
|
||||
|
||||
#buld the backend
|
||||
composer_php:
|
||||
stage: service_build
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#build the UI
|
||||
#node installation
|
||||
npm:
|
||||
stage: node
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#building assets
|
||||
building_assets:
|
||||
stage: building_assets
|
||||
# dependencies:
|
||||
# - npm
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
database:
|
||||
stage: database
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - composer_php
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
unit_test:
|
||||
stage: unit_test
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - database
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
- php artisan test
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,62 +1,39 @@
|
||||
<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>
|
||||
## Shipping portal documentation
|
||||
|
||||
<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>
|
||||
simple documentation on how to install, run, test, commit and deploy application
|
||||
|
||||
## About Laravel
|
||||
## creating and running unit tests
|
||||
|
||||
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:
|
||||
Required Tools
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
- Chromium Driver / selenium
|
||||
- add running and setting selenium on all OS if possible
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
Required Packages :
|
||||
|
||||
## Learning Laravel
|
||||
- laravel/legacy-factories
|
||||
|
||||
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.
|
||||
- codeception/codeception
|
||||
|
||||
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.
|
||||
Or Simply Run
|
||||
|
||||
## Laravel Sponsors
|
||||
``Composer install``
|
||||
|
||||
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).
|
||||
To create a unit test
|
||||
|
||||
### Premium Partners
|
||||
``php artisan make test: Test Example --unit``
|
||||
|
||||
- **[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 the tests :
|
||||
|
||||
## Contributing
|
||||
Running a single Test
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
`` php artisan test --filter Example``
|
||||
|
||||
## Code of Conduct
|
||||
Running Unit tests -
|
||||
|
||||
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).
|
||||
`` php artisan test ``
|
||||
|
||||
## Security Vulnerabilities
|
||||
Running Codeception tests -
|
||||
|
||||
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.
|
||||
``vendor/bin/codecept run``
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class DoesNotHaveGroups implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('groups');
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
|
||||
$query->where('type', $value)->whereIn('status', [0,1,2,3]);
|
||||
})->whereHas('containers', function ($query){
|
||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||
});
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class BillNo implements Filter
|
||||
class OwnerType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@ class BillNo implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('bill_no', $value);
|
||||
return $builder->where('owner_type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PaymentMethodNotIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereNotIn('payment_method', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,11 +24,12 @@ class Helper
|
||||
return array_slice(get_class_methods($className), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param $log
|
||||
* @return none
|
||||
*/
|
||||
static function debugLogger($log){
|
||||
if($log && isset($log['message'])){
|
||||
static function debugLoggerForPerfexCRM($log){
|
||||
if($log){
|
||||
$message = $log['message'];
|
||||
$substring = 'No data were found';
|
||||
if (isset($message)) {
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -12,8 +10,6 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||
|
||||
|
||||
class UpdatePerfexCRM implements ShouldQueue
|
||||
{
|
||||
@@ -22,51 +18,37 @@ class UpdatePerfexCRM implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob;
|
||||
|
||||
/** @var */
|
||||
private $transaction;
|
||||
|
||||
/** @var bool|null */
|
||||
private $shouldCreateInvoice;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRM constructor.
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param Transaction $transaction
|
||||
* @param bool|null $shouldCreateInvoice
|
||||
* @param UpdatePerfexCRMInvoice $nextJob
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
|
||||
{
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob = $nextJob;
|
||||
$this->transaction = $transaction;
|
||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//To use invoice as a reference to decide whether more tasks should be created
|
||||
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
||||
|
||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
if($this->transaction != null && $this->shouldCreateInvoice){
|
||||
if($this->nextJob != null && $this->transaction != null){
|
||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$result->projectId,
|
||||
$this->transaction,
|
||||
true
|
||||
);
|
||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob */
|
||||
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
|
||||
}
|
||||
}
|
||||
|
||||
private function getInvoiceIdOrCreateInvoice(){
|
||||
if($this->transaction != null){
|
||||
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$this->transaction
|
||||
);
|
||||
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
||||
return $invoiceId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,16 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
@@ -30,7 +32,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMSingleTask constructor.
|
||||
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
||||
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||
{
|
||||
@@ -47,7 +49,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = 0;
|
||||
$invoiceStatus = 0;
|
||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug $transaction->owner->bill_no: '.$transaction->owner->bill_no));
|
||||
|
||||
if(is_null($invoice)){
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||
@@ -55,7 +57,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -64,6 +66,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
//This only run when invoice already exist and the invoice does not have a PAID status
|
||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug $this->updatePerfexCRMInvoiceObject->getProjectId(): '.$this->updatePerfexCRMInvoiceObject->getProjectId()));
|
||||
//update invoice
|
||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
}
|
||||
|
||||
@@ -27,22 +27,27 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var bool|null */
|
||||
private $shouldCreateInvoice;
|
||||
/** @var UpdatePerfexCRM */
|
||||
private $nextJob1;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob2;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRMPrelude constructor.
|
||||
* @param $packingList
|
||||
* @param Transaction $transaction
|
||||
* @param $transaction
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param bool|null $shouldCreateInvoice
|
||||
* @param UpdatePerfexCRM $nextJob1
|
||||
* @param UpdatePerfexCRMInvoice $nextJob2
|
||||
*/
|
||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
$this->transaction = $transaction;
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||
$this->nextJob1 = $nextJob1;
|
||||
$this->nextJob2 = $nextJob2;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
@@ -64,7 +69,9 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
|
||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||
$this->updatePerfexCRMObject->setTasks($result);
|
||||
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
||||
/** @var UpdatePerfexCRM $nextJob1 */
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob2 */
|
||||
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
|
||||
}
|
||||
|
||||
function replacePlaceholders($template, $data, $prefix = '')
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
@@ -17,6 +20,7 @@ use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -27,7 +31,8 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Address',
|
||||
'message' => 'You have successfully created a new Address'
|
||||
@@ -74,11 +79,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
@@ -90,16 +95,22 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||
|
||||
if($request->input('phone')){
|
||||
if ($request->input('phone')) {
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
if ($request->input('remark')) {
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
@@ -14,6 +17,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -23,7 +27,8 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Billing Address',
|
||||
'message' => 'You have successfully created a new Billing Address'
|
||||
@@ -60,27 +65,35 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->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 addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
// 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($address));
|
||||
//load address with only owner address
|
||||
|
||||
/* return fractal()
|
||||
->item($billingAddressInputed, new AddressTransformer())
|
||||
->parseIncludes('Owner_address')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||
@@ -17,7 +19,8 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Address',
|
||||
'message' => 'You have successfully retrieved a Address'
|
||||
@@ -45,15 +48,22 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchAddress->passes();
|
||||
|
||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
@@ -45,17 +50,25 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAddresses->passes();
|
||||
|
||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||
|
||||
//a collection of addresses with all incluides
|
||||
/* return fractal()
|
||||
->collection($query, new AddressTransformer)
|
||||
->parseIncludes('Owner_address')
|
||||
->parseIncludes('remark')
|
||||
->parseIncludes('contact')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(AddressResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\DistrictResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -33,7 +34,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
/** @var ResetsAddressesDefault */
|
||||
private $resetsAddressesDefault;
|
||||
|
||||
/** @var SetsAddressToDefault*/
|
||||
/** @var SetsAddressToDefault */
|
||||
private $setsAddressToDefault;
|
||||
|
||||
|
||||
@@ -64,7 +65,15 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
|
||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||
|
||||
$setAddress = $this->setsAddressToDefault->execute($address);
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($setAddress, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -26,7 +27,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Address',
|
||||
'message' => 'You have successfully updated the Address'
|
||||
@@ -77,7 +79,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
@@ -90,18 +92,25 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
$address->contacts()->delete();
|
||||
$address->remarks()->delete();
|
||||
|
||||
if($request->input('phone')){
|
||||
if ($request->input('phone')) {
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
if ($request->input('remark')) {
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
//only remark relationship needed
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -4,24 +4,29 @@ namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
@@ -43,9 +48,6 @@ class CallbackBillplzLogic
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
@@ -53,9 +55,8 @@ class CallbackBillplzLogic
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -63,7 +64,6 @@ class CallbackBillplzLogic
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,30 +111,19 @@ class CallbackBillplzLogic
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
|
||||
// group payment
|
||||
if ($transaction->type == TransactionType::GROUP_PAYMENT && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$group = Group::where('reference', $billplzXSignatureObject->getBillPlzId())->first();
|
||||
|
||||
foreach($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class CreatesBillplzBill
|
||||
{
|
||||
@@ -26,7 +25,7 @@ class CreatesBillplzBill
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => App::environment('production') ? $email : 'development@cief-malaysia.com',
|
||||
'email' => $email,
|
||||
'description' => $description,
|
||||
'amount' => $this->finalizeAmount($amount),
|
||||
'redirect_url' => route('online_payment.redirect'),
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
@@ -45,15 +50,26 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||
|
||||
/*include all relationships*/
|
||||
/* return fractal()
|
||||
->collection($query, new CompanyTransformer)
|
||||
->parseIncludes('company')
|
||||
->parseIncludes('contact')
|
||||
->parseIncludes('remarks')
|
||||
->parseIncludes('address')
|
||||
->parseIncludes('billingAddress')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Transformers\ContactTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -63,6 +64,13 @@ class UpdateContactLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContact->execute($query, $object);
|
||||
|
||||
/*uniformity*/
|
||||
/* return fractal()
|
||||
->item($query, new ContactTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new ContactResource($query));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Order;
|
||||
use App\Transformers\DeliveryOrderTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -52,6 +53,14 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$order = $this->cancelsOrder->execute($order);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||
|
||||
}
|
||||
|
||||
@@ -172,6 +172,12 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||
$this->createsPackage->execute($packageObject, $packingList);
|
||||
|
||||
//add relationship to order
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new DeliveryOrderTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,13 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use League\Fractal;
|
||||
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -58,6 +62,11 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
/* return fractal()
|
||||
->collection($query, new DocumentTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,17 +15,9 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
|
||||
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
private $start_date;
|
||||
private $end_date;
|
||||
|
||||
public function __construct($start_date = null, $end_date = null)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
@@ -34,49 +26,38 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
||||
'Warehouse',
|
||||
'Cbm',
|
||||
'Description',
|
||||
'Quantity',
|
||||
'quantity',
|
||||
'Received Date',
|
||||
'Recorded On',
|
||||
'Days to Record',
|
||||
'Remarks'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$query = PackingList::with([
|
||||
'owner.companyModule.inviters',
|
||||
'owner.orderRoles',
|
||||
'packages',
|
||||
'transports'
|
||||
])
|
||||
->where('type', '=', 1)
|
||||
->where('status', '=', 2)
|
||||
->where('owner_type', Order::class);
|
||||
|
||||
if (!is_null($this->start_date) && !is_null($this->end_date)) {
|
||||
$query->whereHas('transports', function ($q) {
|
||||
$q->whereBetween('drop_date', [
|
||||
Carbon::parse($this->start_date)->startOfDay(),
|
||||
Carbon::parse($this->end_date)->endOfDay()
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
return $query;
|
||||
return PackingList::where('type', '=', 1)->where('status', '=', 2)->where('owner_type', Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $packingList
|
||||
* @return array
|
||||
*/
|
||||
public function map($packingList): array
|
||||
{
|
||||
$order = $packingList->owner;
|
||||
$marking = $order->companyModule->getMarking();
|
||||
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
|
||||
$cbm = $packingList->packages->sum(function ($package) {
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
|
||||
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
||||
|
||||
$cbm = $packingList->packages->sum(function($package){
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
});
|
||||
$arrival_date = $packingList->transports->first()->drop_date->format('d-m-Y');
|
||||
$recorded_on = $packingList->created_at->format('d-m-Y');
|
||||
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
|
||||
|
||||
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
|
||||
|
||||
return [
|
||||
$packingList->owner->reference,
|
||||
@@ -86,9 +67,7 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
||||
$packingList->packages->implode('description', ', '),
|
||||
$packingList->packages->sum('quantity'),
|
||||
$arrival_date,
|
||||
$recorded_on,
|
||||
$days_to_record,
|
||||
''
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
'AccNo',
|
||||
'DetailDescription',
|
||||
@@ -127,7 +126,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
$order->reference,
|
||||
'500-0000',
|
||||
'X1 Freight Service Charge',
|
||||
$furtherDescription,
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -32,10 +31,8 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Groups\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GroupObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $issuer;
|
||||
|
||||
/** @var int */
|
||||
private $receiver;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
|
||||
/** @var float */
|
||||
private $originalAmount;
|
||||
|
||||
/** @var int */
|
||||
private $currencyId;
|
||||
|
||||
/** @var int */
|
||||
private $originalCurrencyId;
|
||||
|
||||
/** @var float */
|
||||
private $currencyRate;
|
||||
|
||||
/** @var float */
|
||||
private $tax;
|
||||
|
||||
/** @var float */
|
||||
private $serviceCharge;
|
||||
|
||||
/** @var int|null */
|
||||
private $status;
|
||||
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $paymentMethod;
|
||||
|
||||
/**
|
||||
* GroupObject constructor.
|
||||
* @param int $issuer
|
||||
* @param int $receiver
|
||||
* @param float $amount
|
||||
* @param float $originalAmount
|
||||
* @param int $currencyId
|
||||
* @param int $originalCurrencyId
|
||||
* @param float $currencyRate
|
||||
* @param float $tax
|
||||
* @param float $serviceCharge
|
||||
* @param string $reference
|
||||
* @param int|null $status
|
||||
* @param int $paymentMethod
|
||||
*/
|
||||
public function __construct(
|
||||
int $issuer,
|
||||
int $receiver,
|
||||
float $amount,
|
||||
float $originalAmount,
|
||||
int $currencyId,
|
||||
int $originalCurrencyId,
|
||||
float $currencyRate,
|
||||
float $tax,
|
||||
float $serviceCharge,
|
||||
int $paymentMethod,
|
||||
?string $reference,
|
||||
?int $status = ApprovalStatus::PENDING_SUBMISSION
|
||||
)
|
||||
{
|
||||
$this->issuer = $issuer;
|
||||
$this->receiver = $receiver;
|
||||
$this->amount = $amount;
|
||||
$this->originalAmount = $originalAmount;
|
||||
$this->currencyId = $currencyId;
|
||||
$this->originalCurrencyId = $originalCurrencyId;
|
||||
$this->currencyRate = $currencyRate;
|
||||
$this->tax = $tax;
|
||||
$this->serviceCharge = $serviceCharge;
|
||||
$this->paymentMethod = $paymentMethod;
|
||||
$this->reference = $reference;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIssuer(): int
|
||||
{
|
||||
return $this->issuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getReceiver(): int
|
||||
{
|
||||
return $this->receiver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getOriginalAmount(): float
|
||||
{
|
||||
return $this->originalAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrencyId(): int
|
||||
{
|
||||
return $this->currencyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOriginalCurrencyId(): int
|
||||
{
|
||||
return $this->originalCurrencyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getCurrencyRate(): float
|
||||
{
|
||||
return $this->currencyRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTax(): float
|
||||
{
|
||||
return $this->tax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getServiceCharge(): float
|
||||
{
|
||||
return $this->serviceCharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): ?int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPaymentMethod(): int
|
||||
{
|
||||
return $this->paymentMethod;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Groups\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Groups\DataTransferObjects\GroupObject;
|
||||
use App\Models\Group;
|
||||
|
||||
class CreatesGroup extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param GroupObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(GroupObject $object) {
|
||||
$model = new Group();
|
||||
$model->issuer = $object->getIssuer();
|
||||
$model->receiver = $object->getReceiver();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->currency_id = $object->getCurrencyId();
|
||||
$model->original_currency_id = $object->getOriginalCurrencyId();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
$model->tax = $object->getTax();
|
||||
$model->service_charge = $object->getServiceCharge();
|
||||
$model->status = $object->getStatus();
|
||||
$model->reference = $object->getReference();
|
||||
$model->payment_method = $object->getPaymentMethod();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -39,6 +40,12 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,20 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
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\Http\Resources\OrderResource;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Models\Address;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -41,6 +47,12 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
/**
|
||||
@@ -51,14 +63,18 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, CreatesAddress $createsAddress, CanCreateAddress $canCreateAddress, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
@@ -83,10 +99,11 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
} else {
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($originWarehouse->reference === WarehouseReferences::YD_YIWU && in_array($address->state_id, [5, 13, 14])) {
|
||||
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ class FetchesDataFromYDPortal
|
||||
$content = str_replace("\r",'', $content);
|
||||
$content = str_replace("\n",'', $content);
|
||||
$content = str_replace("\t",'', $content);
|
||||
$content = str_replace('"data":}', '"data":""}', $content);
|
||||
return json_decode($content);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -56,6 +57,13 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
}
|
||||
|
||||
//only return with packing list relationship
|
||||
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseInclude(['packingLists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +20,8 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -51,10 +53,16 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -70,6 +71,11 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -18,7 +19,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
@@ -50,7 +52,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -59,6 +61,12 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
//load with remarks only
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['remarks'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
}
|
||||
|
||||
+25
-17
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -28,7 +29,8 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
@@ -41,7 +43,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
@@ -54,12 +56,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
@@ -77,11 +79,11 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -92,21 +94,27 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//include transport
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['transport'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Container',
|
||||
'message' => 'You have successfully retrieved a Container'
|
||||
@@ -48,12 +50,18 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
//load with packing lists
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->parseIncludes(['packing_lists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -9,6 +9,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +20,8 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -52,11 +54,16 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
//no relations required
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+16
-5
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -45,16 +50,22 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
//load with no filters, a details page to be added to load one with all related data
|
||||
/* return fractal()
|
||||
->collection($query, new ContainerTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+13
-6
@@ -10,6 +10,7 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,7 +21,8 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
@@ -54,7 +56,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -65,15 +67,20 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//no relationship
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
+21
-10
@@ -3,12 +3,16 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +23,8 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -52,19 +57,19 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
@@ -74,6 +79,12 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContainer->execute($container, $object);
|
||||
|
||||
//no relationships
|
||||
/*
|
||||
return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
@@ -49,11 +51,18 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
|
||||
|
||||
//no relationships queried
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
@@ -49,11 +51,17 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+13
-5
@@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use App\Transformers\DeliverPackingListTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -24,7 +25,8 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
@@ -60,7 +62,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
@@ -68,9 +70,9 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
@@ -82,6 +84,12 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
//no relationships required
|
||||
/* return fractal()
|
||||
->item($deliverPackingList, new DeliverPackingListTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
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\Http\Resources\PackingListResource;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateWarehouseTransportLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Warehouse PackingList',
|
||||
'message' => 'You have successfully created a Warehouse PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
CreatePackingListProcessor $createPackingListProcessor,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule,
|
||||
CreatePackageProcessor $createPackageProcessor,
|
||||
GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber
|
||||
) {
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute([
|
||||
'id' => $request->route('id'),
|
||||
]);
|
||||
|
||||
$count_warehouse_packing_list = PackingList::where('reference', $packing_list->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->count();
|
||||
|
||||
if ($count_warehouse_packing_list) {
|
||||
throw new MalformedRequestException('Warehouse Receive List Exists');
|
||||
}
|
||||
|
||||
$order = $packing_list->owner;
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$packing_list->reference,
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id,
|
||||
PackingListType::WAREHOUSE_RECEIVE_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $request->input('tracking'), Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
|
||||
$scheduleObject = new ScheduleObject(Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
$packages = $packing_list->packages;
|
||||
|
||||
foreach ($packages as $key => $row) {
|
||||
$packageObject = new PackageObject(
|
||||
$row['type'],
|
||||
$row['description'],
|
||||
$row['width'],
|
||||
$row['height'],
|
||||
$row['length'],
|
||||
$row['weight'],
|
||||
$row['quantity'],
|
||||
ApprovalStatus::APPROVED,
|
||||
$row['reference'],
|
||||
);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
@@ -66,7 +65,7 @@ class CreatePackingListProcessor
|
||||
$this->createsPackingList->execute($object, $packingList);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::DEFAULT);
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
return $packingList;
|
||||
|
||||
+2
-14
@@ -26,7 +26,6 @@ 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\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
@@ -36,7 +35,6 @@ 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\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
@@ -64,25 +62,20 @@ class FetchContainersFromYdPortalProcessor
|
||||
/** @var CreateContainerProcessor */
|
||||
private $createContainerProcessor;
|
||||
|
||||
/** @var PackingListToPerfexCRMProcessor */
|
||||
private $packingListToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, CreateContainerProcessor $createContainerProcessor, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
|
||||
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;
|
||||
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +87,7 @@ class FetchContainersFromYdPortalProcessor
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$maxFetchTime = Carbon::now()->subMonths(4);
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDate('created_at', '>=', $maxFetchTime)->doesntHave('containers')->get();
|
||||
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->doesntHave('containers')->get();
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$time_start = microtime(true);
|
||||
@@ -145,10 +137,6 @@ class FetchContainersFromYdPortalProcessor
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::LOAD_CONTAINER);
|
||||
}
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport){
|
||||
|
||||
+4
-43
@@ -8,11 +8,9 @@ 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\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
|
||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
@@ -29,21 +27,16 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var PackingListToPerfexCRMProcessor */
|
||||
private $packingListToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, UpdatesContractObligation $updatesContractObligations, CreatesSchedule $createsSchedule, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, UpdatesContractObligation $updatesContractObligations, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +51,7 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
foreach ($containers as $container) {
|
||||
$time_start = microtime(true);
|
||||
|
||||
$packingList = $container->packingLists()->first();
|
||||
$packingList = $container->packingLists()->random();
|
||||
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $packingList->reference
|
||||
@@ -72,14 +65,10 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
|
||||
$unstuffingDate = null;
|
||||
$delayDate = null;
|
||||
$checkShipSailDate = null;
|
||||
$checkShipArrivalDate = 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();
|
||||
@@ -108,12 +97,10 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
|
||||
if ($trackingRow->tracking === '到港') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$checkShipArrivalDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '已开船') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||
$checkShipSailDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||
@@ -121,32 +108,7 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
}
|
||||
}
|
||||
|
||||
dump($delayDate, $unstuffingDate);
|
||||
|
||||
if($checkShipSailDate){
|
||||
//check if ship has sailed
|
||||
if($checkShipSailDate->isPast()){
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::SHIP_SAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($checkShipArrivalDate){
|
||||
//check if ship has arrived at destination
|
||||
if($checkShipArrivalDate->isPast()){
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::SHIP_ARRIVED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
|
||||
$delayDate = $delayDate->addDays(2);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
@@ -162,6 +124,7 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($unstuffingDate){
|
||||
@@ -183,9 +146,7 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::UNSTUFFING);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-11
@@ -8,8 +8,6 @@ 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\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
@@ -36,21 +34,16 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var PackingListToPerfexCRMProcessor */
|
||||
private $packingListToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(UpdatesContractObligation $updatesContractObligations, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
|
||||
public function __construct(UpdatesContractObligation $updatesContractObligations, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,9 +99,6 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::DELIVERY);
|
||||
}
|
||||
}
|
||||
|
||||
$time_end = microtime(true);
|
||||
|
||||
@@ -121,7 +121,6 @@ class FetchPackingListsFromYdPortalProcessor
|
||||
}
|
||||
|
||||
$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,
|
||||
@@ -132,7 +131,6 @@ class FetchPackingListsFromYdPortalProcessor
|
||||
if(!$rows->data) continue;
|
||||
|
||||
foreach($rows->data as $row){
|
||||
if(!is_numeric($row->goodcount)) continue;
|
||||
|
||||
$time_start = microtime(true);
|
||||
|
||||
|
||||
@@ -42,10 +42,7 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $duedate;
|
||||
|
||||
/** @var int */
|
||||
private $invoiceId;
|
||||
|
||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department, string $priority, string $duedate, int $invoiceId)
|
||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department, string $priority, string $duedate)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->name = $name;
|
||||
@@ -59,7 +56,6 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
$this->department = $department;
|
||||
$this->priority = $priority;
|
||||
$this->duedate = $duedate;
|
||||
$this->invoiceId = $invoiceId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,12 +158,4 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
return $this->duedate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvoiceId(): int
|
||||
{
|
||||
return $this->invoiceId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class FetchPerfexCRMInvoiceObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var Transaction */
|
||||
private $transaction;
|
||||
|
||||
|
||||
public function __construct(string $email, Transaction $transaction)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getTransaction(): Transaction
|
||||
{
|
||||
return $this->transaction;
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,6 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
/** @var int */
|
||||
private $projectStatus;
|
||||
|
||||
/** @var int */
|
||||
private $invoiceId = 0;
|
||||
|
||||
/** @var array */
|
||||
private $milestoneNames;
|
||||
|
||||
@@ -38,7 +35,7 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
private $tasks;
|
||||
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, int $invoiceId, array $milestoneNames, array $tasks)
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $tasks)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
@@ -48,7 +45,6 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
$this->bookingMarking = $bookingMarking;
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->$invoiceId = $invoiceId;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
@@ -109,14 +105,6 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
return $this->projectStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvoiceId(): int
|
||||
{
|
||||
return $this->invoiceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -137,9 +125,4 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
|
||||
public function setInvoiceId($invoiceId)
|
||||
{
|
||||
$this->invoiceId = $invoiceId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,8 +151,7 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
array_push($invoiceItems, $invoiceSingleItem);
|
||||
}
|
||||
|
||||
// $total = $transaction->amount;
|
||||
$total = number_format($transaction->amount, 2,'.','') * 1;
|
||||
$total = $transaction->amount;
|
||||
|
||||
//This setting is similar to Setup > Leads > Sources, Setup > Leads > Statuses
|
||||
//Can be found at Finance > Payment Modes
|
||||
|
||||
@@ -25,7 +25,19 @@ class CreatePerfexCRMTaskProcessor
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
|
||||
$this->createsPerfexCRMTask->execute($createTaskPerfexCRMObject);
|
||||
$this->createsPerfexCRMTask->execute(
|
||||
$createTaskPerfexCRMObject->getName(),
|
||||
$createTaskPerfexCRMObject->getDescription(),
|
||||
$createTaskPerfexCRMObject->getLeadId(),
|
||||
$createTaskPerfexCRMObject->getMilestoneId(),
|
||||
$createTaskPerfexCRMObject->getProjectId(),
|
||||
$createTaskPerfexCRMObject->getReference(),
|
||||
$createTaskPerfexCRMObject->getOnTaskCompletion(),
|
||||
$createTaskPerfexCRMObject->getDepartment(),
|
||||
$createTaskPerfexCRMObject->getStatus(),
|
||||
$createTaskPerfexCRMObject->getPriority(),
|
||||
$createTaskPerfexCRMObject->getDuedate()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class FetchPerfexCRMInvoiceProcessor
|
||||
{
|
||||
private $fetchesPerfexCRMCustomer;
|
||||
/** @var FetchesPerfexCRMCustomer */
|
||||
|
||||
/** @var FetchesPerfexCRMInvoice */
|
||||
private $fetchesPerfexCRMInvoice;
|
||||
|
||||
/** @var CreatePerfexCRMInvoiceProcessor */
|
||||
private $createPerfexCRMInvoiceProcessor;
|
||||
|
||||
/**
|
||||
*
|
||||
* FetchPerfexCRMInvoiceProcessor constructor.
|
||||
* @param FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer
|
||||
* @param FetchesPerfexCRMInvoice $fetchesPerfexCRMInvoice
|
||||
* @param CreatePerfexCRMInvoiceProcessor $createPerfexCRMInvoiceProcessor
|
||||
*/
|
||||
public function __construct(FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer,
|
||||
FetchesPerfexCRMInvoice $fetchesPerfexCRMInvoice,
|
||||
CreatePerfexCRMInvoiceProcessor $createPerfexCRMInvoiceProcessor)
|
||||
{
|
||||
$this->fetchesPerfexCRMCustomer = $fetchesPerfexCRMCustomer;
|
||||
$this->fetchesPerfexCRMInvoice = $fetchesPerfexCRMInvoice;
|
||||
$this->createPerfexCRMInvoiceProcessor = $createPerfexCRMInvoiceProcessor;
|
||||
}
|
||||
|
||||
public function execute(FetchPerfexCRMInvoiceObject $fetchPerfexCRMInvoiceObject)
|
||||
{
|
||||
//invoiceId to be returned - fetch or create
|
||||
$invoiceId = 0;
|
||||
|
||||
//get the client id
|
||||
$customer = $this->fetchesPerfexCRMCustomer->execute($fetchPerfexCRMInvoiceObject->getEmail());
|
||||
$transaction = $fetchPerfexCRMInvoiceObject->getTransaction();
|
||||
|
||||
$number = $transaction->owner->bill_no;
|
||||
|
||||
$prefix = "INV-";
|
||||
//This will remove the prefix if prefix already exist in the string
|
||||
if (substr($number, 0, strlen($prefix)) == $prefix) {
|
||||
$number = substr($number, strlen($prefix));
|
||||
}
|
||||
|
||||
$invoice = $this->fetchesPerfexCRMInvoice->execute($customer->userid,"INV-", $number);
|
||||
if(is_null($invoice)){
|
||||
$result = $this->createPerfexCRMInvoiceProcessor->execute($transaction->owner);
|
||||
if ($result) {
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
$log['message'] = 'FetchPerfexCRMInvoiceProcessor failed for transaction > bill_no: '.$number;
|
||||
Helper::debugLogger($log);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$invoiceId = $invoice->id;
|
||||
}
|
||||
|
||||
return $invoiceId;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ use App\Classes\Jobs\CreatePerfexCRMSingleTask;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskPriority;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class NewLeadTaskToPerfexCRMProcessor
|
||||
{
|
||||
@@ -19,32 +17,26 @@ class NewLeadTaskToPerfexCRMProcessor
|
||||
*/
|
||||
public function execute(Company $company)
|
||||
{
|
||||
try {
|
||||
$companyModule = $company->companyModules()->first();
|
||||
$employee = $companyModule->employees()->first();
|
||||
$contactEmail = $employee->email;
|
||||
$companyModule = $company->companyModules()->first();
|
||||
$employee = $companyModule->employees()->first();
|
||||
$contactEmail = $employee->email;
|
||||
|
||||
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
|
||||
$contactEmail,
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['name'],
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['description'],
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
|
||||
PerfexCRMTaskPriority::DEFAULT,
|
||||
"0",
|
||||
0
|
||||
);
|
||||
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
|
||||
$contactEmail,
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['name'],
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['description'],
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
|
||||
PerfexCRMTaskPriority::DEFAULT,
|
||||
"0"
|
||||
);
|
||||
|
||||
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
|
||||
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception);
|
||||
}
|
||||
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,160 +4,57 @@ namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Classes\Jobs\UpdatePerfexCRM;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
|
||||
use App\Models\PackingList;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PackingListToPerfexCRMProcessor
|
||||
{
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
* @return bool
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packingList, int $stage = PerfexCRMTasksYDStages::DEFAULT): bool
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
try {
|
||||
if($packingList->owner instanceof \App\Models\Order) {
|
||||
$info = $this->extractInfo($packingList);
|
||||
$tasks = $this->defineTasks($stage);
|
||||
$order = $packingList->owner;
|
||||
$companyModule = $order->companyModule()->first();
|
||||
$connection = $companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
$companyName = $companyModule->name;
|
||||
$companyReference = $connection ? $connection->pivot->invitee_reference:'';
|
||||
$employee = $companyModule->employees()->first();
|
||||
$contactEmail = $employee->email;
|
||||
$contactName = $employee->name;
|
||||
|
||||
$orderReference = $packingList->owner->reference;
|
||||
$packingListReference = $packingList->reference;
|
||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
||||
|
||||
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
|
||||
$info['companyName'],
|
||||
$info['companyReference'],
|
||||
$info['contactName'],
|
||||
$info['contactEmail'],
|
||||
$info['bookingMarking'], //For Exchange-2.0
|
||||
$info['projectName'],
|
||||
$companyName,
|
||||
$companyReference,
|
||||
$contactName,
|
||||
$contactEmail,
|
||||
"",
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::NOT_STARTED,
|
||||
0,
|
||||
[],
|
||||
$tasks
|
||||
[
|
||||
PerfexCRMTasks::TASK_LOADED_CONTAINER_1,
|
||||
PerfexCRMTasks::TASK_LOADED_CONTAINER_2,
|
||||
]
|
||||
);
|
||||
$this->dispatchUpdateJob($packingList, $updatePerfexCRMObject);
|
||||
UpdatePerfexCRMPrelude::dispatch($packingList, null, $updatePerfexCRMObject, UpdatePerfexCRM::class, null);
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error('PackingListToPerfexCRMProcessor: ' . json_encode($packingList));
|
||||
Log::error(json_encode('PackingListToPerfexCRMProcessor debug:'));
|
||||
Log::error(json_encode($packingList));
|
||||
Log::error($exception);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Level 1
|
||||
private function extractInfo(PackingList $packingList): array
|
||||
{
|
||||
$order = $packingList->owner;
|
||||
$companyModule = $order->companyModule()->first();
|
||||
$employee = $companyModule->employees()->first();
|
||||
|
||||
$info = [];
|
||||
$info['companyName'] = $companyModule->name;
|
||||
$info['companyReference'] = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$info['contactName'] = $employee->name;
|
||||
$info['contactEmail'] = $employee->email;
|
||||
$info['bookingMarking'] = ''; //For Exchange-2.0
|
||||
$info['projectName'] = 'IZYIM | X1 Shipping | '.$packingList->owner->reference.' | '.$packingList->reference;
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
private function defineTasks(int $stage): array
|
||||
{
|
||||
$tasks = [];
|
||||
|
||||
if ($stage === PerfexCRMTasksYDStages::DEFAULT) {
|
||||
$tasks = $this->defineAllYDStagesTasks();
|
||||
}
|
||||
else if ($stage === PerfexCRMTasksYDStages::LOAD_CONTAINER) {
|
||||
$tasks = $this->updateLoadContainerTasks();
|
||||
}
|
||||
else if ($stage === PerfexCRMTasksYDStages::SHIP_SAILED) {
|
||||
$tasks = $this->updateShipSailedTasks();
|
||||
}
|
||||
else if ($stage === PerfexCRMTasksYDStages::SHIP_ARRIVED) {
|
||||
$tasks = $this->updateShipArrivedTasks();
|
||||
}
|
||||
else if ($stage === PerfexCRMTasksYDStages::UNSTUFFING) {
|
||||
$tasks = $this->updateUnstuffingTasks();
|
||||
}
|
||||
else if ($stage === PerfexCRMTasksYDStages::DELIVERY) {
|
||||
$tasks = $this->updateDeliveryTasks();
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function dispatchUpdateJob(PackingList $packingList, UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||
{
|
||||
UpdatePerfexCRMPrelude::dispatch($packingList, null, $updatePerfexCRMObject, false);
|
||||
}
|
||||
|
||||
|
||||
//Level Others: Nested
|
||||
private function defineAllYDStagesTasks(): array
|
||||
{
|
||||
$tasks = [
|
||||
PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_1,
|
||||
PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_2,
|
||||
PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_3,
|
||||
PerfexCRMTasks::TASK_YD_SHIPPING_1,
|
||||
PerfexCRMTasks::TASK_YD_UNSTUFFING_1,
|
||||
PerfexCRMTasks::TASK_YD_DELIVERY_1,
|
||||
];
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function updateLoadContainerTasks(): array
|
||||
{
|
||||
$tasks = [];
|
||||
$tasks = $this->completeTask(null, PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_3);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function updateShipSailedTasks(): array
|
||||
{
|
||||
$tasks = [];
|
||||
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_3, PerfexCRMTasks::TASK_YD_SHIPPING_1);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function updateShipArrivedTasks(): array
|
||||
{
|
||||
$tasks = [];
|
||||
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_SHIPPING_1, PerfexCRMTasks::TASK_YD_UNSTUFFING_1);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function updateUnstuffingTasks(): array
|
||||
{
|
||||
$tasks = [];
|
||||
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_UNSTUFFING_1, PerfexCRMTasks::TASK_YD_DELIVERY_1);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function updateDeliveryTasks(): array
|
||||
{
|
||||
$tasks = [];
|
||||
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_DELIVERY_1, null);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function completeTask($startTask, $endTask) {
|
||||
$resultArray = [];
|
||||
if($startTask){
|
||||
$startTask['status'] = PerfexCRMTaskStatus::COMPLETED;
|
||||
array_push($resultArray, $startTask);
|
||||
}
|
||||
if($endTask){
|
||||
$endTask['status'] = PerfexCRMTaskStatus::IN_PROGRESS;
|
||||
array_push($resultArray, $endTask);
|
||||
}
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMInvoice;
|
||||
use App\Classes\Jobs\UpdatePerfexCRM;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
|
||||
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransactionToPerfexCRMProcessor
|
||||
{
|
||||
/**
|
||||
* @param Transaction $model
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $model, int $status)
|
||||
{
|
||||
try
|
||||
{
|
||||
if($model->owner instanceof \App\Models\Transaction && $status == ApprovalStatus::APPROVED)
|
||||
{
|
||||
$packingList = $model->owner->owner;
|
||||
$order = $packingList->owner()->first();
|
||||
$companyModule = $order->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 = $order->reference;
|
||||
$packingListReference = $packingList->reference;
|
||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
||||
|
||||
$bookingMarking = $packingList->id."-".$packingList->owner->id;
|
||||
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
|
||||
$companyName,
|
||||
$companyReference,
|
||||
$contactName,
|
||||
$contactEmail,
|
||||
$bookingMarking,
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::IN_PROGRESS,
|
||||
[],
|
||||
[
|
||||
PerfexCRMTasks::TASK_1,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_1,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_2,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_3,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_4,
|
||||
]
|
||||
);
|
||||
|
||||
UpdatePerfexCRMPrelude::dispatch(null, $model, $updatePerfexCRMObject, UpdatePerfexCRM::class, UpdatePerfexCRMInvoice::class);
|
||||
}
|
||||
else if($model->owner instanceof \App\Models\PackingList && $model->status == ApprovalStatus::PENDING_SUBMISSION && $status == ApprovalStatus::APPROVED)
|
||||
{
|
||||
CreatePerfexCRMInvoice::dispatch($model);
|
||||
}
|
||||
}
|
||||
catch (\Exception $exception) {
|
||||
Log::error('TransactionToPerfexCRMProcessor debug:');
|
||||
Log::error($exception);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
|
||||
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransactionToPerfexCRMV2Processor
|
||||
{
|
||||
public function execute(Transaction $model, int $status)
|
||||
{
|
||||
try {
|
||||
if($model->owner instanceof \App\Models\Transaction && in_array($model->type, [TransactionType::PAYMENT])) {
|
||||
//
|
||||
$transaction = $model;
|
||||
$info = $this->extractInfo($transaction);
|
||||
$tasks = $this->defineTasks($model, $status);
|
||||
|
||||
//if(count($tasks) > 0) { //commented, otherwise when customer paid, invoice payment will not get created at crm because there is no tasks attached
|
||||
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
|
||||
$info['companyName'],
|
||||
$info['companyReference'],
|
||||
$info['contactName'],
|
||||
$info['contactEmail'],
|
||||
$info['bookingMarking'],
|
||||
$info['projectName'],
|
||||
PerfexCRMProjectStatus::IN_PROGRESS,
|
||||
0, //invoiceId
|
||||
[], //milestoneNames
|
||||
$tasks
|
||||
);
|
||||
|
||||
$this->dispatchUpdateJob($transaction, $status, $updatePerfexCRMObject);
|
||||
//}
|
||||
}
|
||||
else if($model->owner instanceof \App\Models\PackingList && $model->status == ApprovalStatus::PENDING_SUBMISSION && $status == ApprovalStatus::APPROVED)
|
||||
{
|
||||
CreatePerfexCRMInvoice::dispatch($model);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::error($exception);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Level 1
|
||||
private function extractInfo(Transaction $model): array
|
||||
{
|
||||
$packingList = $model->owner->owner;
|
||||
$order = $packingList->owner()->first();
|
||||
$companyModule = $order->companyModule()->first();
|
||||
$employee = $companyModule->employees()->first();
|
||||
|
||||
$info = [];
|
||||
$info['companyName'] = $companyModule->name;
|
||||
$info['companyReference'] = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$info['contactName'] = $employee->name;
|
||||
$info['contactEmail'] = $employee->email;
|
||||
$info['bookingMarking'] = $packingList->id."-".$packingList->owner->id;
|
||||
$info['projectName'] = 'IZYIM | X1 Shipping | '.$order->reference.' | '.$packingList->reference;
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
private function defineTasks(Transaction $model, int $status): array
|
||||
{
|
||||
$tasks = [];
|
||||
|
||||
if ($status === ApprovalStatus::PENDING_SUBMISSION) {
|
||||
$tasks = $this->defineTasks_handlePendingVerificationStatus($model);
|
||||
} elseif ($status === ApprovalStatus::APPROVED) {
|
||||
$tasks = $this->defineTasks_handleApprovedStatus($model);
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function dispatchUpdateJob(Transaction $model, int $status, UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||
{
|
||||
$withInvoice = ($model->type === TransactionType::PAYMENT && $model->owner instanceof \App\Models\Transaction && $status == ApprovalStatus::APPROVED);
|
||||
UpdatePerfexCRMPrelude::dispatch(null, $model, $updatePerfexCRMObject, $withInvoice);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Level Others: Nested
|
||||
private function defineTasks_handlePendingVerificationStatus(Transaction $model): array
|
||||
{
|
||||
$tasks = [];
|
||||
switch($model->type) {
|
||||
case TransactionType::PAYMENT:
|
||||
$tasks = $this->definePaymentTasks($model);
|
||||
break;
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function defineTasks_handleApprovedStatus(Transaction $model): array
|
||||
{
|
||||
$tasks = [];
|
||||
switch($model->type) {
|
||||
case TransactionType::PAYMENT:
|
||||
$tasks = $this->defineTasks_handleApprovedStatus_handlePaymentApprovedStatus();
|
||||
break;
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
|
||||
private function definePaymentTasks(Transaction $model): array //cief todo: to comfirm what tasks need to be created
|
||||
{
|
||||
$tasks = [];
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function defineTasks_handleApprovedStatus_handlePaymentApprovedStatus(): array //cief todo: to comfirm what tasks need to be created
|
||||
{
|
||||
$tasks = [];
|
||||
// $tasks = [
|
||||
// PerfexCRMTasks::TASK_POST_PAYMENT_1,
|
||||
// PerfexCRMTasks::TASK_POST_PAYMENT_2,
|
||||
// PerfexCRMTasks::TASK_POST_PAYMENT_3,
|
||||
// PerfexCRMTasks::TASK_POST_PAYMENT_4,
|
||||
// ];
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function completeTask($startTask, $endTask) {
|
||||
$startTask['status'] = PerfexCRMTaskStatus::COMPLETED;
|
||||
$endTask['status'] = PerfexCRMTaskStatus::IN_PROGRESS;
|
||||
return [$startTask, $endTask];
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,10 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -208,46 +207,18 @@ class UpdatePerfexCRMProcessor
|
||||
}
|
||||
|
||||
// Get existing or create task
|
||||
$taskName = $tasks[$count]['name'];
|
||||
$taskReference = $tasks[$count]['reference'];
|
||||
$taskOnTaskCompletion = $tasks[$count]['on_task_completion'];
|
||||
$taskIsAllowMultiple = $tasks[$count]['is_allow_multiple'];
|
||||
$taskIsOnTaskCompletionUpdate = $tasks[$count]['is_on_task_completion_update'];
|
||||
if($updatePerfexCRMObject->getInvoiceId() != 0 && $taskIsAllowMultiple){
|
||||
$taskName = $taskName." (".$updatePerfexCRMObject->getInvoiceId().")";
|
||||
$taskReference = $taskReference."_".$updatePerfexCRMObject->getInvoiceId();
|
||||
if($taskOnTaskCompletion && $taskIsOnTaskCompletionUpdate){
|
||||
$taskOnTaskCompletion = $taskOnTaskCompletion."_".$updatePerfexCRMObject->getInvoiceId();
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->fetchesPerfexCRMTask->execute($taskName, $milestoneId, 'project', $projectId, $updatePerfexCRMObject->getInvoiceId());
|
||||
|
||||
$result = $this->fetchesPerfexCRMTask->execute($tasks[$count]['name'], $milestoneId, 'project', $projectId);
|
||||
if(isset($result->payload)){
|
||||
//Check to make sure that task that is already completed do not get updated again
|
||||
if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED && $result->payload[0]['status'] != PerfexCRMTaskStatus::COMPLETED && $result->payload[0]['status'] != $taskStatus)
|
||||
{
|
||||
$task = $result->payload[0];
|
||||
$result = $this->updatesPerfexCRMTask->execute($task['id'], $task['name'], $task['milestone'], $task['rel_id'], $taskStatus, $task['startdate'], is_null($task['duedate']) ? '': $task['duedate']);
|
||||
}
|
||||
break; //Breaking the rest of the tasks in array assuming that they are all created as a batch previously
|
||||
//The following are code not needed at Shipping Portal, Exchange need certain task's status to be updated dynamically
|
||||
// if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED && $result->payload[0]['status'] == PerfexCRMTaskStatus::NOT_STARTED)
|
||||
// {
|
||||
// $task = $result->payload[0];
|
||||
// $result = $this->updatesPerfexCRMTask->execute($task['id'], $task['name'], $task['milestone'], $task['rel_id'], $taskStatus, $task['startdate'], is_null($task['duedate']) ? '': $task['duedate']);
|
||||
// }
|
||||
}
|
||||
else{
|
||||
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
|
||||
"",
|
||||
$taskName,
|
||||
$tasks[$count]['description'],
|
||||
"",
|
||||
$projectId,
|
||||
$milestoneId,
|
||||
$taskReference,
|
||||
$taskOnTaskCompletion,
|
||||
$taskStatus,
|
||||
$tasks[$count]['department'],
|
||||
$tasks[$count]['priority'],
|
||||
$tasks[$count]['duedate'],
|
||||
$updatePerfexCRMObject->getInvoiceId()
|
||||
);
|
||||
$result = $this->createsPerfexCRMTask->execute($createTaskPerfexCRMObject);
|
||||
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'], $tasks[$count]['department'], $taskStatus, $tasks[$count]['priority'], $tasks[$count]['duedate']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class ConvertsPerfexCRMLeadToCustomer
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('ConvertsPerfexCRMLeadToCustomer: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -27,7 +27,7 @@ class CreatesPerfexCRMCustomer
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMCustomer: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMCustomerContact
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMCustomerContact: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -33,7 +33,7 @@ class CreatesPerfexCRMCustomerProject
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMCustomerProject: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -53,7 +53,7 @@ class CreatesPerfexCRMInvoice
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMInvoice: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -33,7 +33,7 @@ class CreatesPerfexCRMInvoicePayment
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMInvoicePayment: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -40,7 +40,7 @@ class CreatesPerfexCRMLead
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMLead: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -36,7 +36,7 @@ class CreatesPerfexCRMMilestone
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMMilestone: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -6,47 +6,67 @@ use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
|
||||
class CreatesPerfexCRMTask
|
||||
{
|
||||
/**
|
||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
||||
* @param string $taskName
|
||||
* @param string $taskDescription
|
||||
* @param string $leadId
|
||||
* @param string $milestoneId
|
||||
* @param string $projectId
|
||||
* @param string $reference
|
||||
* @param string $on_task_completion
|
||||
* @param string $department
|
||||
* @param string $status
|
||||
* @param string $priority
|
||||
* @param string $duedate
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
|
||||
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
|
||||
public function execute(string $taskName, string $taskDescription, string $leadId, string $milestoneId, string $projectId, string $reference, string $on_task_completion, string $department, string $status, string $priority, string $duedate) {
|
||||
try{
|
||||
$custom_fields = [];
|
||||
if($createTaskPerfexCRMObject->getDepartment() != ""){
|
||||
if($department != ""){
|
||||
$custom_fields = [
|
||||
"tasks" => [
|
||||
PerfexCRMCustomFields::TASKS_DEPARTMENT => $createTaskPerfexCRMObject->getDepartment()
|
||||
PerfexCRMCustomFields::TASKS_DEPARTMENT => $department
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $createTaskPerfexCRMObject->getName(),
|
||||
'description' => $createTaskPerfexCRMObject->getDescription(),
|
||||
'milestone' => $createTaskPerfexCRMObject->getMilestoneId(),
|
||||
'name' => $taskName,
|
||||
'description' => $taskDescription,
|
||||
'milestone' => $milestoneId,
|
||||
'startdate' => date('Y-m-d'),
|
||||
'rel_type' => 'project',
|
||||
'rel_id' => $createTaskPerfexCRMObject->getProjectId(),
|
||||
'status' => $createTaskPerfexCRMObject->getStatus(),
|
||||
'rel_id' => $projectId,
|
||||
'status' => $status,
|
||||
'is_system_created' => 1,
|
||||
'reference' => $createTaskPerfexCRMObject->getReference(),
|
||||
'on_task_completion' => $createTaskPerfexCRMObject->getOnTaskCompletion(),
|
||||
'reference' => $reference,
|
||||
'on_task_completion' => $on_task_completion,
|
||||
'custom_fields' => $custom_fields,
|
||||
'priority' => $createTaskPerfexCRMObject->getPriority(),
|
||||
'duedate' => date('Y-m-d', strtotime('+' . $createTaskPerfexCRMObject->getDuedate() . ' days')),
|
||||
'invoice_id' => $createTaskPerfexCRMObject->getInvoiceId(),
|
||||
'priority' => $priority,
|
||||
'duedate' => date('Y-m-d', strtotime('+' . $duedate . ' days')),
|
||||
];
|
||||
|
||||
if($createTaskPerfexCRMObject->getLeadId() != '') {
|
||||
$data['rel_type'] = 'lead';
|
||||
$data['rel_id'] = $createTaskPerfexCRMObject->getLeadId();
|
||||
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,
|
||||
'custom_fields' => $custom_fields,
|
||||
'priority' => $priority,
|
||||
'duedate' => date('Y-m-d', strtotime('+' . $duedate . ' days')),
|
||||
];
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
@@ -57,7 +77,7 @@ class CreatesPerfexCRMTask
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('CreatesPerfexCRMTask: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -24,7 +24,7 @@ class FetchesPerfexCRMCustomer
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMCustomer: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -26,7 +26,7 @@ class FetchesPerfexCRMInvoice
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMInvoice: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -24,7 +24,7 @@ class FetchesPerfexCRMLead
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMLead: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -30,7 +30,7 @@ class FetchesPerfexCRMMilestone
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMMilestone: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -30,7 +30,7 @@ class FetchesPerfexCRMProject
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('FetchesPerfexCRMProject: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -17,7 +17,7 @@ class FetchesPerfexCRMTask
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskName, string $milestoneId, string $relType, string $relId, string $invoiceId) {
|
||||
public function execute(string $taskName, string $milestoneId, string $relType, string $relId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
@@ -30,11 +30,6 @@ class FetchesPerfexCRMTask
|
||||
$data = array_merge($data, $newItem);
|
||||
}
|
||||
|
||||
if($invoiceId != 0) {
|
||||
$newItem = ['invoice_id' => $invoiceId ];
|
||||
$data = array_merge($data, $newItem);
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/tasks/customsearch', $data);
|
||||
@@ -44,7 +39,7 @@ class FetchesPerfexCRMTask
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Helper::debugLogger($response);
|
||||
Helper::debugLoggerForPerfexCRM($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -38,7 +38,7 @@ class UpdatesPerfexCRMCustomer
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
// Helper::debugLogger($response);
|
||||
Helper::debugLoggerForPerfexCRM($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -60,7 +60,7 @@ class UpdatesPerfexCRMInvoice
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMInvoice: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -41,7 +41,7 @@ class UpdatesPerfexCRMLead
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMLead: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -33,7 +33,7 @@ class UpdatesPerfexCRMProject
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMProject: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -38,7 +38,7 @@ class UpdatesPerfexCRMTask
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error('UpdatesPerfexCRMTask: '.$response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -29,8 +29,7 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
* @param UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
)
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor)
|
||||
{
|
||||
$this->updatePostcodeSegmentProcessor = $updatePostcodeSegmentProcessor;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<?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([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,20 +7,24 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Groups\DataTransferObjects\GroupObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Group;
|
||||
use App\Classes\Modules\Groups\Services\CreatesGroup;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Processors\CreateWalletTopUpTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\GroupTransaction;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
|
||||
class CreateGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -39,141 +43,212 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreateWalletTopUpTransactionProcessor */
|
||||
private $createWalletTopUpTransactionProcessor;
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var CreatesGroup */
|
||||
private $createsGroup;
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreateWalletTopUpTransactionProcessor $createWalletTopUpTransactionProcessor,
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor,
|
||||
CreatesGroup $createsGroup
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createWalletTopUpTransactionProcessor = $createWalletTopUpTransactionProcessor;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->createsGroup = $createsGroup;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
$groupPyamentStatus = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
|
||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
if (count($invoice_ids) > 1) {
|
||||
dd('more than 1 invoice');
|
||||
// creates group transaction
|
||||
$group = new Group();
|
||||
|
||||
// todo-new: check why is this not working
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
$issuer = '';
|
||||
$receiver = '';
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = '';
|
||||
$currency_rate = '';
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
|
||||
if ($payment_method == PaymentMethodType::WALLET) {
|
||||
// todo-new: check why is this not working
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
|
||||
$companyModuleId = $invoices->first()->receiver;
|
||||
foreach ($invoices as $invoice) {
|
||||
// todo-new: attach transaction to the group id
|
||||
// create one payment for each, then mark as pending_approval
|
||||
$issuer = $invoice->issuer;
|
||||
$receiver = $invoice->receiver;
|
||||
$amount += $invoice->amount;
|
||||
$original_amount += $invoice->original_amount;
|
||||
$currency_id = $invoice->currency_id;
|
||||
$original_currency_id = $invoice->original_currency_id;
|
||||
$currency_rate = $invoice->currency_rate;
|
||||
$tax += $invoice->tax;
|
||||
$service_charge += $invoice->service_charge;
|
||||
}
|
||||
|
||||
$wallet = Wallet::where('owner_id', $companyModuleId)->first();
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->reference = $billNumber;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
|
||||
// todo-new: verify currently checking wallet amount based on 'amount' value passed by frontend
|
||||
if((float) number_format(($wallet->amount - $request->input('amount')),2) < 0){
|
||||
$group->save();
|
||||
|
||||
|
||||
// attach payment on group transaction
|
||||
|
||||
// $invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids->first()]);
|
||||
// $amount = $request->input('amount');
|
||||
// $company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
|
||||
$invoice_transaction = $group;
|
||||
$transferDetails = $billNumber;
|
||||
$company_module = $group->receiverCompany;
|
||||
} else {
|
||||
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids[0]]);
|
||||
$amount = $request->input('amount');
|
||||
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
$transferDetails = $invoice_transaction->bill_no;
|
||||
}
|
||||
|
||||
$payment_reference = null;
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $transferDetails,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$request->input('bank_code'),
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
$groupPyamentStatus = ApprovalStatus::APPROVED;
|
||||
}
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$issuer = 0;
|
||||
$receiver = 0;
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = 0;
|
||||
$currency_rate = 0;
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$group = new GroupObject(
|
||||
$issuer,
|
||||
$receiver,
|
||||
$amount,
|
||||
$original_amount,
|
||||
$currency_id,
|
||||
$original_currency_id,
|
||||
$currency_rate,
|
||||
$tax,
|
||||
$service_charge,
|
||||
$payment_method,
|
||||
'-',
|
||||
$groupPyamentStatus,
|
||||
);
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
$group = $this->createsGroup->execute($group);
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
if ($payment_method == PaymentMethodType::WALLET) {
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $request->input('bank_code'));
|
||||
if (count($invoice_ids) > 1) {
|
||||
// do one by one
|
||||
// dd($invoices);
|
||||
// todo-new: update all the transaction inside
|
||||
} else {
|
||||
// $invoice_transaction;
|
||||
$packingList = $invoice_transaction->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
$issuer = $invoice->issuer;
|
||||
$receiver = $invoice->receiver;
|
||||
$amount += $invoice->amount;
|
||||
$original_amount += $invoice->original_amount;
|
||||
$currency_id = $invoice->currency_id;
|
||||
$original_currency_id = $invoice->original_currency_id;
|
||||
$currency_rate = $invoice->currency_rate;
|
||||
$tax += $invoice->tax;
|
||||
$service_charge += $invoice->service_charge;
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
// creates group transaction
|
||||
$groupTransaction = new GroupTransaction();
|
||||
$groupTransaction->group_id = $group->id;
|
||||
$groupTransaction->transaction_id = $invoice->id;
|
||||
$groupTransaction->save();
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
||||
// create only one billplz payment for wallet top up
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$companyModuleId = $invoice->receiver;
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||
// createsPaymentTransaction
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$request->input('amount'),
|
||||
$request->input('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'), true, $payment_method);
|
||||
}
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->reference = $payment_method === PaymentMethodType::PAYMENT_GATEWAY ? $topUpTransaction->payment_reference : $billNumber;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
$group->status = $groupPyamentStatus;
|
||||
$group->save();
|
||||
|
||||
if ($payment_method === PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
return $this->resourceResponse(new WalletTransactionResource($topUpTransaction));
|
||||
|
||||
} else {
|
||||
return $this->response([]);
|
||||
}
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
}
|
||||
}
|
||||
|
||||
+79
-20
@@ -5,15 +5,30 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -27,39 +42,83 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionDetail */
|
||||
private $createsTransactionDetail;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesTransactionDetail $createsTransactionDetail,
|
||||
CreatesBillplzBill $createsBillplzBill
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]);
|
||||
$amount = $request->input('amount');
|
||||
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
|
||||
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
if ($request->input('payment_method') == 5) {
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $invoice_transaction->bill_no,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$request->input('bank_code'),
|
||||
true
|
||||
);
|
||||
|
||||
//cief todo: at exchange there is a transition step
|
||||
// if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){
|
||||
// $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION);
|
||||
// }
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
// if(config('perfexcrm.is_enabled') == 'true'){
|
||||
// $this->transactionToPerfexCRMV2Processor->execute($transaction, $status);
|
||||
// }
|
||||
|
||||
//To use
|
||||
//ApprovalStatus::PENDING_VERIFICATION;
|
||||
//use this to trigger $this->transactionToPerfexCRMV2Processor->execute > defineTasks > defineTasks_handlePendingVerificationStatus > definePaymentTasks
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$request->input('amount'),
|
||||
$request->input('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_SUBMISSION,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
||||
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\DeletesGroup;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -23,11 +25,14 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var FetchesGroup */
|
||||
private $fetchesGroup;
|
||||
|
||||
/** @var DeletesGroup */
|
||||
private $deletesGroup;
|
||||
/** @var DeletesTransaction */
|
||||
private $deletesTransaction;
|
||||
|
||||
/**
|
||||
* DeleteGroupLogic constructor.
|
||||
@@ -35,10 +40,11 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
||||
* @param FetchesGroup $fetchesGroup
|
||||
* @param DeletesTransaction $deletesTransaction
|
||||
*/
|
||||
public function __construct(FetchesGroup $fetchesGroup, DeletesGroup $deletesGroup)
|
||||
public function __construct(updatesTransactionStatus $updatesTransactionStatus, FetchesGroup $fetchesGroup, DeletesTransaction $deletesTransaction)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->fetchesGroup = $fetchesGroup;
|
||||
$this->deletesGroup = $deletesGroup;
|
||||
$this->deletesTransaction = $deletesTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,9 +56,24 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesGroup->execute($group);
|
||||
$items = $group->transactions()->get();
|
||||
|
||||
return $this->response([]);
|
||||
foreach($items as $item) {
|
||||
$bill = $item;
|
||||
$payment = $bill->owner;
|
||||
$group->transactions()->detach($bill->id);
|
||||
$this->updatesTransactionStatus->execute($payment, ApprovalStatus::APPROVED);
|
||||
$this->deletesTransaction->execute($bill);
|
||||
}
|
||||
|
||||
$group->delete();
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
class GenerateCreditNotePdfLogic
|
||||
{
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/**
|
||||
* GenerateCreditNotePdfLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string|\Symfony\Component\HttpFoundation\Response
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$supplier = $this->fetchesCompanyModule->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction, 'supplier' => $supplier]);
|
||||
|
||||
return $pdf->stream('CreditNote.pdf');
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -22,7 +23,8 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Groups',
|
||||
'message' => 'You have successfully retrieved a list of groups'
|
||||
@@ -32,10 +34,15 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/** @var ListsGroups */
|
||||
private $listsGroups;
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$query = $this->listsGroups->execute($this->listsGroups->deserializeFilters($request->input('filters')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(GroupResource::collection($query));
|
||||
}
|
||||
|
||||
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Http\Resources\MappableTransactionWithDetailsResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ListMappableTransactionWithDetailsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Transactions With Details',
|
||||
'message' => 'You have successfully retrieved a list of transactions'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
/**
|
||||
* ListTransactionsLogic constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$filePath = storage_path('logs/list_mappable_transaction_with_details.log');
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $request->input('filters') . PHP_EOL;
|
||||
|
||||
file_put_contents($filePath, $textToAppend, FILE_APPEND);
|
||||
|
||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(MappableTransactionWithDetailsResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Http\Resources\BookingResource;
|
||||
use App\Http\Resources\MappableTransactionResource;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListMappableTransactionsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Transactions',
|
||||
'message' => 'You have successfully retrieved a list of transactions'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
/**
|
||||
* ListTransactionsLogic constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(MappableTransactionResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -32,7 +32,8 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Group Transaction',
|
||||
'message' => 'You have successfully updated this Group Transaction'
|
||||
@@ -86,7 +87,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -100,7 +101,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
|
||||
|
||||
|
||||
foreach($transactions as $transaction) {
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
|
||||
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
||||
@@ -169,7 +170,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($pdf->output()))],
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'currency_vendor_order'
|
||||
@@ -179,6 +180,11 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
$document = $this->createsDocument->execute($group, $object);
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatePaymentTransactionProcessor
|
||||
{
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
/**
|
||||
* @param FetchesTransaction $fetchesTransaction,
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
* @param CreatesPaymentTransaction $createsPaymentTransaction
|
||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
||||
* @param CreatesBillplzBill $createsBillplzBil
|
||||
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $invoice, $payment_method, $bank_code)
|
||||
{
|
||||
$amount = $invoice->amount;
|
||||
Log::info($invoice->owner);
|
||||
$company_module = $invoice->owner->owner->companyModule()->first();
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $billNumber,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$bank_code,
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
// later use this variabke to create a approved payment transaction
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
|
||||
|
||||
return $payment_transaction;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Group;
|
||||
|
||||
class DeletesGroup extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Group $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Group $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Group;
|
||||
|
||||
class FetchesGroup extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Transaction */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesTransaction constructor.
|
||||
* @param Transaction $repository
|
||||
*/
|
||||
public function __construct(Group $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user