Compare commits

..

174 Commits

Author SHA1 Message Date
edmondlang a701242646 fix wallet audit 2023-10-24 00:49:07 +08:00
edmondlang 4bdeae997d Merge branch 'wallet-audit' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal 2023-10-23 23:54:19 +08:00
edmondlang 36809f34cc Merge branch 'steve/aging-listing' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal 2023-10-23 23:53:35 +08:00
edmondlang 032171bb18 update aging listing 2023-10-23 23:53:10 +08:00
JiaSheng d41bd3db39 fix bug when packing list is deleted 2023-10-23 22:00:31 +08:00
edmondlang af8444e0d9 Merge branch 'wallet-audit' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal 2023-10-20 16:30:33 +08:00
edmondlang b2a7d1f73d update group payment 2023-10-20 16:26:18 +08:00
edmondlang 9d2ff3fafa update cash payment method 2023-10-20 16:22:19 +08:00
edmondlang 487d07e28c update design for approve payment 2023-10-20 16:02:04 +08:00
edmondlang 4176e09ea3 fix bug upload receipt modal not showing 2023-10-20 15:46:59 +08:00
edmondlang c44bf46a42 update web route for active wallet 2023-10-20 15:14:29 +08:00
edmondlang e687dd2b9a deletes payment 2023-10-19 22:54:21 +08:00
edmondlang 59951c4efd updater delete group transaction 2023-10-19 22:02:14 +08:00
edmondlang c00a4712a0 revert 2023-10-19 21:41:48 +08:00
edmondlang 1bb07e9402 revert 2023-10-19 21:38:24 +08:00
edmondlang 683bdec1f7 revert 2023-10-19 21:27:19 +08:00
edmondlang ee53a9438a temporary show all invoice 2023-10-19 21:25:44 +08:00
edmondlang 2e2087f16e temporary show all invoice 2023-10-19 21:23:15 +08:00
edmondlang 998b0b4da5 update delete group transaction 2023-10-19 20:48:22 +08:00
edmondlang dcf5c2e455 show billplz failed callback command 2023-10-19 20:14:59 +08:00
edmondlang 156b1dee07 update logic, for group payment, wallet must be credited first, then make group payment 2023-10-19 13:50:59 +08:00
edmondlang 544d7907c3 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into wallet-audit 2023-10-19 13:43:53 +08:00
edmondlang 5b77f7baa6 add group payment in top up history 2023-10-19 11:44:25 +08:00
Jia Sheng Lee b33016aac4 only super admin can use the manual transfer for group payment 2023-10-18 15:28:12 +08:00
Jia Sheng Lee 2788e349ae manual transfer for admin to upload for bulk invoice payment 2023-10-18 15:06:46 +08:00
Steve Ng 04af87f640 csv download aging report 2023-10-18 08:48:30 +08:00
edmondlang 5b190d5334 revert ExportPendingArrangementPackingListV2Controller 2023-10-16 13:48:58 +08:00
Dillon Ngo 8f32769656 Merge branch 'dillon/44-quick-undo' into 'master'
Quick undo experimental security check

See merge request CIEFWorldwideSdnBhd/shipping-portal!176
2023-10-16 05:33:40 +00:00
Dillon 0e79bbfd6a Quick undo experimental security check 2023-10-16 13:24:30 +08:00
Dillon Ngo 3a411e8b9a Merge branch 'dillon/44-customer-satisfaction-feedback-project-b' into 'master'
Preparation for help menu

See merge request CIEFWorldwideSdnBhd/shipping-portal!175
2023-10-15 17:16:57 +00:00
Dillon bffe438455 Disable help menu 2023-10-16 01:09:24 +08:00
Dillon Ngo d17beda04b Merge branch 'dillon/44-customer-satisfaction-feedback-project' into 'master'
New Feedback Form for gathering feedback from customer

