mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-21 13:34:00 +00:00
Compare commits
255 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c70596e6bb | |||
| 924d94796d | |||
| 92a38a96a0 | |||
| c8cdc5ff78 | |||
| 33d922bb23 | |||
| 1b0f864921 | |||
| dfacae1a5d | |||
| caaab55e88 | |||
| 07d353d4bb | |||
| 823958504c | |||
| 4cb30ad7ab | |||
| 7b8eadd5d1 | |||
| 9d130e1531 | |||
| 893d10c7f6 | |||
| 68257952ab | |||
| 07a7901844 | |||
| 91fcb76863 | |||
| cac02b8ebe | |||
| 4370ba2f9c | |||
| 41db8f57f5 | |||
| 3497de9727 | |||
| 14a4c37fee | |||
| f27e0aa8c6 | |||
| 5c109d625c | |||
| 965dfb3098 | |||
| d6fad96d4d | |||
| 351447b1fc | |||
| a9910c5a12 | |||
| 4bee415d2d | |||
| 02f7adb1e9 | |||
| 039a6155ca | |||
| c8d806a51d | |||
| 4dbaf6a5dc | |||
| fcc0135843 | |||
| 4a922ac340 | |||
| c4d421db76 | |||
| 2816e80bee | |||
| 466e90a0af | |||
| 5e6ae2a905 | |||
| 3378d37ffb | |||
| fff3d948d0 | |||
| c181882145 | |||
| 2a333f7d19 | |||
| 8f8622aa10 | |||
| f88936c873 | |||
| 20f3004e22 | |||
| fd4bbe5d4f | |||
| a630b49867 | |||
| 75ce5bd752 | |||
| abb7bc2e4c | |||
| 857003b25b | |||
| 551119e313 | |||
| b567f50711 | |||
| 395b15af90 | |||
| 833ffdab8d | |||
| 2f6a30a512 | |||
| 4c433f74f1 | |||
| 852da05e24 | |||
| 1658b65484 | |||
| 8e9ff0cad5 | |||
| acee1a7884 | |||
| 0079d745ba | |||
| 0bd3464184 | |||
| 7ec1bc65a5 | |||
| c401d1e0d5 | |||
| a2983ec9f1 | |||
| 2421640c0a | |||
| 7dae2228f6 | |||
| 75039466ab | |||
| f3df5fbe9f | |||
| 362e47aaa0 | |||
| ba26cda598 | |||
| 8995a567d5 | |||
| 5eeec7806b | |||
| fd46a4fb7f | |||
| 1100267316 | |||
| e133f1fab8 | |||
| 5d5892ce07 | |||
| b26700ea6f | |||
| 589c2e01d9 | |||
| 9cf6058a65 | |||
| ff4d81966c | |||
| a4891aa0de | |||
| 05ba0ba6fd | |||
| 9217970237 | |||
| 828f424cfd | |||
| 057ca8480b | |||
| d07901f31b | |||
| c22638b29e | |||
| c292bfd1e0 | |||
| 85942eff1d | |||
| d69896f807 | |||
| 2c5c97488f | |||
| 99e38b96ce | |||
| 81a00a8195 | |||
| dbab7a9f8c | |||
| 046676d174 | |||
| 2b4f1ad570 | |||
| bcb78f2392 | |||
| 345a62fec6 | |||
| 6257b11a6e | |||
| 4b124ca96d | |||
| 4b25764fb3 | |||
| 422a0af465 | |||
| c73d65343b | |||
| 9e5784b6ec | |||
| 9a863e2143 | |||
| 8024865d5d | |||
| 66abe81e73 | |||
| ca178e1b31 | |||
| e52a27aedb | |||
| 6c2c28fb31 | |||
| 049da351ef | |||
| 0ce8709f70 | |||
| 1e5609bb1b | |||
| 8e7970a925 | |||
| 06b2c5166d | |||
| 6ba3b873a2 | |||
| 623fb1609b | |||
| 24be20a60d | |||
| 3535201481 | |||
| cdefd48d26 | |||
| 45fbcf1447 | |||
| 53805f3608 | |||
| 99e90ad357 | |||
| 5edb9b5cfe | |||
| 86a5a3b2d9 | |||
| a6590e3b81 | |||
| b1bb2b9f33 | |||
| 9318e7471f | |||
| e19ba1c9f3 | |||
| 8cffae079b | |||
| 594b25b71b | |||
| d142a86683 | |||
| 935f3e9bf5 | |||
| dedd6464f4 | |||
| 38aba65178 | |||
| 091119c244 | |||
| 4d095b5459 | |||
| 1c50181132 | |||
| 9e26c470f5 | |||
| 4c0bf164a0 | |||
| 8ab7f72e90 | |||
| 5772e30575 | |||
| 4b2daa62d7 | |||
| 2bd8700a61 | |||
| ad7e77c169 | |||
| e95c41bd3e | |||
| 903269e714 | |||
| 4120a50559 | |||
| 88b31f2d3f | |||
| a2f9bf83ce | |||
| dd2ac4c966 | |||
| c88f6890d6 | |||
| bf4b3fa97f | |||
| 6bcea5a8f1 | |||
| 2704ec1665 | |||
| 0c636d2156 | |||
| 1270ba3f43 | |||
| f2c32c5024 | |||
| ccb3bde260 | |||
| a7eb14c2b7 | |||
| abac96b1e5 | |||
| ecb48c8897 | |||
| 2686229a0f | |||
| 558fa7ae52 | |||
| 88e2136c07 | |||
| 70cdcded9b | |||
| 4022b640f9 | |||
| 0d780074b8 | |||
| 078f675a7f | |||
| 2b48a86f98 | |||
| 19f3aa18fc | |||
| 2b4c932fc8 | |||
| 89f0ca651a | |||
| c9fc5938c6 | |||
| 2ad8235c1b | |||
| dbf8301cb9 | |||
| 7d582c6bca | |||
| 3c4b6afcb2 | |||
| e4bc56d188 | |||
| 9a448d5a3d | |||
| 5c1074b244 | |||
| 49fcdfd89e | |||
| c900759234 | |||
| cd3b47ab1a | |||
| c5f95cdf61 | |||
| cc428a92b8 | |||
| 97bac45612 | |||
| 8048396a88 | |||
| 400ec31235 | |||
| 4d9346c62c | |||
| 94fd2069e8 | |||
| 1f401eb347 | |||
| 80e282bda0 | |||
| 65cd6aae3c | |||
| eba2a30024 | |||
| c103deb2a7 | |||
| dcef782587 | |||
| 10e7da4673 | |||
| faff35f241 | |||
| e2c1562f19 | |||
| df35ceb798 | |||
| cdb81a0bf4 | |||
| f1b1955190 | |||
| 860632b7a3 | |||
| bde7a61fb4 | |||
| b6600c5168 | |||
| 25f38ef7fe | |||
| ddeb44b920 | |||
| 02be710203 | |||
| 2ffbfc9f1c | |||
| 7b34f8116c | |||
| 8a9b6df255 | |||
| c881dd44d6 | |||
| 1cfaeaf8bb | |||
| 914f29184d | |||
| f510d57463 | |||
| 7833c17938 | |||
| 97fdffe6eb | |||
| b1f2900f1c | |||
| ddf015dc71 | |||
| 2a9d4fd212 | |||
| 2cacc23a38 | |||
| a7fd5a038e | |||
| 626b31084f | |||
| 4f3c25d5bd | |||
| 8da942e41e | |||
| b599c8a151 | |||
| d41f796825 | |||
| dd612e2660 | |||
| c503b5e677 | |||
| 0b433cfa18 | |||
| 75aba8c4ac | |||
| 81c65874a3 | |||
| 79d29d9c7b | |||
| 1e558b93af | |||
| 6d3d52639e | |||
| a1d460aa6c | |||
| 5a0bc7aaea | |||
| c7962b4231 | |||
| d14bb39ae8 | |||
| 5cc2f51c02 | |||
| a185f73e8a | |||
| f9a9598210 | |||
| 9976ccec41 | |||
| 8bfb2d749a | |||
| 7bf9a570a1 | |||
| b38df170e8 | |||
| bf38ace70c | |||
| 66c008f97e | |||
| 0298eb946f | |||
| 70fb35e37c | |||
| 1a30877ca9 | |||
| 569a22c0db |
+4
-2
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
|||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=laravel
|
DB_DATABASE=shpping_portal
|
||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=root
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
@@ -56,6 +56,8 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
|||||||
|
|
||||||
YD_API_CODE=''
|
YD_API_CODE=''
|
||||||
|
|
||||||
|
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||||
|
|
||||||
PERFEXCRM_BASE_URL=""
|
PERFEXCRM_BASE_URL=""
|
||||||
PERFEXCRM_API_KEY=""
|
PERFEXCRM_API_KEY=""
|
||||||
PERFEXCRM_IS_ENABLED="false"
|
PERFEXCRM_IS_ENABLED="false"
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=shpping_portal
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=P@ssw0rd
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
FILESYSTEM_DRIVER=local
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=smtp
|
||||||
|
MAIL_HOST=mailhog
|
||||||
|
MAIL_PORT=1025
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
PUSHER_APP_KEY=
|
||||||
|
PUSHER_APP_SECRET=
|
||||||
|
PUSHER_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
|
|
||||||
|
UNITY_APP_URL="https://unity.izyim.com"
|
||||||
|
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||||
|
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||||
|
|
||||||
|
YD_API_CODE=''
|
||||||
|
|
||||||
|
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
/public/hot
|
/public/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
|
/tests/_output
|
||||||
|
/tests/_support
|
||||||
/vendor
|
/vendor
|
||||||
**/.idea/
|
**/.idea/
|
||||||
.env
|
.env
|
||||||
|
|||||||
+120
@@ -0,0 +1,120 @@
|
|||||||
|
image: php:7.4
|
||||||
|
stages:
|
||||||
|
- service_build
|
||||||
|
- node
|
||||||
|
- building_assets
|
||||||
|
- database
|
||||||
|
- unit_test
|
||||||
|
- acceptance_test
|
||||||
|
- code_quality
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
variables:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_USER: mysql_password
|
||||||
|
MYSQL_PASSWORD: mysql_password
|
||||||
|
MYSQL_DATABASE: shpping_portal
|
||||||
|
DB_HOST: mysql
|
||||||
|
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- apt-get update -yqq
|
||||||
|
- apt-get install -yqq
|
||||||
|
- apt-get install -y libonig-dev
|
||||||
|
- apt-get install -y libxml2-dev
|
||||||
|
- apt-get install -y libzip-dev
|
||||||
|
- apt-get install -y libgd-dev
|
||||||
|
- apt-get install -y libgd-dev
|
||||||
|
|
||||||
|
# Install PDO MySQL extension
|
||||||
|
- docker-php-ext-install pdo_mysql
|
||||||
|
|
||||||
|
#install php dependencies
|
||||||
|
- docker-php-ext-install mbstring xml zip gd
|
||||||
|
|
||||||
|
# Install composer package manager
|
||||||
|
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||||
|
- chmod +x /usr/local/bin/composer
|
||||||
|
|
||||||
|
# Install MySQL client
|
||||||
|
- apt-get install -y default-mysql-client
|
||||||
|
|
||||||
|
#install node js
|
||||||
|
- apt-get update && apt-get install -y nodejs npm
|
||||||
|
|
||||||
|
#install gulp Js
|
||||||
|
- npm install -g gulp-cli
|
||||||
|
|
||||||
|
|
||||||
|
#jobs
|
||||||
|
|
||||||
|
#buld the backend
|
||||||
|
composer_php:
|
||||||
|
stage: service_build
|
||||||
|
script:
|
||||||
|
- composer install
|
||||||
|
- cp .env.example .env
|
||||||
|
- php artisan key:generate
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
#build the UI
|
||||||
|
#node installation
|
||||||
|
npm:
|
||||||
|
stage: node
|
||||||
|
script:
|
||||||
|
- npm install # Install npm dependencies
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
#building assets
|
||||||
|
building_assets:
|
||||||
|
stage: building_assets
|
||||||
|
# dependencies:
|
||||||
|
# - npm
|
||||||
|
script:
|
||||||
|
- npm install # Install npm dependencies
|
||||||
|
- gulp build # Build assets
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
#mysql
|
||||||
|
database:
|
||||||
|
stage: database
|
||||||
|
services:
|
||||||
|
- name: mysql:8.0
|
||||||
|
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||||
|
#dependencies:
|
||||||
|
# - composer_php
|
||||||
|
script:
|
||||||
|
- composer install
|
||||||
|
- cp .env.example .env
|
||||||
|
- php artisan key:generate
|
||||||
|
- php artisan migrate:fresh
|
||||||
|
- php artisan db:seed
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
#mysql
|
||||||
|
#unit_test:
|
||||||
|
# stage: unit_test
|
||||||
|
# services:
|
||||||
|
# - name: mysql:8.0
|
||||||
|
# command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||||
|
#dependencies:
|
||||||
|
# - database
|
||||||
|
# script:
|
||||||
|
# - npm install # Install npm dependencies
|
||||||
|
# - gulp build # Build assets
|
||||||
|
# - composer install
|
||||||
|
# - cp .env.example .env
|
||||||
|
# - php artisan key:generate
|
||||||
|
# - php artisan migrate:fresh
|
||||||
|
# - php artisan db:seed
|
||||||
|
# - php artisan test
|
||||||
|
# rules:
|
||||||
|
# - if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,62 +1,39 @@
|
|||||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
## Shipping portal documentation
|
||||||
|
|
||||||
<p align="center">
|
simple documentation on how to install, run, test, commit and deploy application
|
||||||
<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>
|
|
||||||
|
|
||||||
## 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).
|
- Chromium Driver / selenium
|
||||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
- add running and setting selenium on all OS if possible
|
||||||
- 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).
|
|
||||||
|
|
||||||
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/)**
|
Running the tests :
|
||||||
- **[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)**
|
|
||||||
|
|
||||||
## 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,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Exceptions;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
final class ConnectionErrorException extends ServiceApiException {
|
|
||||||
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
|
|
||||||
Log::error($message. ": ". $exceptionMessage);
|
|
||||||
if($payload){
|
|
||||||
Log::error('Payload: '.$payload);
|
|
||||||
}
|
|
||||||
if($exceptionTrace){
|
|
||||||
Log::error($exceptionTrace);
|
|
||||||
}
|
|
||||||
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
|
|
||||||
HttpStatus::SERVER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Abstracts;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ErrorException;
|
|
||||||
use App\Classes\Exceptions\InternalServerErrorException;
|
|
||||||
use App\Classes\ValueObjects\Constants\Notifications;
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
|
||||||
use ErrorException as GeneralExceptions;
|
|
||||||
use TypeError;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
abstract class Abstract2ControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
abstract protected function notification(): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getNotificationTitle():string {
|
|
||||||
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getNotificationMessage():string {
|
|
||||||
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return BinaryFileResponse
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
abstract protected function logic(Request $request) : BinaryFileResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return BinaryFileResponse
|
|
||||||
*/
|
|
||||||
public function execute(Request $request) : BinaryFileResponse {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
DB::beginTransaction();
|
|
||||||
|
|
||||||
$response = $this->logic($request);
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
|
||||||
abort(404, $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array|null $data
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function response(?array $data = []) : JsonResponse {
|
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
|
|
||||||
$this->getNotificationMessage(),
|
|
||||||
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param JsonResource $resource
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function resourceResponse(JsonResource $resource){
|
|
||||||
return $this->response(['data' => $resource]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceCollection $collection
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function collectionResponse(ResourceCollection $collection){
|
|
||||||
return $this->response(json_decode($collection->response()->getContent(), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
|||||||
abstract class AbstractRule
|
abstract class AbstractRule
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract protected function authorized($object): bool;
|
abstract protected function authorized(): bool;
|
||||||
|
|
||||||
abstract protected function validators($object): bool;
|
abstract protected function validators($object): bool;
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ abstract class AbstractRule
|
|||||||
*/
|
*/
|
||||||
public function passes(?DataTransferObject $object = null): bool {
|
public function passes(?DataTransferObject $object = null): bool {
|
||||||
try {
|
try {
|
||||||
if(!$this->authorized($object)){
|
if(!$this->authorized()){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators($object);
|
$this->validators($object);
|
||||||
@@ -36,7 +36,7 @@ abstract class AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch(AccessForbiddenException $exception){
|
} catch(AccessForbiddenException $exception){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||||
} catch(\Exception $exception){
|
} catch(\Exception $exception){
|
||||||
throw new RequestValidationException($exception->getMessage());
|
throw new RequestValidationException($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedAfterOrEqual implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
$startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
|
|
||||||
return $builder->where("{$table}.created_at", '>=', $startDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedBeforeOrEqual implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
$endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay();
|
|
||||||
return $builder->where("{$table}.created_at", '<=', $endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HasQuestionnaireGroupIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('question.questionnaire', function (Builder $query) use ($value) {
|
|
||||||
$query->whereIn('group', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderByIdDesc implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->orderBy('id', 'desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderByUpdatedAtDesc implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->orderBy('updated_at', 'desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@ class OwnerId implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->where('owner_id', $value);
|
||||||
return $builder->where("{$table}.owner_id", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,8 +14,7 @@ class OwnerType implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->where('owner_type', $value);
|
||||||
return $builder->where("{$table}.owner_type", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PaymentMethodNotIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereNotIn('payment_method', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class ShortUrl implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('short_url', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@ class StatusIn implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->whereIn('status', $value);
|
||||||
return $builder->whereIn("{$table}.status", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithAgingColumn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$today = Carbon::now();
|
|
||||||
return $builder->select('packing_lists.*')
|
|
||||||
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
|
|
||||||
->addSelect(DB::raw("CASE
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
|
|
||||||
ELSE 4
|
|
||||||
END AS due_date_number"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithOrderReferenceLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no')
|
|
||||||
->join('transactions as t3', 't3.id', '=', 't2.owner_id')
|
|
||||||
->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id')
|
|
||||||
->join('orders', function ($join) use ($value) {
|
|
||||||
$join->on('orders.id', '=', 'packing_lists.owner_id')
|
|
||||||
->where('orders.reference', 'LIKE', '%'.$value.'%');
|
|
||||||
})
|
|
||||||
->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithTrashed implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->withTrashed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,11 +24,12 @@ class Helper
|
|||||||
return array_slice(get_class_methods($className), 1);
|
return array_slice(get_class_methods($className), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $log
|
* @param $log
|
||||||
|
* @return none
|
||||||
*/
|
*/
|
||||||
static function debugLogger($log){
|
static function debugLoggerForPerfexCRM($log){
|
||||||
if($log && isset($log['message'])){
|
if($log){
|
||||||
$message = $log['message'];
|
$message = $log['message'];
|
||||||
$substring = 'No data were found';
|
$substring = 'No data were found';
|
||||||
if (isset($message)) {
|
if (isset($message)) {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@@ -12,8 +10,6 @@ use Illuminate\Queue\InteractsWithQueue;
|
|||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRM implements ShouldQueue
|
class UpdatePerfexCRM implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -22,51 +18,37 @@ class UpdatePerfexCRM implements ShouldQueue
|
|||||||
/** @var UpdatePerfexCRMObject */
|
/** @var UpdatePerfexCRMObject */
|
||||||
private $updatePerfexCRMObject;
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
|
/** @var UpdatePerfexCRMInvoice */
|
||||||
|
private $nextJob;
|
||||||
|
|
||||||
/** @var */
|
/** @var */
|
||||||
private $transaction;
|
private $transaction;
|
||||||
|
|
||||||
/** @var bool|null */
|
|
||||||
private $shouldCreateInvoice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdatePerfexCRM constructor.
|
* UpdatePerfexCRM constructor.
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
* @param Transaction $transaction
|
* @param UpdatePerfexCRMInvoice $nextJob
|
||||||
* @param bool|null $shouldCreateInvoice
|
* @param $transaction
|
||||||
*/
|
*/
|
||||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
|
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
|
||||||
{
|
{
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
|
$this->nextJob = $nextJob;
|
||||||
$this->transaction = $transaction;
|
$this->transaction = $transaction;
|
||||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
//To use invoice as a reference to decide whether more tasks should be created
|
|
||||||
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
|
||||||
|
|
||||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||||
if($this->transaction != null && $this->shouldCreateInvoice){
|
if($this->nextJob != null && $this->transaction != null){
|
||||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
$this->updatePerfexCRMObject->getContactEmail(),
|
||||||
$result->projectId,
|
$result->projectId,
|
||||||
$this->transaction,
|
$this->transaction,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
/** @var UpdatePerfexCRMInvoice $nextJob */
|
||||||
|
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getInvoiceIdOrCreateInvoice(){
|
|
||||||
if($this->transaction != null){
|
|
||||||
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
|
||||||
$this->transaction
|
|
||||||
);
|
|
||||||
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
|
||||||
return $invoiceId;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
|||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||||
|
use App\Models\PackingList;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
use App\Classes\General\Helper;
|
use App\Classes\General\Helper;
|
||||||
|
|
||||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||||
@@ -30,7 +32,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CreatePerfexCRMSingleTask constructor.
|
* CreatePerfexCRMSingleTask constructor.
|
||||||
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
||||||
*/
|
*/
|
||||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||||
{
|
{
|
||||||
@@ -47,7 +49,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
$invoiceId = 0;
|
$invoiceId = 0;
|
||||||
$invoiceStatus = 0;
|
$invoiceStatus = 0;
|
||||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||||
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
Log::error(json_encode('UpdatePerfexCRMInvoice debug $transaction->owner->bill_no: '.$transaction->owner->bill_no));
|
||||||
|
|
||||||
if(is_null($invoice)){
|
if(is_null($invoice)){
|
||||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||||
@@ -55,7 +57,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
$invoiceId = $result->payload['id'];
|
$invoiceId = $result->payload['id'];
|
||||||
} else {
|
} else {
|
||||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||||
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -64,6 +66,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
|
|
||||||
//This only run when invoice already exist and the invoice does not have a PAID status
|
//This only run when invoice already exist and the invoice does not have a PAID status
|
||||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||||
|
Log::error(json_encode('UpdatePerfexCRMInvoice debug $this->updatePerfexCRMInvoiceObject->getProjectId(): '.$this->updatePerfexCRMInvoiceObject->getProjectId()));
|
||||||
//update invoice
|
//update invoice
|
||||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,22 +27,27 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
|||||||
/** @var UpdatePerfexCRMObject */
|
/** @var UpdatePerfexCRMObject */
|
||||||
private $updatePerfexCRMObject;
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
/** @var bool|null */
|
/** @var UpdatePerfexCRM */
|
||||||
private $shouldCreateInvoice;
|
private $nextJob1;
|
||||||
|
|
||||||
|
/** @var UpdatePerfexCRMInvoice */
|
||||||
|
private $nextJob2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdatePerfexCRMPrelude constructor.
|
* UpdatePerfexCRMPrelude constructor.
|
||||||
* @param $packingList
|
* @param $packingList
|
||||||
* @param Transaction $transaction
|
* @param $transaction
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
* @param bool|null $shouldCreateInvoice
|
* @param UpdatePerfexCRM $nextJob1
|
||||||
|
* @param UpdatePerfexCRMInvoice $nextJob2
|
||||||
*/
|
*/
|
||||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
|
||||||
{
|
{
|
||||||
$this->packingList = $packingList;
|
$this->packingList = $packingList;
|
||||||
$this->transaction = $transaction;
|
$this->transaction = $transaction;
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
$this->nextJob1 = $nextJob1;
|
||||||
|
$this->nextJob2 = $nextJob2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
@@ -64,7 +69,9 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
|||||||
|
|
||||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||||
$this->updatePerfexCRMObject->setTasks($result);
|
$this->updatePerfexCRMObject->setTasks($result);
|
||||||
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
/** @var UpdatePerfexCRM $nextJob1 */
|
||||||
|
/** @var UpdatePerfexCRMInvoice $nextJob2 */
|
||||||
|
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replacePlaceholders($template, $data, $prefix = '')
|
function replacePlaceholders($template, $data, $prefix = '')
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\General\Interfaces\Contactable;
|
use App\Classes\General\Interfaces\Contactable;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
@@ -17,6 +20,7 @@ use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -27,7 +31,8 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Address',
|
'title' => 'Created Address',
|
||||||
'message' => 'You have successfully created a new Address'
|
'message' => 'You have successfully created a new Address'
|
||||||
@@ -74,11 +79,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
@@ -90,16 +95,22 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||||
|
|
||||||
if($request->input('phone')){
|
if ($request->input('phone')) {
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('remark')){
|
if ($request->input('remark')) {
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return fractal()
|
||||||
|
->item($address, new AddressTransformer())
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||||
@@ -14,6 +17,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -23,7 +27,8 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Billing Address',
|
'title' => 'Created Billing Address',
|
||||||
'message' => 'You have successfully created a new Billing Address'
|
'message' => 'You have successfully created a new Billing Address'
|
||||||
@@ -60,27 +65,35 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
$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
|
// delete all current billing address
|
||||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||||
|
|
||||||
// create addrress
|
// create new billing 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);
|
$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->canCreateAddress->passes($billingAddress);
|
||||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
//load address with only owner address
|
||||||
|
|
||||||
|
/* return fractal()
|
||||||
|
->item($billingAddressInputed, new AddressTransformer())
|
||||||
|
->parseIncludes('Owner_address')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
|
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||||
@@ -17,7 +19,8 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Address',
|
'title' => 'Retrieved Address',
|
||||||
'message' => 'You have successfully retrieved a Address'
|
'message' => 'You have successfully retrieved a Address'
|
||||||
@@ -45,15 +48,22 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canFetchAddress->passes();
|
$this->canFetchAddress->passes();
|
||||||
|
|
||||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
|
||||||
|
//load address with no relationships
|
||||||
|
/* return fractal()
|
||||||
|
->item($address, new AddressTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($query));
|
return $this->resourceResponse(new AddressResource($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +21,8 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Addresses',
|
'title' => 'Retrieved Addresses',
|
||||||
'message' => 'You have successfully retrieved a list of Addresses'
|
'message' => 'You have successfully retrieved a list of Addresses'
|
||||||
@@ -45,17 +50,25 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListAddresses->passes();
|
$this->canListAddresses->passes();
|
||||||
|
|
||||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
|
//a collection of addresses with all incluides
|
||||||
|
/* return fractal()
|
||||||
|
->collection($query, new AddressTransformer)
|
||||||
|
->parseIncludes('Owner_address')
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->parseIncludes('contact')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(AddressResource::collection($query));
|
return $this->collectionResponse(AddressResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
|
||||||
use App\Http\Resources\DistrictResource;
|
use App\Http\Resources\DistrictResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
|
||||||
use App\Http\Resources\StateResource;
|
use App\Http\Resources\StateResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|||||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
/** @var ResetsAddressesDefault */
|
/** @var ResetsAddressesDefault */
|
||||||
private $resetsAddressesDefault;
|
private $resetsAddressesDefault;
|
||||||
|
|
||||||
/** @var SetsAddressToDefault*/
|
/** @var SetsAddressToDefault */
|
||||||
private $setsAddressToDefault;
|
private $setsAddressToDefault;
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +65,15 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
|
||||||
|
$setAddress = $this->setsAddressToDefault->execute($address);
|
||||||
|
//no relationships needed
|
||||||
|
/* return fractal()
|
||||||
|
->item($setAddress, new AddressTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\AddressType;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Address',
|
'title' => 'Updated Address',
|
||||||
'message' => 'You have successfully updated the Address'
|
'message' => 'You have successfully updated the Address'
|
||||||
@@ -77,7 +79,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
|
|
||||||
@@ -90,18 +92,25 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->updatesAddress->execute($address, $object);
|
$address = $this->updatesAddress->execute($address, $object);
|
||||||
|
|
||||||
$address->contacts()->delete(); $address->remarks()->delete();
|
$address->contacts()->delete();
|
||||||
|
$address->remarks()->delete();
|
||||||
|
|
||||||
if($request->input('phone')){
|
if ($request->input('phone')) {
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('remark')){
|
if ($request->input('remark')) {
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//only remark relationship needed
|
||||||
|
/* return fractal()
|
||||||
|
->item($address, new AddressTransformer())
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -14,17 +14,14 @@ use App\Classes\Exceptions\MalformedRequestException;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Models\Group;
|
use App\Models\Group;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CallbackBillplzLogic
|
class CallbackBillplzLogic
|
||||||
{
|
{
|
||||||
@@ -49,12 +46,6 @@ class CallbackBillplzLogic
|
|||||||
/** @var CreatePaymentTransactionProcessor */
|
/** @var CreatePaymentTransactionProcessor */
|
||||||
private $createPaymentTransactionProcessor;
|
private $createPaymentTransactionProcessor;
|
||||||
|
|
||||||
/** @var CallbackBillplzProcessor */
|
|
||||||
private $callbackBillplzProcessor;
|
|
||||||
|
|
||||||
/** @var CheckStorageInvoiceTransactionProcessor */
|
|
||||||
private $storageInvoiceTransactionProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CallbackBillplzLogic constructor.
|
* CallbackBillplzLogic constructor.
|
||||||
* @param GetBillplzBill $getBillplzBill
|
* @param GetBillplzBill $getBillplzBill
|
||||||
@@ -63,10 +54,8 @@ class CallbackBillplzLogic
|
|||||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||||
* @param CallbackBillplzProcessor $callbackBillplzProcessor
|
|
||||||
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
|
||||||
*/
|
*/
|
||||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CallbackBillplzProcessor $callbackBillplzProcessor, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||||
{
|
{
|
||||||
$this->getBillplzBill = $getBillplzBill;
|
$this->getBillplzBill = $getBillplzBill;
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
@@ -75,8 +64,6 @@ class CallbackBillplzLogic
|
|||||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
|
||||||
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,13 +103,44 @@ class CallbackBillplzLogic
|
|||||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('Debug billPlz status: '.$status);
|
|
||||||
|
|
||||||
$token = Auth::fromUser(User::find(1));
|
$token = Auth::fromUser(User::find(1));
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||||
|
|
||||||
$this->storageInvoiceBackDoorPreventionCheck($transaction, $status);
|
// check if is wallet top up
|
||||||
$result = $this->callbackBillplzProcessor->execute($transaction, $status);
|
if($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||||
|
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// group payment
|
||||||
|
if ($transaction->type == TransactionType::GROUP_PAYMENT && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||||
|
$group = Group::where('reference', $billplzXSignatureObject->getBillPlzId())->first();
|
||||||
|
|
||||||
|
foreach($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
$group->status = $status;
|
||||||
|
$group->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||||
|
|
||||||
|
if (!$transaction->owner instanceof Wallet) {
|
||||||
|
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||||
|
|
||||||
@@ -133,22 +151,6 @@ class CallbackBillplzLogic
|
|||||||
$company_module_marking = $order->companyModule->connections? $order->companyModule->connections->first()->invitee_reference: null;
|
$company_module_marking = $order->companyModule->connections? $order->companyModule->connections->first()->invitee_reference: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status, 'result' => $result]);
|
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status]);
|
||||||
}
|
|
||||||
|
|
||||||
private function storageInvoiceBackDoorPreventionCheck($transaction, $status){
|
|
||||||
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
|
||||||
$group = Group::where('reference', $transaction->payment_reference)->first();
|
|
||||||
if ($group) {
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
|
||||||
$invoice = $groupTransaction->transaction;
|
|
||||||
$pL = $invoice->owner;
|
|
||||||
$order = $pL->owner;
|
|
||||||
if($order){
|
|
||||||
$this->storageInvoiceTransactionProcessor->executeOrder($order, false); //original was set true here so that no group is soft deleted or billplz bill got deleted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Billplzs\Processors;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\Wallet;
|
|
||||||
use App\Models\Group;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|
||||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CallbackBillplzProcessor
|
|
||||||
{
|
|
||||||
/** @var UpdatesTransactionStatus */
|
|
||||||
private $updatesTransactionStatus;
|
|
||||||
|
|
||||||
/** @var UpdateDoFromVTPortalProcessor */
|
|
||||||
private $updateDoFromVTPortalProcessor;
|
|
||||||
|
|
||||||
/** @var UpdateDoFromYDPortalProcessor */
|
|
||||||
private $updateDoFromYDPortalProcessor;
|
|
||||||
|
|
||||||
/** @var UpdatesWalletBalance */
|
|
||||||
private $updatesWalletBalance;
|
|
||||||
|
|
||||||
/** @var CreatePaymentTransactionProcessor */
|
|
||||||
private $createPaymentTransactionProcessor;
|
|
||||||
|
|
||||||
/** @var ReleaseGoodsToCustomerProcessor */
|
|
||||||
private $releaseGoodsToCustomerProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreateUserProcessor constructor.
|
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
|
||||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
|
||||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
|
||||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
|
||||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
|
||||||
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
|
||||||
{
|
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
|
||||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
|
||||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
|
||||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
|
||||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
|
||||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute($transaction, $status)
|
|
||||||
{
|
|
||||||
$invoice = $transaction->owner;
|
|
||||||
$packingList = $invoice->owner;
|
|
||||||
|
|
||||||
$proceed = $this->checkForGroupPayment($transaction);
|
|
||||||
if(!$proceed) return false;
|
|
||||||
|
|
||||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
|
||||||
|
|
||||||
// check if is wallet top up
|
|
||||||
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
|
||||||
|
|
||||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
|
||||||
|
|
||||||
$group = Group::where('reference', $transaction->payment_reference)->first();
|
|
||||||
|
|
||||||
// check if is group payment
|
|
||||||
if ($group) {
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
|
||||||
$invoice = $groupTransaction->transaction;
|
|
||||||
|
|
||||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
|
||||||
|
|
||||||
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
|
||||||
$pL = $invoice->owner;
|
|
||||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$group->status = $status;
|
|
||||||
$group->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$transaction->owner instanceof Wallet) {
|
|
||||||
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function checkForGroupPayment($transaction){
|
|
||||||
//This check is targetting group payment that expired and soft deleted
|
|
||||||
//command:check-storage-invoices must already run for this part of the code to work properly
|
|
||||||
$group = Group::withTrashed()->where('reference', $transaction->payment_reference)->first();
|
|
||||||
if ($group) {
|
|
||||||
$totalAmountToBePaid = 0;
|
|
||||||
$actualAmountPaid = $transaction->amount;
|
|
||||||
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
|
||||||
$invoice = $groupTransaction->transaction;
|
|
||||||
$totalAmountToBePaid += $invoice->amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed
|
|
||||||
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Billplzs\Services;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class DeletesBillplzBill
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $billID
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(string $billID) {
|
|
||||||
try{
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->delete(config('billplz.base_url').'/api/v3/bills/'.$billID);
|
|
||||||
Log::channel('storage_invoices')->info('DeletesBillplzBill response: '.json_encode($response));
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
// $data['url'] = $data['url'].'?auto_submit=true';
|
|
||||||
|
|
||||||
return (object) $data;
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(\Exception $exception){
|
|
||||||
throw new MalformedRequestException('Unable to get correct response from billplz server: ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,13 +3,16 @@
|
|||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||||
use App\Http\Resources\CompanyResource;
|
use App\Transformers\CompanyTransformer;
|
||||||
use ErrorException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Spatie\Fractalistic\ArraySerializer;
|
||||||
|
|
||||||
class ListCompaniesLogic extends AbstractControllerLogic
|
class ListCompaniesLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -45,16 +48,24 @@ class ListCompaniesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListCompanies->passes();
|
$this->canListCompanies->passes();
|
||||||
|
|
||||||
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
||||||
return $this->collectionResponse(CompanyResource::collection($query));
|
// return $this->collectionResponse(CompanyResource::collection($query));
|
||||||
|
|
||||||
|
return fractal()
|
||||||
|
->parseIncludes(['owner'])
|
||||||
|
->collection($query, new CompanyTransformer(), "data")
|
||||||
|
->serializeWith(new ArraySerializer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||||
use App\Http\Resources\CompanyModuleResource;
|
use App\Http\Resources\CompanyModuleResource;
|
||||||
|
use App\Transformers\CompanyTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +21,8 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Company Moduels',
|
'title' => 'Retrieved Company Moduels',
|
||||||
'message' => 'You have successfully retrieved a list of Companies'
|
'message' => 'You have successfully retrieved a list of Companies'
|
||||||
@@ -45,15 +50,26 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListCompanies->passes();
|
$this->canListCompanies->passes();
|
||||||
|
|
||||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
|
/*include all relationships*/
|
||||||
|
/* return fractal()
|
||||||
|
->collection($query, new CompanyTransformer)
|
||||||
|
->parseIncludes('company')
|
||||||
|
->parseIncludes('contact')
|
||||||
|
->parseIncludes('remarks')
|
||||||
|
->parseIncludes('address')
|
||||||
|
->parseIncludes('billingAddress')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCompanyModule extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListCompanies extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanUpdateCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
|||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||||
use App\Http\Resources\ContactResource;
|
use App\Http\Resources\ContactResource;
|
||||||
|
use App\Transformers\ContactTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -63,6 +64,13 @@ class UpdateContactLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->updatesContact->execute($query, $object);
|
$query = $this->updatesContact->execute($query, $object);
|
||||||
|
|
||||||
|
/*uniformity*/
|
||||||
|
/* return fractal()
|
||||||
|
->item($query, new ContactTransformer())
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ContactResource($query));
|
return $this->resourceResponse(new ContactResource($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateContact extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanFetchCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanListCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
if (!\Auth::user()->can('add currency_rate')) {
|
if (!\Auth::user()->can('add currency_rate')) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanListRates extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CanUpdateRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
|||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||||
use App\Http\Resources\DeliveryOrderResource;
|
use App\Http\Resources\DeliveryOrderResource;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
use App\Transformers\DeliveryOrderTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -52,6 +53,14 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
|||||||
/** @var Order $order */
|
/** @var Order $order */
|
||||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
$order = $this->cancelsOrder->execute($order);
|
||||||
|
|
||||||
|
//no relationship needed
|
||||||
|
/* return fractal()
|
||||||
|
->item($order, new DeliveryOrderTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,12 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
|||||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||||
$this->createsPackage->execute($packageObject, $packingList);
|
$this->createsPackage->execute($packageObject, $packingList);
|
||||||
|
|
||||||
|
//add relationship to order
|
||||||
|
/* return fractal()
|
||||||
|
->item($order, new DeliveryOrderTransformer())
|
||||||
|
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ class ListOrdersLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||||
|
|
||||||
|
|
||||||
|
//no relationship needed
|
||||||
|
/* return fractal()
|
||||||
|
->collection($query, new DeliveryOrderTransformer)
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,21 @@
|
|||||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||||
use App\Http\Resources\DocumentResource;
|
use App\Http\Resources\DocumentResource;
|
||||||
|
use App\Models\Document;
|
||||||
|
use App\Transformers\DocumentTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
|
||||||
class ListDocumentLogic extends AbstractControllerLogic
|
class ListDocumentLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -17,7 +25,8 @@ class ListDocumentLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Document',
|
'title' => 'Retrieved Document',
|
||||||
'message' => 'You have successfully retrieved a list of Document'
|
'message' => 'You have successfully retrieved a list of Document'
|
||||||
@@ -45,19 +54,29 @@ class ListDocumentLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListDocuments->passes();
|
$this->canListDocuments->passes();
|
||||||
|
|
||||||
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
||||||
|
|
||||||
return $this->collectionResponse(DocumentResource::collection($query));
|
$data = fractal()
|
||||||
|
->parseIncludes(['owner'])
|
||||||
|
->collection($query, new DocumentTransformer, "data")
|
||||||
|
->serializeWith(new ArraySerializer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
use App\Classes\General\Interfaces\DataTransferObject;
|
||||||
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
|
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ class DocumentObject implements DataTransferObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function getFiles(): array
|
public function getFiles(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ class UploadDocumentForHelpMenuProcessor
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $filesUpload
|
* @param Request $request
|
||||||
* @param QAUserAnswerSelected qaUserAnswerSelected
|
* @param QAUserAnswerSelected qaUserAnswerSelected
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute($filesUpload, QAUserAnswerSelected $qaUserAnswerSelected) {
|
public function execute(Request $request, QAUserAnswerSelected $qaUserAnswerSelected) {
|
||||||
$object = new DocumentObject("HELP_MENU", $filesUpload,
|
$object = new DocumentObject("HELP_MENU", $request->input('files'),
|
||||||
'123456', ApprovalStatus::PENDING_VERIFICATION, 'help_menu'); //cief todo: 123456 cannot be hardcoded
|
'123456', ApprovalStatus::PENDING_VERIFICATION, 'help_menu'); //cief todo: 123456 cannot be hardcoded
|
||||||
|
|
||||||
/** @var Document $document */
|
/** @var Document $document */
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ class ConvertsBase64ToFile
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
private function generateFile(FileObject $file, string $suffix = '') {
|
private function generateFile(FileObject $file, string $suffix = ''): string
|
||||||
|
{
|
||||||
|
|
||||||
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanApproveDocument extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CanCreateDocument extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CanCreateFile extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanListDocuments extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanRenderDocument extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CanUpdateDocument extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CanUpdateDocumentReference extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsFeedback;
|
|
||||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportFeedback;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
||||||
use Maatwebsite\Excel\Excel;
|
|
||||||
|
|
||||||
class ExportFeedbackDataLogic extends Abstract2ControllerLogic
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Retrieved Feedback',
|
|
||||||
'message' => 'You have successfully exported feedback data'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var ExportsFeedback */
|
|
||||||
private $exportsFeedback;
|
|
||||||
|
|
||||||
/** @var CanExportFeedback */
|
|
||||||
private $canExportFeedback;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExportFeedbackDataLogic constructor.
|
|
||||||
* @param ExportsFeedback $exportsFeedback
|
|
||||||
* @param CanExportFeedback $canExportFeedback
|
|
||||||
*/
|
|
||||||
public function __construct(ExportsFeedback $exportsFeedback, CanExportFeedback $canExportFeedback)
|
|
||||||
{
|
|
||||||
$this->exportsFeedback = $exportsFeedback;
|
|
||||||
$this->canExportFeedback = $canExportFeedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : BinaryFileResponse
|
|
||||||
{
|
|
||||||
$this->canExportFeedback->passes();
|
|
||||||
|
|
||||||
$response = $this->exportsFeedback->download('feedback.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
|
||||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportPackingList;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
||||||
use Maatwebsite\Excel\Excel;
|
|
||||||
|
|
||||||
class ExportPackingListLogic extends Abstract2ControllerLogic
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Retrieved PackingList',
|
|
||||||
'message' => 'You have successfully exported PackingList'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var ExportsOnHoldPackingList */
|
|
||||||
private $exportsOnHoldPackingList;
|
|
||||||
|
|
||||||
/** @var ExportsPendingArrangementDeliveryList */
|
|
||||||
private $exportsPendingArrangementDeliveryList;
|
|
||||||
|
|
||||||
/** @var CanExportPackingList */
|
|
||||||
private $canExportPackingList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExportPackingListLogic constructor.
|
|
||||||
* @param ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList
|
|
||||||
* @param ExportsOnHoldPackingList $exportsOnHoldPackingList
|
|
||||||
* @param CanExportPackingList $canExportPackingList
|
|
||||||
*/
|
|
||||||
public function __construct(ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList, ExportsOnHoldPackingList $exportsOnHoldPackingList, CanExportPackingList $canExportPackingList)
|
|
||||||
{
|
|
||||||
$this->exportsPendingArrangementDeliveryList = $exportsPendingArrangementDeliveryList;
|
|
||||||
$this->exportsOnHoldPackingList = $exportsOnHoldPackingList;
|
|
||||||
$this->canExportPackingList = $canExportPackingList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : BinaryFileResponse
|
|
||||||
{
|
|
||||||
$this->canExportPackingList->passes();
|
|
||||||
$isSetPendingArrangement = $request->header('PendingArrangement');
|
|
||||||
if($isSetPendingArrangement){
|
|
||||||
$response = $this->exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$response = $this->exportsOnHoldPackingList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
}
|
|
||||||
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
|
||||||
{
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
private $filters;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->filters = [
|
|
||||||
"has_invoice_status_in" => [2],
|
|
||||||
"packing_list_ordered_by_invoice_date" => true,
|
|
||||||
"with_aging_column" => true
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Company Name',
|
|
||||||
'Customer Marking',
|
|
||||||
'Order Number',
|
|
||||||
'Invoice No',
|
|
||||||
'Invoice Date',
|
|
||||||
'Days',
|
|
||||||
'Amount',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return (new ApplyFiltersToQuery())->execute(PackingList::query(), $this->filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($list): array
|
|
||||||
{
|
|
||||||
$marking = null;
|
|
||||||
$orderNo = null;
|
|
||||||
$name = null;
|
|
||||||
$invDate = 'n/a';
|
|
||||||
$invNo = 'n/a';
|
|
||||||
$days = 'n/a';
|
|
||||||
|
|
||||||
if ($list->owner instanceof Order) {
|
|
||||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
|
||||||
|
|
||||||
if ($inviterPivotInviteeReference) {
|
|
||||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
|
||||||
$orderNo = $list->owner->reference;
|
|
||||||
}
|
|
||||||
$name = $list->owner->companyModule->company->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction = $list->transactions()->whereIn('status', [ApprovalStatus::APPROVED])->first();
|
|
||||||
if ($transaction) {
|
|
||||||
|
|
||||||
$invoiceDate = $transaction->created_at;
|
|
||||||
$invDate = date_format($invoiceDate, 'd-m-Y');
|
|
||||||
$invNo = $transaction->bill_no;
|
|
||||||
$amt = number_format($transaction->amount, 2);
|
|
||||||
|
|
||||||
$currentDate = new DateTime();
|
|
||||||
$interval = $currentDate->diff($invoiceDate);
|
|
||||||
$days = $interval->format('%a');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
$name,
|
|
||||||
$marking,
|
|
||||||
$orderNo,
|
|
||||||
$invNo,
|
|
||||||
$invDate,
|
|
||||||
$days,
|
|
||||||
$amt,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function dueDateColumn($colNum, $dueDateNumber, $amt)
|
|
||||||
{
|
|
||||||
if ($colNum == $dueDateNumber) return $amt;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,17 +15,9 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|||||||
|
|
||||||
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||||
{
|
{
|
||||||
|
|
||||||
use Exportable;
|
use Exportable;
|
||||||
|
|
||||||
private $start_date;
|
|
||||||
private $end_date;
|
|
||||||
|
|
||||||
public function __construct($start_date = null, $end_date = null)
|
|
||||||
{
|
|
||||||
$this->start_date = $start_date;
|
|
||||||
$this->end_date = $end_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
public function headings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -34,49 +26,38 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
|||||||
'Warehouse',
|
'Warehouse',
|
||||||
'Cbm',
|
'Cbm',
|
||||||
'Description',
|
'Description',
|
||||||
'Quantity',
|
'quantity',
|
||||||
'Received Date',
|
'Received Date',
|
||||||
'Recorded On',
|
|
||||||
'Days to Record',
|
|
||||||
'Remarks'
|
'Remarks'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection|mixed
|
||||||
|
*/
|
||||||
public function query()
|
public function query()
|
||||||
{
|
{
|
||||||
$query = PackingList::with([
|
return PackingList::where('type', '=', 1)->where('status', '=', 2)->where('owner_type', Order::class);
|
||||||
'owner.companyModule.inviters',
|
|
||||||
'owner.orderRoles',
|
|
||||||
'packages',
|
|
||||||
'transports'
|
|
||||||
])
|
|
||||||
->where('type', '=', 1)
|
|
||||||
->where('status', '=', 2)
|
|
||||||
->where('owner_type', Order::class);
|
|
||||||
|
|
||||||
if (!is_null($this->start_date) && !is_null($this->end_date)) {
|
|
||||||
$query->whereHas('transports', function ($q) {
|
|
||||||
$q->whereBetween('drop_date', [
|
|
||||||
Carbon::parse($this->start_date)->startOfDay(),
|
|
||||||
Carbon::parse($this->end_date)->endOfDay()
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $packingList
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function map($packingList): array
|
public function map($packingList): array
|
||||||
{
|
{
|
||||||
$order = $packingList->owner;
|
$order = $packingList->owner;
|
||||||
$marking = $order->companyModule->getMarking();
|
|
||||||
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
|
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
|
||||||
$cbm = $packingList->packages->sum(function ($package) {
|
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
|
||||||
|
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
||||||
|
|
||||||
|
$cbm = $packingList->packages->sum(function($package){
|
||||||
|
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||||
});
|
});
|
||||||
$arrival_date = $packingList->transports->first()->drop_date->format('d-m-Y');
|
|
||||||
$recorded_on = $packingList->created_at->format('d-m-Y');
|
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
|
||||||
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$packingList->owner->reference,
|
$packingList->owner->reference,
|
||||||
@@ -86,8 +67,6 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
|||||||
$packingList->packages->implode('description', ', '),
|
$packingList->packages->implode('description', ', '),
|
||||||
$packingList->packages->sum('quantity'),
|
$packingList->packages->sum('quantity'),
|
||||||
$arrival_date,
|
$arrival_date,
|
||||||
$recorded_on,
|
|
||||||
$days_to_record,
|
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use App\Models\Company;
|
|
||||||
use App\Models\Wallet;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
|
|
||||||
class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
||||||
{
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
private $request;
|
|
||||||
private $runningBalance = 0;
|
|
||||||
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Date',
|
|
||||||
'Description',
|
|
||||||
'Incoming',
|
|
||||||
'Outgoing',
|
|
||||||
'Balance',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
$wallet = Wallet::find($this->request->route('wallet_id'));
|
|
||||||
$transactions = $wallet->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id');
|
|
||||||
|
|
||||||
return $transactions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Transaction $transaction
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($transaction): array
|
|
||||||
{
|
|
||||||
$decimals = $this->request->route('is_precise') == 'true' ? 5 : 2;
|
|
||||||
|
|
||||||
$description = '';
|
|
||||||
switch ((int) $transaction->type) {
|
|
||||||
case TransactionType::TOP_UP:
|
|
||||||
$description = (float) $transaction->amount . ' Credit Top up';
|
|
||||||
break;
|
|
||||||
case TransactionType::GROUP_PAYMENT:
|
|
||||||
$description = (float) $transaction->amount . ' Credit Top up';
|
|
||||||
break;
|
|
||||||
case TransactionType::CREDIT_NOTE:
|
|
||||||
$description = 'Credit Voucher for ' . $transaction->payment_reference;
|
|
||||||
break;
|
|
||||||
case TransactionType::PAYMENT:
|
|
||||||
$booking = Transaction::where('payment_reference', $transaction->bill_no)->first()->owner;
|
|
||||||
|
|
||||||
if (!$booking) {
|
|
||||||
$description = 'Payment for unknown booking, please contact tech support.';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$marking = $booking->marking;
|
|
||||||
$description = 'Payment For booking refs' . $marking;
|
|
||||||
break;
|
|
||||||
case TransactionType::DEBIT_NOTE:
|
|
||||||
$description = 'Debit Voucher for ' . $transaction->payment_reference;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$incoming = $outgoing = '';
|
|
||||||
|
|
||||||
if (in_array($transaction->type, [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT])) {
|
|
||||||
$incoming = number_format($transaction->amount, $decimals, '.', ',');
|
|
||||||
$this->runningBalance += $transaction->amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array($transaction->type, [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])) {
|
|
||||||
$outgoing = number_format($transaction->amount, $decimals, '.', ',');
|
|
||||||
$this->runningBalance -= $transaction->amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
Carbon::parse($transaction->created_at)->format('d-m-Y h:i:s A'),
|
|
||||||
$description,
|
|
||||||
$incoming,
|
|
||||||
$outgoing,
|
|
||||||
number_format($this->runningBalance, $decimals, '.', ',')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user