mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
247 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c109d625c | |||
| 299d5fd4fe | |||
| d56abc78f7 | |||
| b3b7b67c66 | |||
| d6f29976c7 | |||
| 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 | |||
| b2a986b838 | |||
| 5d5892ce07 | |||
| 160fa2b2d9 | |||
| e0d0dccb4c | |||
| f47c7ebc50 | |||
| b26700ea6f | |||
| 589c2e01d9 | |||
| 9cf6058a65 | |||
| ff4d81966c | |||
| a4891aa0de | |||
| 05ba0ba6fd | |||
| 9217970237 | |||
| 828f424cfd | |||
| 057ca8480b | |||
| d07901f31b | |||
| f30a0cf7ee | |||
| f2a02230c7 | |||
| 2978eed61d | |||
| c22638b29e | |||
| c292bfd1e0 | |||
| c76c50466d | |||
| b4437c8907 | |||
| e7942731ad | |||
| 85942eff1d | |||
| 5db9d79cc1 | |||
| d69896f807 | |||
| dff001c9b5 | |||
| 2353c637d7 | |||
| 2c5c97488f | |||
| eea8708b76 | |||
| 99e38b96ce | |||
| 81a00a8195 | |||
| dbab7a9f8c | |||
| 046676d174 | |||
| 2b4f1ad570 | |||
| bcb78f2392 | |||
| 345a62fec6 | |||
| 6257b11a6e | |||
| 4b124ca96d | |||
| 4b25764fb3 | |||
| 422a0af465 | |||
| c73d65343b | |||
| 9e5784b6ec | |||
| 9a863e2143 | |||
| 8024865d5d | |||
| 66abe81e73 | |||
| ca178e1b31 | |||
| e52a27aedb | |||
| 6c2c28fb31 | |||
| 049da351ef | |||
| 0ce8709f70 | |||
| 1e5609bb1b | |||
| 8e7970a925 | |||
| 06b2c5166d | |||
| 6ba3b873a2 | |||
| 623fb1609b | |||
| 24be20a60d | |||
| 3535201481 | |||
| cdefd48d26 | |||
| 45fbcf1447 | |||
| 53805f3608 | |||
| 99e90ad357 | |||
| 5edb9b5cfe | |||
| 86a5a3b2d9 | |||
| a6590e3b81 | |||
| b1bb2b9f33 | |||
| 9318e7471f | |||
| e19ba1c9f3 | |||
| 8cffae079b | |||
| 594b25b71b | |||
| d142a86683 | |||
| 935f3e9bf5 | |||
| dedd6464f4 | |||
| 38aba65178 | |||
| 091119c244 | |||
| 4d095b5459 | |||
| 1c50181132 | |||
| 9e26c470f5 | |||
| 4c0bf164a0 | |||
| 8ab7f72e90 | |||
| 5772e30575 | |||
| 4b2daa62d7 | |||
| 2bd8700a61 | |||
| ad7e77c169 | |||
| e95c41bd3e | |||
| 903269e714 | |||
| 4120a50559 | |||
| 88b31f2d3f | |||
| a2f9bf83ce | |||
| dd2ac4c966 | |||
| c88f6890d6 | |||
| bf4b3fa97f | |||
| 6bcea5a8f1 | |||
| 2704ec1665 | |||
| 0c636d2156 | |||
| 1270ba3f43 | |||
| f2c32c5024 | |||
| ccb3bde260 | |||
| a7eb14c2b7 | |||
| abac96b1e5 | |||
| ecb48c8897 | |||
| 2686229a0f | |||
| 558fa7ae52 | |||
| 88e2136c07 | |||
| 70cdcded9b | |||
| 4022b640f9 | |||
| 0d780074b8 | |||
| 078f675a7f | |||
| 2b48a86f98 | |||
| 19f3aa18fc | |||
| 2b4c932fc8 | |||
| 89f0ca651a | |||
| c9fc5938c6 | |||
| 2ad8235c1b | |||
| dbf8301cb9 | |||
| 7d582c6bca | |||
| 3c4b6afcb2 | |||
| e4bc56d188 | |||
| 9a448d5a3d | |||
| 5c1074b244 | |||
| 49fcdfd89e | |||
| c900759234 | |||
| cd3b47ab1a | |||
| c5f95cdf61 | |||
| cc428a92b8 | |||
| 97bac45612 | |||
| 8048396a88 | |||
| 400ec31235 | |||
| 4d9346c62c | |||
| 94fd2069e8 | |||
| 1f401eb347 | |||
| 80e282bda0 | |||
| 65cd6aae3c | |||
| eba2a30024 | |||
| c103deb2a7 | |||
| dcef782587 | |||
| 10e7da4673 | |||
| faff35f241 | |||
| e2c1562f19 | |||
| df35ceb798 | |||
| cdb81a0bf4 | |||
| f1b1955190 | |||
| 860632b7a3 | |||
| bde7a61fb4 | |||
| b6600c5168 | |||
| 25f38ef7fe | |||
| ddeb44b920 | |||
| 02be710203 | |||
| 2ffbfc9f1c | |||
| 7b34f8116c | |||
| 8a9b6df255 | |||
| c881dd44d6 | |||
| 1cfaeaf8bb | |||
| 914f29184d | |||
| f510d57463 | |||
| 7833c17938 | |||
| 97fdffe6eb | |||
| b1f2900f1c | |||
| ddf015dc71 | |||
| 2a9d4fd212 | |||
| 2cacc23a38 | |||
| a7fd5a038e | |||
| 626b31084f | |||
| 4f3c25d5bd | |||
| 8da942e41e | |||
| b599c8a151 | |||
| d41f796825 | |||
| dd612e2660 | |||
| c503b5e677 | |||
| 0b433cfa18 | |||
| 75aba8c4ac | |||
| 81c65874a3 | |||
| 79d29d9c7b | |||
| 1e558b93af | |||
| 6d3d52639e | |||
| a1d460aa6c | |||
| 5a0bc7aaea | |||
| c7962b4231 | |||
| d14bb39ae8 | |||
| 5cc2f51c02 | |||
| a185f73e8a | |||
| f9a9598210 | |||
| 9976ccec41 | |||
| 8bfb2d749a | |||
| 7bf9a570a1 | |||
| b38df170e8 | |||
| bf38ace70c | |||
| 66c008f97e | |||
| 0298eb946f | |||
| 70fb35e37c | |||
| 1a30877ca9 | |||
| 569a22c0db |
+4
-2
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
DB_PASSWORD=root
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -56,6 +56,8 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=P@ssw0rd
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
@@ -2,6 +2,8 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- service_build
|
||||
- node
|
||||
- building_assets
|
||||
- database
|
||||
- unit_test
|
||||
- acceptance_test
|
||||
- code_quality
|
||||
|
||||
# Variables
|
||||
variables:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: mysql_password
|
||||
MYSQL_PASSWORD: mysql_password
|
||||
MYSQL_DATABASE: shpping_portal
|
||||
DB_HOST: mysql
|
||||
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
#install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install MySQL client
|
||||
- apt-get install -y default-mysql-client
|
||||
|
||||
#install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
#install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
|
||||
|
||||
#jobs
|
||||
|
||||
#buld the backend
|
||||
composer_php:
|
||||
stage: service_build
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#build the UI
|
||||
#node installation
|
||||
npm:
|
||||
stage: node
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#building assets
|
||||
building_assets:
|
||||
stage: building_assets
|
||||
# dependencies:
|
||||
# - npm
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
database:
|
||||
stage: database
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - composer_php
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
unit_test:
|
||||
stage: unit_test
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - database
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
- php artisan test
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,62 +1,39 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
||||
## Shipping portal documentation
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
simple documentation on how to install, run, test, commit and deploy application
|
||||
|
||||
## About Laravel
|
||||
## creating and running unit tests
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
Required Tools
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
- Chromium Driver / selenium
|
||||
- add running and setting selenium on all OS if possible
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
Required Packages :
|
||||
|
||||
## Learning Laravel
|
||||
- laravel/legacy-factories
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
- codeception/codeception
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
Or Simply Run
|
||||
|
||||
## Laravel Sponsors
|
||||
``Composer install``
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
To create a unit test
|
||||
|
||||
### Premium Partners
|
||||
``php artisan make test: Test Example --unit``
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
Running the tests :
|
||||
|
||||
## Contributing
|
||||
Running a single Test
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
`` php artisan test --filter Example``
|
||||
|
||||
## Code of Conduct
|
||||
Running Unit tests -
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
`` php artisan test ``
|
||||
|
||||
## Security Vulnerabilities
|
||||
Running Codeception tests -
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
``vendor/bin/codecept run``
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class DoesNotHavePaymentStatusIn implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||
$query->where('type', TransactionType::PAYMENT)->whereIn('status', $value);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HavePaymentStatusNotIn implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('transactions', function (Builder $query) use($value) {
|
||||
$query->where('type', TransactionType::PAYMENT)->whereNotIn('status', $value);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,14 +11,16 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
@@ -17,6 +20,7 @@ use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -27,7 +31,8 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Address',
|
||||
'message' => 'You have successfully created a new Address'
|
||||
@@ -74,11 +79,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
@@ -90,16 +95,22 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||
|
||||
if($request->input('phone')){
|
||||
if ($request->input('phone')) {
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
if ($request->input('remark')) {
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
@@ -14,6 +17,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -23,7 +27,8 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Billing Address',
|
||||
'message' => 'You have successfully created a new Billing Address'
|
||||
@@ -60,27 +65,35 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
// create new billing addrress
|
||||
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
//load address with only owner address
|
||||
|
||||
/* return fractal()
|
||||
->item($billingAddressInputed, new AddressTransformer())
|
||||
->parseIncludes('Owner_address')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||
@@ -17,7 +19,8 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Address',
|
||||
'message' => 'You have successfully retrieved a Address'
|
||||
@@ -45,15 +48,22 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchAddress->passes();
|
||||
|
||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
@@ -45,17 +50,25 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAddresses->passes();
|
||||
|
||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||
|
||||
//a collection of addresses with all incluides
|
||||
/* return fractal()
|
||||
->collection($query, new AddressTransformer)
|
||||
->parseIncludes('Owner_address')
|
||||
->parseIncludes('remark')
|
||||
->parseIncludes('contact')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(AddressResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\DistrictResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -33,7 +34,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
/** @var ResetsAddressesDefault */
|
||||
private $resetsAddressesDefault;
|
||||
|
||||
/** @var SetsAddressToDefault*/
|
||||
/** @var SetsAddressToDefault */
|
||||
private $setsAddressToDefault;
|
||||
|
||||
|
||||
@@ -64,7 +65,15 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
|
||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||
|
||||
$setAddress = $this->setsAddressToDefault->execute($address);
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($setAddress, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -26,7 +27,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Address',
|
||||
'message' => 'You have successfully updated the Address'
|
||||
@@ -77,7 +79,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
@@ -90,18 +92,25 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
$address->contacts()->delete();
|
||||
$address->remarks()->delete();
|
||||
|
||||
if($request->input('phone')){
|
||||
if ($request->input('phone')) {
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
if ($request->input('remark')) {
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
//only remark relationship needed
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ class CallbackBillplzLogic
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
@@ -53,13 +56,14 @@ class CallbackBillplzLogic
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +106,11 @@ class CallbackBillplzLogic
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
// check if is wallet top up
|
||||
if($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
@@ -109,18 +118,28 @@ class CallbackBillplzLogic
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
$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;
|
||||
|
||||
if ($transaction->owner instanceof Wallet) {
|
||||
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||
} else {
|
||||
|
||||
$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, 'transaction' => $transaction, 'status' => $status]);
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
@@ -45,15 +50,26 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||
|
||||
/*include all relationships*/
|
||||
/* return fractal()
|
||||
->collection($query, new CompanyTransformer)
|
||||
->parseIncludes('company')
|
||||
->parseIncludes('contact')
|
||||
->parseIncludes('remarks')
|
||||
->parseIncludes('address')
|
||||
->parseIncludes('billingAddress')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Transformers\ContactTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -63,6 +64,13 @@ class UpdateContactLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContact->execute($query, $object);
|
||||
|
||||
/*uniformity*/
|
||||
/* return fractal()
|
||||
->item($query, new ContactTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new ContactResource($query));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Order;
|
||||
use App\Transformers\DeliveryOrderTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -52,6 +53,14 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$order = $this->cancelsOrder->execute($order);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||
|
||||
}
|
||||
|
||||
@@ -172,6 +172,12 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||
$this->createsPackage->execute($packageObject, $packingList);
|
||||
|
||||
//add relationship to order
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new DeliveryOrderTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,13 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use League\Fractal;
|
||||
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -58,6 +62,11 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
/* return fractal()
|
||||
->collection($query, new DocumentTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -32,10 +31,8 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -39,6 +40,12 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,20 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Models\Address;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -41,6 +47,12 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
/**
|
||||
@@ -51,14 +63,18 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, CreatesAddress $createsAddress, CanCreateAddress $canCreateAddress, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -56,6 +57,13 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
}
|
||||
|
||||
//only return with packing list relationship
|
||||
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseInclude(['packingLists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +20,8 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -51,10 +53,16 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -70,6 +71,11 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -18,7 +19,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
@@ -50,7 +52,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -59,6 +61,12 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
//load with remarks only
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['remarks'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
}
|
||||
|
||||
+25
-17
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -28,7 +29,8 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
@@ -41,7 +43,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
@@ -54,12 +56,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
@@ -77,11 +79,11 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -92,21 +94,27 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//include transport
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['transport'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Container',
|
||||
'message' => 'You have successfully retrieved a Container'
|
||||
@@ -48,12 +50,18 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
//load with packing lists
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->parseIncludes(['packing_lists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -9,6 +9,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +20,8 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -52,11 +54,16 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
//no relations required
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+16
-5
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -45,16 +50,22 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
//load with no filters, a details page to be added to load one with all related data
|
||||
/* return fractal()
|
||||
->collection($query, new ContainerTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+13
-6
@@ -10,6 +10,7 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,7 +21,8 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
@@ -54,7 +56,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -65,15 +67,20 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//no relationship
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
+21
-10
@@ -3,12 +3,16 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +23,8 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -52,19 +57,19 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
@@ -74,6 +79,12 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContainer->execute($container, $object);
|
||||
|
||||
//no relationships
|
||||
/*
|
||||
return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
@@ -49,11 +51,18 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
|
||||
|
||||
//no relationships queried
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
@@ -49,11 +51,17 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+13
-5
@@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use App\Transformers\DeliverPackingListTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -24,7 +25,8 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
@@ -60,7 +62,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
@@ -68,9 +70,9 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
@@ -82,6 +84,12 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
//no relationships required
|
||||
/* return fractal()
|
||||
->item($deliverPackingList, new DeliverPackingListTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\Document;
|
||||
|
||||
class CreateCombinedInvoicesLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Shipping Invoice Status',
|
||||
'message' => 'You have successfully updated multiple shipping invoices status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$items = $request->input('ids');
|
||||
$invoice_transactions=array();
|
||||
foreach($items as $item){
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $item['id']]);
|
||||
|
||||
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
array_push($invoice_transactions, $invoice_transaction);
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $invoice_transactions]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
$user = $packing_list->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
|
||||
class CreateGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Create Group Transaction',
|
||||
'message' => 'You have successfully created a group transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
|
||||
if (count($invoice_ids) > 1) {
|
||||
dd('more than 1 invoice');
|
||||
// creates group transaction
|
||||
$group = new Group();
|
||||
|
||||
$issuer = '';
|
||||
$receiver = '';
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = '';
|
||||
$currency_rate = '';
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
|
||||
// todo-new: check why is this not working
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
// todo-new: attach transaction to the group id
|
||||
// create one payment for each, then mark as pending_approval
|
||||
$issuer = $invoice->issuer;
|
||||
$receiver = $invoice->receiver;
|
||||
$amount += $invoice->amount;
|
||||
$original_amount += $invoice->original_amount;
|
||||
$currency_id = $invoice->currency_id;
|
||||
$original_currency_id = $invoice->original_currency_id;
|
||||
$currency_rate = $invoice->currency_rate;
|
||||
$tax += $invoice->tax;
|
||||
$service_charge += $invoice->service_charge;
|
||||
}
|
||||
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->reference = $billNumber;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
|
||||
$group->save();
|
||||
|
||||
|
||||
// attach payment on group transaction
|
||||
|
||||
// $invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids->first()]);
|
||||
// $amount = $request->input('amount');
|
||||
// $company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
|
||||
$invoice_transaction = $group;
|
||||
$transferDetails = $billNumber;
|
||||
$company_module = $group->receiverCompany;
|
||||
} else {
|
||||
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids[0]]);
|
||||
$amount = $request->input('amount');
|
||||
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
$transferDetails = $invoice_transaction->bill_no;
|
||||
}
|
||||
|
||||
$payment_reference = null;
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $transferDetails,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$request->input('bank_code'),
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
if (count($invoice_ids) > 1) {
|
||||
// do one by one
|
||||
// dd($invoices);
|
||||
// todo-new: update all the transaction inside
|
||||
} else {
|
||||
// $invoice_transaction;
|
||||
$packingList = $invoice_transaction->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
// createsPaymentTransaction
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$request->input('amount'),
|
||||
$request->input('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
||||
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteGroupLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Delete Group Transaction',
|
||||
'message' => 'You have successfully deleted this Group Transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var FetchesGroup */
|
||||
private $fetchesGroup;
|
||||
|
||||
/** @var DeletesTransaction */
|
||||
private $deletesTransaction;
|
||||
|
||||
/**
|
||||
* DeleteGroupLogic constructor.
|
||||
* @param updatesTransactionStatus $updatesTransactionStatus
|
||||
* @param FetchesGroup $fetchesGroup
|
||||
* @param DeletesTransaction $deletesTransaction
|
||||
*/
|
||||
public function __construct(updatesTransactionStatus $updatesTransactionStatus, FetchesGroup $fetchesGroup, DeletesTransaction $deletesTransaction)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->fetchesGroup = $fetchesGroup;
|
||||
$this->deletesTransaction = $deletesTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
$items = $group->transactions()->get();
|
||||
|
||||
foreach($items as $item) {
|
||||
$bill = $item;
|
||||
$payment = $bill->owner;
|
||||
$group->transactions()->detach($bill->id);
|
||||
$this->updatesTransactionStatus->execute($payment, ApprovalStatus::APPROVED);
|
||||
$this->deletesTransaction->execute($bill);
|
||||
}
|
||||
|
||||
$group->delete();
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* ListTransactionsLogic constructor.
|
||||
* @param ListsGroups $listsGroups
|
||||
*/
|
||||
public function __construct(ListsGroups $listsGroups)
|
||||
{
|
||||
$this->listsGroups = $listsGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Groups',
|
||||
'message' => 'You have successfully retrieved a list of groups'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsGroups */
|
||||
private $listsGroups;
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$query = $this->listsGroups->execute($this->listsGroups->deserializeFilters($request->input('filters')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(GroupResource::collection($query));
|
||||
}
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Models\Document;
|
||||
|
||||
class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Regenerate Shipping Invoice',
|
||||
'message' => 'You have successfully regenerated shipping invoice'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* @param CreatesDocument $createsDocument
|
||||
*/
|
||||
public function __construct(CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$orders = Order::where('company_module_id', $request->route('company_module_id'))->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
$document =$this->createsDocument->execute($invoice, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
|
||||
// dump($document);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Models\Document;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use ErrorException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class UpdateGroupLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Group Transaction',
|
||||
'message' => 'You have successfully updated this Group Transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesGroup */
|
||||
private $fetchesGroup;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CalculatesTransactionServiceCharge */
|
||||
private $calculatesTransactionServiceCharge;
|
||||
|
||||
/** @var UpdatesTransaction */
|
||||
private $updatesTransaction;
|
||||
|
||||
/** @var CalculatesTransactionTransferFee */
|
||||
private $calculatesTransactionTransferFee;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
/**
|
||||
* UpdateGroupLogic constructor.
|
||||
* @param FetchesGroup $fetchesGroup
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge
|
||||
* @param UpdatesTransaction $updatesTransaction
|
||||
* @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
*/
|
||||
public function __construct(FetchesGroup $fetchesGroup, FetchesCompany $fetchesCompany, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, UpdatesTransaction $updatesTransaction, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, CreatesDocument $createsDocument, CreatesFiles $createsFile)
|
||||
{
|
||||
$this->fetchesGroup = $fetchesGroup;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge;
|
||||
$this->updatesTransaction = $updatesTransaction;
|
||||
$this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
$transactions = $group->transactions()->get();
|
||||
|
||||
$rate = $request->input('rate');
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $request->input('supplier_id')]);
|
||||
|
||||
// $group->transactions()->update(['issuer' => $supplier->id, 'currency_rate' => $rate]);
|
||||
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
|
||||
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
|
||||
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
||||
|
||||
$object = new TransactionObject(
|
||||
$transaction->bill_no,
|
||||
TransactionType::BILL,
|
||||
$supplier->id,
|
||||
1,
|
||||
$supplier->banks()->where('default', true)->first()->id,
|
||||
PaymentMethodType::CASH,
|
||||
$transaction->original_amount * (1 / $rate),
|
||||
$transaction->original_amount,
|
||||
1,
|
||||
$transaction->original_currency_id,
|
||||
$rate,
|
||||
0,
|
||||
$serviceCharge,
|
||||
null,
|
||||
ApprovalStatus::PENDING_VERIFICATION
|
||||
);
|
||||
|
||||
$billTransaction = $this->updatesTransaction->execute($transaction, $object);
|
||||
|
||||
$transferTransaction = $transaction->transactions()->where('type', TransactionType::TRANSFER_FEE)->first();
|
||||
|
||||
$transferFee = $this->calculatesTransactionTransferFee->execute($billTransaction->original_amount, $constant);
|
||||
|
||||
$object = new TransactionObject(
|
||||
$transferTransaction->bill_no,
|
||||
TransactionType::TRANSFER_FEE,
|
||||
$supplier->id,
|
||||
1,
|
||||
$supplier->banks()->where('default', true)->first()->id,
|
||||
PaymentMethodType::CASH,
|
||||
$transaction->original_amount,
|
||||
$transaction->original_amount,
|
||||
$transaction->original_currency_id,
|
||||
$transaction->original_currency_id,
|
||||
1,
|
||||
0,
|
||||
$transferFee,
|
||||
null,
|
||||
ApprovalStatus::PENDING_VERIFICATION
|
||||
);
|
||||
|
||||
$this->updatesTransaction->execute($transferTransaction, $object);
|
||||
}
|
||||
|
||||
$group->issuer = $supplier->id;
|
||||
$group->amount = $group->transactions()->sum('amount');
|
||||
$group->currency_rate = $rate;
|
||||
$group->tax = $group->transactions()->sum('tax');
|
||||
$group->service_charge = $group->transactions()->sum('service_charge');
|
||||
|
||||
$group->save();
|
||||
|
||||
$group->documents()->delete();
|
||||
|
||||
$transferFeeTransactions = $group->transactions()->with([
|
||||
'transactions' => function ($transaction) {
|
||||
return $transaction->where('type', TransactionType::TRANSFER_FEE);
|
||||
}])->get()->pluck('transactions')->flatten();
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $group->transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]);
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'currency_vendor_order'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($group, $object);
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class UpdateWalletTransactionProcessor
|
||||
{
|
||||
/** @var CreatesWalletTransaction */
|
||||
private $createsWalletTransaction;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var ListWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWallet $updatesWallet)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Booking $booking
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(int $transactionId, int $transactionStatus)
|
||||
{
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $transactionId]);
|
||||
$wallet = $transaction->wallet;
|
||||
|
||||
switch($transaction->type){
|
||||
case TransactionType::TOP_UP:
|
||||
$updateWalletAmount = $transaction->amount + $wallet->amount;
|
||||
break;
|
||||
case TransactionType::WITHDRAW:
|
||||
$updateWalletAmount = $wallet->amount - $transaction->amount;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $transactionStatus);
|
||||
|
||||
$this->updatesWallet->execute($wallet, $walletOject);
|
||||
|
||||
return $wallet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CreatesTransactionableTransaction extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param Transactionable $transactionable
|
||||
* @param TransactionObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transactionable $transactionable, TransactionObject $object) {
|
||||
$model = new Transaction();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->type = $object->getTransactionType();
|
||||
$model->issuer = $object->getIssuer();
|
||||
$model->receiver = $object->getReceiver();
|
||||
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
|
||||
$model->payment_method = $object->getPaymentMethod();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->currency_id = $object->getCurrencyId();
|
||||
$model->original_currency_id = $object->getOriginalCurrencyId();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
$model->tax = $object->getTax();
|
||||
$model->service_charge = $object->getServiceCharge();
|
||||
$model->expires_on = $object->getExpiresOn();
|
||||
$model->status = $object->getStatus();
|
||||
$model->payment_reference = $object->getPaymentReference();
|
||||
|
||||
return $this->handler($transactionable->transactions(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
use App\Models\Group;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
|
||||
class ListsGroups extends AbstractListRecord
|
||||
{
|
||||
/** @var Group */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsBookings constructor.
|
||||
* @param Group $repository
|
||||
*/
|
||||
public function __construct(Group $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Wallet',
|
||||
'message' => 'You have successfully created a company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canCreateCompanyWallet;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->canCreateCompanyWallet = $canCreateCompanyWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new WalletObject($request->input('company_module_id'), $request->input('currency_id'), $this->generatesWalletCode->execute());
|
||||
|
||||
$this->canCreateCompanyWallet->passes($object);
|
||||
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$wallet = $this->createsWallet->execute($object, $company_module);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletTransactionBillNo;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\Modules\Currencies\Services\RateCalculatesCurrency;
|
||||
/*
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCreateUser;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyEmployeeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentCompanies\Standards\Rules\CanCreateSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\Services\CreatesSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
|
||||
*/
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateWalletTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Wallet Transaction',
|
||||
'message' => 'You have successfully created a wallet transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWalletTransaction */
|
||||
private $createsWalletTransaction;
|
||||
|
||||
/** @var GeneratesWalletTransactionBillNo */
|
||||
private $generatesWalletTransactionBillNo;
|
||||
|
||||
/** @var CanCreateWalletTransaction */
|
||||
private $canCreateWalletTransaction;
|
||||
|
||||
private $fetchesCurrency;
|
||||
|
||||
private $rateCalculatesCurrency;
|
||||
|
||||
private $fetchesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWalletTransaction $createsWalletTransaction
|
||||
* @param GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo
|
||||
* @param CanCreateWalletTransaction $canCreateWalletTransaction
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
* @param RateCalculatesCurrency $rateCalculatesCurrency
|
||||
* @param FetchesWallet $fetchesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
CreatesWalletTransaction $createsWalletTransaction, GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo, CanCreateWalletTransaction $canCreateWalletTransaction,
|
||||
FetchesCurrency $fetchesCurrency,RateCalculatesCurrency $rateCalculatesCurrency, FetchesWallet $fetchesWallet
|
||||
)
|
||||
{
|
||||
$this->createsWalletTransaction = $createsWalletTransaction;
|
||||
$this->generatesWalletTransactionBillNo = $generatesWalletTransactionBillNo;
|
||||
$this->canCreateWalletTransaction = $canCreateWalletTransaction;
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
$this->rateCalculatesCurrency = $rateCalculatesCurrency;
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$wallet = $this->fetchesWallet->execute(['id' => $request->route('id')]);
|
||||
$conversion_currency = $this->fetchesCurrency->execute(['id' => $request->input('currency_id')]);
|
||||
$convertable_currency = $this->fetchesCurrency->execute(['id' => $wallet->currency_id]);//MYR
|
||||
|
||||
$convert_amount = $this->rateCalculatesCurrency->execute($conversion_currency, $convertable_currency, $request->input('amount'));
|
||||
$convert_rate = $this->rateCalculatesCurrency->execute_rate($conversion_currency, $convertable_currency);
|
||||
|
||||
|
||||
$object = new WalletTransactionObject(
|
||||
$wallet->id, $this->generatesWalletTransactionBillNo->execute(),$request->input('trans_type'),
|
||||
number_format( (float) $convert_amount, 5, '.', ''), $wallet->currency_id , number_format( (float) $request->input('amount'), 5, '.', ''),
|
||||
$request->input('currency_id'),number_format( (float) $convert_rate, 5, '.', '')
|
||||
);
|
||||
|
||||
$this->canCreateWalletTransaction->passes($object);
|
||||
|
||||
$wallet_transaction = $this->createsWalletTransaction->execute($object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($wallet_transaction));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
|
||||
class CreditWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Credit into Company Wallet',
|
||||
'message' => 'You have successfully credit company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/** @var CreditWalletProcessor */
|
||||
private $creditWalletProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
* @param CreditWalletProcessor $creditWalletProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet,
|
||||
CreditWalletProcessor $creditWalletProcessor
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
$this->creditWalletProcessor = $creditWalletProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$reference = $request->input('reference');
|
||||
|
||||
$type = $request->input('transaction_type');
|
||||
|
||||
$wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DebitWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Debit into Company Wallet',
|
||||
'message' => 'You have successfully debit company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
$reference = $request->input('reference');
|
||||
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('DEBIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::DEBIT_NOTE,
|
||||
1,
|
||||
$wallet->company->id,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED,
|
||||
[],
|
||||
$reference
|
||||
);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
$updateWalletAmount = $wallet->amount - $transaction->amount;
|
||||
|
||||
$walletOject = new WalletObject($wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletOject);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Models\Wallet;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
|
||||
class FetchWalletByCompanyModuleControllerLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Wallet',
|
||||
'message' => 'You have successfully retrieved a wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canCreateCompanyWallet;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesWallet $fetchesWallet
|
||||
*/
|
||||
public function __construct(FetchesWallet $fetchesWallet, CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->canCreateCompanyWallet = $canCreateCompanyWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
// $this->canFetchWallet->passes();
|
||||
|
||||
if (!count(Wallet::where('owner_id', $request->route('company_module_id'))->get())) {
|
||||
$object = new WalletObject($request->route('company_module_id'), $request->input('currency_id') ?? 1, $this->generatesWalletCode->execute());
|
||||
|
||||
$this->canCreateCompanyWallet->passes($object);
|
||||
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->route('company_module_id')]);
|
||||
|
||||
$wallet = $this->createsWallet->execute($object, $company_module);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
|
||||
$filters = $this->fetchesWallet->deserializeFilters($request->input('filters'));
|
||||
|
||||
$filters['owner_id'] = $request->route('company_module_id');
|
||||
|
||||
$query = $this->fetchesWallet->execute($filters);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ListWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'List Company Wallet',
|
||||
'message' => 'You have successfully list company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListWallet */
|
||||
private $listsWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
|
||||
{
|
||||
$this->canListWallet = $canListWallet;
|
||||
$this->listsWallet = $listsWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
//$this->canListWallet->passes();
|
||||
|
||||
$query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(WalletResource::collection($query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TopUpWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'TopUp into Company Wallet',
|
||||
'message' => 'You have successfully created a topup request for company\'s wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
|
||||
/**
|
||||
* TopUpWalletLogic constructor.
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
*/
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, GeneratesWalletCode $generatesWalletCode, CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesBillplzBill $createsBillplzBill, CreatesTransactionableTransaction $createsTransactionableTransaction)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $companyModule->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $this->createsWallet->execute($object, $companyModule);
|
||||
}
|
||||
|
||||
$user = $companyModule->employees()->first();
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-');
|
||||
|
||||
if($amount < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
|
||||
$billPlzBill = $this->createsBillplzBill->execute($companyModule->name, $user->email, 'This payment is credit topup for company ref. ' . $companyModule->reference, $amount, $billNumber, $request->input('bank_code'), true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $companyModule->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($transaction));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Transactions\Processors\UpdateWalletTransactionProcessor;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateStatusWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Status Transaction Company Wallet',
|
||||
'message' => 'You have successfully status transaction company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
|
||||
/** @var UpdateWalletTransactionProcessor */
|
||||
private $updateWalletTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(FetchesWallet $fetchesWallet, UpdateWalletTransactionProcessor $updateWalletTransactionProcessor)
|
||||
{
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->updateWalletTransactionProcessor = $updateWalletTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$status = ($request->route('status')=='approve') ? 2 : 4;
|
||||
|
||||
$wallet = $this->updateWalletTransactionProcessor->execute($request->route('transaction_id'), $status);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanWithdrawWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithdrawWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Withdraw from Company Wallet',
|
||||
'message' => 'You have successfully withdraw company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CanWithdrawWallet */
|
||||
private $canWithdrawWallet;
|
||||
|
||||
/** @var CreateWalletTransactionProcessor */
|
||||
private $createWalletTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanWithdrawWallet $canWithdrawWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor)
|
||||
{
|
||||
$this->canWithdrawWallet = $canWithdrawWallet;
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->createWalletTransactionProcessor = $createWalletTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]);
|
||||
|
||||
$walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount'));
|
||||
|
||||
$this->canWithdrawWallet->passes($walletOject);
|
||||
|
||||
$transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::WITHDRAW);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WalletObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $company_module_id;
|
||||
|
||||
/** @var int */
|
||||
private $currency_id;
|
||||
|
||||
/** @var int */
|
||||
private $code;
|
||||
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* WalletObject constructor.
|
||||
* @param int $company_module_id
|
||||
* @param int $currency
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct(int $company_module_id, int $currency, int $code, float $amount=0)
|
||||
{
|
||||
$this->company_module_id = $company_module_id;
|
||||
$this->currency_id = $currency;
|
||||
$this->code = $code;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCompanyModuleId(): int
|
||||
{
|
||||
return $this->company_module_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrency(): int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCode(): int
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WalletTransactionObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $wallet_id;
|
||||
|
||||
private $bill_no;
|
||||
|
||||
private $trans_type;
|
||||
|
||||
private $amount;
|
||||
|
||||
private $currency_id;
|
||||
|
||||
private $original_amount;
|
||||
|
||||
private $original_currency_id;
|
||||
|
||||
private $currency_rate;
|
||||
|
||||
public function __construct(
|
||||
int $wallet_id, int $bill_no,int $trans_type,
|
||||
float $amount, int $currency_id, int $original_amount,
|
||||
int $original_currency_id, float $currency_rate
|
||||
){
|
||||
$this->wallet_id = $wallet_id;
|
||||
$this->bill_no = $bill_no;
|
||||
$this->trans_type = $trans_type;
|
||||
$this->amount= $amount;
|
||||
$this->currency_id = $currency_id;
|
||||
$this->original_amount = $original_amount;
|
||||
$this->original_currency_id = $original_currency_id;
|
||||
$this->currency_rate = $currency_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWalletId(): int
|
||||
{
|
||||
return $this->wallet_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBillNo(): int
|
||||
{
|
||||
return $this->bill_no;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTransType(): int
|
||||
{
|
||||
return $this->trans_type;
|
||||
}
|
||||
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrency(): int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
|
||||
public function getOriginalAmount(): float
|
||||
{
|
||||
return $this->original_amount;
|
||||
}
|
||||
|
||||
public function getOriginalCurrency(): int
|
||||
{
|
||||
return $this->original_currency_id;
|
||||
}
|
||||
|
||||
public function getCurrencyRate(): float
|
||||
{
|
||||
return $this->currency_rate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Processors;
|
||||
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
|
||||
class CreditWalletProcessor
|
||||
{
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param int $transactionType
|
||||
* @param float $amount
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, int $transactionType, float $amount, string $reference)
|
||||
{
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
|
||||
|
||||
$walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletObject);
|
||||
|
||||
return $wallet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Models\Wallet;
|
||||
|
||||
class ChecksIfWalletCodeExists
|
||||
{
|
||||
|
||||
/** @var wallet */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* ChecksIfWalletCodeExists constructor.
|
||||
* @param Wallet $repository
|
||||
*/
|
||||
public function __construct(wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $code): bool {
|
||||
return $this->repository->where('code', $code)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class ChecksIfWalletTransactionBillNoExists
|
||||
{
|
||||
|
||||
private $repository;
|
||||
|
||||
public function __construct(WalletTransaction $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $bill_no): bool {
|
||||
return $this->repository->where('bill_no', $bill_no)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class CreatesWallet extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WalletObject $object, CompanyModule $companyModule) {
|
||||
$model = new Wallet();
|
||||
// $model->company_module_id = $object->getCompanyModuleId();
|
||||
$model->code = $object->getCode();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
|
||||
return $this->handler($companyModule->wallets(), $model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class CreatesWalletTransaction extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WalletTransactionObject $object) {
|
||||
$model = new WalletTransaction();
|
||||
$model->wallet_id = $object->getWalletId();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->trans_type = $object->getTransType();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->original_currency_id = $object->getOriginalCurrency();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class FetchesWallet extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Wallet */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesWallet constructor.
|
||||
* @param Wallet $repository
|
||||
*/
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
class GeneratesWalletCode
|
||||
{
|
||||
|
||||
/** @var ChecksIfWalletCodeExists */
|
||||
private $walletCodeExists;
|
||||
|
||||
/**
|
||||
* GeneratesWalletCode constructor.
|
||||
* @param ChecksIfWalletCodeExists $walletCodeExists
|
||||
*/
|
||||
public function __construct(ChecksIfWalletCodeExists $walletCodeExists)
|
||||
{
|
||||
$this->walletCodeExists = $walletCodeExists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function execute(): int {
|
||||
|
||||
$code = mt_rand(100000001, 999999999);
|
||||
return !$this->walletCodeExists->execute($code) ? $code : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
class GeneratesWalletTransactionBillNo
|
||||
{
|
||||
|
||||
|
||||
private $walletTransationBillNoExists;
|
||||
|
||||
|
||||
public function __construct(ChecksIfWalletTransactionBillNoExists $walletTransationBillNoExists)
|
||||
{
|
||||
$this->walletTransationBillNoExists = $walletTransationBillNoExists;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function execute(): int {
|
||||
|
||||
$code = mt_rand(100000001, 999999999);
|
||||
return !$this->walletTransationBillNoExists->execute($code) ? $code : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class ListsWallet extends AbstractListRecord
|
||||
{
|
||||
/** @var Booking */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsBookings constructor.
|
||||
* @param Booking $repository
|
||||
*/
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWallet extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, WalletObject $object) {
|
||||
$model->amount = $object->getAmount();
|
||||
$model->code = $object->getCode();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Wallet $model
|
||||
* @param $amount
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
|
||||
$model->amount = $model->amount + $amount;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\CompanyWalletValidation;
|
||||
|
||||
class CanCreateCompanyWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var CompanyWalletValidation */
|
||||
private $companyWalletValidation;
|
||||
|
||||
/**
|
||||
* CanCreateCompanyWallet constructor.
|
||||
* @param CompanyWalletValidation $companyWalletValidation
|
||||
*/
|
||||
public function __construct(CompanyWalletValidation $companyWalletValidation)
|
||||
{
|
||||
$this->companyWalletValidation = $companyWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\WalletTransactionValidation;
|
||||
|
||||
class CanCreateWalletTransaction extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WalletTransactionValidation */
|
||||
private $walletTransactionValidation;
|
||||
|
||||
|
||||
public function __construct(WalletTransactionValidation $walletTransactionValidation)
|
||||
{
|
||||
$this->walletTransactionValidation = $walletTransactionValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->walletTransactionValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\ListWalletValidation;
|
||||
|
||||
class CanListWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ListWalletValidation */
|
||||
private $listWalletValidation;
|
||||
|
||||
|
||||
public function __construct(ListWalletValidation $listWalletValidation)
|
||||
{
|
||||
$this->listWalletValidation = $listWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->listWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\TopUpWalletValidation;
|
||||
|
||||
class CanTopUpWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var TopUpWalletValidation */
|
||||
private $topUpWalletValidation;
|
||||
|
||||
|
||||
public function __construct(TopUpWalletValidation $topUpWalletValidation)
|
||||
{
|
||||
$this->topUpWalletValidation = $topUpWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->topUpWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\WithdrawWalletValidation;
|
||||
|
||||
class CanWithdrawWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WithdrawWalletValidation */
|
||||
private $witdrawWalletValidation;
|
||||
|
||||
|
||||
public function __construct(WithdrawWalletValidation $witdrawWalletValidation)
|
||||
{
|
||||
$this->witdrawWalletValidation = $witdrawWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->witdrawWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
|
||||
class CompanyWalletValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'company_module_id' => $object->getCompanyModuleId(),
|
||||
'currency_id' => $object->getCurrency(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'company_module_id' => 'required',
|
||||
'currency_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class ListWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class TopUpWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class WalletTransactionValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'wallet_id' => $object->getWalletId(),
|
||||
'currency_id' => $object->getCurrency(),
|
||||
'amount' => $object->getAmount(),
|
||||
'trans_type'=>$object->getTransType()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'wallet_id' => 'required',
|
||||
'currency_id' => 'required',
|
||||
'amount' => 'required',
|
||||
'trans_type'=>'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class WithdrawWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ final class PaymentMethodType {
|
||||
'cheque' => self::CHEQUE,
|
||||
'ba' => self::BA,
|
||||
'wallet' => self::WALLET,
|
||||
'payment gateway' => self::PAYMENT_GATEWAY,
|
||||
'payment_gateway' => self::PAYMENT_GATEWAY,
|
||||
];
|
||||
|
||||
public const PAYMENT_METHODS_ID = [
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class RouteType {
|
||||
|
||||
public const WEB = 1;
|
||||
|
||||
public const API = 2;
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@ final class TransactionType {
|
||||
|
||||
// public const PERFORMA = 4;
|
||||
|
||||
// public const TOP_UP = 5;
|
||||
public const TOP_UP = 5;
|
||||
|
||||
// public const REFUND = 6;
|
||||
|
||||
@@ -25,8 +25,17 @@ final class TransactionType {
|
||||
|
||||
// public const SUPPLIER_DELIVER = 8;
|
||||
|
||||
// public const SHIPPING_COST = 9;
|
||||
public const CREDIT_NOTE = 9;
|
||||
|
||||
public const WITHDRAW = 10;
|
||||
|
||||
public const DEBIT_NOTE = 11;
|
||||
|
||||
public const TRANSFER_FEE = 12;
|
||||
|
||||
public const CASH_BACK = 13;
|
||||
|
||||
// public const SHIPPING_COST = 14;
|
||||
public const TRANSACTION_TYPE_ID = [
|
||||
self::SHIPPING_INVOICE => "Shipping Invoice",
|
||||
self::PAYMENT => "Payment",
|
||||
|
||||
+17
-12
@@ -28,26 +28,31 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
|
||||
$schedule->command('command:curlVTCommand')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
// $schedule->command('command:curlVTCommand')
|
||||
// ->cron('0 8 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('30 9-18/3 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('0 9 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('0 9 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
|
||||
$schedule->command('invoice:generate')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
|
||||
|
||||
$schedule->command('approve:invoice')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/approve_invoice.log');
|
||||
|
||||
$schedule->command('billplz-failed-callback:fix')
|
||||
->dailyAt('00:00')
|
||||
->withoutOverlapping()
|
||||
|
||||
@@ -19,7 +19,39 @@ use Illuminate\Http\Request;
|
||||
|
||||
class MonthlyReportController
|
||||
{
|
||||
public function salesReport(Request $request): JsonResponse {
|
||||
|
||||
/**
|
||||
* Get Containers
|
||||
* @param $from
|
||||
* @param $to
|
||||
* @return mixed
|
||||
*/
|
||||
private function getContainersByLoadingDate($from, $to)
|
||||
{
|
||||
return Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
|
||||
}
|
||||
|
||||
private function getPackages($from, $to)
|
||||
{
|
||||
|
||||
$containers = $this->getContainersByLoadingDate($from, $to);
|
||||
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
return $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function salesReport(Request $request): JsonResponse
|
||||
{
|
||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
||||
|
||||
@@ -39,16 +71,18 @@ class MonthlyReportController
|
||||
return $container->orders;
|
||||
})->unique();
|
||||
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
$packages = $this->getPackages($from, $to);
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
/* $packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});*/
|
||||
|
||||
$totalCbm = $packages->sum(function($package){
|
||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
||||
@@ -89,19 +123,18 @@ class MonthlyReportController
|
||||
$model = (int) $request->route('model');
|
||||
$value = (float) $request->route('value');
|
||||
|
||||
$packages = $this->getPackages($from, $to);
|
||||
|
||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
/* $packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});*/
|
||||
|
||||
$totalCbm = $packages->sum(function($package){
|
||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
||||
@@ -142,18 +175,20 @@ class MonthlyReportController
|
||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::parse('01-01-2018');
|
||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now();
|
||||
|
||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
/* $containers = $this->getContainersByLoadingDate($from, $to);
|
||||
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});*/
|
||||
|
||||
$packages = $this->getPackages($from, $to);
|
||||
|
||||
$packages = $packages->filter(function($package) use ($id) {
|
||||
return $package->companyModule->id === $id;
|
||||
@@ -210,17 +245,19 @@ class MonthlyReportController
|
||||
$minCbm = $request->input('cbm');
|
||||
$minOrders = $request->input('minOrders');
|
||||
|
||||
$activeCompanies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', \Carbon\Carbon::parse($inactive_start))->where('drop_date', '<=', \Carbon\Carbon::parse($inactive_end)->addDay());
|
||||
});
|
||||
})->pluck('id');
|
||||
/* $activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
|
||||
});
|
||||
})->pluck('id');
|
||||
|
||||
$companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', \Carbon\Carbon::parse($active_start))->whereDate('drop_date', '<=', \Carbon\Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();
|
||||
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function ($query) use ($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();*/
|
||||
|
||||
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
||||
|
||||
$customerActivityData = [];
|
||||
$counter = 1;
|
||||
@@ -240,7 +277,7 @@ class MonthlyReportController
|
||||
if ($minOrders != 'null' && $packingList->count() < $minOrders) { continue; }
|
||||
|
||||
array_push($customerActivityData, array(
|
||||
'key' => $counter,
|
||||
'key' => $counter,
|
||||
'marking' => $marking,
|
||||
'packingListCount'=> $packingList->count(),
|
||||
'totalCbm'=> $totalCbm,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\CreateCombinedInvoicesLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCombinedInvoicesController
|
||||
{
|
||||
|
||||
public function combine(Request $request, CreateCombinedInvoicesLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\CreateGroupsLogic;
|
||||
|
||||
|
||||
class CreateGroupsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreatePurchaseOrderTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateGroupsLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\DeleteGroupLogic;
|
||||
|
||||
class DeleteGroupController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteGroupTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteGroupLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ListGroupsLogic;
|
||||
|
||||
|
||||
class ListGroupsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListGroupsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListGroupsLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\RegenerateShippingInvoiceTransactionLogic;
|
||||
|
||||
|
||||
class RegenerateShippingInvoiceTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RegenerateShippingInvoiceTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function regenerate(Request $request, RegenerateShippingInvoiceTransactionLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateGroupLogic;
|
||||
|
||||
class UpdateGroupController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteGroupTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateGroupLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreateWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreateWalletTransactionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletTransactionController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateWalletTransactionLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreditWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreditWalletController
|
||||
{
|
||||
|
||||
public function credit(Request $request, CreditWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\DebitWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DebitWalletController
|
||||
{
|
||||
|
||||
public function debit(Request $request, DebitWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\FetchWalletByCompanyModuleControllerLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchWalletByCompanyModuleController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchWalletByCompanyModuleControllerLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchWalletByCompanyModuleControllerLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\ListWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListWalletController
|
||||
{
|
||||
public function list(Request $request, ListWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\TopUpWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TopUpWalletController
|
||||
{
|
||||
|
||||
public function topUp(Request $request, TopUpWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\UpdateStatusWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateStatusWalletController
|
||||
{
|
||||
public function updateStatus(Request $request, UpdateStatusWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user