See merge request CIEFWorldwideSdnBhd/shipping-portal!174
2023-10-15 10:19:13 +00:00
Dillon 7acc6932b5 Merge branch 'master' into dillon/44-customer-satisfaction-feedback-project 2023-10-15 18:07:26 +08:00
Jia Sheng Lee 2d175f4acc recalculate wallet balance 2023-10-14 15:57:22 +08:00
edmondlang 31905e56be enable top up for superadmin 2023-10-13 15:00:30 +08:00
edmondlang 6508155aea fix group payment not showing in wallet transaction history 2023-10-12 13:17:24 +08:00
edmondlang 760f8684ea fix group payment not showing in wallet transaction history 2023-10-12 13:12:50 +08:00
edmondlang 979b8b2ef9 show accident-approve-invoice 2023-10-12 13:06:51 +08:00
edmondlang 9a0073e906 add company active wallet web 2023-10-12 12:43:35 +08:00
edmondlang 976e54bb4c temporary disable wallet top up 2023-10-11 17:33:22 +08:00
edmondlang 87226377be update packinglist measurement template 2023-10-09 20:38:53 +08:00
edmondlang 674fd84fa0 update packinglist measurement template 2023-10-09 20:31:02 +08:00
edmondlang da1ed10740 update packinglist measurement template 2023-10-09 20:30:36 +08:00
edmondlang eb73d20b00 update packinglist measurement 2023-10-09 20:27:42 +08:00
Jia Sheng Lee 782aed06e4 add callback processor 2023-10-09 13:51:15 +08:00
edmondlang 158fa2eefe Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into add-delivery-order-to-invoice 2023-10-09 00:26:24 +08:00
edmondlang fa4cfc0d75 debug billplz 2023-10-08 23:53:39 +08:00
edmondlang f87bcff930 update packinglist measurement 2023-10-08 21:48:47 +08:00
Dillon e774962c44 Backend validation for generating feedback url 2023-10-08 18:58:43 +08:00
Dillon f5482a29e4 New exception handling for all PerfexCRM services 2023-10-08 17:23:55 +08:00
Dillon 0a14a64fbb Security Patch - Retrieving list of packing list 2023-10-08 16:56:15 +08:00
Dillon ee5051fc26 Merge branch 'dillon/44-customer-satisfaction-feedback-project-e' into dillon/44-customer-satisfaction-feedback-project 2023-10-08 05:25:57 +08:00
Dillon 034c93091a Security Patch - Exporting packinglist data to excel file 2023-10-08 05:25:38 +08:00
Dillon 8b184313cb Error 500 fix 2023-10-08 05:14:03 +08:00
Dillon c2b097e6d1 Merge branch 'dillon/44-customer-satisfaction-feedback-project-e' into dillon/44-customer-satisfaction-feedback-project 2023-10-08 05:12:58 +08:00
Dillon b0195a9640 Merge branch 'dillon/44-customer-satisfaction-feedback-project-d' into dillon/44-customer-satisfaction-feedback-project 2023-10-08 04:55:39 +08:00
Dillon 38d69434fa Security Patch - Exporting packinglist data to excel file 2023-10-08 04:54:38 +08:00
Dillon 1b559f91a2 Security Patch - Exporting feedback data to excel file 2023-10-08 03:50:19 +08:00
edmondlang 05a21af5a6 add line break on top of the file 2023-10-07 18:58:47 +08:00
edmondlang 3e7fbdbafc update packinglist mearuement in invoice 2023-10-07 17:56:47 +08:00
Dillon 527eca50fe Minor UI Fix 2023-10-07 08:42:53 +08:00
Dillon d010a8f8c7 Function for admin to export feedback data 2023-10-07 08:12:52 +08:00
Dillon 7bc2ca512a Function for admin to export feedback data 2023-10-07 07:33:51 +08:00
Dillon b76e0ebeef Merge branch 'dillon/44-customer-satisfaction-feedback-project-a' into dillon/44-customer-satisfaction-feedback-project 2023-10-07 07:33:07 +08:00
Dillon f595c43f2c Function for admin to export feedback data 2023-10-07 07:24:06 +08:00
Dillon 5584d22376 Improvement to log capture thrown by custom exception (ConnectionErrorException), to evaluate if need to extend to other custom exception as well 2023-10-05 19:58:07 +08:00
Dillon 42b6140df7 UX update when system failed to open a support ticket via help menu 2023-10-05 17:30:29 +08:00
Dillon 619fc25605 Merge branch 'dillon/44-customer-satisfaction-feedback-project' into dillon/44-customer-satisfaction-feedback-project-b 2023-10-05 17:04:41 +08:00
Dillon 8c24c86c77 Extra log to capture when ticket not created from Help Menu 2023-10-05 17:02:34 +08:00
Dillon 822046cc69 Updated comments in code 2023-10-05 16:52:42 +08:00
Dillon d708b8b540 404 page when feedback form not found 2023-10-05 16:41:21 +08:00
Jia Sheng Lee 553d2c44aa add delivery order to shipping invoice 2023-10-04 16:53:11 +08:00
Dillon 0f7f5f7ab9 Shorten feedback url 2023-10-04 01:34:45 +08:00
Dillon a5c1ae14b7 Shorten feedback url 2023-10-04 01:02:19 +08:00
Omair Saleh 8f5aa0a861 change ui for feedback answers to use columns instead of rows 2023-10-03 16:11:46 +08:00
Omair Saleh 1bed7f1cc9 change ui for feedback answers to use columns instead of rows 2023-10-03 14:09:46 +08:00
Omair Saleh 0a16e40a23 change ui for feedback answers to use columns instead of rows 2023-10-03 13:53:21 +08:00
Dillon 5c24b6f81e Relocate help menu and make dynamic questionnaire set generation 2023-10-01 00:32:40 +08:00
Dillon b81f3e50ad Filter out help menu questions and answers from been listed in admin feedback q&a list + disabled help menu 2023-09-30 18:45:35 +08:00
Dillon 3f1a8a6d12 Security patch for generating feedback url (for internal and external api calling) 2023-09-30 17:06:36 +08:00
Dillon 2240c1723d Merge branch 'dillon/44-customer-satisfaction-feedback-project' into dillon/44-customer-satisfaction-feedback-project-a 2023-09-30 15:30:10 +08:00
Dillon 5d07598c5e Meeting feedback Fixes and improvement with new sets of questions for customer feedback 2023-09-29 01:45:24 +08:00
edmondlang c493b3786c update credit_note pdf 2023-09-25 22:34:13 +08:00
Dillon e4f60a7bff Limit access to certain api query to admin only 2023-09-25 10:55:47 +08:00
Dillon fe000b7a6f Minor UI fix on front end 2023-09-23 18:07:46 +08:00
Dillon 707ef9d9f3 Minor UI fix on /feedback admin page 2023-09-23 17:36:46 +08:00
Dillon b5abb04c63 Minor UI fix on /feedback admin page 2023-09-23 16:53:18 +08:00
Dillon 1dbad7d6e5 Minor UI fix on navigation 2023-09-23 16:47:58 +08:00
Dillon 25417ba5be New api for public use to get feedback url 2023-09-21 21:31:25 +08:00
Dillon fe67cc6c5b Rename 2023-09-21 20:35:14 +08:00
Dillon 90b85c0df1 Rename 2023-09-21 20:16:22 +08:00
Dillon 0cdff7c544 Fix a problem customer marking cannot be found 2023-09-21 08:04:33 +08:00
Dillon 42561a7c56 New Customer Satisfaction Feedback Module 2023-09-21 00:19:21 +08:00
edmondlang 99f4699260 update wallet credit note 2023-09-15 18:42:14 +08:00
edmondlang 0ea52048e1 update wallet credit note 2023-09-15 18:37:04 +08:00
edmondlang a47bb95e50 update wallet credit note 2023-09-15 18:32:36 +08:00
edmondlang 431aed18d3 update wallet credit note 2023-09-15 18:03:39 +08:00
edmondlang 6ab289057b wallet credit note 2023-09-15 17:34:16 +08:00
JiaSheng c55a8e7af9 fix account statement mapping issue 2023-09-14 14:59:02 +08:00
Dillon 60fbe77829 Merge branch 'dillon/crisp-help-menu-2' into dillon/44-customer-satisfaction-feedback-project 2023-09-14 10:28:04 +08:00
Omair Saleh fbf097eb62 fix wallet transaction history and top up list bug 2023-09-13 14:22:36 +08:00
Omair Saleh 30c2673fdf fix wallet transaction history and top up list bug 2023-09-13 13:59:49 +08:00
Omair Saleh fd3709e103 fix wallet transaction history and top up list bug 2023-09-13 13:59:08 +08:00
Omair Saleh 08473d85ab fix wallet transaction history and top up list bug 2023-09-13 13:58:29 +08:00
Omair Saleh 489974ca5a fix wallet transaction history and top up list bug 2023-09-13 13:55:21 +08:00
Omair Saleh 6a6a0f0ee7 fix wallet transaction history and top up list bug 2023-09-13 13:46:20 +08:00
Omair Saleh 402f64364b export arrived parcel improvements 2023-09-01 05:27:13 +08:00
Omair Saleh a3bff9d079 export arrived parcel improvements 2023-09-01 05:26:32 +08:00
Omair Saleh 2a7a448059 export arrived parcel improvements 2023-09-01 05:25:41 +08:00
Omair Saleh 7d855064da export arrived parcel improvements 2023-09-01 05:24:47 +08:00
Omair Saleh efc0a3b94e export arrived parcel improvements 2023-09-01 05:24:05 +08:00
Omair Saleh 01654ee0d3 export arrived parcel improvements 2023-09-01 05:22:58 +08:00
Omair Saleh 23c2f92e6d export arrived parcel improvements 2023-09-01 05:21:32 +08:00
Omair Saleh 3945c47f52 export arrived parcel improvements 2023-09-01 05:20:36 +08:00
Omair Saleh 51ab6ce48b export arrived parcel improvements 2023-09-01 05:19:33 +08:00
Omair Saleh ca8140a1ba export arrived parcel improvements 2023-09-01 05:17:35 +08:00
Omair Saleh a84580c1dd export arrived parcel improvements 2023-09-01 05:14:07 +08:00
Omair Saleh 63b212a66c export arrived parcel improvements 2023-09-01 05:13:21 +08:00
Omair Saleh 7979d89997 export arrived parcel improvements 2023-09-01 05:00:36 +08:00
Omair Saleh bc603fc125 Merge remote-tracking branch 'origin/master' 2023-09-01 04:54:17 +08:00
Omair Saleh b55fd49830 export arrived parcel improvements 2023-09-01 04:54:00 +08:00
edmondlang 60ceac645f fix bug invoices/approve 2023-08-24 14:36:47 +08:00
Dillon Ngo 90c599049b Merge branch 'dillon/42-crm-code-sync-with-exchange-b' into 'master'
CRM invoice decimal problem fix + fetch invoice fail fix + debug log update

See merge request CIEFWorldwideSdnBhd/shipping-portal!170
2023-08-23 20:59:33 +00:00
Dillon f538fb7f2f Post Deployment monitoring: CRM invoice decimal problem fix + fetch invoice fail fix + debug log update 2023-08-24 04:52:34 +08:00
Omair Saleh a45105f5ae fix yd api 2023-08-23 14:08:47 +08:00
Omair Saleh 2f1a8ee648 fix yd api 2023-08-23 14:06:43 +08:00
Omair Saleh aacf4ea53d fix yd api 2023-08-23 14:05:15 +08:00
Omair Saleh 1fa2b60871 fix duplicate packages 2023-08-22 15:40:44 +08:00
Omair Saleh 203dc0c230 fix duplicate packages 2023-08-22 15:39:42 +08:00
Omair Saleh fcc4da1a56 fix duplicate packages 2023-08-22 15:24:38 +08:00
Omair Saleh c5a49bbc44 fix duplicate packages 2023-08-22 15:21:47 +08:00
Omair Saleh f8131b3a1e fix duplicate packages 2023-08-22 15:20:06 +08:00
Omair Saleh 336cc0b37f Merge remote-tracking branch 'origin/master' 2023-08-22 15:05:58 +08:00
Omair Saleh 42f096b09c fix duplicate packages 2023-08-22 15:01:44 +08:00
Dillon Ngo 614167cac5 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
Update condition to update CRM task status

