mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
155 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b30357568 | |||
| 034e9da69e | |||
| 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 |
+3
-5
@@ -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,4 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
@@ -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
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- service_build
|
||||
- node
|
||||
- building_assets
|
||||
- database
|
||||
- unit_test
|
||||
- acceptance_test
|
||||
- code_quality
|
||||
|
||||
# Variables
|
||||
variables:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: mysql_password
|
||||
MYSQL_PASSWORD: mysql_password
|
||||
MYSQL_DATABASE: shpping_portal
|
||||
DB_HOST: mysql
|
||||
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
#install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install MySQL client
|
||||
- apt-get install -y default-mysql-client
|
||||
|
||||
#install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
#install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
|
||||
|
||||
#jobs
|
||||
|
||||
#buld the backend
|
||||
composer_php:
|
||||
stage: service_build
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#build the UI
|
||||
#node installation
|
||||
npm:
|
||||
stage: node
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#building assets
|
||||
building_assets:
|
||||
stage: building_assets
|
||||
# dependencies:
|
||||
# - npm
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
database:
|
||||
stage: database
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - composer_php
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#unit test
|
||||
unit_test:
|
||||
stage: unit_test
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - database
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
- php artisan test
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
|
||||
|
||||
#acceptance tests
|
||||
acceptance_test:
|
||||
stage: acceptance_test
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
- selenium/standalone-chrome:latest
|
||||
#dependencies:
|
||||
# - database
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
- php artisan serve &
|
||||
- vendor/bin/codecept run
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- tests/_output
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,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,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class AmountExceed implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('amount', '>', $value);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class AmountShort implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('amount', '<', $value);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedBefore implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('created_at', '<', Carbon::parse($value));
|
||||
}
|
||||
}
|
||||
@@ -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]);
|
||||
$query->where('type', $value);
|
||||
})->whereHas('containers', function ($query){
|
||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||
});
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class EmailLike implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('email', 'LIKE', '%'.$value.'%');
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -4,7 +4,7 @@ namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PaymentMethod implements Filter
|
||||
class OwnerType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@ class PaymentMethod implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('payment_method', $value);
|
||||
return $builder->where('owner_type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Classes\General;
|
||||
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Helper
|
||||
{
|
||||
@@ -24,21 +24,4 @@ class Helper
|
||||
return array_slice(get_class_methods($className), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $log
|
||||
* @return none
|
||||
*/
|
||||
static function debugLoggerForPerfexCRM($log){
|
||||
if($log){
|
||||
$message = $log['message'];
|
||||
$substring = 'No data were found';
|
||||
if (isset($message)) {
|
||||
if (strpos($message, $substring) !== false) {
|
||||
// Log::info('Message exist');
|
||||
} else {
|
||||
Log::info($log['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMLead;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -30,12 +28,6 @@ class CreatePerfexCRMCustomer implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createLeadPerfexCRMObject->getEmail());
|
||||
if(!is_null($lead)){
|
||||
(App()->make(UpdatesPerfexCRMLead::class))->execute($lead, $this->createLeadPerfexCRMObject->getCompanyReference());
|
||||
}
|
||||
else{
|
||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
||||
}
|
||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CreatePerfexCRMInvoice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var Transaction $transaction*/
|
||||
private $transaction;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMInvoice constructor.
|
||||
* @param Transaction $transaction
|
||||
*/
|
||||
public function __construct(Transaction $transaction)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,12 @@ namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
|
||||
class CreatePerfexCRMSingleTask implements ShouldQueue
|
||||
{
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
||||
|
||||
class InitializePerfexCRM implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var InitialPerfexCRMObject */
|
||||
private $initialPerfexCRMObject;
|
||||
|
||||
/**
|
||||
* InitializePerfexCRM constructor.
|
||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
||||
*/
|
||||
public function __construct(InitialPerfexCRMObject $initialPerfexCRMObject)
|
||||
{
|
||||
$this->initialPerfexCRMObject = $initialPerfexCRMObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(InitializePerfexCRMProcessor::class))->execute($this->initialPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
|
||||
class UpdatePerfexCRM implements ShouldQueue
|
||||
{
|
||||
@@ -18,37 +17,17 @@ class UpdatePerfexCRM implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob;
|
||||
|
||||
/** @var */
|
||||
private $transaction;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRM constructor.
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param UpdatePerfexCRMInvoice $nextJob
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||
{
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob = $nextJob;
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
if($this->nextJob != null && $this->transaction != null){
|
||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$result->projectId,
|
||||
$this->transaction,
|
||||
true
|
||||
);
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob */
|
||||
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
|
||||
}
|
||||
(App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
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\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 App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoiceObject */
|
||||
private $updatePerfexCRMInvoiceObject;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMSingleTask constructor.
|
||||
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||
{
|
||||
$this->updatePerfexCRMInvoiceObject = $updatePerfexCRMInvoiceObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//get the client id
|
||||
$customer = (App()->make(FetchesPerfexCRMCustomer::class))->execute($this->updatePerfexCRMInvoiceObject->getEmail());
|
||||
$transaction = $this->updatePerfexCRMInvoiceObject->getTransaction();
|
||||
|
||||
//get the invoice id
|
||||
$invoiceId = 0;
|
||||
$invoiceStatus = 0;
|
||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||
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());
|
||||
if ($result) {
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
}
|
||||
}
|
||||
else{
|
||||
$invoiceId = $invoice->id;
|
||||
$invoiceStatus = $invoice->status;
|
||||
|
||||
//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());
|
||||
}
|
||||
}
|
||||
|
||||
//create invoice payment
|
||||
if($invoiceId != 0 && $invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||
|
||||
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
||||
|
||||
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
||||
$invoiceId,
|
||||
"$transaction->amount",
|
||||
$date,
|
||||
1,
|
||||
"",
|
||||
""
|
||||
);
|
||||
(App()->make(CreatesPerfexCRMInvoicePayment::class))->execute($invoicePaymentPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
|
||||
public function delay($delay)
|
||||
{
|
||||
// Add delay in seconds to the job
|
||||
$this->delay = $delay;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var */
|
||||
private $packingList;
|
||||
|
||||
/** @var */
|
||||
private $transaction;
|
||||
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRM */
|
||||
private $nextJob1;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob2;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRMPrelude constructor.
|
||||
* @param $packingList
|
||||
* @param $transaction
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param UpdatePerfexCRM $nextJob1
|
||||
* @param UpdatePerfexCRMInvoice $nextJob2
|
||||
*/
|
||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
$this->transaction = $transaction;
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob1 = $nextJob1;
|
||||
$this->nextJob2 = $nextJob2;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if(is_null($this->packingList)){
|
||||
$this->packingList = $this->transaction->owner->owner;
|
||||
}
|
||||
$amount = 0.00;
|
||||
if(!is_null($this->transaction)){
|
||||
$amount = $this->transaction->amount;
|
||||
}
|
||||
$data = [
|
||||
'amount' => number_format($amount, 2, '.', ''),
|
||||
'link_order' => config('app.url').'/order/show/'.$this->packingList->owner->reference,
|
||||
'link_autocount_or' => 'https://docs.google.com/spreadsheets/d/1Q3rJBGQ9Bo04HZp5WR9zbLp7pIW2kfDYsabxG7JON-4/edit#gid=2013983170',
|
||||
'link_perfex' => 'https://perfex.cief-malaysia.com/admin/projects/view/89',
|
||||
];
|
||||
|
||||
|
||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||
$this->updatePerfexCRMObject->setTasks($result);
|
||||
/** @var UpdatePerfexCRM $nextJob1 */
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob2 */
|
||||
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
|
||||
}
|
||||
|
||||
function replacePlaceholders($template, $data, $prefix = '')
|
||||
{
|
||||
foreach ($template as $key => $value) {
|
||||
foreach ($data as $dataKey => $dataValue) {
|
||||
if (is_array($dataValue)) {
|
||||
$template[$key] = $this->replacePlaceholders($template[$key], $dataValue, $dataKey);
|
||||
} else {
|
||||
if ($prefix != '') {
|
||||
$template[$key] = str_replace('{' .$prefix. "." .$dataKey . '}', $dataValue, $template[$key]);
|
||||
} else {
|
||||
$template[$key] = str_replace('{' . $dataKey . '}', $dataValue, $template[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -161,8 +161,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$request->input('name'),
|
||||
$request->input('email'),
|
||||
$request->input('phone'),
|
||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name'),
|
||||
$connection->invitee_reference
|
||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name')
|
||||
);
|
||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesUserFullName;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||
@@ -29,8 +29,8 @@ class UpdateUserLogic extends AbstractControllerLogic
|
||||
/** @var CanUpdateUser */
|
||||
private $canUpdateUser;
|
||||
|
||||
/** @var UpdatesUserFullName */
|
||||
private $updatesUserFullName;
|
||||
/** @var UpdatesUser */
|
||||
private $updatesUser;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
@@ -38,13 +38,13 @@ class UpdateUserLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* UpdateAddressLogic constructor.
|
||||
* @param CanUpdateUser $canUpdateUser
|
||||
* @param UpdatesUserFullName $updatesUserFullName
|
||||
* @param UpdatesUser $updatesUser
|
||||
* @param FetchesUser $fetchesUSer
|
||||
*/
|
||||
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUserFullName $updatesUserFullName, FetchesUser $fetchesUser)
|
||||
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser)
|
||||
{
|
||||
$this->canUpdateUser = $canUpdateUser;
|
||||
$this->updatesUserFullName = $updatesUserFullName;
|
||||
$this->updatesUser = $updatesUser;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class UpdateUserLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesUserFullName->execute($query, $object);
|
||||
$query = $this->updatesUser->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new UserResource($query));
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Http\Resources\UserResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateUserRoleLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Admin Role',
|
||||
'message' => 'You have successfully updated the Admin Role'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateUser */
|
||||
private $canUpdateUser;
|
||||
|
||||
/** @var UpdatesUser */
|
||||
private $updatesUser;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/**
|
||||
* UpdateAddressLogic constructor.
|
||||
* @param CanUpdateUser $canUpdateUser
|
||||
* @param UpdatesUser $updatesUser
|
||||
* @param FetchesUser $fetchesUSer
|
||||
*/
|
||||
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser)
|
||||
{
|
||||
$this->canUpdateUser = $canUpdateUser;
|
||||
$this->updatesUser = $updatesUser;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new UserObject($query->name, $request->input('type'));
|
||||
|
||||
$this->canUpdateUser->passes($object);
|
||||
|
||||
$query = $this->updatesUser->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new UserResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class UserObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* FullNameObject constructor.
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(string $name, int $type)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||
use App\Models\User;
|
||||
|
||||
class UpdatesUser extends AbstractUpdateRecord
|
||||
@@ -11,14 +11,13 @@ class UpdatesUser extends AbstractUpdateRecord
|
||||
|
||||
/**
|
||||
* @param User $model
|
||||
* @param UserObject $object
|
||||
* @param FullNameObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(User $model, UserObject $object) {
|
||||
public function execute(User $model, FullNameObject $object) {
|
||||
|
||||
$model->name = $object->getName();
|
||||
$model->type = $object->getType();
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||
use App\Models\User;
|
||||
|
||||
class UpdatesUserFullName extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param User $model
|
||||
* @param FullNameObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(User $model, FullNameObject $object) {
|
||||
|
||||
$model->name = $object->getName();
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -68,19 +68,19 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->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));
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -66,8 +66,8 @@ class UpdateAnnouncementLogic extends AbstractControllerLogic
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
Carbon::createFromFormat('d-m-Y', $request->input('starting_on'))->format('Y-m-d H:i:s'),
|
||||
Carbon::createFromFormat('d-m-Y', $request->input('ending_on'))->format('Y-m-d H:i:s')
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||
|
||||
@@ -23,7 +23,6 @@ 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\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -102,11 +101,9 @@ class CallbackBillplzLogic
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Company Type',
|
||||
'message' => 'You have successfully updated the Company Tyoe'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new CompanyObject($query->name, $query->reference, $request->input('type'));
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
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 ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateContactLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Contact',
|
||||
'message' => 'You have successfully updated the Contact'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var UpdatesContact */
|
||||
private $updatesContact;
|
||||
|
||||
/** @var FetchesContact */
|
||||
private $fetchesContact;
|
||||
|
||||
/**
|
||||
* UpdateContactLogic constructor.
|
||||
* @param UpdatesContact $updatesContact
|
||||
* @param FetchesContact $fetchesContact
|
||||
*/
|
||||
public function __construct(UpdatesContact $updatesContact, FetchesContact $fetchesContact)
|
||||
{
|
||||
$this->updatesContact = $updatesContact;
|
||||
$this->fetchesContact = $fetchesContact;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ContactObject(
|
||||
$request->input('reference'),
|
||||
$request->input('phone'),
|
||||
$request->input('email'),
|
||||
$request->input('wechat_id')
|
||||
);
|
||||
|
||||
// $this->canUpdateContact->passes($object);
|
||||
|
||||
$query = $this->fetchesContact->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesContact->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new ContactResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Contact;
|
||||
|
||||
class FetchesContact extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Contact */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesContact constructor.
|
||||
* @param Contact $repository
|
||||
*/
|
||||
public function __construct(Contact $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Models\Contact;
|
||||
|
||||
class UpdatesContact extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Contact $model
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Contact $model, ContactObject $object)
|
||||
{
|
||||
$model->reference = $object->getReference();
|
||||
$model->phone = $object->getPhone();
|
||||
$model->email = $object->getEmail();
|
||||
$model->wechat_id = $object->getWechatId();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
'ProjNo',
|
||||
'DeptNo',
|
||||
'Qty',
|
||||
'UnitPrice',
|
||||
// 'marking',
|
||||
// 'contact person',
|
||||
// 'contact number',
|
||||
// 'link',
|
||||
// 'amount'
|
||||
'UnitPrice'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -102,10 +97,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$order = $transaction->owner->owner;
|
||||
$company = $order->companyModule->company;
|
||||
$shippingTransactionDetails = $transaction->transactionDetails()->where('reference', 'SHIPPING_FEE')->first();
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$contact = $order->companyModule->company->contacts->first();
|
||||
$userName = $order->companyModule->employees()->first();
|
||||
$link = route('customer.payment-and-billing', $marking);
|
||||
|
||||
$furtherDescription = '';
|
||||
|
||||
@@ -132,12 +123,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$container->reference,
|
||||
'CIEF',
|
||||
$shippingTransactionDetails->quantity,
|
||||
$shippingTransactionDetails->price,
|
||||
// $marking,
|
||||
// $contact ? $contact->phone : '',
|
||||
// $userName->name,
|
||||
// $link,
|
||||
// $transaction->amount
|
||||
$shippingTransactionDetails->price
|
||||
];
|
||||
return [
|
||||
'<<New>>',
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -4,22 +4,26 @@ 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;
|
||||
|
||||
class CreateOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order',
|
||||
'message' => 'You have successfully created a new Order'
|
||||
@@ -41,8 +45,12 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -50,54 +58,55 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @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)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
public function logic(Request $request) : JsonResponse {
|
||||
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
|
||||
|
||||
// todo-new: fix this
|
||||
// if select warehouse foshan
|
||||
if ($request->input('warehouse_id') === 'foshan') {
|
||||
// 13 - sabah, 14 - sarawak
|
||||
if (in_array($address->state->id, [13, 14])) {
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_FS_WEST_MALAYSIA]);
|
||||
} else {
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_FS_WEST_MALAYSIA]);
|
||||
}
|
||||
} else {
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
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 ($request->input('billing_address_id')) {
|
||||
$companyModule = $company->companyModules->first();
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create new billing addrress
|
||||
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
|
||||
$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.');
|
||||
}
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->newLeadTaskToPerfexCRMProcessor->execute($company);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanFetchOrder;
|
||||
use App\Http\Resources\OrderV2Resource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchOrderV2Logic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Order',
|
||||
'message' => 'You have successfully retrieved an order'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchOrder */
|
||||
private $canFetchOrder;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* FetchOrderLogic constructor.
|
||||
* @param CanFetchOrder $canFetchOrder
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(CanFetchOrder $canFetchOrder, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->canFetchOrder = $canFetchOrder;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$this->canFetchOrder->passes();
|
||||
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
return $this->resourceResponse(new OrderV2Resource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Http\Resources\OrderV2Resource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListOrdersV2Logic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Orders',
|
||||
'message' => 'You have successfully retrieved a list of Orders'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListOrders */
|
||||
private $canListOrders;
|
||||
|
||||
/** @var ListsOrders */
|
||||
private $listsOrders;
|
||||
|
||||
/**
|
||||
* ListOrdersLogic constructor.
|
||||
* @param CanListOrders $canListOrders
|
||||
* @param ListsOrders $listsOrders
|
||||
*/
|
||||
public function __construct(CanListOrders $canListOrders, ListsOrders $listsOrders)
|
||||
{
|
||||
$this->canListOrders = $canListOrders;
|
||||
$this->listsOrders = $listsOrders;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListOrders->passes();
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]));
|
||||
|
||||
return $this->collectionResponse(OrderV2Resource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeletePackingListByPackageIdLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Deleted PackingList',
|
||||
'message' => 'You have successfully deleted a PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var CanDeletePackingList */
|
||||
private $canDeletePackingList;
|
||||
|
||||
/** @var DeletesPackingList */
|
||||
private $deletesPackingList;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesPackage */
|
||||
private $fetchesPackage;
|
||||
|
||||
/**
|
||||
* DeletePackingListByPackageIdLogic constructor.
|
||||
* @param CanDeletePackingList $canDeletePackingList
|
||||
* @param DeletesPackingList $deletesPackingList
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesPackage $fetchesPackage
|
||||
*/
|
||||
public function __construct(CanDeletePackingList $canDeletePackingList, DeletesPackingList $deletesPackingList, FetchesPackingList $fetchesPackingList, FetchesPackage $fetchesPackage)
|
||||
{
|
||||
$this->canDeletePackingList = $canDeletePackingList;
|
||||
$this->deletesPackingList = $deletesPackingList;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesPackage = $fetchesPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canDeletePackingList->passes();
|
||||
|
||||
$package = $this->fetchesPackage->execute(['id' => $request->route('id')]);
|
||||
|
||||
$packingList = $package->packingList;
|
||||
|
||||
$packingList = PackingList::where('reference', $packingList->reference)->get();
|
||||
|
||||
$childPackingList = PackingList::where('owner_type', PackingList::class)->whereIn('owner_id', $packingList->pluck('id'))->get();
|
||||
|
||||
$packingList->each->delete();
|
||||
|
||||
$childPackingList->each->delete();
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
@@ -26,20 +25,16 @@ class CreatePackingListProcessor
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
/** @var PackingListToPerfexCRMProcessor */
|
||||
private $packingListToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* CreatePackingListProcessor constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CreatesPackingList $createsPackingList, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CreatesPackingList $createsPackingList)
|
||||
{
|
||||
$this->canCreatePackingList = $canCreatePackingList;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,10 +59,6 @@ class CreatePackingListProcessor
|
||||
$object = new PackingListObject($object->getReference().'_01', $appointee_id, $type, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$this->createsPackingList->execute($object, $packingList);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
return $packingList;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,13 @@ class CreateLeadPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $companyName;
|
||||
|
||||
/** @var string */
|
||||
private $companyReference;
|
||||
|
||||
public function __construct(string $name, string $email, string $phone, string $companyName, string $companyReference)
|
||||
public function __construct(string $name, string $email, string $phone, string $companyName)
|
||||
{
|
||||
|
||||
$this->name = $name;
|
||||
$this->email = $email;
|
||||
$this->phone = $phone;
|
||||
$this->companyName = $companyName;
|
||||
$this->companyReference = $companyReference;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,11 +60,4 @@ class CreateLeadPerfexCRMObject implements DataTransferObject
|
||||
return $this->companyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyReference(): string
|
||||
{
|
||||
return $this->companyReference;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,16 +33,8 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $status;
|
||||
|
||||
/** @var string */
|
||||
private $department;
|
||||
|
||||
/** @var string */
|
||||
private $priority;
|
||||
|
||||
/** @var string */
|
||||
private $duedate;
|
||||
|
||||
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)
|
||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->name = $name;
|
||||
@@ -53,9 +45,6 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
$this->reference = $reference;
|
||||
$this->onTaskCompletion = $onTaskCompletion;
|
||||
$this->status = $status;
|
||||
$this->department = $department;
|
||||
$this->priority = $priority;
|
||||
$this->duedate = $duedate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,27 +124,4 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDepartment(): string
|
||||
{
|
||||
return $this->department;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriority(): string
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDuedate(): string
|
||||
{
|
||||
return $this->duedate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,6 @@ class InitialPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $projectName;
|
||||
|
||||
/** @var int */
|
||||
private $projectStatus;
|
||||
|
||||
/** @var array */
|
||||
private $milestoneNames;
|
||||
|
||||
@@ -35,7 +32,7 @@ class InitialPerfexCRMObject implements DataTransferObject
|
||||
private $taskNames;
|
||||
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $taskNames)
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, array $milestoneNames, array $taskNames)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
@@ -44,7 +41,6 @@ class InitialPerfexCRMObject implements DataTransferObject
|
||||
$this->contactEmail = $contactEmail;
|
||||
$this->bookingMarking = $bookingMarking;
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->taskNames = $taskNames;
|
||||
}
|
||||
@@ -97,14 +93,6 @@ class InitialPerfexCRMObject implements DataTransferObject
|
||||
return $this->projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectStatus(): int
|
||||
{
|
||||
return $this->projectStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class InvoicePerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
/** @var int */
|
||||
private $clientId;
|
||||
|
||||
/** @var string */
|
||||
@@ -56,9 +56,9 @@ class InvoicePerfexCRMObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getClientId(): string
|
||||
public function getClientId(): int
|
||||
{
|
||||
return $this->clientId;
|
||||
}
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@ class InvoiceSingleItemPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
public $longDescription;
|
||||
|
||||
/** @var float */
|
||||
/** @var int */
|
||||
public $qty;
|
||||
|
||||
/** @var float */
|
||||
@@ -26,7 +26,7 @@ class InvoiceSingleItemPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
public $unit;
|
||||
|
||||
public function __construct(string $description, string $longDescription, float $qty, float $rate, int $order, string $unit)
|
||||
public function __construct(string $description, string $longDescription, int $qty, float $rate, int $order, string $unit)
|
||||
{
|
||||
$this->description = $description;
|
||||
$this->longDescription = $longDescription;
|
||||
@@ -53,9 +53,9 @@ class InvoiceSingleItemPerfexCRMObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return int
|
||||
*/
|
||||
public function getQty(): float
|
||||
public function getQty(): int
|
||||
{
|
||||
return $this->qty;
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class UpdatePerfexCRMInvoiceObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var Transaction */
|
||||
private $transaction;
|
||||
|
||||
/** @var bool */
|
||||
private $isPaid;
|
||||
|
||||
/** @var string */
|
||||
private $projectId;
|
||||
|
||||
public function __construct(string $email, string $projectId, Transaction $transaction, bool $isPaid)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->transaction = $transaction;
|
||||
$this->isPaid = $isPaid;
|
||||
$this->projectId = $projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectId(): string
|
||||
{
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getTransaction(): Transaction
|
||||
{
|
||||
return $this->transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsPaid(): bool
|
||||
{
|
||||
return $this->isPaid;
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,6 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $companyReference;
|
||||
|
||||
/** @var string */
|
||||
private $contactName;
|
||||
|
||||
/** @var string */
|
||||
private $contactEmail;
|
||||
|
||||
@@ -25,28 +22,23 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $projectName;
|
||||
|
||||
/** @var int */
|
||||
private $projectStatus;
|
||||
/** @var string */
|
||||
private $milestoneName;
|
||||
|
||||
/** @var array */
|
||||
private $milestoneNames;
|
||||
|
||||
/** @var array */
|
||||
private $tasks;
|
||||
/** @var string */
|
||||
private $taskName;
|
||||
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $tasks)
|
||||
public function __construct(string $companyName, string $companyReference, string $contactEmail, string $bookingMarking, string $projectName, string $milestoneName, string $taskName)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
$this->companyReference = $companyReference;
|
||||
$this->contactName = $contactName;
|
||||
$this->contactEmail = $contactEmail;
|
||||
$this->bookingMarking = $bookingMarking;
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->tasks = $tasks;
|
||||
$this->milestoneName = $milestoneName;
|
||||
$this->taskName = $taskName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,14 +57,6 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
return $this->companyReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContactName(): string
|
||||
{
|
||||
return $this->contactName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -98,31 +82,19 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectStatus(): int
|
||||
public function getMilestoneName(): string
|
||||
{
|
||||
return $this->projectStatus;
|
||||
return $this->milestoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string
|
||||
*/
|
||||
public function getMilestoneNames(): array
|
||||
public function getTaskName(): string
|
||||
{
|
||||
return $this->milestoneNames;
|
||||
return $this->taskName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getTasks(): array
|
||||
{
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
public function setTasks($tasks)
|
||||
{
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,14 @@
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Models\Transaction;
|
||||
// use App\Classes\Modules\PerfexCRM\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoiceSingleItemPerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatePerfexCRMInvoiceProcessor
|
||||
{
|
||||
@@ -28,116 +23,84 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
||||
private $convertsPerfexCRMLeadToCustomer;
|
||||
|
||||
/** @var FetchesPerfexCRMProject */
|
||||
private $fetchesPerfexCRMProject;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerProject */
|
||||
private $createsPerfexCRMCustomerProject;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMInvoiceProcessor constructor.
|
||||
* @param CreatesPerfexCRMInvoice $createsPerfexCRMInvoice
|
||||
*/
|
||||
public function __construct(CreatesPerfexCRMInvoice $createsPerfexCRMInvoice,
|
||||
CreatesPerfexCRMInvoicePayment $createsPerfexCRMInvoicePayment,
|
||||
ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject)
|
||||
ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer)
|
||||
{
|
||||
$this->createsPerfexCRMInvoice = $createsPerfexCRMInvoice;
|
||||
$this->createsPerfexCRMInvoicePayment = $createsPerfexCRMInvoicePayment;
|
||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param bool $isPaid, default: false
|
||||
* @param $transaction
|
||||
* @param $purchaseOrder
|
||||
* @param $supplier
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $transaction, bool $isPaid = false) {
|
||||
public function execute($transaction, $purchaseOrder, $supplier) {
|
||||
$clientId = "";
|
||||
$number = $transaction->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));
|
||||
}
|
||||
|
||||
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
||||
$dueDate = Carbon::parse($transaction->created_at)->addDays(6)->startOfDay()->format('Y-m-d');
|
||||
$currency = 1;
|
||||
$date = Carbon::parse($transaction->booking->created_at)->format('Y-m-d');
|
||||
$dueDate = Carbon::parse($transaction->booking->created_at)->format('Y-m-d');
|
||||
$currency = 1; //cief TODO: To look into Malaysia and Chinese currency
|
||||
$subTotal = 0.00;
|
||||
$total = 0.00;
|
||||
|
||||
$companyModule = $transaction->owner->owner->companyModule;
|
||||
$billingStreet = "";
|
||||
$addresses = $companyModule
|
||||
->addresses()
|
||||
->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)
|
||||
->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
$addresses = $supplier->addresses()->where('billing', '=', true)->first();
|
||||
|
||||
if ($addresses !== null) {
|
||||
$billingStreet = $billingStreet.$addresses->street_one;
|
||||
$billingStreet = $billingStreet.$addresses->street_two.',';
|
||||
$billingStreet = $billingStreet.$addresses->district()->first()->name.',';
|
||||
$billingStreet = $billingStreet.$addresses->postcode;
|
||||
$billingStreet = $billingStreet.$addresses->state()->first()->name.',';
|
||||
$billingStreet = $billingStreet.$addresses->country()->first()->name;
|
||||
}
|
||||
else{
|
||||
$billingStreet = "[Pending Billing Details by user]";
|
||||
}
|
||||
$billingStreet = $billingStreet.$addresses->street_one;
|
||||
$billingStreet = $billingStreet.$addresses->street_two.',';
|
||||
$billingStreet = $billingStreet.$addresses->district()->first()->name.',';
|
||||
$billingStreet = $billingStreet.$addresses->postcode;
|
||||
$billingStreet = $billingStreet.$addresses->state()->first()->name.',';
|
||||
$billingStreet = $billingStreet.$addresses->country()->first()->name;
|
||||
|
||||
$projectId = "";
|
||||
$allowedPaymentModes = [];
|
||||
$invoiceItems = [];
|
||||
|
||||
$employee = $companyModule->employees()->first();
|
||||
$email = $employee->email;
|
||||
|
||||
$email = $supplier->employees()->first()->email;
|
||||
$email = 'dillon37@yahoo.com'; //cief TODO: To be updated to user actual email address
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($email);
|
||||
if(isset($result->payload)){
|
||||
$clientId = $result->payload['client_id'];
|
||||
}
|
||||
|
||||
//get project
|
||||
$projectId = ""; //Project only exist in CRM if the customer already made payment
|
||||
$projectName = "";
|
||||
if($isPaid){
|
||||
if($transaction->owner instanceof PackingList){
|
||||
$orderReference = $transaction->owner->owner->reference;
|
||||
$packingListReference = $transaction->owner->reference;
|
||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
||||
$result = $this->fetchesPerfexCRMProject->execute($projectName, $clientId);
|
||||
if(isset($result->payload)){
|
||||
$project = $result->payload[0];
|
||||
$projectId = $project['id'];
|
||||
}
|
||||
else{
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($projectName, PerfexCRMProjectStatus::NOT_STARTED, $clientId);
|
||||
if(isset($result->payload)){ //Here means project creation successful
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($projectId == ""){
|
||||
Log::error(json_encode('CreatePerfexCRMInvoiceProcessor debug: '.$projectName));
|
||||
Log::error(json_encode($transaction->owner));
|
||||
}
|
||||
}
|
||||
|
||||
//newitems
|
||||
foreach ($transaction->transactionDetails as $key => $transaction_detail){
|
||||
foreach ($purchaseOrder->transactionDetails as $key => $transaction_detail){
|
||||
$order = $key + 1;
|
||||
$description = $transaction_detail->name;
|
||||
$stockCode = $transaction_detail->product_code;
|
||||
$description = $transaction_detail->product_name;
|
||||
$quantity = $transaction_detail->quantity;
|
||||
$unitPrice = $transaction_detail->price;
|
||||
$unitPrice = 0.00;
|
||||
if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
$unitPrice = (1/$transaction->currency_rate) * $transaction_detail->price;
|
||||
else
|
||||
$unitPrice = $transaction_detail->price;
|
||||
|
||||
$subTotal = $subTotal + $transaction_detail->amount;
|
||||
//$totalAmount = 0.00;
|
||||
if($transaction->booking()->first()->fix_currency_id !== 1){
|
||||
|
||||
//$totalAmount = (float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity;
|
||||
$subTotal += (1/$transaction->currency_rate) * $transaction_detail->price * $transaction_detail->quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//$totalAmount = (float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity;
|
||||
$subTotal += $transaction_detail->price * $transaction_detail->quantity;
|
||||
}
|
||||
|
||||
//string $description, string $longDescription, int $qty, int $rate, int $order, string $unit
|
||||
$invoiceSingleItem = new InvoiceSingleItemPerfexCRMObject(
|
||||
@@ -151,11 +114,16 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
array_push($invoiceItems, $invoiceSingleItem);
|
||||
}
|
||||
|
||||
$total = $transaction->amount;
|
||||
if($transaction->booking()->first()->fix_currency_id !== 1){
|
||||
$total = ((1/$transaction->currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax;
|
||||
}
|
||||
else{
|
||||
$total = $transaction->amount + $transaction->service_charge + $transaction->tax;
|
||||
}
|
||||
|
||||
//This setting is similar to Setup > Leads > Sources, Setup > Leads > Statuses
|
||||
//Can be found at Finance > Payment Modes
|
||||
//cief TODO: To be updated, temporarily hardcoded allow payment modes
|
||||
array_push($allowedPaymentModes, 1, 2);
|
||||
|
||||
$invoicePerfexCRMObject = new InvoicePerfexCRMObject(
|
||||
$clientId,
|
||||
$number,
|
||||
@@ -172,7 +140,20 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
|
||||
$result = $this->createsPerfexCRMInvoice->execute($invoicePerfexCRMObject);
|
||||
|
||||
return $result;
|
||||
//If there is a checking whether an payment to an invoice need to be generated, do it here
|
||||
if(true && $result->payload['id']){
|
||||
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
||||
$result->payload['id'],
|
||||
$total,
|
||||
$date,
|
||||
1,
|
||||
"",
|
||||
""
|
||||
);
|
||||
$this->createsPerfexCRMInvoicePayment->execute($invoicePaymentPerfexCRMObject);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,7 @@ class CreatePerfexCRMTaskProcessor
|
||||
$createTaskPerfexCRMObject->getProjectId(),
|
||||
$createTaskPerfexCRMObject->getReference(),
|
||||
$createTaskPerfexCRMObject->getOnTaskCompletion(),
|
||||
$createTaskPerfexCRMObject->getDepartment(),
|
||||
$createTaskPerfexCRMObject->getStatus(),
|
||||
$createTaskPerfexCRMObject->getPriority(),
|
||||
$createTaskPerfexCRMObject->getDuedate()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMMilestone;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMMilestone;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerContact;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMMilestones;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMStatus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InitializePerfexCRMProcessor
|
||||
{
|
||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
||||
private $convertsPerfexCRMLeadToCustomer;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerProject */
|
||||
private $createsPerfexCRMCustomerProject;
|
||||
|
||||
/** @var CreatesPerfexCRMMilestone */
|
||||
private $createsPerfexCRMMilestone;
|
||||
|
||||
/** @var CreatesPerfexCRMTask */
|
||||
private $createsPerfexCRMTask;
|
||||
|
||||
/** @var FetchesPerfexCRMProject */
|
||||
private $fetchesPerfexCRMProject;
|
||||
|
||||
/** @var FetchesPerfexCRMMilestone */
|
||||
private $fetchesPerfexCRMMilestone;
|
||||
|
||||
/** @var FetchesPerfexCRMTask */
|
||||
private $fetchesPerfexCRMTask;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomer */
|
||||
private $createsPerfexCRMCustomer;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerContact */
|
||||
private $createsPerfexCRMCustomerContact;
|
||||
|
||||
/** @var UpdatesPerfexCRM */
|
||||
private $updatePerfexCRM;
|
||||
|
||||
/** @var UpdatesPerfexCRMCustomer */
|
||||
private $updatesPerfexCRMCustomer;
|
||||
|
||||
/**
|
||||
* @param ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer
|
||||
* @param CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject
|
||||
* @param CreatesPerfexCRMMilestone $createsPerfexCRMMilestone
|
||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
||||
* @param FetchesPerfexCRMProject $fetchesPerfexCRMProject
|
||||
* @param FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone
|
||||
* @param FetchesPerfexCRMTask $fetchesPerfexCRMTask
|
||||
* @param CreatesPerfexCRMCustomer $createsPerfexCRMCustomer
|
||||
* @param CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact
|
||||
* @param UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer
|
||||
*/
|
||||
public function __construct(ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
||||
UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer)
|
||||
{
|
||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
||||
$this->createsPerfexCRMMilestone = $createsPerfexCRMMilestone;
|
||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
||||
$this->fetchesPerfexCRMMilestone = $fetchesPerfexCRMMilestone;
|
||||
$this->fetchesPerfexCRMTask = $fetchesPerfexCRMTask;
|
||||
$this->createsPerfexCRMCustomer = $createsPerfexCRMCustomer;
|
||||
$this->createsPerfexCRMCustomerContact = $createsPerfexCRMCustomerContact;
|
||||
$this->updatesPerfexCRMCustomer = $updatesPerfexCRMCustomer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(InitialPerfexCRMObject $initialPerfexCRMObject) {
|
||||
|
||||
// Customer has to exist first before Project can appear under it
|
||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
||||
$crmCompany = $initialPerfexCRMObject->getCompanyName();
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($initialPerfexCRMObject->getContactEmail());
|
||||
if(isset($result->payload)){
|
||||
$crmClientId = $result->payload['client_id'];
|
||||
if (isset($result->payload['company'])) {
|
||||
$crmCompany = $result->payload['company'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
//if reach this point, this means this user is not a official customer nor is a lead in crm
|
||||
//Create Customer has 2 parts: Create Company (client), Create Contact
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
if(is_null($result)){
|
||||
$crmCompany = $crmCompany." 2";
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
}
|
||||
|
||||
$crmClientId = $result->payload['clientId'];
|
||||
|
||||
$customerContactObject = new CustomerContactObject(
|
||||
$crmClientId,
|
||||
$initialPerfexCRMObject->getContactName(),
|
||||
$initialPerfexCRMObject->getContactName(),
|
||||
$initialPerfexCRMObject->getContactEmail(),
|
||||
"pU^T@sC#9Q",
|
||||
"on",
|
||||
"on"
|
||||
);
|
||||
$result = $this->createsPerfexCRMCustomerContact->execute($customerContactObject);
|
||||
}
|
||||
|
||||
//Update custom fields to identify company reference from exchange or shipping portal
|
||||
$value_exists = false;
|
||||
if (isset($result->payload['customfields'])) {
|
||||
foreach ($result->payload['customfields'] as $element) {
|
||||
if ($element['value'] === $initialPerfexCRMObject->getCompanyReference()) {
|
||||
$value_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$value_exists);
|
||||
{
|
||||
$result = $this->updatesPerfexCRMCustomer->execute($crmClientId, $crmCompany, $initialPerfexCRMObject->getCompanyReference());
|
||||
}
|
||||
|
||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($initialPerfexCRMObject->getProjectName(), $crmClientId);
|
||||
if(isset($result->payload)){ //Here means project creation successful
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
else{
|
||||
$projectId = $this->fetchesPerfexCRMProject->execute($initialPerfexCRMObject->getProjectName(), $crmClientId)->id;
|
||||
}
|
||||
|
||||
if(!is_null($result)){
|
||||
$tasks = $initialPerfexCRMObject->getTaskNames();
|
||||
|
||||
//Create tasks with milestone
|
||||
for($count=0; $count < count($tasks); $count++) {
|
||||
$milestoneId = 0; //By default milestoneId is 0, having this set at individual task is optional
|
||||
if($tasks[$count]['milestone'] != "") //Create milestone only if it is defined
|
||||
{
|
||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
||||
$result = $this->createsPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId, $count);
|
||||
if(isset($result->payload)){
|
||||
$milestoneId = $result->payload['milestone_id'];
|
||||
}
|
||||
else{
|
||||
$milestone = $this->fetchesPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId);
|
||||
$array = json_decode(json_encode($milestone), true);
|
||||
$milestoneId = $array[0]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$taskStatus = PerfexCRMStatus::NOT_STARTED;
|
||||
if($tasks[$count]['status'] != ''){
|
||||
$taskStatus = $tasks[$count]['status'];
|
||||
}
|
||||
|
||||
// Get existing or create task
|
||||
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'], $taskStatus);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,37 +3,28 @@
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMStatus;
|
||||
use App\Classes\Jobs\CreatePerfexCRMSingleTask;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskPriority;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Models\Company;
|
||||
|
||||
class NewLeadTaskToPerfexCRMProcessor
|
||||
{
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param None
|
||||
* @return true
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company)
|
||||
public function execute()
|
||||
{
|
||||
$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'],
|
||||
"dillontest1@gmail.com",
|
||||
"test is the name of the task",
|
||||
"this is the description of the task",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
|
||||
PerfexCRMTaskPriority::DEFAULT,
|
||||
"0"
|
||||
PerfexCRMStatus::NOT_STARTED
|
||||
);
|
||||
|
||||
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
|
||||
|
||||
@@ -1,60 +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\Jobs\UpdatePerfexCRM;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
|
||||
use App\Models\PackingList;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PackingListToPerfexCRMProcessor
|
||||
{
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
try {
|
||||
if($packingList->owner instanceof \App\Models\Order) {
|
||||
$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(
|
||||
$companyName,
|
||||
$companyReference,
|
||||
$contactName,
|
||||
$contactEmail,
|
||||
"",
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::NOT_STARTED,
|
||||
[],
|
||||
[
|
||||
PerfexCRMTasks::TASK_LOADED_CONTAINER_1,
|
||||
PerfexCRMTasks::TASK_LOADED_CONTAINER_2,
|
||||
]
|
||||
);
|
||||
UpdatePerfexCRMPrelude::dispatch($packingList, null, $updatePerfexCRMObject, UpdatePerfexCRM::class, null);
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error(json_encode('PackingListToPerfexCRMProcessor debug:'));
|
||||
Log::error(json_encode($packingList));
|
||||
Log::error($exception);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,45 @@
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\Init;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMMilestones;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\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;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Jobs\InitializePerfexCRM;
|
||||
use App\Classes\Jobs\UpdatePerfexCRM;
|
||||
|
||||
class TransactionToPerfexCRMProcessor
|
||||
{
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatePerfexCRMProcessor */
|
||||
private $updatePerfexCRMProcessor;
|
||||
|
||||
/** @var InitializePerfexCRMProcessor */
|
||||
private $initializePerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* TransactionToPerfexCRMProcessor constructor.
|
||||
* @param UpdatePerfexCRMProcessor $updatePerfexCRMProcessor
|
||||
* @param InitializePerfexCRMProcessor $initializePerfexCRMProcessor
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMProcessor $updatePerfexCRMProcessor, InitializePerfexCRMProcessor $initializePerfexCRMProcessor, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->updatePerfexCRMProcessor = $updatePerfexCRMProcessor;
|
||||
$this->initializePerfexCRMProcessor = $initializePerfexCRMProcessor;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Transaction $model
|
||||
* @param int $status
|
||||
@@ -23,52 +49,40 @@ class TransactionToPerfexCRMProcessor
|
||||
*/
|
||||
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;
|
||||
if($model->owner instanceof \App\Models\Transaction && $status == ApprovalStatus::APPROVED){
|
||||
//dd(json_encode($packingList->owner()->first()->companyModule()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference));
|
||||
//dd(json_encode($model->owner->owner->owner()->first()->companyModule()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference));
|
||||
$companyModule = $model->owner->owner->owner()->first()->companyModule()->first();
|
||||
$companyName = $companyModule->name;
|
||||
$companyReference = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$employee = $companyModule->employees()->first();
|
||||
$contactEmail = $employee->email;
|
||||
$contactName = $employee->name;
|
||||
|
||||
$orderReference = $order->reference;
|
||||
$packingListReference = $packingList->reference;
|
||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
||||
$orderReference = $model->owner->owner->owner()->first()->reference;
|
||||
$packingListReference = $model->owner->owner->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,
|
||||
]
|
||||
);
|
||||
$bookingMarking = $model->owner->owner->id."-".$model->owner->owner->owner->id;
|
||||
$initialPerfexCRMObject = new InitialPerfexCRMObject(
|
||||
$companyName,
|
||||
$companyReference,
|
||||
$contactName,
|
||||
$contactEmail,
|
||||
$bookingMarking,
|
||||
$projectName,
|
||||
[],
|
||||
[
|
||||
PerfexCRMTasks::TASK_1,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_1,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_2,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_3,
|
||||
PerfexCRMTasks::TASK_POST_PAYMENT_4,
|
||||
]
|
||||
);
|
||||
|
||||
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);
|
||||
//$this->initializePerfexCRMProcessor->execute($initialPerfexCRMObject);
|
||||
InitializePerfexCRM::dispatch($initialPerfexCRMObject);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,13 +12,10 @@ use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerContact;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\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\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMStatus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -55,13 +52,8 @@ class UpdatePerfexCRMProcessor
|
||||
/** @var UpdatesPerfexCRMTask */
|
||||
private $updatesPerfexCRMTask;
|
||||
|
||||
/** @var UpdatesPerfexCRMCustomer */
|
||||
private $updatesPerfexCRMCustomer;
|
||||
|
||||
/** @var UpdatesPerfexCRMProject */
|
||||
private $updatesPerfexCRMProject;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer
|
||||
* @param CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject
|
||||
* @param CreatesPerfexCRMMilestone $createsPerfexCRMMilestone
|
||||
@@ -72,21 +64,17 @@ class UpdatePerfexCRMProcessor
|
||||
* @param CreatesPerfexCRMCustomer $createsPerfexCRMCustomer
|
||||
* @param CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact
|
||||
* @param UpdatesPerfexCRMTask $updatesPerfexCRMTask
|
||||
* @param UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer
|
||||
* @param UpdatesPerfexCRMProject $updatesPerfexCRMProject
|
||||
*/
|
||||
public function __construct(ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
||||
UpdatesPerfexCRMTask $updatesPerfexCRMTask,
|
||||
UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer,
|
||||
UpdatesPerfexCRMProject $updatesPerfexCRMProject)
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
||||
UpdatesPerfexCRMTask $updatesPerfexCRMTask)
|
||||
{
|
||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
||||
@@ -98,134 +86,54 @@ class UpdatePerfexCRMProcessor
|
||||
$this->createsPerfexCRMCustomer = $createsPerfexCRMCustomer;
|
||||
$this->createsPerfexCRMCustomerContact = $createsPerfexCRMCustomerContact;
|
||||
$this->updatesPerfexCRMTask = $updatesPerfexCRMTask;
|
||||
$this->updatesPerfexCRMCustomer = $updatesPerfexCRMCustomer;
|
||||
$this->updatesPerfexCRMProject = $updatesPerfexCRMProject;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param PerfexCRMObject $perfexCRMObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(UpdatePerfexCRMObject $updatePerfexCRMObject) {
|
||||
$projectId = "";
|
||||
|
||||
// Customer has to exist first before Project can appear under it
|
||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
||||
$crmCompany = $updatePerfexCRMObject->getCompanyName();
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($updatePerfexCRMObject->getContactEmail());
|
||||
if(isset($result->payload)){
|
||||
$crmClientId = $result->payload['client_id'];
|
||||
if (isset($result->payload['company'])) {
|
||||
$crmCompany = $result->payload['company'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
//if reach this point, this means this user is not a official customer nor is a lead in crm
|
||||
//Create Customer has 2 parts: Create Company (client), Create Contact
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
if(is_null($result)){
|
||||
$crmCompany = $crmCompany." 2";
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
}
|
||||
|
||||
$crmClientId = $result->payload['clientId'];
|
||||
|
||||
$customerContactObject = new CustomerContactObject(
|
||||
$crmClientId,
|
||||
$updatePerfexCRMObject->getContactName(),
|
||||
$updatePerfexCRMObject->getContactName(),
|
||||
$updatePerfexCRMObject->getContactEmail(),
|
||||
"pU^T@sC#9Q",
|
||||
"on",
|
||||
"on"
|
||||
);
|
||||
$result = $this->createsPerfexCRMCustomerContact->execute($customerContactObject);
|
||||
}
|
||||
|
||||
//Update custom fields to identify company reference from exchange or shipping portal
|
||||
$value_exists = false;
|
||||
if (isset($result->payload['customfields'])) {
|
||||
foreach ($result->payload['customfields'] as $element) {
|
||||
if ($element['value'] === $updatePerfexCRMObject->getCompanyReference()) {
|
||||
$value_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$value_exists);
|
||||
{
|
||||
$result = $this->updatesPerfexCRMCustomer->execute($crmClientId, $crmCompany, $updatePerfexCRMObject->getCompanyReference());
|
||||
}
|
||||
|
||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
||||
$result = $this->fetchesPerfexCRMProject->execute($updatePerfexCRMObject->getProjectName(), $crmClientId);
|
||||
public function execute(UpdatePerfexCRMObject $updatePerfexCRMObject) {
|
||||
|
||||
// Customer has to exist first before Project can appear under it
|
||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($updatePerfexCRMObject->getContactEmail());
|
||||
if(isset($result->payload)){
|
||||
$project = $result->payload[0];
|
||||
$projectId = $project['id'];
|
||||
|
||||
//if the project status is anything but PerfexCRMProjectStatus::NOT_STARTED, update the project
|
||||
if($updatePerfexCRMObject->getProjectStatus() != PerfexCRMProjectStatus::NOT_STARTED && $project['status'] == PerfexCRMProjectStatus::NOT_STARTED)
|
||||
{
|
||||
$this->updatesPerfexCRMProject->execute($project, $updatePerfexCRMObject->getProjectStatus());
|
||||
}
|
||||
}
|
||||
else{
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($updatePerfexCRMObject->getProjectName(), $updatePerfexCRMObject->getProjectStatus(), $crmClientId);
|
||||
if(isset($result->payload)){ //Here means project creation successful
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
$crmClientId = $result->payload['client_id'];
|
||||
}
|
||||
|
||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($updatePerfexCRMObject->getProjectName(), $crmClientId);
|
||||
if(isset($result->payload)){
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
else{
|
||||
$projectId = $this->fetchesPerfexCRMProject->execute($updatePerfexCRMObject->getProjectName(), $crmClientId)->id;
|
||||
}
|
||||
|
||||
$tasks = $updatePerfexCRMObject->getTasks();
|
||||
if(count($tasks) > 0){
|
||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
||||
$result = $this->createsPerfexCRMMilestone->execute($updatePerfexCRMObject->getMilestoneName(), $projectId);
|
||||
if(isset($result->payload)){
|
||||
$milestoneId = $result->payload['milestone_id'];
|
||||
}
|
||||
else{
|
||||
$milestone = $this->fetchesPerfexCRMMilestone->execute($updatePerfexCRMObject->getMilestoneName(), $projectId);
|
||||
$array = json_decode(json_encode($milestone), true);
|
||||
$milestoneId = $array[0]['id'];
|
||||
}
|
||||
|
||||
//Create tasks with milestone
|
||||
for($count=0; $count < count($tasks); $count++) {
|
||||
$milestoneId = 0; //By default milestoneId is 0, having this set at individual task is optional
|
||||
if($tasks[$count]['milestone'] != "") //Create milestone only if it is defined
|
||||
{
|
||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
||||
$result = $this->fetchesPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId);
|
||||
if(isset($result->payload)){
|
||||
$array = json_decode(json_encode($result->payload[0]), true);
|
||||
$milestoneId = $array['id'];
|
||||
}
|
||||
else{
|
||||
$result = $this->createsPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId, $count);
|
||||
if(isset($result->payload)){
|
||||
$milestoneId = $result->payload['milestone_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get existing or create task
|
||||
$result = $this->createsPerfexCRMTask->execute($updatePerfexCRMObject->getTaskName(), $milestoneId, $projectId);
|
||||
if(isset($result->payload)){
|
||||
$taskId = $result->payload['task_id'];
|
||||
}
|
||||
else{
|
||||
$taskId = $this->fetchesPerfexCRMTask->execute($updatePerfexCRMObject->getTaskName(), $milestoneId)->id;
|
||||
}
|
||||
|
||||
$taskStatus = PerfexCRMTaskStatus::NOT_STARTED;
|
||||
if($tasks[$count]['status'] != ''){
|
||||
$taskStatus = $tasks[$count]['status'];
|
||||
}
|
||||
$this->updatesPerfexCRMTask->execute($taskId, $updatePerfexCRMObject->getTaskName(), $milestoneId, $projectId, PerfexCRMStatus::COMPLETED);
|
||||
|
||||
// Get existing or create task
|
||||
$result = $this->fetchesPerfexCRMTask->execute($tasks[$count]['name'], $milestoneId, 'project', $projectId);
|
||||
if(isset($result->payload)){
|
||||
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{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$payload = [];
|
||||
$payload['projectId'] = $projectId;
|
||||
return (object) $payload;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class CreatesPerfexCRMCustomerProject
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $projectName, int $status, string $clientId) {
|
||||
public function execute(string $projectName, string $clientId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $projectName,
|
||||
@@ -22,7 +22,7 @@ class CreatesPerfexCRMCustomerProject
|
||||
'billing_type' => 1,
|
||||
'clientid' => $clientId,
|
||||
'start_date' => date('Y-m-d'),
|
||||
'status' => $status
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
|
||||
@@ -16,17 +16,14 @@ class CreatesPerfexCRMInvoice
|
||||
*/
|
||||
public function execute(InvoicePerfexCRMObject $invoicePerfexCRMObject) {
|
||||
try{
|
||||
$subtotal = floor($invoicePerfexCRMObject->getSubTotal() * 100) / 100;
|
||||
$total = floor($invoicePerfexCRMObject->getTotal() * 100) / 100;
|
||||
|
||||
$data = [
|
||||
'clientid' => $invoicePerfexCRMObject->getClientId(),
|
||||
'number' => $invoicePerfexCRMObject->getNumber(),
|
||||
'date' => $invoicePerfexCRMObject->getDate(),
|
||||
'duedate' => $invoicePerfexCRMObject->getDueDate(),
|
||||
'currency' => $invoicePerfexCRMObject->getCurrency(),
|
||||
'subtotal' => number_format($subtotal, 2, '.', ''),
|
||||
'total' => number_format($total, 2, '.', ''),
|
||||
'subtotal' => $invoicePerfexCRMObject->getSubTotal(),
|
||||
'total' => $invoicePerfexCRMObject->getTotal(),
|
||||
'billing_street' => $invoicePerfexCRMObject->getBillingStreet(),
|
||||
'project_id' => $invoicePerfexCRMObject->getProjectId(),
|
||||
'allowed_payment_modes[0]' => 1,
|
||||
|
||||
@@ -18,7 +18,7 @@ class CreatesPerfexCRMInvoicePayment
|
||||
try{
|
||||
$data = [
|
||||
'invoiceid' => $invoicePaymentPerfexCRMObject->getInvoiceId(),
|
||||
'amount' => number_format($invoicePaymentPerfexCRMObject->getAmount(), 2, '.', ''),
|
||||
'amount' => $invoicePaymentPerfexCRMObject->getAmount(),
|
||||
'date' => $invoicePaymentPerfexCRMObject->getDate(),
|
||||
'paymentmode' => $invoicePaymentPerfexCRMObject->getPaymentMode(),
|
||||
'transactionid' => $invoicePaymentPerfexCRMObject->getTransactionId(),
|
||||
|
||||
@@ -16,20 +16,13 @@ class CreatesPerfexCRMLead
|
||||
*/
|
||||
public function execute(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject) {
|
||||
try{
|
||||
$custom_fields = [
|
||||
"leads" => [
|
||||
4 => $createLeadPerfexCRMObject->getCompanyReference()
|
||||
]
|
||||
];
|
||||
|
||||
$data = [
|
||||
'name' => $createLeadPerfexCRMObject->getName(),
|
||||
'email' => $createLeadPerfexCRMObject->getEmail(),
|
||||
'phonenumber' => $createLeadPerfexCRMObject->getPhone(),
|
||||
'company' => $createLeadPerfexCRMObject->getCompanyName(),
|
||||
'source' => 2, //1: Exchange, 2: Shipping Portal
|
||||
'status' => 2, //2: Lead, 1: Customer
|
||||
'custom_fields' => $custom_fields
|
||||
'status' => 2 //2: Lead, 1: Customer
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
|
||||
class CreatesPerfexCRMTask
|
||||
{
|
||||
@@ -15,26 +14,14 @@ class CreatesPerfexCRMTask
|
||||
* @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
|
||||
* @param string $reference, default: ''
|
||||
* @param string $on_task_completion, default: ''
|
||||
* @param string $status, default: 1
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskName, string $taskDescription, string $leadId, string $milestoneId, string $projectId, string $reference, string $on_task_completion, string $department, string $status, string $priority, string $duedate) {
|
||||
public function execute(string $taskName, string $taskDescription, string $leadId, string $milestoneId, string $projectId, string $reference = '', string $on_task_completion = '', string $status = "1") {
|
||||
try{
|
||||
$custom_fields = [];
|
||||
if($department != ""){
|
||||
$custom_fields = [
|
||||
"tasks" => [
|
||||
PerfexCRMCustomFields::TASKS_DEPARTMENT => $department
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
'description' => $taskDescription,
|
||||
@@ -45,10 +32,7 @@ class CreatesPerfexCRMTask
|
||||
'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')),
|
||||
'on_task_completion' => $on_task_completion
|
||||
];
|
||||
|
||||
if($leadId != '') {
|
||||
@@ -62,10 +46,7 @@ class CreatesPerfexCRMTask
|
||||
'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')),
|
||||
'on_task_completion' => $on_task_completion
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMCustomer
|
||||
{
|
||||
/**
|
||||
* @param string $email
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $email) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/customers/byemail/'.$email);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMInvoice
|
||||
{
|
||||
/**
|
||||
* @param string $clientId
|
||||
* @param string $invoicePrefix
|
||||
* @param string $invoiceNumber
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $clientId, string $invoicePrefix, string $invoiceNumber) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/invoices/customsearch/'.$clientId.'/'.$invoicePrefix.'/'.$invoiceNumber);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,9 @@ class FetchesPerfexCRMMilestone
|
||||
*/
|
||||
public function execute(string $milestoneName, string $projectId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $milestoneName,
|
||||
'project_id' => $projectId,
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/milestones/bynameandprojectid', $data);
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/milestones/bynameandprojectid/'.rawurlencode($milestoneName).'/'.$projectId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
@@ -5,41 +5,27 @@ namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class FetchesPerfexCRMTask
|
||||
{
|
||||
/**
|
||||
* @param string $taskName
|
||||
* @param string $milestoneId
|
||||
* @param string $relType
|
||||
* @param string $relId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskName, string $milestoneId, string $relType, string $relId) {
|
||||
public function execute(string $taskName, string $milestoneId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
'rel_type' => $relType,
|
||||
'rel_id' => $relId,
|
||||
];
|
||||
|
||||
if($milestoneId != '') {
|
||||
$newItem = ['milestone' => $milestoneId ];
|
||||
$data = array_merge($data, $newItem);
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/tasks/customsearch', $data);
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/tasks/bynameandmilestoneid/'.rawurlencode($taskName).'/'.$milestoneId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Helper::debugLoggerForPerfexCRM($response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatesPerfexCRMCustomer
|
||||
{
|
||||
@@ -21,7 +19,7 @@ class UpdatesPerfexCRMCustomer
|
||||
try{
|
||||
$custom_fields = [
|
||||
"customers" => [
|
||||
PerfexCRMCustomFields::CUSTOMERS_SHIPPING_PORTAL_REFERENCE => $companyReference
|
||||
2 => $companyReference
|
||||
]
|
||||
];
|
||||
|
||||
@@ -38,7 +36,7 @@ class UpdatesPerfexCRMCustomer
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Helper::debugLoggerForPerfexCRM($response);
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdatesPerfexCRMInvoice
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $invoice
|
||||
* @param string $projectId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute($invoice, string $projectId) {
|
||||
try{
|
||||
// <p>The Invoice number field is required.<\/p>
|
||||
// <p>The Invoice date field is required.<\/p>
|
||||
// <p>The Currency field is required.<\/p>
|
||||
// <p>The Items field is required.<\/p>
|
||||
// <p>The Allow Payment Mode field is required.<\/p>
|
||||
// <p>The Billing Street field is required.<\/p>
|
||||
// <p>The Sub Total field is required.<\/p>
|
||||
// <p>The Total field is required.<\/p>
|
||||
|
||||
$newInvoiceItems = [];
|
||||
foreach ($invoice->items as $item) {
|
||||
$item['itemid'] = $item['id'];
|
||||
unset($item['id']);
|
||||
$item['order'] = $item['item_order'];
|
||||
unset($item['item_order']);
|
||||
array_push($newInvoiceItems,$item);
|
||||
}
|
||||
|
||||
$allowedPaymentModes = [];
|
||||
array_push($allowedPaymentModes, 1, 2);
|
||||
|
||||
$data = [
|
||||
'number' => $invoice->number,
|
||||
'date' => $invoice->date,
|
||||
'duedate' => $invoice->duedate,
|
||||
'currency' => $invoice->currency,
|
||||
'subtotal' => $invoice->subtotal,
|
||||
'total' => $invoice->total,
|
||||
'billing_street' => $invoice->billing_street,
|
||||
'shipping_street' => $invoice->billing_street,
|
||||
'project_id' => $projectId,
|
||||
'items' => $newInvoiceItems,
|
||||
'allowed_payment_modes' => $allowedPaymentModes,
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/invoices/'.$invoice->id, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
|
||||
class UpdatesPerfexCRMLead
|
||||
{
|
||||
/**
|
||||
* @param $lead
|
||||
* @param string $companyReference
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute($lead, string $companyReference) {
|
||||
try{
|
||||
$custom_fields = [
|
||||
"leads" => [
|
||||
PerfexCRMCustomFields::LEADS_SHIPPING_PORTAL_REFERENCE => $companyReference
|
||||
]
|
||||
];
|
||||
|
||||
$data = [
|
||||
'name' => $lead->name,
|
||||
'email' => $lead->email,
|
||||
'phonenumber' => $lead->phonenumber,
|
||||
'company' => $lead->company,
|
||||
'custom_fields' => $custom_fields,
|
||||
'source' => $lead->source,
|
||||
'status' => $lead->status,
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/leads/'.$lead->id, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdatesPerfexCRMProject
|
||||
{
|
||||
/**
|
||||
* @param $project
|
||||
* @param int $status
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute($project, int $status) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $project['name'],
|
||||
'clientid' => $project['clientid'],
|
||||
// 'rel_type' => 'customer',
|
||||
'billing_type' => 1,
|
||||
'start_date' => $project['start_date'],
|
||||
'status' => $status
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/projects/'.$project['id'], $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,17 @@ namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Processors\UpdatePostcodeSegmentProcessor;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\AddItemToConstantValueArray;
|
||||
use App\Classes\Modules\Segments\Services\RemoveItemFromConstantValueArray;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
|
||||
class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -21,17 +30,54 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var UpdatePostcodeSegmentProcessor */
|
||||
private $updatePostcodeSegmentProcessor;
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var AddItemToConstantValueArray */
|
||||
private $addItemToConstantValueArray;
|
||||
|
||||
/** @var RemoveItemFromConstantValueArray */
|
||||
private $removeItemFromConstantValueArray;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
/**
|
||||
* UpdateConstantLogic constructor.
|
||||
* @param UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param AddItemToConstantValueArray $addItemToConstantValueArray
|
||||
* @param CreatesConstant $createsConstant
|
||||
* @param RemoveItemFromConstantValueArray $removeItemFromConstantValueArray
|
||||
*/
|
||||
public function __construct(
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor)
|
||||
CanUpdateConstant $canUpdateConstant,
|
||||
UpdatesConstant $updatesConstant,
|
||||
FetchesSegment $fetchesSegment,
|
||||
FetchesConstant $fetchesConstant,
|
||||
AddItemToConstantValueArray $addItemToConstantValueArray,
|
||||
RemoveItemFromConstantValueArray $removeItemFromConstantValueArray,
|
||||
CreatesConstant $createsConstant
|
||||
)
|
||||
{
|
||||
$this->updatePostcodeSegmentProcessor = $updatePostcodeSegmentProcessor;
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->addItemToConstantValueArray = $addItemToConstantValueArray;
|
||||
$this->removeItemFromConstantValueArray = $removeItemFromConstantValueArray;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
@@ -42,9 +88,44 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$constant = $this->updatePostcodeSegmentProcessor->execute($request->route('id'), $request->input('reference'), $request->input('postcode'));
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
|
||||
|
||||
$constantValue = $this->addItemToConstantValueArray->execute($constant->value, $request->input('postcode'));
|
||||
|
||||
$object = new ConstantObject($request->input('reference'), $constantValue);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$constantObject = [$request->input('postcode')];
|
||||
|
||||
$object = new ConstantObject(
|
||||
$request->input('reference'),
|
||||
$constantObject
|
||||
);
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
}
|
||||
|
||||
try {
|
||||
// check if postcode exist in the opposite constant, and delete it
|
||||
$oppositeConstant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference') == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE]);
|
||||
|
||||
$oppositeConstantValue = $this->removeItemFromConstantValueArray->execute($oppositeConstant->value, $request->input('postcode'));
|
||||
|
||||
$oppositeObject = new ConstantObject($request->input('reference') == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE, $oppositeConstantValue);
|
||||
|
||||
$this->updatesConstant->execute($oppositeConstant, $oppositeObject);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
// if opposite constant does not exist, do nothing
|
||||
}
|
||||
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\AddItemToConstantValueArray;
|
||||
use App\Classes\Modules\Segments\Services\RemoveItemFromConstantValueArray;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
|
||||
class UpdatePostcodeSegmentProcessor
|
||||
{
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var AddItemToConstantValueArray */
|
||||
private $addItemToConstantValueArray;
|
||||
|
||||
/** @var RemoveItemFromConstantValueArray */
|
||||
private $removeItemFromConstantValueArray;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
/**
|
||||
* UpdatePostcodeSegmentProcessor constructor.
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param AddItemToConstantValueArray $addItemToConstantValueArray
|
||||
* @param CreatesConstant $createsConstant
|
||||
* @param RemoveItemFromConstantValueArray $removeItemFromConstantValueArray
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateConstant $canUpdateConstant,
|
||||
UpdatesConstant $updatesConstant,
|
||||
FetchesSegment $fetchesSegment,
|
||||
FetchesConstant $fetchesConstant,
|
||||
AddItemToConstantValueArray $addItemToConstantValueArray,
|
||||
RemoveItemFromConstantValueArray $removeItemFromConstantValueArray,
|
||||
CreatesConstant $createsConstant
|
||||
)
|
||||
{
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->addItemToConstantValueArray = $addItemToConstantValueArray;
|
||||
$this->removeItemFromConstantValueArray = $removeItemFromConstantValueArray;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $companyModuleId
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute($segment_id, $reference, $postcode){
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segment_id]);
|
||||
|
||||
try {
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $reference]);
|
||||
|
||||
$constantValue = $this->addItemToConstantValueArray->execute($constant->value, $postcode);
|
||||
|
||||
$object = new ConstantObject($reference, $constantValue);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$constantObject = [$postcode];
|
||||
|
||||
$object = new ConstantObject(
|
||||
$reference,
|
||||
$constantObject
|
||||
);
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
}
|
||||
|
||||
try {
|
||||
// check if postcode exist in the opposite constant, and delete it
|
||||
$oppositeConstant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $reference == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE]);
|
||||
|
||||
$oppositeConstantValue = $this->removeItemFromConstantValueArray->execute($oppositeConstant->value, $postcode);
|
||||
|
||||
$oppositeObject = new ConstantObject($reference == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE, $oppositeConstantValue);
|
||||
|
||||
$this->updatesConstant->execute($oppositeConstant, $oppositeObject);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
// if opposite constant does not exist, do nothing
|
||||
}
|
||||
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
return $constant;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
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\UpdatesTransactionStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Delete Transaction',
|
||||
'message' => 'You have successfully deleted the transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
|
||||
/**
|
||||
* SuspendTransactionLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$transaction->delete();
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
-3
@@ -16,7 +16,6 @@ use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
||||
|
||||
class ApproveShippingInvoiceTransactionProcessor
|
||||
{
|
||||
@@ -30,7 +29,6 @@ class ApproveShippingInvoiceTransactionProcessor
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
|
||||
/**
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
@@ -74,7 +72,6 @@ class ApproveShippingInvoiceTransactionProcessor
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packingList));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,25 @@ namespace App\Classes\Modules\Transactions\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Transaction;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\TransactionToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
class UpdatesTransactionStatus extends AbstractUpdateRecord
|
||||
{
|
||||
/** @var TransactionToPerfexCRMProcessor */
|
||||
private $transactionToPerfexCRMProcessor;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* UpdatesTransactionStatus constructor.
|
||||
* @param TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor)
|
||||
public function __construct(TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
{
|
||||
$this->transactionToPerfexCRMProcessor = $transactionToPerfexCRMProcessor;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,13 +34,11 @@ class UpdatesTransactionStatus extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Transaction $model, int $status)
|
||||
{
|
||||
$transaction = clone($model);
|
||||
$model->status = $status;
|
||||
$result = $this->handler($model);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->transactionToPerfexCRMProcessor->execute($transaction, $status);
|
||||
$this->transactionToPerfexCRMProcessor->execute($model, $status);
|
||||
// $this->newLeadTaskToPerfexCRMProcessor->execute();
|
||||
}
|
||||
return $result;
|
||||
$model->status = $status;
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,4 @@ final class CompanyType {
|
||||
|
||||
public const COMPANY_BUSINESS = 1;
|
||||
|
||||
public const COMPANY_TYPE_ID = [
|
||||
self::PERSONAL_BUSINESS => "Personal Business",
|
||||
self::COMPANY_BUSINESS => "Company Business",
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMCustomFields {
|
||||
|
||||
public const CUSTOMERS_EXCHANGE_REFERENCE = 1;
|
||||
|
||||
public const CUSTOMERS_SHIPPING_PORTAL_REFERENCE = 2;
|
||||
|
||||
public const LEADS_EXCHANGE_REFERENCE = 3;
|
||||
|
||||
public const LEADS_SHIPPING_PORTAL_REFERENCE = 4;
|
||||
|
||||
public const TICKETS_CUSTOM_TAGS = 5;
|
||||
|
||||
public const TASKS_DEPARTMENT = 6;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMInvoiceStatus {
|
||||
|
||||
public const UNPAID = 1;
|
||||
|
||||
public const PAID = 2;
|
||||
|
||||
public const PARTIALLY_PAID = 3;
|
||||
|
||||
public const OVERDUE = 4;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMProjectStatus {
|
||||
|
||||
public const NOT_STARTED = 1;
|
||||
|
||||
public const IN_PROGRESS = 2;
|
||||
|
||||
public const ON_HOLD = 3;
|
||||
|
||||
public const FINISHED = 4;
|
||||
|
||||
public const CANCELLED = 5;
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMTaskStatus {
|
||||
final class PerfexCRMStatus {
|
||||
|
||||
public const NOT_STARTED = 1;
|
||||
|
||||
@@ -11,7 +11,7 @@ final class PerfexCRMTaskStatus {
|
||||
public const TESTING = 3;
|
||||
|
||||
public const IN_PROGRESS = 4;
|
||||
|
||||
|
||||
public const COMPLETED = 5;
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMTaskPriority {
|
||||
|
||||
public const DEFAULT = 0;
|
||||
|
||||
public const LOW = 1;
|
||||
|
||||
public const MEDIUM = 2;
|
||||
|
||||
public const HIGH = 3;
|
||||
|
||||
public const URGENT = 4;
|
||||
|
||||
}
|
||||
@@ -4,19 +4,13 @@ namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
class PerfexCRMTasks
|
||||
{
|
||||
//IMPORTANT NOTE: TASK NAME MUST BE UNIQUE ACCORDING TO REL_TYPE
|
||||
//e.g. rel_type: lead, project
|
||||
|
||||
public const TASK_1 = [
|
||||
'name' => 'Customer Paid',
|
||||
'description' => '',
|
||||
'milestone' => 'MILESTONE 1 - Customer Paid',
|
||||
'reference' => '',
|
||||
'on_task_completion' => '',
|
||||
'department' => '',
|
||||
'status' => PerfexCRMTaskStatus::COMPLETED,
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'status' => PerfexCRMStatus::COMPLETED
|
||||
];
|
||||
|
||||
public const TASK_POST_PAYMENT_1 = [
|
||||
@@ -32,22 +26,22 @@ class PerfexCRMTasks
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_1',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_2',
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'status' => PerfexCRMStatus::IN_PROGRESS
|
||||
];
|
||||
public const TASK_POST_PAYMENT_2 = [
|
||||
'name' => 'Approve Payment',
|
||||
'description' => '○ Purpose: To verify and approve the customer\'s payment on IZYIM<br>
|
||||
○ Amount To be Approve: RM {amount}<br>',
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline:Same day<br>
|
||||
○ Responsible department: Accounts<br>
|
||||
○ Next step: Change the status of the Issue Shipping Autocount Invoice operation to "In Progress"<br>
|
||||
○ Additional details: When the payment method is FPX or Wallet this task is performed automatically by the system.<br>
|
||||
○ Dependencies: Map Transaction operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The payment will be approved in IZYIM, which will release the customer’s goods for delivery.<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_2',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_3',
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'status' => ''
|
||||
];
|
||||
public const TASK_POST_PAYMENT_3 = [
|
||||
'name' => 'Issue Shipping Autocount Invoince',
|
||||
@@ -62,23 +56,7 @@ class PerfexCRMTasks
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_3',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_4',
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
];
|
||||
public const TASK_POST_PAYMENT_3_1 = [
|
||||
'name' => 'Issue Shipping Autocount OR',
|
||||
'description' => '○ Purpose: To issue an invoice for the customer\'s payment in accounting software.<br>
|
||||
○ Note: Customer Actually Upload Bank Slip or Not, If not, Invoice Will Not be Exported<br>
|
||||
○ {link_autocount_or}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_3_1',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_4',
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'status' => ''
|
||||
];
|
||||
public const TASK_POST_PAYMENT_4 = [
|
||||
'name' => 'Knockoff Invoice',
|
||||
@@ -93,55 +71,6 @@ class PerfexCRMTasks
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_4',
|
||||
'on_task_completion' => '',
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
];
|
||||
|
||||
public const TASK_LOADED_CONTAINER_1 = [
|
||||
'name' => 'Generate Shipping Invoices',
|
||||
'description' => '○ Purpose: -<br>
|
||||
○ Link to order page: {link_order}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_LOADED_CONTAINER_1',
|
||||
'on_task_completion' => 'TASK_LOADED_CONTAINER_2',
|
||||
'department' => 'Operations',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 1
|
||||
];
|
||||
|
||||
public const TASK_LOADED_CONTAINER_2 = [
|
||||
'name' => 'Approve Shipping Invoices',
|
||||
'description' => '○ Purpose: -<br>
|
||||
○ Link to refer Pay On Behalf or Any extra charge: : {link_perfex}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_LOADED_CONTAINER_2',
|
||||
'on_task_completion' => '',
|
||||
'department' => 'Customer Services',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 1
|
||||
];
|
||||
|
||||
|
||||
public const TASK_IDENTIFICATION_1 = [
|
||||
'name' => 'Approve Identification Verification (Shipping)',
|
||||
'description' => '○ Purpose: To ensure the customer submit information matches the information in their identification document.<br>
|
||||
○ Initial Status: In Progress<br>
|
||||
○ Deadline: Same Day<br>
|
||||
○ Responsible department: Operation<br>
|
||||
○ Next step: None<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: None<br>
|
||||
○ Outcomes: Customer account identification is verified<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_IDENTIFICATION_1',
|
||||
'on_task_completion' => '',
|
||||
'department' => 'Operations',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'status' => ''
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,10 +16,4 @@ final class RoleTypes
|
||||
|
||||
public const USER = 3;
|
||||
|
||||
public const USER_TYPE_ID = [
|
||||
self::SHADOW_ADMIN => "Shadow Admin",
|
||||
self::SUPER_ADMIN => "Super Admin",
|
||||
self::ADMIN => "Admin",
|
||||
self::USER => "User",
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class RouteType {
|
||||
|
||||
public const WEB = 1;
|
||||
|
||||
public const API = 2;
|
||||
|
||||
}
|
||||
@@ -27,9 +27,4 @@ final class TransactionType {
|
||||
|
||||
// public const SHIPPING_COST = 9;
|
||||
|
||||
public const TRANSACTION_TYPE_ID = [
|
||||
self::SHIPPING_INVOICE => "Shipping Invoice",
|
||||
self::PAYMENT => "Payment",
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@ final class WarehouseReferences {
|
||||
|
||||
public const VT_SARAWAK = 'SRW-V01';
|
||||
|
||||
public const YD_FS_WEST_MALAYSIA = 'FS-V01';
|
||||
|
||||
public const YD_FS_EAST_MALAYSIA = 'FS-V02';
|
||||
|
||||
public const VT_DESTINATION_WAREHOUSE = [
|
||||
1 => self::VT_KLANG,
|
||||
2 => self::VT_KLANG,
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class AuditBillplzInvoice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-invoice:audit';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all unpaid invoice but marked paid at our system';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Audit Billplz Invoice cron started.');
|
||||
$start = new Carbon();
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED)->whereHas('transactions', function($query){
|
||||
return $query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->where('status', ApprovalStatus::REJECTED);
|
||||
})->get();
|
||||
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$payment_transaction = $transaction->transactions->sortByDesc('created_at')->first();
|
||||
|
||||
if ($payment_transaction->status === ApprovalStatus::REJECTED) {
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order Marking: '. $payment_transaction->owner->owner->owner->reference . '. Transaction Id: '. $payment_transaction->id . '. Invoice Id: '. $transaction->id . ' - Date: '.$payment_transaction->created_at->format('d-m-Y').' - Amount: '. $payment_transaction->amount);
|
||||
|
||||
$totalAmount += $transaction->amount;
|
||||
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Audit Billplz. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class AuditBillplzPayment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-payment:audit';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all failed payment in billplz, but marked at success at our system';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Audit Billplz Payment cron started.');
|
||||
$start = new Carbon();
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
|
||||
} else {
|
||||
$totalAmount += $transaction->amount;
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Audit Billplz. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CheckDeletedInvoiceButPaid extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'check-deleted-paid-invoice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all deleted invoice but has completed payment';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Start Check all deleted invoice but has completed payment.');
|
||||
$start = new Carbon();
|
||||
|
||||
$totalAmount = 0;
|
||||
|
||||
$softDeletedTransactions = Transaction::onlyTrashed()->where('type', TransactionType::SHIPPING_INVOICE)->whereHas('transactions', function (Builder $query) {
|
||||
$query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY);
|
||||
})->get();
|
||||
|
||||
foreach ($softDeletedTransactions as $invoice) {
|
||||
$invoice_payments = $invoice->transactions()->payments()->get();
|
||||
|
||||
foreach($invoice_payments as $invoice_payment) {
|
||||
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$invoice_payment->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
$orderReference = $invoice->owner->owner->reference ?? null;
|
||||
|
||||
if($data['paid']){
|
||||
$this->info('Invoice id: ' . $invoice->id. '. Payment id: ' . $invoice_payment->id . '. Order: ' . $orderReference);
|
||||
} else {
|
||||
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Check all deleted invoice but has completed payment. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class FixBillplzFailedCallbackPayment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-failed-callback:fix';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fix all failled callback from billplz';
|
||||
|
||||
protected $output = null;
|
||||
|
||||
protected $outputArray = [];
|
||||
|
||||
/** @var GetBillplzBill */
|
||||
private $getBillplzBill;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Fix failled callback from billplz cron started.');
|
||||
$this->outputArray = [];
|
||||
$start = new Carbon();
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
$totalAmount += $transaction->amount;
|
||||
$invoiceStatus = null;
|
||||
|
||||
switch($transaction->owner->status) {
|
||||
case 3:
|
||||
$invoiceStatus = 'Payment Completed';
|
||||
break;
|
||||
case 5:
|
||||
$invoiceStatus = 'Dispute in progress';
|
||||
break;
|
||||
case 6:
|
||||
$invoiceStatus = 'Cancelled Invoice';
|
||||
break;
|
||||
default:
|
||||
$invoiceStatus = 'Pending Payment';
|
||||
}
|
||||
|
||||
$order = $transaction->owner->owner->owner;
|
||||
|
||||
if (in_array($invoiceStatus , ['Pending Payment', 'Payment Completed'])) {
|
||||
// code here
|
||||
|
||||
// $billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
|
||||
|
||||
// if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
|
||||
|
||||
// $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if($data['state'] === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
// if($data->state === 'due') {
|
||||
// $status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
// }
|
||||
|
||||
// $token = Auth::fromUser(User::find(1));
|
||||
// $request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
$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);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
$this->info('Updated invoice ' . $counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
} else {
|
||||
$this->info('Failed to update invoice due to unsufficeint payment ' . $counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if(!$order instanceof Order) {
|
||||
$this->info("Error transaction id:" . $transaction->id . 'Type: ' . get_class($order));
|
||||
} else {
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// $totalAmount += $transaction->amount;
|
||||
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ShowBillplzPaymentStatus extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-payment-status {billplz_id}` ';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Show Billplz payment status';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Show Billplz payment status started.');
|
||||
$start = new Carbon();
|
||||
|
||||
$billplz_id = $this->argument('billplz_id');
|
||||
$billplz_id = explode(",", $billplz_id);
|
||||
|
||||
foreach ($billplz_id as $payment) {
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment);
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
dump($data);
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Showing Billplz payment status. ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ShowFixBillplzFailedCallbackPayment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-failed-callback:show';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all failled callback from billplz';
|
||||
|
||||
protected $output = null;
|
||||
|
||||
protected $outputArray = [];
|
||||
|
||||
/** @var GetBillplzBill */
|
||||
private $getBillplzBill;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Billplz Failled Callback cron started.');
|
||||
$this->outputArray = [];
|
||||
$start = new Carbon();
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
$totalAmount += $transaction->amount;
|
||||
$invoiceStatus = null;
|
||||
|
||||
switch($transaction->owner->status) {
|
||||
case 3:
|
||||
$invoiceStatus = 'Payment Completed';
|
||||
break;
|
||||
case 5:
|
||||
$invoiceStatus = 'Dispute in progress';
|
||||
break;
|
||||
case 6:
|
||||
$invoiceStatus = 'Cancelled Invoice';
|
||||
break;
|
||||
default:
|
||||
$invoiceStatus = 'Pending Payment';
|
||||
}
|
||||
|
||||
$order = $transaction->owner->owner->owner;
|
||||
|
||||
if(!$order instanceof Order) {
|
||||
$this->info("Error transaction id:" . $transaction->id . 'Type: ' . get_class($order));
|
||||
} else {
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
}
|
||||
|
||||
} else {
|
||||
// $totalAmount += $transaction->amount;
|
||||
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SuccessUpdatePaymentStatusButFailedCallback extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'fix-invoice-status';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Success Updated Payment Status But Inoie stat';
|
||||
|
||||
protected $output = null;
|
||||
|
||||
protected $outputArray = [];
|
||||
|
||||
/** @var GetBillplzBill */
|
||||
private $getBillplzBill;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->info(Carbon::now() . ' : Billplz Failled Callback cron started.');
|
||||
$this->outputArray = [];
|
||||
$start = new Carbon();
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)
|
||||
->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->get();
|
||||
|
||||
foreach ($transactions as $payment) {
|
||||
$invoice = $payment->owner ?? null;
|
||||
if (!$invoice) {
|
||||
$this->info('Payment has no owner. Payment ID: ' . $payment->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$packingList = $invoice->owner ?? null;
|
||||
if (!$packingList) {
|
||||
$this->info('Invoice has no owner. Invoice ID: ' . $invoice->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$order = $packingList->owner;
|
||||
if (!$invoice) {
|
||||
$this->info('PackingList has no owner. PackingList ID: ' . $packingList->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($invoice->status == ApprovalStatus::APPROVED) {
|
||||
|
||||
$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);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
dump('Updated invoice ' . $invoice->id . '. Order: '. $order->reference);
|
||||
} else {
|
||||
$this->info('Failed Update invoice ' . $invoice->id . ' because payment not enough. Invoice Amount: ' . $invoice->amount . ' . Paid Amount: ' . $totalPaidAmount . ' . Order: '. $order->reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime );
|
||||
}
|
||||
}
|
||||
+15
-15
@@ -28,30 +28,30 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
|
||||
$schedule->command('command:curlVTCommand')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
// $schedule->command('command:curlVTCommand')
|
||||
// ->cron('0 8 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('30 9-18/3 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('0 9 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('0 9 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
|
||||
$schedule->command('invoice:generate')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
|
||||
|
||||
$schedule->command('billplz-failed-callback:fix')
|
||||
->dailyAt('00:00')
|
||||
$schedule->command('approve:invoice')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/dix_failed_callback_from_billplz.log');
|
||||
->appendOutputTo (storage_path().'/logs/approve_invoice.log');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\UpdateUserRoleLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateUserRoleController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateUserLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateUserRoleLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyTypeLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyTypeController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param AddNewMemberLogic $execute
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, UpdateCompanyTypeLogic $execute) : JsonResponse
|
||||
{
|
||||
return $execute->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contacts;
|
||||
|
||||
use App\Classes\Modules\Contacts\ControllersLogic\UpdateContactLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateContactController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateContactLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class DownloadOrderQrPdfController
|
||||
$warehousePrefix = 'YW/';
|
||||
}
|
||||
|
||||
if(in_array($warehouse->reference,[WarehouseReferences::YD_GUANG_ZHOU, WarehouseReferences::YD_GUANG_ZHOU_2, WarehouseReferences::YD_FS_EAST_MALAYSIA, WarehouseReferences::YD_FS_WEST_MALAYSIA])){
|
||||
if(in_array($warehouse->reference,[WarehouseReferences::YD_GUANG_ZHOU, WarehouseReferences::YD_GUANG_ZHOU_2])){
|
||||
$warehousePrefix = 'YD/';
|
||||
|
||||
if(strtolower($deliveryAddress->state->name) === 'sabah' || strtolower($deliveryAddress->state->name) === 'labuan' || in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Orders;
|
||||
|
||||
use App\Classes\Modules\Orders\ControllersLogic\FetchOrderV2Logic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchOrderV2Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchOrderLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchOrderV2Logic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Orders;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Orders\ControllersLogic\ListOrdersV2Logic;
|
||||
|
||||
|
||||
class ListOrdersV2Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListOrdersV2Logic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
|
||||
public function list(Request $request, ListOrdersV2Logic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\DeletePackingListByPackageIdLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeletePackingListByPackageIdController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeletePackingListLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeletePackingListByPackageIdLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\CreateCombinedInvoicesLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCombinedInvoicesController
|
||||
{
|
||||
|
||||
public function combine(Request $request, CreateCombinedInvoicesLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\DeleteTransactionLogic;
|
||||
|
||||
|
||||
class DeleteTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteTransactionLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user