See merge request CIEFWorldwideSdnBhd/shipping-portal!169
2023-08-20 08:02:07 +00:00
Dillon e5421f8810 Update condition to update CRM task status 2023-08-20 15:57:51 +08:00
Dillon Ngo 8dc84baee0 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
CRM Integration (Part 2 of code sync with Exchange-2.0)

See merge request CIEFWorldwideSdnBhd/shipping-portal!168
2023-08-19 21:43:07 +00:00
Dillon a413533975 CRM Integration (Part 2 of code sync with Exchange-2.0) 2023-08-20 05:30:54 +08:00
Dillon Ngo 0a98f8a8c6 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
Quick fix

See merge request CIEFWorldwideSdnBhd/shipping-portal!167
2023-08-18 04:14:46 +00:00
Dillon aceed5f754 Quick fix 2023-08-18 12:13:47 +08:00
Dillon Ngo 761d191c1d Merge branch 'dillon/42-crm-code-sync-with-exchange' into 'master'
Exchange-2.0 code sync for crm changes

See merge request CIEFWorldwideSdnBhd/shipping-portal!166
2023-08-17 13:58:09 +00:00
Dillon d769be137e Exchange-2.0 code sync for crm changes 2023-08-17 21:49:48 +08:00
Dillon d6a5dd56c6 Exchange-2.0 code sync for crm changes 2023-08-17 21:34:18 +08:00
Omair Saleh f279d39ddb fix yd bug 2023-08-15 13:50:22 +08:00
Omair Saleh 2e1e8875b4 fix yd bug 2023-08-15 13:47:53 +08:00
Omair Saleh c30c5a36f2 fix yd bug 2023-08-15 13:46:24 +08:00
Omair Saleh 7d3901ee48 fix yd bug 2023-08-15 13:41:00 +08:00
Omair Saleh 463398945f fix yd bug 2023-08-15 13:40:18 +08:00
Omair Saleh d619862e63 fix yd bug 2023-08-15 13:38:18 +08:00
Omair Saleh 9665a0e242 fix yd bug 2023-08-14 15:43:02 +08:00
Omair Saleh 7ed6c11f37 fix yd bug 2023-08-14 15:40:40 +08:00
Omair Saleh 3eaee0d122 fix yd bug 2023-08-14 15:35:47 +08:00
Omair Saleh b7816873fe fix yd bug 2023-08-14 15:30:05 +08:00
Omair Saleh 8809caa046 Merge remote-tracking branch 'origin/master' 2023-08-14 14:55:35 +08:00
Omair Saleh b8b6910a45 fix yd quantity is not a number bug 2023-08-14 14:55:21 +08:00
edmondlang 64bfbac4f7 update manual generate warehouse packinglist 2023-08-03 14:30:45 +08:00
edmondlang a5b7e79964 manual generate warehouse packinglist 2023-08-03 13:45:07 +08:00
edmondlang 03c9bec256 fix-duplicate-container-reference cron 2023-08-01 00:04:20 +08:00
edmondlang 06134e006c fix deleted packinglist 2023-07-23 15:42:35 +08:00
Omair Saleh 7563b455ba update yd updates link 2023-07-21 12:40:56 +08:00
Omair Saleh 26edb3bebd Merge remote-tracking branch 'origin/master' 2023-07-21 12:34:35 +08:00
Omair Saleh 55e1a6ad02 remove all customer from vt warehouse list 2023-07-21 12:34:19 +08:00
edmondlang 381425c6bc update export mappable transaction 2023-07-18 12:53:00 +08:00
edmondlang 09ab95faf8 update listing mapping transaction 2023-07-18 11:54:27 +08:00
edmondlang 8bb6f0317a update list mappable transactino details log 2023-07-11 17:59:43 +08:00
edmondlang fe95db2605 update list mappable transactino details log 2023-07-11 17:48:09 +08:00
edmondlang 02640e6ae8 update list mappable transactino details log 2023-07-11 17:39:09 +08:00
Omair Saleh 104dd19a6f Merge remote-tracking branch 'origin/master' 2023-07-10 12:52:35 +08:00
Omair Saleh 89117c0706 debug yd api 2023-07-10 12:51:59 +08:00
edmondlang bc650b0816 update public endpoint for exchange to get transaction data for accounting mapping 2023-07-09 22:01:35 +08:00
edmondlang a6a239c489 add public endpoint for exchange to get transaction data for accounting mapping 2023-07-09 21:54:56 +08:00
edmondlang 45b78465da add debtor code in company module resource for exchange accounting mapping purpose 2023-07-07 00:59:48 +08:00
Omair Saleh 71edeca994 Merge remote-tracking branch 'origin/master' 2023-07-05 14:18:02 +08:00
Omair Saleh cd229c6a8f fix the invoice export format 2023-07-05 14:17:43 +08:00
450 changed files with 6833 additions and 6994 deletions
+2 -4
View File
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=shpping_portal
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
@@ -56,8 +56,6 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
YD_API_CODE=''
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
PERFEXCRM_BASE_URL=""
PERFEXCRM_API_KEY=""
PERFEXCRM_IS_ENABLED="false"
-59
View File
@@ -1,59 +0,0 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=shpping_portal
DB_USERNAME=root
DB_PASSWORD=P@ssw0rd
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
UNITY_APP_URL="https://unity.izyim.com"
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
YD_API_CODE=''
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
-2
View File
@@ -2,8 +2,6 @@
/public/hot
/public/storage
/storage/*.key
/tests/_output
/tests/_support
/vendor
**/.idea/
.env
-120
View File
@@ -1,120 +0,0 @@
image: php:7.4
stages:
- service_build
- node
- building_assets
- database
- unit_test
- acceptance_test
- code_quality
# Variables
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: mysql_password
MYSQL_PASSWORD: mysql_password
MYSQL_DATABASE: shpping_portal
DB_HOST: mysql
before_script:
- apt-get update -yqq
- apt-get install -yqq
- apt-get install -y libonig-dev
- apt-get install -y libxml2-dev
- apt-get install -y libzip-dev
- apt-get install -y libgd-dev
- apt-get install -y libgd-dev
# Install PDO MySQL extension
- docker-php-ext-install pdo_mysql
#install php dependencies
- docker-php-ext-install mbstring xml zip gd
# Install composer package manager
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
- chmod +x /usr/local/bin/composer
# Install MySQL client
- apt-get install -y default-mysql-client
#install node js
- apt-get update && apt-get install -y nodejs npm
#install gulp Js
- npm install -g gulp-cli
#jobs
#buld the backend
composer_php:
stage: service_build
script:
- composer install
- cp .env.example .env
- php artisan key:generate
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#build the UI
#node installation
npm:
stage: node
script:
- npm install # Install npm dependencies
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#building assets
building_assets:
stage: building_assets
# dependencies:
# - npm
script:
- npm install # Install npm dependencies
- gulp build # Build assets
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#mysql
database:
stage: database
services:
- name: mysql:8.0
command: [ "--default-authentication-plugin=mysql_native_password" ]
#dependencies:
# - composer_php
script:
- composer install
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:fresh
- php artisan db:seed
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#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 =~ /.*/'
+43 -20
View File
@@ -1,39 +1,62 @@
## Shipping portal documentation
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
simple documentation on how to install, run, test, commit and deploy application
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## creating and running unit tests
## About Laravel
Required Tools
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Chromium Driver / selenium
- add running and setting selenium on all OS if possible
- [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).
Required Packages :
Laravel is accessible, powerful, and provides tools required for large, robust applications.
- laravel/legacy-factories
## Learning Laravel
- codeception/codeception
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
Or Simply Run
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
``Composer install``
## Laravel Sponsors
To create a unit test
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
``php artisan make test: Test Example --unit``
### Premium Partners
Running the tests :
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
Running a single Test
## Contributing
`` php artisan test --filter Example``
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
Running Unit tests -
## Code of Conduct
`` php artisan test ``
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
Running Codeception tests -
## Security Vulnerabilities
``vendor/bin/codecept run``
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
use Illuminate\Support\Facades\Log;
final class ConnectionErrorException extends ServiceApiException {
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
Log::error($message. ": ". $exceptionMessage);
if($payload){
Log::error('Payload: '.$payload);
}
if($exceptionTrace){
Log::error($exceptionTrace);
}
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
HttpStatus::SERVER_ERROR);
}
}
@@ -0,0 +1,97 @@
<?php
namespace App\Classes\General\Abstracts;
use App\Classes\Exceptions\ErrorException;
use App\Classes\Exceptions\InternalServerErrorException;
use App\Classes\ValueObjects\Constants\Notifications;
use App\Classes\ValueObjects\Constants\HttpStatus;
use App\Classes\ValueObjects\Response\ApiResponseObject;
use ErrorException as GeneralExceptions;
use TypeError;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Facades\DB;
abstract class Abstract2ControllerLogic
{
/**
* @return array
*/
abstract protected function notification(): array;
/**
* @return string
*/
private function getNotificationTitle():string {
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
}
/**
* @return string
*/
private function getNotificationMessage():string {
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
}
/**
* @param Request $request
* @return BinaryFileResponse
* @throws ErrorException
*/
abstract protected function logic(Request $request) : BinaryFileResponse;
/**
* @param Request $request
* @return BinaryFileResponse
*/
public function execute(Request $request) : BinaryFileResponse {
try {
DB::beginTransaction();
$response = $this->logic($request);
DB::commit();
return $response;
} catch (ErrorException|GeneralExceptions|TypeError $exception){
abort(404, $exception->getMessage());
}
}
/**
* @param array|null $data
* @return JsonResponse
*/
public function response(?array $data = []) : JsonResponse {
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
$this->getNotificationMessage(),
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
}
/**
* @param JsonResource $resource
* @return JsonResponse
*/
public function resourceResponse(JsonResource $resource){
return $this->response(['data' => $resource]);
}
/**
* @param ResourceCollection $collection
* @return JsonResponse
*/
public function collectionResponse(ResourceCollection $collection){
return $this->response(json_decode($collection->response()->getContent(), true));
}
}
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
abstract class AbstractRule
{
abstract protected function authorized(): bool;
abstract protected function authorized($object): bool;
abstract protected function validators($object): bool;
@@ -26,8 +26,8 @@ abstract class AbstractRule
*/
public function passes(?DataTransferObject $object = null): bool {
try {
if(!$this->authorized()){
throw new AccessForbiddenException('You don\'t have permission to preform this action');
if(!$this->authorized($object)){
throw new AccessForbiddenException('You don\'t have permission to perform this action');
}
$this->validators($object);
@@ -36,11 +36,11 @@ abstract class AbstractRule
return true;
} catch(AccessForbiddenException $exception){
throw new AccessForbiddenException('You don\'t have permission to preform this action');
throw new AccessForbiddenException('You don\'t have permission to perform this action');
} catch(\Exception $exception){
throw new RequestValidationException($exception->getMessage());
}
}
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class HasQuestionnaireGroupIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('question.questionnaire', function (Builder $query) use ($value) {
$query->whereIn('group', $value);
});
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class PaymentMethodNotIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereNotIn('payment_method', $value);
}
}
@@ -4,7 +4,7 @@ namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class OwnerType implements Filter
class ShortUrl implements Filter
{
/**
@@ -14,7 +14,7 @@ class OwnerType implements Filter
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('owner_type', $value);
return $builder->where('short_url', $value);
}
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Builder;
class WithAgingColumn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
$today = Carbon::now();
return $builder->select('packing_lists.*')
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
->addSelect(DB::raw("CASE
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
ELSE 4
END AS due_date_number"));
}
}
+3 -4
View File
@@ -24,12 +24,11 @@ class Helper
return array_slice(get_class_methods($className), 1);
}
/**
/**
* @param $log
* @return none
*/
static function debugLoggerForPerfexCRM($log){
if($log){
static function debugLogger($log){
if($log && isset($log['message'])){
$message = $log['message'];
$substring = 'No data were found';
if (isset($message)) {
+28 -10
View File
@@ -3,6 +3,8 @@
namespace App\Classes\Jobs;
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@@ -10,6 +12,8 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
class UpdatePerfexCRM implements ShouldQueue
{
@@ -18,37 +22,51 @@ class UpdatePerfexCRM implements ShouldQueue
/** @var UpdatePerfexCRMObject */
private $updatePerfexCRMObject;
/** @var UpdatePerfexCRMInvoice */
private $nextJob;
/** @var */
private $transaction;
/** @var bool|null */
private $shouldCreateInvoice;
/**
* UpdatePerfexCRM constructor.
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
* @param UpdatePerfexCRMInvoice $nextJob
* @param $transaction
* @param Transaction $transaction
* @param bool|null $shouldCreateInvoice
*/
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
{
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
$this->nextJob = $nextJob;
$this->transaction = $transaction;
$this->shouldCreateInvoice = $shouldCreateInvoice;
}
public function handle()
{
//To use invoice as a reference to decide whether more tasks should be created
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
if($this->nextJob != null && $this->transaction != null){
if($this->transaction != null && $this->shouldCreateInvoice){
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
$this->updatePerfexCRMObject->getContactEmail(),
$result->projectId,
$this->transaction,
true
);
/** @var UpdatePerfexCRMInvoice $nextJob */
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
}
}
private function getInvoiceIdOrCreateInvoice(){
if($this->transaction != null){
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
$this->updatePerfexCRMObject->getContactEmail(),
$this->transaction
);
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
return $invoiceId;
}
return 0;
}
}
+4 -7
View File
@@ -11,16 +11,14 @@ 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 Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use App\Classes\General\Helper;
class UpdatePerfexCRMInvoice implements ShouldQueue
@@ -32,7 +30,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
/**
* CreatePerfexCRMSingleTask constructor.
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
*/
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
{
@@ -49,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
$invoiceId = 0;
$invoiceStatus = 0;
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
Log::error(json_encode('UpdatePerfexCRMInvoice debug $transaction->owner->bill_no: '.$transaction->owner->bill_no));
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
if(is_null($invoice)){
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
@@ -57,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
$invoiceId = $result->payload['id'];
} else {
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
}
}
else{
@@ -66,7 +64,6 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
//This only run when invoice already exist and the invoice does not have a PAID status
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
Log::error(json_encode('UpdatePerfexCRMInvoice debug $this->updatePerfexCRMInvoiceObject->getProjectId(): '.$this->updatePerfexCRMInvoiceObject->getProjectId()));
//update invoice
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
}
+7 -14
View File
@@ -27,27 +27,22 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
/** @var UpdatePerfexCRMObject */
private $updatePerfexCRMObject;
/** @var UpdatePerfexCRM */
private $nextJob1;
/** @var UpdatePerfexCRMInvoice */
private $nextJob2;
/** @var bool|null */
private $shouldCreateInvoice;
/**
* UpdatePerfexCRMPrelude constructor.
* @param $packingList
* @param $transaction
* @param Transaction $transaction
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
* @param UpdatePerfexCRM $nextJob1
* @param UpdatePerfexCRMInvoice $nextJob2
* @param bool|null $shouldCreateInvoice
*/
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
{
$this->packingList = $packingList;
$this->transaction = $transaction;
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
$this->nextJob1 = $nextJob1;
$this->nextJob2 = $nextJob2;
$this->shouldCreateInvoice = $shouldCreateInvoice;
}
public function handle()
@@ -69,9 +64,7 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
$this->updatePerfexCRMObject->setTasks($result);
/** @var UpdatePerfexCRM $nextJob1 */
/** @var UpdatePerfexCRMInvoice $nextJob2 */
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
}
function replacePlaceholders($template, $data, $prefix = '')
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -54,4 +54,4 @@ class CanAuthenticateUser extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanCreateUser extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -51,4 +51,4 @@ class CanCrossAuthenticateUser extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanDeleteUser extends AbstractRule
return true;
}
}
}
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -39,4 +39,4 @@ class CanFetchUser extends AbstractRule
return true;
}
}
}
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -62,4 +62,4 @@ class CanGeneratePasswordReset extends AbstractRule
}
}
}
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -39,4 +39,4 @@ class CanListUsers extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanRegisterUser extends AbstractRule
{
return true;
}
}
}
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
@@ -62,4 +62,4 @@ class CanResetPassword extends AbstractRule
return $this->passwordResetTokenExists->execute($object->getToken());
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanUpdateUser extends AbstractRule
return true;
}
}
}
@@ -3,9 +3,6 @@
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;
@@ -20,7 +17,6 @@ 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;
@@ -31,8 +27,7 @@ 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'
@@ -79,11 +74,11 @@ class CreateAddressLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @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')]);
@@ -95,22 +90,16 @@ 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,9 +3,6 @@
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;
@@ -17,7 +14,6 @@ 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;
@@ -27,8 +23,7 @@ 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'
@@ -65,35 +60,27 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\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')]);
$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) {
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
// delete all current billing address
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
// create new billing addrress
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
// 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);
$this->canCreateAddress->passes($billingAddress);
$this->createsAddress->execute($companyModule, $billingAddress);
}
//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));
return $this->resourceResponse(new AddressResource($address));
}
}
@@ -3,8 +3,6 @@
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;
@@ -19,8 +17,7 @@ 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'
@@ -48,22 +45,15 @@ class FetchAddressLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\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,14 +3,10 @@
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;
@@ -21,8 +17,7 @@ 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'
@@ -50,25 +45,17 @@ class ListAddressesLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\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,6 +7,7 @@ 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,6 +7,7 @@ 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,7 +9,6 @@ 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;
@@ -34,7 +33,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
/** @var ResetsAddressesDefault */
private $resetsAddressesDefault;
/** @var SetsAddressToDefault */
/** @var SetsAddressToDefault*/
private $setsAddressToDefault;
@@ -65,15 +64,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
$this->resetsAddressesDefault->execute($address->owner, $address->type);
$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));
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
}
}
@@ -17,7 +17,6 @@ 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;
@@ -27,8 +26,7 @@ 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'
@@ -79,7 +77,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')]);
@@ -92,25 +90,18 @@ 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));
}
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanCreateAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanDeleteAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanFetchAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanListAddresses extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -54,4 +54,4 @@ class CanUpdateAddress extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -47,4 +47,4 @@ class CanCreateAnnouncement extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanDeleteAnnouncement extends AbstractRule
return true;
}
}
}
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanUpdateAnnouncement extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -47,4 +47,4 @@ class CanCreateBank extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanDeleteBank extends AbstractRule
return true;
}
}
}
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
return true;
}
@@ -34,4 +34,4 @@ class CanListBanks extends AbstractRule
{
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanUpdateBank extends AbstractRule
return true;
}
}
}
@@ -14,6 +14,7 @@ use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
@@ -46,6 +47,9 @@ class CallbackBillplzLogic
/** @var CreatePaymentTransactionProcessor */
private $createPaymentTransactionProcessor;
/** @var CallbackBillplzProcessor */
private $callbackBillplzProcessor;
/**
* CallbackBillplzLogic constructor.
* @param GetBillplzBill $getBillplzBill
@@ -54,8 +58,9 @@ class CallbackBillplzLogic
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
* @param CallbackBillplzProcessor $callbackBillplzProcessor
*/
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CallbackBillplzProcessor $callbackBillplzProcessor)
{
$this->getBillplzBill = $getBillplzBill;
$this->fetchesTransaction = $fetchesTransaction;
@@ -64,6 +69,7 @@ class CallbackBillplzLogic
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
$this->updatesWalletBalance = $updatesWalletBalance;
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
}
@@ -106,41 +112,7 @@ 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);
}
// group payment
if ($transaction->type == TransactionType::GROUP_PAYMENT && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
$group = Group::where('reference', $billplzXSignatureObject->getBillPlzId())->first();
foreach($group->groupTransactions as $groupTransaction) {
$invoice = $groupTransaction->transaction;
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
}
$group->status = $status;
$group->save();
}
$this->updatesTransactionStatus->execute($transaction, $status);
if (!$transaction->owner instanceof Wallet) {
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
if(($invoice->amount - $totalPaidAmount) < 0.01) {
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
$packingList->status = ApprovalStatus::APPROVED;
$packingList->save();
if(app()->environment('production')){
$this->updateDoFromVTPortalProcessor->execute($packingList);
$this->updateDoFromYDPortalProcessor->execute($packingList);
}
}
}
$this->callbackBillplzProcessor->execute($transaction, $status);
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
@@ -0,0 +1,98 @@
<?php
namespace App\Classes\Modules\Billplzs\Processors;
use Illuminate\Http\Request;
use App\Models\Wallet;
use App\Models\Group;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
class CallbackBillplzProcessor
{
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/** @var UpdateDoFromVTPortalProcessor */
private $updateDoFromVTPortalProcessor;
/** @var UpdateDoFromYDPortalProcessor */
private $updateDoFromYDPortalProcessor;
/** @var UpdatesWalletBalance */
private $updatesWalletBalance;
/** @var CreatePaymentTransactionProcessor */
private $createPaymentTransactionProcessor;
/**
* CreateUserProcessor constructor.
* @param UpdatesTransactionStatus $updatesTransactionStatus
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
* @param UpdatesWalletBalance $updatesWalletBalance
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
*/
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
{
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
$this->updatesWalletBalance = $updatesWalletBalance;
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
}
/**
* @param Request $request
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute($transaction, $status)
{
$invoice = $transaction->owner;
$packingList = $invoice->owner;
$this->updatesTransactionStatus->execute($transaction, $status);
// check if is wallet top up
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
$group = Group::where('reference', $transaction->payment_reference)->first();
// check if is group payment
if ($group) {
foreach ($group->groupTransactions as $groupTransaction) {
$invoice = $groupTransaction->transaction;
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
}
$group->status = $status;
$group->save();
}
}
if (!$transaction->owner instanceof Wallet) {
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
if (($invoice->amount - $totalPaidAmount) < 0.01) {
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
$packingList->status = ApprovalStatus::APPROVED;
$packingList->save();
if (app()->environment('production')) {
$this->updateDoFromVTPortalProcessor->execute($packingList);
$this->updateDoFromYDPortalProcessor->execute($packingList);
}
}
}
}
}
@@ -3,16 +3,13 @@
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\ListsCompanies;
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
use App\Transformers\CompanyTransformer;
use App\Http\Resources\CompanyResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Spatie\Fractalistic\ArraySerializer;
class ListCompaniesLogic extends AbstractControllerLogic
{
@@ -48,24 +45,16 @@ class ListCompaniesLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
{
$this->canListCompanies->passes();
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
// return $this->collectionResponse(CompanyResource::collection($query));
return fractal()
->parseIncludes(['owner'])
->collection($query, new CompanyTransformer(), "data")
->serializeWith(new ArraySerializer())
->respond(200, [], JSON_PRETTY_PRINT);
return $this->collectionResponse(CompanyResource::collection($query));
}
@@ -3,14 +3,10 @@
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;
@@ -21,8 +17,7 @@ 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'
@@ -50,26 +45,15 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\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));
}
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanAssignEmployee extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanCreateCompany extends AbstractRule
{
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateCompanyModule extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchCompany extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanFetchCompany extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanListCompanies extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanListCompanies extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanUpdateCompany extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanUpdateCompany extends AbstractRule
{
return true;
}
}
}
@@ -8,7 +8,6 @@ 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;
@@ -64,13 +63,6 @@ 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));
}
@@ -26,7 +26,7 @@ class CanCreateContact extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanCreateContact extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -48,4 +48,4 @@ class CanCreateCurrency extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanDeleteCurrency extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanFetchCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -37,4 +37,4 @@ class CanFetchCurrency extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanListCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -38,4 +38,4 @@ class CanListCurrency extends AbstractRule
return true;
}
}
}
@@ -26,7 +26,7 @@ class CanUpdateCurrency extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -51,4 +51,4 @@ class CanUpdateCurrency extends AbstractRule
return true;
}
}
}
@@ -24,7 +24,7 @@ class CanCreateRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
if (!\Auth::user()->can('add currency_rate')) {
@@ -52,4 +52,4 @@ class CanCreateRate extends AbstractRule
{
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanDeleteRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -42,4 +42,4 @@ class CanDeleteRate extends AbstractRule
return true;
}
}
}
@@ -13,7 +13,7 @@ class CanFetchRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -40,4 +40,4 @@ class CanFetchRate extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanListRates extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -42,4 +42,4 @@ class CanListRates extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanUpdateRate extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
@@ -55,4 +55,4 @@ class CanUpdateRate extends AbstractRule
return true;
}
}
}
@@ -7,7 +7,6 @@ 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;
@@ -53,14 +52,6 @@ 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,12 +172,6 @@ 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,12 +48,6 @@ 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));
}
@@ -3,21 +3,13 @@
namespace App\Classes\Modules\Documents\ControllersLogic;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\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\Serializer\ArraySerializer;
use League\Fractal;
class ListDocumentLogic extends AbstractControllerLogic
{
@@ -25,8 +17,7 @@ class ListDocumentLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification(): array
{
protected function notification():array {
return [
'title' => 'Retrieved Document',
'message' => 'You have successfully retrieved a list of Document'
@@ -54,29 +45,19 @@ class ListDocumentLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request): JsonResponse
public function logic(Request $request) : JsonResponse
{
$this->canListDocuments->passes();
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
$data = fractal()
->parseIncludes(['owner'])
->collection($query, new DocumentTransformer, "data")
->serializeWith(new ArraySerializer())
->respond(200, [], JSON_PRETTY_PRINT);
return $data;
return $this->collectionResponse(DocumentResource::collection($query));
}
}
@@ -2,7 +2,6 @@
namespace App\Classes\Modules\Documents\DataTransferObjects;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\General\Interfaces\DataTransferObject;
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
@@ -69,7 +68,7 @@ class DocumentObject implements DataTransferObject
/**
* @return array
* @throws MalformedRequestException
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function getFiles(): array
{
@@ -32,12 +32,12 @@ class UploadDocumentForHelpMenuProcessor
/**
* @param Request $request
* @param $filesUpload
* @param QAUserAnswerSelected qaUserAnswerSelected
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Request $request, QAUserAnswerSelected $qaUserAnswerSelected) {
$object = new DocumentObject("HELP_MENU", $request->input('files'),
public function execute($filesUpload, QAUserAnswerSelected $qaUserAnswerSelected) {
$object = new DocumentObject("HELP_MENU", $filesUpload,
'123456', ApprovalStatus::PENDING_VERIFICATION, 'help_menu'); //cief todo: 123456 cannot be hardcoded
/** @var Document $document */
@@ -97,8 +97,7 @@ class ConvertsBase64ToFile
* @return string
* @throws MalformedRequestException
*/
private function generateFile(FileObject $file, string $suffix = ''): string
{
private function generateFile(FileObject $file, string $suffix = '') {
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
@@ -12,7 +12,7 @@ class CanApproveDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanApproveDocument extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanCreateDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -50,4 +50,4 @@ class CanCreateDocument extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanCreateFile extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -50,4 +50,4 @@ class CanCreateFile extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanListDocuments extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
/*
@@ -44,4 +44,4 @@ class CanListDocuments extends AbstractRule
return true;
}
}
}
@@ -10,7 +10,7 @@ class CanRenderDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanRenderDocument extends AbstractRule
return true;
}
}
}
@@ -25,7 +25,7 @@ class CanUpdateDocument extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -50,4 +50,4 @@ class CanUpdateDocument extends AbstractRule
return true;
}
}
}
@@ -11,7 +11,7 @@ class CanUpdateDocumentReference extends AbstractRule
/**
* @return bool
*/
protected function authorized(): bool
protected function authorized($object): bool
{
// TODO Set Authorization rules
return true;
@@ -36,4 +36,4 @@ class CanUpdateDocumentReference extends AbstractRule
return true;
}
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Classes\Modules\Exports\ControllersLogic;
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
use App\Classes\Modules\Exports\Services\ExportsFeedback;
use App\Classes\Modules\Exports\Standards\Rules\CanExportFeedback;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Maatwebsite\Excel\Excel;
class ExportFeedbackDataLogic extends Abstract2ControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Feedback',
'message' => 'You have successfully exported feedback data'
];
}
/** @var ExportsFeedback */
private $exportsFeedback;
/** @var CanExportFeedback */
private $canExportFeedback;
/**
* ExportFeedbackDataLogic constructor.
* @param ExportsFeedback $exportsFeedback
* @param CanExportFeedback $canExportFeedback
*/
public function __construct(ExportsFeedback $exportsFeedback, CanExportFeedback $canExportFeedback)
{
$this->exportsFeedback = $exportsFeedback;
$this->canExportFeedback = $canExportFeedback;
}
/**
* @param Request $request
* @return Response
*/
public function logic(Request $request) : BinaryFileResponse
{
$this->canExportFeedback->passes();
$response = $this->exportsFeedback->download('feedback.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
ob_end_clean();
return $response;
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Classes\Modules\Exports\ControllersLogic;
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
use App\Classes\Modules\Exports\Standards\Rules\CanExportPackingList;
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Maatwebsite\Excel\Excel;
class ExportPackingListLogic extends Abstract2ControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved PackingList',
'message' => 'You have successfully exported PackingList'
];
}
/** @var ExportsOnHoldPackingList */
private $exportsOnHoldPackingList;
/** @var ExportsPendingArrangementDeliveryList */
private $exportsPendingArrangementDeliveryList;
/** @var CanExportPackingList */
private $canExportPackingList;
/**
* ExportPackingListLogic constructor.
* @param ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList
* @param ExportsOnHoldPackingList $exportsOnHoldPackingList
* @param CanExportPackingList $canExportPackingList
*/
public function __construct(ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList, ExportsOnHoldPackingList $exportsOnHoldPackingList, CanExportPackingList $canExportPackingList)
{
$this->exportsPendingArrangementDeliveryList = $exportsPendingArrangementDeliveryList;
$this->exportsOnHoldPackingList = $exportsOnHoldPackingList;
$this->canExportPackingList = $canExportPackingList;
}
/**
* @param Request $request
* @return Response
*/
public function logic(Request $request) : BinaryFileResponse
{
$this->canExportPackingList->passes();
$isSetPendingArrangement = $request->header('PendingArrangement');
if($isSetPendingArrangement){
$response = $this->exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
}
else {
$response = $this->exportsOnHoldPackingList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
}
ob_end_clean();
return $response;
}
}
@@ -0,0 +1,98 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Models\Order;
use App\Models\PackingList;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use DateTime;
class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
{
use Exportable;
private $filters;
public function __construct()
{
$this->filters = [
"has_invoice_status_in" => [2],
"packing_list_ordered_by_invoice_date" => true,
"with_aging_column" => true
];
}
public function headings(): array
{
return [
'Company Name',
'Customer Marking',
'Order Number',
'Invoice No',
'Invoice Date',
'Days',
'Amount',
];
}
public function query()
{
return (new ApplyFiltersToQuery())->execute(PackingList::query(), $this->filters);
}
public function map($list): array
{
$marking = null;
$orderNo = null;
$name = null;
$invDate = 'n/a';
$invNo = 'n/a';
$days = 'n/a';
if ($list->owner instanceof Order) {
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
if ($inviterPivotInviteeReference) {
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
$orderNo = $list->owner->reference;
}
$name = $list->owner->companyModule->company->name;
}
$transaction = $list->transactions()->whereIn('status', [ApprovalStatus::APPROVED])->first();
if ($transaction) {
$invoiceDate = $transaction->created_at;
$invDate = date_format($invoiceDate, 'd-m-Y');
$invNo = $transaction->bill_no;
$amt = number_format($transaction->amount, 2);
$currentDate = new DateTime();
$interval = $currentDate->diff($invoiceDate);
$days = $interval->format('%a');
}
return [
$name,
$marking,
$orderNo,
$invNo,
$invDate,
$days,
$amt,
];
}
private function dueDateColumn($colNum, $dueDateNumber, $amt)
{
if ($colNum == $dueDateNumber) return $amt;
return null;
}
}
@@ -15,9 +15,17 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
{
use Exportable;
private $start_date;
private $end_date;
public function __construct($start_date = null, $end_date = null)
{
$this->start_date = $start_date;
$this->end_date = $end_date;
}
public function headings(): array
{
return [
@@ -26,38 +34,49 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
'Warehouse',
'Cbm',
'Description',
'quantity',
'Quantity',
'Received Date',
'Recorded On',
'Days to Record',
'Remarks'
];
}
/**
* @return \Illuminate\Support\Collection|mixed
*/
public function query()
{
return PackingList::where('type', '=', 1)->where('status', '=', 2)->where('owner_type', Order::class);
$query = PackingList::with([
'owner.companyModule.inviters',
'owner.orderRoles',
'packages',
'transports'
])
->where('type', '=', 1)
->where('status', '=', 2)
->where('owner_type', Order::class);
if (!is_null($this->start_date) && !is_null($this->end_date)) {
$query->whereHas('transports', function ($q) {
$q->whereBetween('drop_date', [
Carbon::parse($this->start_date)->startOfDay(),
Carbon::parse($this->end_date)->endOfDay()
]);
});
}
return $query;
}
/**
* @param $packingList
* @return array
*/
public function map($packingList): array
{
$order = $packingList->owner;
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
$marking = $connection ? $connection->pivot->invitee_reference:'';
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
$cbm = $packingList->packages->sum(function($package){
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
$marking = $order->companyModule->getMarking();
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
$cbm = $packingList->packages->sum(function ($package) {
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
});
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
$arrival_date = $packingList->transports->first()->drop_date->format('d-m-Y');
$recorded_on = $packingList->created_at->format('d-m-Y');
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
return [
$packingList->owner->reference,
@@ -67,7 +86,9 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
$packingList->packages->implode('description', ', '),
$packingList->packages->sum('quantity'),
$arrival_date,
$recorded_on,
$days_to_record,
''
];
}
}
}
@@ -0,0 +1,70 @@
<?php
namespace App\Classes\Modules\Exports\Services;
use App\Models\QAUserAnswerSelected;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use App\Classes\ValueObjects\Constants\QASystemSourceType;
use Carbon\Carbon;
class ExportsFeedback implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
{
use Exportable;
public function headings(): array
{
return [
'Question Set',
'Question Text',
'Answer',
'Source System',
'Source Marking',
'Source Email',
'Created Date'
];
}
/**
* @return \Illuminate\Support\Collection|mixed
*/
public function query()
{
return QAUserAnswerSelected::whereHas('question', function ($query) {
$query->whereHas('questionnaire', function ($innerQuery) {
$innerQuery->where('group', 'feedback');
})->where('created_at', '>', Carbon::now()->subMonths(1));
})->orderBy('created_at', 'desc');
}
/**
* @param QAUserAnswerSelected $userAnswer
*
* @return array
*/
public function map($userAnswer): array
{
$source = $userAnswer->userSource;
$user = $userAnswer->source_id === 0 ? $userAnswer->user : null;
$user_marking = '';
if($user){
$companyModule = $user->companyModule()->first();
$user_marking = $companyModule ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : "";
}
return [
$userAnswer->question->questionnaire->description,
$userAnswer->question->question_text,
$userAnswer->free_text_answer,
$user ? QASystemSourceType::getText(QASystemSourceType::IZYIM) : QASystemSourceType::getText($source->system),
$user ? $user_marking : $source->marking,
$user ? $user->email : $source->email,
Carbon::parse($userAnswer->created_at)->format('d-m-Y'),
];
}
}
@@ -32,7 +32,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
'DocNo',
'DocDate',
'DebtorCode',
'DebtorCode',
'Ref',
'ShipInfo',
'AccNo',
'DetailDescription',
@@ -5,6 +5,7 @@ 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;
@@ -31,8 +32,10 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
*/
public function query()
{
return Order::whereHas('addresses', function($address) {
$address->where('status', ApprovalStatus::APPROVED);
$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);
})->whereHas('packingLists', function($packingLists) {
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
});
@@ -0,0 +1,48 @@
<?php
namespace App\Classes\Modules\Exports\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\ValueObjects\Constants\RoleTypes;
class CanExportFeedback extends AbstractRule
{
/**
* @return bool
*/
protected function authorized($object): bool
{
if(Auth()->user()){
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
return true;
}
else {
return false;
}
}
return false;
}
/**
* @param $object
* @return bool
*/
protected function validators($object): bool
{
return true;
}
/**
* @param $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,49 @@
<?php
namespace App\Classes\Modules\Exports\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\ValueObjects\Constants\RoleTypes;
class CanExportPackingList extends AbstractRule
{
/**
* @return bool
*/
protected function authorized($object): bool
{
if(Auth()->user()){
$roleToCheck = Auth()->user()->type;
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
return true;
}
else {
return false;
}
}
return false;
}
/**
* @param $object
* @return bool
*/
protected function validators($object): bool
{
return true;
}
/**
* @param $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -1,62 +0,0 @@
<?php
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\Standards\Rules\CanFetchHelpMenuQuestionList;
use App\Classes\Modules\HelpMenu\Processors\FetchFirstHelpMenuQuestionProcessor;
use App\Http\Resources\HelpMenuQuestionResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class FetchHelpMenuQuestionLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Help Menu First Question',
'message' => 'You have successfully retrieved a Help Menu First Question'
];
}
/** @var CanFetchHelpMenuQuestionList */
private $canFetchHelpMenuQuestionList;
/** @var FetchFirstHelpMenuQuestionProcessor */
private $fetchFirstHelpMenuQuestionProcessor;
/**
* FetchHelpMenuQuestionLogic constructor.
* @param CanFetchHelpMenuQuestionList $canFetchHelpMenuQuestionList
* @param FetchFirstHelpMenuQuestionProcessor $fetchFirstHelpMenuQuestionProcessor
*/
public function __construct(CanFetchHelpMenuQuestionList $canFetchHelpMenuQuestionList, FetchFirstHelpMenuQuestionProcessor $fetchFirstHelpMenuQuestionProcessor)
{
$this->canFetchHelpMenuQuestionList = $canFetchHelpMenuQuestionList;
$this->fetchFirstHelpMenuQuestionProcessor = $fetchFirstHelpMenuQuestionProcessor;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$this->canFetchHelpMenuQuestionList->passes();
$userId = Auth::user()->id;
$query = $this->fetchFirstHelpMenuQuestionProcessor->execute($request);
return $this->resourceResponse(new HelpMenuQuestionResource($query, $userId));
}
}
@@ -0,0 +1,62 @@
<?php
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\Standards\Rules\CanFetchHelpMenuQuestion;
use App\Classes\Modules\HelpMenu\Processors\FetchFirstQuestionQAProcessor;
use App\Http\Resources\HelpMenuQuestionResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class FetchQuestionQALogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Help Menu First Question',
'message' => 'You have successfully retrieved a Help Menu First Question'
];
}
/** @var CanFetchHelpMenuQuestion */
private $canFetchHelpMenuQuestion;
/** @var FetchFirstQuestionQAProcessor */
private $fetchFirstQuestionQAProcessor;
/**
* FetchQuestionQALogic constructor.
* @param CanFetchHelpMenuQuestion $canFetchHelpMenuQuestion
* @param FetchFirstQuestionQAProcessor $fetchFirstQuestionQAProcessor
*/
public function __construct(CanFetchHelpMenuQuestion $canFetchHelpMenuQuestion, FetchFirstQuestionQAProcessor $fetchFirstQuestionQAProcessor)
{
$this->canFetchHelpMenuQuestion = $canFetchHelpMenuQuestion;
$this->fetchFirstQuestionQAProcessor = $fetchFirstQuestionQAProcessor;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$this->canFetchHelpMenuQuestion->passes();
$userId = Auth::user()->id;
$query = $this->fetchFirstQuestionQAProcessor->execute($request);
return $this->resourceResponse(new HelpMenuQuestionResource($query, $userId));
}
}
@@ -0,0 +1,75 @@
<?php
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\DataTransferObjects\UrlObject;
use App\Classes\Modules\HelpMenu\Standards\Rules\CanGenerateFeedbackUrl;
use App\Classes\Modules\HelpMenu\Services\CreatesUrl;
use App\Classes\Modules\HelpMenu\DataTransferObjects\GenerateFeedbackUrlObject;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Log;
class GenerateFeedbackUrlLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Generate Feedback Url',
'message' => 'You have successfully generated a feedback url'
];
}
/** @var CanGenerateFeedbackUrl */
private $canGenerateFeedbackUrl;
/** @var CreatesUrl */
private $createsUrl;
/**
* GenerateFeedbackUrlLogic constructor.
* @param CanGenerateFeedbackUrl $canGenerateFeedbackUrl
* @param CreatesUrl $createsUrl
*/
public function __construct(CanGenerateFeedbackUrl $canGenerateFeedbackUrl, CreatesUrl $createsUrl)
{
$this->canGenerateFeedbackUrl = $canGenerateFeedbackUrl;
$this->createsUrl = $createsUrl;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$apiKey = "";
if($request->get('apiKeyExist'))
{
$apiKey = $request->get('apiKeyExist');
}
$object = new GenerateFeedbackUrlObject($apiKey, $request->input('system'), $request->input('customer_marking'), $request->input('email'), $request->input('question_set'));
$this->canGenerateFeedbackUrl->passes($object);
$shortUrl = Str::random(20);
$originalText = $object->getSystem() . '|' . $object->getCustomerMarking(). '|' . $object->getEmail(). '|' . $object->getQuestionSet() . '|' . $shortUrl;
$originalUrl = Crypt::encryptString($originalText);
$url = $this->createsUrl->execute(new UrlObject('feedback', $shortUrl, $originalUrl));
$resource = ['token' => $url->short_url];
return $this->response(['data' => $resource]);
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\Services\ListsHelpMenuUserAnswerSelected;
use App\Classes\Modules\HelpMenu\Standards\Rules\CanListHelpMenuQuestions;
use App\Http\Resources\HelpMenuQuestionsAnswersResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListQuestionsAnswersQALogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Questions Answers',
'message' => 'You have successfully retrieved a list of questions and answers'
];
}
/** @var CanListHelpMenuQuestions */
private $canListHelpMenuQuestions;
/** @var ListsHelpMenuUserAnswerSelected */
private $listsHelpMenuUserAnswerSelected;
/**
* ListQuestionsAnswersQALogic constructor.
* @param CanListHelpMenuQuestions $canListHelpMenuQuestions
* @param ListsHelpMenuUserAnswerSelected $listsHelpMenuUserAnswerSelected
*/
public function __construct(CanListHelpMenuQuestions $canListHelpMenuQuestions, ListsHelpMenuUserAnswerSelected $listsHelpMenuUserAnswerSelected)
{
$this->canListHelpMenuQuestions = $canListHelpMenuQuestions;
$this->listsHelpMenuUserAnswerSelected = $listsHelpMenuUserAnswerSelected;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
{
$this->canListHelpMenuQuestions->passes();
$query = $this->listsHelpMenuUserAnswerSelected->execute($this->listsHelpMenuUserAnswerSelected->deserializeFilters($request->input('filters')));
return $this->collectionResponse(HelpMenuQuestionsAnswersResource::collection($query));
}
}
@@ -0,0 +1,66 @@
<?php
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\Services\ListsHelpMenuQuestions;
use App\Classes\Modules\HelpMenu\Services\FetchesUrl;
use App\Http\Resources\HelpMenuQuestionResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use App\Classes\Exceptions\ResourceNotFoundException;
class ListQuestionsQALogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Questions',
'message' => 'You have successfully retrieved a list of Questions'
];
}
/** @var ListsHelpMenuQuestions */
private $listsHelpMenuQuestions;
/** @var FetchesUrl */
private $fetchesUrl;
/**
* ListQuestionsQALogic constructor.
* @param ListsHelpMenuQuestions $listsHelpMenuQuestions
* @param FetchesUrl $fetchesUrl
*/
public function __construct(ListsHelpMenuQuestions $listsHelpMenuQuestions, FetchesUrl $fetchesUrl)
{
$this->listsHelpMenuQuestions = $listsHelpMenuQuestions;
$this->fetchesUrl = $fetchesUrl;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws \App\Classes\Exceptions\ResourceNotFoundException
*/
public function logic(Request $request) : JsonResponse
{
$url = $this->fetchesUrl->execute(['short_url' => $request->input('token')]);
$token = $url->original_url;
$decriptedToken = Crypt::decryptString($token);
$delimiter = "|";
$parts = explode($delimiter, $decriptedToken);
$questionSet = $parts[3];
$query = $this->listsHelpMenuQuestions->execute(['questionnaire_set_id' => $questionSet]);
return $this->collectionResponse(HelpMenuQuestionResource::collection($query));
}
}
@@ -0,0 +1,89 @@
<?php
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\HelpMenu\Processors\SaveAnswerProcessor;
use App\Classes\Modules\HelpMenu\Processors\UserSourceForQAProcessor;
use App\Classes\Modules\HelpMenu\Services\FetchesUrl;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Crypt;
class SubmitQAQuestionsLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Feedback Submission',
'message' => 'You have successfully submitted yours answers'
];
}
/** @var SaveAnswerProcessor */
private $saveAnswerProcessor;
/** @var UserSourceForQAProcessor */
private $userSourceForQAProcessor;
/** @var FetchesUrl */
private $fetchesUrl;
/**
* SubmitQAQuestionsLogic constructor.
* @param SaveAnswerProcessor $saveAnswerProcessor
* @param UserSourceForQAProcessor $userSourceForQAProcessor
* @param FetchesUrl $fetchesUrl
*/
public function __construct(SaveAnswerProcessor $saveAnswerProcessor, UserSourceForQAProcessor $userSourceForQAProcessor, FetchesUrl $fetchesUrl)
{
$this->saveAnswerProcessor = $saveAnswerProcessor;
$this->userSourceForQAProcessor = $userSourceForQAProcessor;
$this->fetchesUrl = $fetchesUrl;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$originalToken = '';
$shortToken = $request->input('token');
$userId = 0;
$sourceId = 0;
try {
$url = $this->fetchesUrl->execute(['short_url' => $shortToken]);
$originalToken = $url->original_url;
$decriptedToken = Crypt::decryptString($originalToken);
$delimiter = "|";
$parts = explode($delimiter, $decriptedToken);
$system = $parts[0];
$customerMarking = $parts[1];
$email = $parts[2];
$result = $this->userSourceForQAProcessor->execute($system, $customerMarking, $email);
$userId = $result['userId'];
$sourceId = $result['sourceId'];
} catch (\Throwable $e) {
Log::error($e);
}
$answers = $request->input('answers');
foreach ($answers as $answer) {
$filesUpload = $request->input('files');
$this->saveAnswerProcessor->execute($userId, $sourceId, $answer['questionId'], $answer['answer'], $answer['answerId'], $filesUpload, $shortToken);
}
$response = ['message' => 'Thank you for your feedback.'];
return $this->response(['data' => $response]);
}
}

Some files were not shown because too many files have changed in this diff Show More