Compare commits

...

338 Commits

Author SHA1 Message Date
Martin Maina Kiragu 5c109d625c Merge branch 'system/transformers' into 'dev'
System/transformers

See merge request CIEFWorldwideSdnBhd/shipping-portal!163
2023-05-02 05:02:59 +00:00
edmondlang 299d5fd4fe fix bug no contact found 2023-04-27 00:13:51 +08:00
edmondlang d56abc78f7 fix bug no contact found 2023-04-27 00:11:48 +08:00
edmondlang b3b7b67c66 show undefined country code 2023-04-27 00:09:29 +08:00
edmondlang d6f29976c7 change order page list order filter to increase loading speed 2023-04-27 00:04:20 +08:00
edmondlang 2bc43cbc8f list order v2 2023-04-25 23:40:27 +08:00
Martin Kiragu a9910c5a12 GroupTransformer 2023-04-24 21:26:35 +03:00
Martin Kiragu 4bee415d2d DeliveryPackingListTransformer transformer updated 2023-04-24 21:08:29 +03:00
Martin Kiragu 02f7adb1e9 DeliveryOrderTransformer added 2023-04-24 21:02:39 +03:00
Martin Kiragu 039a6155ca addation of DeliverPackingListTransformer 2023-04-24 20:51:30 +03:00
Martin Kiragu c8d806a51d updated all resource transformers optionally required by the container transformer 2023-04-24 16:50:53 +03:00
Martin Kiragu 4dbaf6a5dc added ContainerTransformer and its optional relationships 2023-04-24 15:57:31 +03:00
Martin Kiragu fcc0135843 ContactResource with ContactTransformer 2023-04-24 14:35:22 +03:00
Martin Kiragu 4a922ac340 add company transformer with multiple optional relationship loader 2023-04-24 14:29:46 +03:00
Martin Kiragu c4d421db76 add a todo to delete the BookingResource not used anywhere 2023-04-24 14:01:36 +03:00
Martin Kiragu 2816e80bee Bank Account Transformer 2023-04-24 13:56:00 +03:00
Martin Kiragu 466e90a0af Build a AnnouncementTransformer for uniformity and future relationships updates 2023-04-24 13:50:20 +03:00
Martin Kiragu 5e6ae2a905 add backend conditional relationship loading on the AddressResource/AddressTransformer 2023-04-24 13:43:47 +03:00
Omair Saleh e0a02c7051 update foshan map png 2023-04-20 00:01:38 +08:00
Omair Saleh 34a08563f3 Merge remote-tracking branch 'origin/master' 2023-04-19 23:57:31 +08:00
Omair Saleh 9df1e158a4 disable temporary include new columns to invoice export for chasing payment 2023-04-19 23:55:31 +08:00
edmondlang 33cd313950 foshan-warehouse image 2023-04-19 23:53:16 +08:00
EDMOND MING 2af5035e99 Delete foshan-map.png 2023-04-19 15:52:26 +00:00
Omair Saleh acb7337b4a temporary include new columns to invoice export for chasing payment 2023-04-19 15:41:19 +08:00
Omair Saleh 0a9bc29202 temporary include new columns to invoice export for chasing payment 2023-04-19 15:33:16 +08:00
Omair Saleh 1568c7272a temporary include new columns to invoice export for chasing payment 2023-04-19 15:31:12 +08:00
Omair Saleh 14f0560055 Merge remote-tracking branch 'origin/master' 2023-04-19 15:27:06 +08:00
Omair Saleh fc339f1dec temporary include new columns to invoice export for chasing payment 2023-04-19 15:26:45 +08:00
edmondlang 3378d37ffb Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-19 12:53:50 +08:00
edmondlang 77f7e86a5f fix bug date error in update announcement function in settings page 2023-04-19 12:52:46 +08:00
edmondlang 6970908b75 update generate PDF controller 2023-04-19 12:34:01 +08:00
edmondlang 3f31d2d578 add foshan map 2023-04-19 00:32:22 +08:00
edmondlang fff3d948d0 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development
# Conflicts:
#	app/Classes/Modules/Orders/ControllersLogic/CreateOrderLogic.php
2023-04-18 23:44:36 +08:00
edmondlang 8d8c468b09 foshan-warehouse 2023-04-18 23:42:49 +08:00
Dillon Ngo 557ab483f8 Merge branch 'dillon/improvement-1' into 'master'
Reduce flooding of logs from Perfex CRM

See merge request CIEFWorldwideSdnBhd/shipping-portal!162
2023-04-15 14:02:03 +00:00
Dillon c181882145 Merge branch 'dillon/improvement-1' into development 2023-04-15 21:57:58 +08:00
Dillon 4b0b88b5d8 Reduce flooding of logs from Perfex CRM 2023-04-15 21:46:26 +08:00
edmondlang 1960cff426 create a cron job to fix all billplz failed callback for all the success payments. 2023-04-14 11:39:24 +08:00
edmondlang 0402fc67e2 update package loading animation 2023-04-13 22:57:46 +08:00
edmondlang 4089683ab7 remove all css comments 2023-04-13 22:53:12 +08:00
edmondlang 3fdd2a2b56 update package loading animation 2023-04-13 22:46:41 +08:00
edmondlang 2a333f7d19 Merge branch 'order-v2' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-13 16:09:37 +08:00
edmondlang 76193eeb9f update order v2 2023-04-13 16:09:18 +08:00
edmondlang 8f8622aa10 Merge branch 'order-v2' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-13 16:05:38 +08:00
edmondlang a696e1dab9 change all order to v2 link 2023-04-13 16:05:20 +08:00
edmondlang f88936c873 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-13 16:01:45 +08:00
edmondlang c9642bd8f5 update order v2 page 2023-04-13 16:01:12 +08:00
DESKTOP-5I7S92L\nicho a3d26bfb63 uncomment order package code 2023-04-13 12:20:49 +08:00
DESKTOP-5I7S92L\nicho 094f995dcf orde v2 include packages 2023-04-13 12:18:22 +08:00
edmondlang 1a5db25285 update show duplicated invoice logic 2023-04-12 12:15:06 +08:00
edmondlang 2bb4afe426 update show duplicated invoice logic 2023-04-12 11:58:10 +08:00
edmondlang f7a9b2332c enable customer 769SMC summary in 2 different year 2022 and 2023 2023-04-11 11:39:22 +08:00
Dillon Ngo fa0c97b1da Merge branch 'dillon/accounting-bank-mapping' into 'master'
New route, middleware, token table, filters for query to allow  third party to access api

See merge request CIEFWorldwideSdnBhd/shipping-portal!161
2023-04-06 15:19:15 +00:00
Dillon 20f3004e22 Merge branch 'dillon/accounting-bank-mapping' into development 2023-04-06 22:59:39 +08:00
Dillon 43cd6f35be New route, middleware, token table, filters for query to allow third party to access api 2023-04-06 22:57:50 +08:00
edmondlang fd4bbe5d4f Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-06 19:25:35 +08:00
edmondlang 697c02ac8a delete packing list by package id 2023-04-06 19:22:40 +08:00
edmondlang 3dd9dfe361 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into delete-packing-list 2023-04-06 18:52:48 +08:00
edmondlang 7c50dfbfc3 update 769SMC summary 2023-04-06 17:30:02 +08:00
edmondlang a630b49867 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-06 14:25:33 +08:00
edmondlang e77e513bef support page update 2023-04-06 14:24:56 +08:00
DESKTOP-5I7S92L\nicho e173a9ddd3 support update 2023-04-06 14:00:41 +08:00
edmondlang 75ce5bd752 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-06 00:08:24 +08:00
edmondlang c40d563372 add support at menu 2023-04-06 00:08:06 +08:00
edmondlang abb7bc2e4c Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-04-05 23:50:22 +08:00
edmondlang 7f0de1c1e4 support page 2023-04-05 23:49:23 +08:00
edmondlang c5477890d6 oder v2 2023-04-05 20:27:22 +08:00
edmondlang 26027f5f3f order profile v2 2023-04-05 19:13:17 +08:00
edmondlang a28f735d8f order v2 2023-04-05 19:12:07 +08:00
DESKTOP-5I7S92L\nicho 225abaacb8 order v2 2023-04-05 16:38:28 +08:00
DESKTOP-5I7S92L\nicho 70fc8285f8 order v2 2023-04-05 16:21:53 +08:00
DESKTOP-5I7S92L\nicho 1f6eaa65a5 order v2 2023-04-05 16:02:10 +08:00
DESKTOP-5I7S92L\nicho 7e2428957e delete packing list 2023-04-05 15:18:46 +08:00
edmondlang 069c3cea35 Showing Billplz payment status 2023-04-02 12:09:44 +08:00
edmondlang 857003b25b update code conflict 2023-04-02 11:45:58 +08:00
edmondlang 551119e313 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development
# Conflicts:
#	app/Classes/ValueObjects/Constants/TransactionType.php
#	routes/web.php
2023-04-02 11:41:55 +08:00
edmondlang 07998c6850 super admin delete invoice/transaction 2023-04-02 11:25:50 +08:00
Dillon Ngo cd3e955f3e Merge branch 'dillon/debug-and-fixes-2' into 'master'
Another attempt to solve invoice without projectId, rewriting job chaining one after another

See merge request CIEFWorldwideSdnBhd/shipping-portal!160
2023-04-01 16:28:55 +00:00
edmondlang 869397056c final-duplicated-invoice-debug 2023-04-01 19:36:43 +08:00
edmondlang c58cdde254 final-duplicated-invoice-debug 2023-04-01 19:35:47 +08:00
edmondlang 982a7c1d44 final-duplicated-invoice-debug 2023-04-01 19:34:30 +08:00
edmondlang c976319521 final-duplicated-invoice-debug 2023-04-01 19:19:48 +08:00
edmondlang 145bf3263a final-duplicated-invoice-debug 2023-04-01 18:51:37 +08:00
edmondlang 57eb1e147d final-duplicated-invoice-debug 2023-04-01 18:48:34 +08:00
edmondlang e1c69f2de4 final-duplicated-invoice-debug 2023-04-01 18:35:15 +08:00
edmondlang 90b2bffd19 final-duplicated-invoice-debug 2023-04-01 18:31:02 +08:00
edmondlang 562815f9fe final-duplicated-invoice-debug 2023-04-01 18:27:04 +08:00
edmondlang 401db91437 final-duplicated-invoice-debug 2023-04-01 18:20:22 +08:00
edmondlang 0d1a623512 final-duplicated-invoice-debug 2023-04-01 17:36:59 +08:00
edmondlang 548a50c14a final-duplicated-invoice-debug 2023-04-01 17:33:51 +08:00
edmondlang 299512ec08 final-duplicated-invoice-debug 2023-04-01 17:29:28 +08:00
edmondlang 7241db7743 final-duplicated-invoice-debug 2023-04-01 17:27:13 +08:00
edmondlang ce24deea18 final-duplicated-invoice-debug 2023-04-01 17:11:07 +08:00
edmondlang c4642c2042 final-duplicated-invoice-debug 2023-04-01 17:06:37 +08:00
edmondlang 3871d8c010 clean up web routes 2023-04-01 16:01:20 +08:00
edmondlang cb65a1f29b fix bug billplz failed callback 2023-03-31 21:24:43 +08:00
edmondlang b1b13d7cbf fix bug billplz failed callback 2023-03-31 21:21:26 +08:00
Omair Saleh f6fa2fcf51 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	routes/web.php
2023-03-31 15:44:13 +08:00
Omair Saleh 6c00a57446 smc summary report 2023-03-31 15:43:04 +08:00
edmondlang b567f50711 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-31 00:42:03 +08:00
edmondlang 48445020fb adjust warehouse contact ui 2023-03-31 00:41:45 +08:00
edmondlang 395b15af90 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development
# Conflicts:
#	routes/api.php
2023-03-31 00:32:46 +08:00
edmondlang 46f1368a92 ui and api to update warehouse contact 2023-03-31 00:29:15 +08:00
edmondlang 82a16a5d9d update address 2023-03-30 17:26:19 +08:00
edmondlang 833ffdab8d Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-30 15:18:00 +08:00
edmondlang 23002f61da update admin role type 2023-03-30 15:13:41 +08:00
edmondlang 2f6a30a512 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-30 14:38:15 +08:00
edmondlang 2355c74b65 update customer/summary/monthly to 2023 records 2023-03-30 14:22:10 +08:00
edmondlang bd81560c3d remove console.log 2023-03-30 14:21:31 +08:00
edmondlang 575491e500 search admin in settings 2023-03-30 14:18:22 +08:00
edmondlang 4c433f74f1 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-30 12:53:00 +08:00
edmondlang 1c703489b9 update admin role type 2023-03-30 12:47:02 +08:00
DESKTOP-5I7S92L\nicho 30ef3a7e41 fix call API bug for changeAdminRoleTypeForm 2023-03-30 12:35:30 +08:00
DESKTOP-5I7S92L\nicho f9b1289d28 call api 2023-03-30 12:28:45 +08:00
edmondlang 9fe49d8658 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into update-admin-role-type 2023-03-30 12:16:04 +08:00
DESKTOP-5I7S92L\nicho e265b069d2 change button color to transparent 2023-03-30 12:12:35 +08:00
edmondlang f90818dbca updates user name and admin type api 2023-03-30 12:06:33 +08:00
DESKTOP-5I7S92L\nicho bfd490854d change admin role type 2023-03-30 11:53:54 +08:00
Dillon 852da05e24 Merge branch 'dillon/debug-and-fixes-2' into development 2023-03-30 06:00:12 +08:00
edmondlang feaab3cd8e check billplz failed callback 2023-03-30 00:37:09 +08:00
edmondlang 094801abbe check billplz failed callback 2023-03-30 00:35:59 +08:00
edmondlang 275d8880d9 check billplz failed callback 2023-03-30 00:30:12 +08:00
edmondlang 98843d0688 check billplz failed callback 2023-03-30 00:07:21 +08:00
edmondlang 317f4c2351 check billplz failed callback 2023-03-29 23:39:58 +08:00
edmondlang 83c7d70551 check billplz failed callback 2023-03-29 23:29:05 +08:00
Dillon Ngo 20099c416f Merge branch 'dillon/debug-and-fixes-2' into 'master'
New merge request From dillon/debug-and-fixes-2 into master

See merge request CIEFWorldwideSdnBhd/shipping-portal!159
2023-03-29 13:35:13 +00:00
Dillon Ngo eb399dcbae Merge branch 'dillon/debug-and-fixes-2' into 'master'
New merge request From dillon/debug-and-fixes-2 into master

See merge request CIEFWorldwideSdnBhd/shipping-portal!158
2023-03-28 16:03:34 +00:00
Dillon 1658b65484 A quick fix 2023-03-28 23:42:59 +08:00
Dillon 8e9ff0cad5 Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-28 23:36:35 +08:00
edmondlang acee1a7884 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-28 16:17:14 +08:00
edmondlang 0079d745ba Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-26 22:48:42 +08:00
Dillon 0bd3464184 Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-25 14:20:49 +08:00
Dillon 7ec1bc65a5 Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-25 02:18:03 +08:00
Dillon c401d1e0d5 Merge branch 'development' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-24 15:15:32 +08:00
Dillon a2983ec9f1 Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-24 15:15:15 +08:00
Martin Maina Kiragu 2421640c0a Merge branch 'feature/dashboard_optimization' into 'development'
Feature/dashboard optimization

See merge request CIEFWorldwideSdnBhd/shipping-portal!156
2023-03-24 03:48:40 +00:00
Martin Kiragu 7dae2228f6 fix ide-autospace formatting 2023-03-24 06:34:04 +03:00
Martin Kiragu 75039466ab fix ide-autospace formatting 2023-03-24 06:28:53 +03:00
Martin Kiragu f3df5fbe9f fix ide-autospace formatting 2023-03-24 06:13:35 +03:00
Martin Kiragu 362e47aaa0 fix ide-autospace formatting 2023-03-24 06:04:28 +03:00
Martin Kiragu ba26cda598 switched the Modal resources to Transformers for /document/lists endpoint 2023-03-24 05:51:32 +03:00
Dillon 8995a567d5 Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-24 03:16:47 +08:00
Dillon 5eeec7806b Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-23 04:31:47 +08:00
Dillon fd46a4fb7f Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-23 04:18:38 +08:00
Dillon 1100267316 Merge branch 'dillon/crm-create-task-3-26' into development 2023-03-22 22:23:43 +08:00
edmondlang e133f1fab8 Merge branch 'multi-payment-final' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-21 17:38:35 +08:00
edmondlang b2a986b838 update multi payment bill plz call back 2023-03-21 17:38:12 +08:00
edmondlang 5d5892ce07 Merge branch 'multi-payment-final' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development
# Conflicts:
#	routes/transaction.php
2023-03-21 14:13:20 +08:00
edmondlang 160fa2b2d9 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into multi-payment-final 2023-03-21 14:11:59 +08:00
edmondlang e0d0dccb4c multi payment final 2023-03-21 14:11:42 +08:00
edmondlang f47c7ebc50 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into multi-payment-final 2023-03-21 11:11:33 +08:00
edmondlang b26700ea6f Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-20 18:08:50 +08:00
Dillon 589c2e01d9 Merge branch 'dillon/debug-and-fixes-1' into development 2023-03-19 22:32:53 +08:00
Dillon 9cf6058a65 Merge branch 'dillon/debug-and-fixes-1' into development 2023-03-19 17:34:52 +08:00
Dillon ff4d81966c Merge branch 'dillon/debug-and-fixes-1' into development 2023-03-19 16:39:40 +08:00
Martin Kiragu a4891aa0de added a debugber optional paramenter for addational resource on ListDocument resource 2023-03-19 06:31:44 +03:00
Martin Kiragu 05ba0ba6fd update fix conflicts 2023-03-19 04:41:40 +03:00
Martin Kiragu 9217970237 update helpers 2023-03-19 04:38:24 +03:00
Dillon 828f424cfd Merge branch 'dillon/crm-invoice-update-23' into development 2023-03-19 04:50:46 +08:00
Dillon 057ca8480b Merge branch 'dillon/crm-invoice-update-23' into development 2023-03-19 04:30:36 +08:00
edmondlang d07901f31b Merge branch 'multi-payment-final' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development
# Conflicts:
#	app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php
#	routes/web.php
2023-03-18 23:36:37 +08:00
edmondlang f30a0cf7ee wallet top up logic 2023-03-18 23:34:38 +08:00
edmondlang f2a02230c7 update payment redirect 2023-03-18 23:16:08 +08:00
edmondlang 2978eed61d Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into multi-payment-final 2023-03-18 23:06:50 +08:00
Dillon c22638b29e Merge branch 'dillon/debug-and-fixes-1' into development 2023-03-17 17:36:56 +08:00
Martin Kiragu c292bfd1e0 extract repeated queries on MonthlyReport Controller and Add a global Library helper.php file 2023-03-13 09:21:51 +03:00
edmondlang c76c50466d multi payment final ui 2023-03-13 13:43:28 +08:00
edmondlang b4437c8907 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into multi-payment-final
# Conflicts:
#	routes/web.php
2023-03-13 12:12:26 +08:00
edmondlang e7942731ad revert call back bill plz logic 2023-03-13 00:10:26 +08:00
edmondlang 85942eff1d Merge branch 'multi-payment-final' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-12 23:27:57 +08:00
edmondlang 5db9d79cc1 multi payment final - payment fail - redirect and show error 2023-03-12 23:27:21 +08:00
edmondlang d69896f807 Merge branch 'multi-payment-final' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-12 23:13:58 +08:00
edmondlang dff001c9b5 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into multi-payment-final 2023-03-12 23:13:21 +08:00
edmondlang 2353c637d7 multi payment final - finish top up and trsanction history 2023-03-12 23:13:03 +08:00
Dillon 2c5c97488f Merge branch 'dillon/crm-tasks-department' into development 2023-03-12 17:38:48 +08:00
edmondlang eea8708b76 migrate wallets and create function for regenerates invoice 2023-03-11 16:48:54 +08:00
Dillon 99e38b96ce Merge branch 'dillon/crm-create-task-2' into development 2023-03-11 16:34:04 +08:00
Dillon 81a00a8195 Merge branch 'dillon/crm-create-task-2' into development 2023-03-10 21:14:00 +08:00
Dillon dbab7a9f8c Merge branch 'dillon/crm-feed-improvement-1' into development 2023-03-10 17:59:34 +08:00
Dillon 046676d174 Merge branch 'dillon/crm-create-task-2' into development 2023-03-10 02:52:53 +08:00
edmondlang 2b4f1ad570 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-08 14:34:36 +08:00
Dillon bcb78f2392 undo debug logs 2023-03-06 16:00:58 +08:00
Dillon 345a62fec6 debug 2023-03-06 15:54:57 +08:00
Dillon 6257b11a6e Merge branch 'dillon/crm-create-invoice' into development 2023-03-06 15:13:17 +08:00
Dillon 4b124ca96d Merge branch 'dillon/crm-create-invoice' into development 2023-03-05 20:30:04 +08:00
Martin Kiragu 4b25764fb3 Merge branch 'development' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-03 06:29:16 +03:00
Martin Kiragu 422a0af465 move all UI related tests to codeception tets 2023-03-03 06:28:45 +03:00
edmondlang c73d65343b Merge branch 'update-create-dilivery-address' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-02 23:38:33 +08:00
edmondlang 9e5784b6ec update force create order delivery address 2023-03-02 23:38:12 +08:00
edmondlang 9a863e2143 Merge branch 'update-create-dilivery-address' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-02 23:18:12 +08:00
edmondlang 8024865d5d create order with force enter billing address 2023-03-02 23:17:42 +08:00
Martin Kiragu 66abe81e73 Merge remote-tracking branch 'origin/development' into development 2023-03-02 12:24:07 +03:00
Martin Kiragu ca178e1b31 add HasFactory facade to Users model 2023-03-02 12:23:49 +03:00
edmondlang e52a27aedb Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-02 17:06:55 +08:00
Martin Kiragu 6c2c28fb31 rerun UI build on the test job 2023-03-02 11:58:09 +03:00
Martin Kiragu 049da351ef Merge remote-tracking branch 'origin/development' into development 2023-03-02 11:28:03 +03:00
Martin Kiragu 0ce8709f70 reduplicate mysql service for unit test job 2023-03-02 11:27:25 +03:00
edmondlang 1e5609bb1b Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-02 16:26:11 +08:00
edmondlang 8e7970a925 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-03-02 16:16:23 +08:00
Martin Kiragu 06b2c5166d remove dependencies test and add reruns 2023-03-02 11:01:10 +03:00
Martin Kiragu 6ba3b873a2 add building assets and dependencies test 2023-03-02 10:47:45 +03:00
Martin Kiragu 623fb1609b switch dependencies with an installation rerun 2023-03-02 10:29:40 +03:00
Martin Kiragu 24be20a60d switch dependencies with an installation rerun 2023-03-02 10:17:30 +03:00
Martin Kiragu 3535201481 remove test dependency injection 2023-03-02 10:04:09 +03:00
Martin Kiragu cdefd48d26 remove pdo echo 2023-03-02 09:50:44 +03:00
Martin Kiragu 45fbcf1447 pdo addition 2023-03-02 09:42:49 +03:00
Martin Kiragu 53805f3608 add database test 2023-03-02 09:20:02 +03:00
Martin Kiragu 99e90ad357 update remove pdo and mysql extension 2023-03-02 09:03:28 +03:00
Martin Kiragu 5edb9b5cfe add node and gulp builds 2023-03-02 08:58:23 +03:00
Martin Kiragu 86a5a3b2d9 add migration and seeder 2023-03-02 08:37:38 +03:00
Martin Kiragu a6590e3b81 test set up on the set up job 2023-03-02 08:31:14 +03:00
Martin Kiragu b1bb2b9f33 add .env.example to the env file 2023-03-02 08:25:04 +03:00
Dillon 9318e7471f Merge branch 'dillon/crm-create-task' into development 2023-03-01 12:36:15 +08:00
Martin Maina Kiragu e19ba1c9f3 Merge branch 'feature/TDD' into 'development'
Feature/tdd

See merge request CIEFWorldwideSdnBhd/shipping-portal!140
2023-03-01 03:54:54 +00:00
edmondlang 8cffae079b test approve invoice 2023-02-28 14:46:04 +08:00
edmondlang 594b25b71b temporary disable all other cron on development server 2023-02-28 14:29:04 +08:00
edmondlang d142a86683 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-28 14:23:11 +08:00
edmondlang 935f3e9bf5 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-27 15:59:49 +08:00
edmondlang dedd6464f4 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-24 18:08:22 +08:00
edmondlang 38aba65178 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-23 14:53:41 +08:00
Dillon 091119c244 Merge branch 'dillon/crm-integration' into development 2023-02-22 18:09:51 +08:00
Dillon 4d095b5459 Merge branch 'development' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-22 17:10:08 +08:00
Dillon 1c50181132 Merge branch 'dillon/crm-integration' into development 2023-02-22 10:37:19 +08:00
edmondlang 9e26c470f5 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-21 23:54:08 +08:00
edmondlang 4c0bf164a0 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-21 23:43:18 +08:00
edmondlang 8ab7f72e90 reverse invoice search function 2023-02-21 23:42:00 +08:00
edmondlang 5772e30575 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-21 23:41:19 +08:00
edmondlang 4b2daa62d7 test auto generate invoice function 2023-02-21 17:32:20 +08:00
edmondlang 2bd8700a61 Merge branch 'auto-generate-invoice' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-21 16:50:42 +08:00
edmondlang ad7e77c169 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-21 15:01:09 +08:00
edmondlang e95c41bd3e Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-20 19:51:11 +08:00
edmondlang 903269e714 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-20 18:22:48 +08:00
edmondlang 4120a50559 commented on the web routes and api routes to test on the crm 2023-02-18 23:09:24 +08:00
Dillon 88b31f2d3f Merge branch 'dillon/crm-integration' into development 2023-02-18 21:08:08 +08:00
Dillon a2f9bf83ce Merge branch 'dillon/crm-integration' into development 2023-02-18 20:29:57 +08:00
Dillon dd2ac4c966 Merge branch 'dillon/crm-integration' into development 2023-02-18 20:09:08 +08:00
Dillon c88f6890d6 Merge branch 'dillon/crm-integration' into development 2023-02-17 09:24:38 +08:00
edmondlang bf4b3fa97f Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-16 23:13:22 +08:00
edmondlang 6bcea5a8f1 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-16 16:53:12 +08:00
Martin Maina Kiragu 2704ec1665 Merge branch 'feature/pipeline' into 'development'
Update .gitlab-ci.yml file

See merge request CIEFWorldwideSdnBhd/shipping-portal!144
2023-02-13 07:28:57 +00:00
Martin Maina Kiragu 0c636d2156 remove spaces on Export warehouse service 2023-02-13 05:17:03 +00:00
Martin Kiragu 1270ba3f43 delete the code ide-helper file 2023-02-13 08:08:06 +03:00
Martin Kiragu f2c32c5024 fix more spaces 2023-02-13 08:07:11 +03:00
Martin Kiragu ccb3bde260 clean up spaces on my branch 2023-02-13 08:01:23 +03:00
Martin Kiragu a7eb14c2b7 Merge branch 'feature/TDD' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into feature/TDD 2023-02-13 07:37:01 +03:00
Martin Kiragu abac96b1e5 revert all models changes 2023-02-13 07:36:40 +03:00
Martin Maina Kiragu ecb48c8897 Merge branch 'master' into 'feature/TDD'
# Conflicts:
#   config/app.php
2023-02-13 04:24:32 +00:00
Martin Maina Kiragu 2686229a0f Merge branch 'master' into 'feature/pipeline'
# Conflicts:
#   config/app.php
2023-02-13 04:12:19 +00:00
Martin Kiragu 558fa7ae52 remove migration and seeder 2023-02-13 06:49:08 +03:00
Martin Kiragu 88e2136c07 add cp .env 2023-02-13 06:47:58 +03:00
Martin Kiragu 70cdcded9b generate key, run migration and database seeder 2023-02-13 06:40:02 +03:00
Martin Kiragu 4022b640f9 test by rerunning the install 2023-02-13 06:31:05 +03:00
Martin Kiragu 0d780074b8 vender test to php 2023-02-13 06:23:53 +03:00
Martin Kiragu 078f675a7f add codeception and change vender test to php 2023-02-13 06:20:42 +03:00
Martin Kiragu 2b48a86f98 comment the Meneses\LaravelMpdf\LaravelMpdfServiceProvider 2023-02-13 06:11:41 +03:00
Martin Maina Kiragu 19f3aa18fc Update .gitlab-ci.yml file
add libzip
2023-02-13 03:07:34 +00:00
Martin Maina Kiragu 2b4c932fc8 Update .gitlab-ci.yml file
add libzip
2023-02-13 03:05:29 +00:00
Martin Maina Kiragu 89f0ca651a Update .gitlab-ci.yml file
add libzip
2023-02-13 03:01:07 +00:00
Martin Maina Kiragu c9fc5938c6 Update .gitlab-ci.yml file
add libzip
2023-02-13 02:55:41 +00:00
Martin Maina Kiragu 2ad8235c1b Update .gitlab-ci.yml file
add libzip
2023-02-13 02:53:22 +00:00
Martin Maina Kiragu dbf8301cb9 Update .gitlab-ci.yml file
add libzip
2023-02-13 02:49:27 +00:00
Martin Maina Kiragu 7d582c6bca Update .gitlab-ci.yml file
add libzip
2023-02-13 02:48:30 +00:00
Martin Maina Kiragu 3c4b6afcb2 Update .gitlab-ci.yml file
add zip
2023-02-13 02:46:21 +00:00
Martin Maina Kiragu e4bc56d188 Update .gitlab-ci.yml file 2023-02-13 02:44:10 +00:00
Martin Maina Kiragu 9a448d5a3d Update .gitlab-ci.yml file 2023-02-13 02:41:24 +00:00
Martin Maina Kiragu 5c1074b244 Update .gitlab-ci.yml file 2023-02-13 02:38:49 +00:00
Martin Maina Kiragu 49fcdfd89e Update .gitlab-ci.yml file 2023-02-13 02:36:51 +00:00
Martin Maina Kiragu c900759234 Update .gitlab-ci.yml file 2023-02-13 02:30:15 +00:00
Martin Maina Kiragu cd3b47ab1a Update .gitlab-ci.yml file 2023-02-13 02:26:31 +00:00
Martin Maina Kiragu c5f95cdf61 Update .gitlab-ci.yml file 2023-02-13 02:22:31 +00:00
Martin Maina Kiragu cc428a92b8 Update .gitlab-ci.yml file 2023-02-13 02:08:09 +00:00
Martin Maina Kiragu 97bac45612 Update .gitlab-ci.yml file 2023-02-13 02:03:30 +00:00
Martin Maina Kiragu 8048396a88 Update .gitlab-ci.yml file 2023-02-13 01:59:14 +00:00
Martin Maina Kiragu 400ec31235 Update .gitlab-ci.yml file 2023-02-13 01:54:53 +00:00
Martin Maina Kiragu 4d9346c62c Update .gitlab-ci.yml file 2023-02-13 01:49:47 +00:00
Martin Maina Kiragu 94fd2069e8 Update .gitlab-ci.yml file 2023-02-13 01:43:41 +00:00
Martin Maina Kiragu 1f401eb347 Update .gitlab-ci.yml file 2023-02-13 01:39:09 +00:00
Martin Maina Kiragu 80e282bda0 Update .gitlab-ci.yml file 2023-02-13 01:35:00 +00:00
Martin Maina Kiragu 65cd6aae3c Update .gitlab-ci.yml file 2023-02-13 01:33:05 +00:00
Martin Maina Kiragu eba2a30024 Update .gitlab-ci.yml file 2023-02-13 01:28:16 +00:00
Martin Maina Kiragu c103deb2a7 Update .gitlab-ci.yml file 2023-02-13 01:25:16 +00:00
Martin Maina Kiragu dcef782587 Update .gitlab-ci.yml file
--update to php 7.4
2023-02-13 01:22:54 +00:00
Martin Maina Kiragu 10e7da4673 Update .gitlab-ci.yml file 2023-02-13 01:15:20 +00:00
Martin Kiragu faff35f241 update the pipeline with master branch code 2023-02-13 04:07:33 +03:00
Martin Maina Kiragu e2c1562f19 Update .gitlab-ci.yml file 2023-02-13 00:57:12 +00:00
Martin Maina Kiragu df35ceb798 Update .gitlab-ci.yml file 2023-02-13 00:51:03 +00:00
Martin Maina Kiragu cdb81a0bf4 Update .gitlab-ci.yml file 2023-02-13 00:48:41 +00:00
Martin Maina Kiragu f1b1955190 Update .gitlab-ci.yml file 2023-02-13 00:42:05 +00:00
Martin Maina Kiragu 860632b7a3 Update .gitlab-ci.yml file 2023-02-13 00:39:49 +00:00
Martin Maina Kiragu bde7a61fb4 Update .gitlab-ci.yml file 2023-02-13 00:35:42 +00:00
edmondlang b6600c5168 Merge branch 'update-laravelmpdf' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-10 20:56:42 +08:00
edmondlang 25f38ef7fe Merge branches 'development' and 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-07 23:40:38 +08:00
edmondlang ddeb44b920 Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-07 23:32:35 +08:00
Martin Maina Kiragu 02be710203 Update .gitlab-ci.yml file try php 7.3 2023-02-06 16:14:50 +00:00
Martin Maina Kiragu 2ffbfc9f1c Update .gitlab-ci.yml file 2023-02-06 16:12:41 +00:00
Martin Maina Kiragu 7b34f8116c Update .gitlab-ci.yml file 2023-02-06 16:09:41 +00:00
Martin Maina Kiragu 8a9b6df255 Update .gitlab-ci.yml file 2023-02-06 16:04:42 +00:00
Martin Kiragu c881dd44d6 updated action file 2023-02-06 18:38:12 +03:00
Martin Kiragu 1cfaeaf8bb add triggers 2023-02-06 18:28:46 +03:00
Martin Kiragu 914f29184d simple pipeline configuration 2023-02-06 18:23:51 +03:00
edmondlang f510d57463 Merge branch 'change-company-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-06 23:08:03 +08:00
edmondlang 7833c17938 Merge branch 'change-company-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-06 23:02:43 +08:00
edmondlang 97fdffe6eb Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-06 22:46:53 +08:00
edmondlang b1f2900f1c Merge branch 'change-company-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-06 22:25:33 +08:00
edmondlang ddf015dc71 Revert "work on combine invoices"
This reverts commit 2a9d4fd212.
2023-02-06 22:24:48 +08:00
Sheikh Ahmer 2a9d4fd212 work on combine invoices 2023-02-04 16:36:09 +05:00
Martin Kiragu 2cacc23a38 login acceptance test 2023-02-04 10:04:34 +03:00
Martin Kiragu a7fd5a038e Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into feature/TDD 2023-02-04 07:53:45 +03:00
edmondlang 626b31084f Merge branch 'wip-invoice-tab' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-02-03 16:11:48 +08:00
Martin Kiragu 4f3c25d5bd Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into feature/TDD 2023-01-29 10:51:30 +03:00
Martin Kiragu 8da942e41e updated list of all user, passwords and emails unit tests 2023-01-28 12:56:41 +03:00
edmondlang b599c8a151 Merge branch 'multi-invoice-combined-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-20 17:15:25 +08:00
Martin Kiragu d41f796825 fix access_token issue 2023-01-20 10:39:39 +03:00
Martin Kiragu dd612e2660 fix issues 2023-01-19 12:12:54 +03:00
Martin Kiragu c503b5e677 acceptance test set up and demo 2023-01-19 12:03:09 +03:00
Martin Kiragu 0b433cfa18 ed debug 2023-01-19 09:39:16 +03:00
Martin Kiragu 75aba8c4ac remove password related tests on auth test class 2023-01-19 09:39:16 +03:00
Martin Kiragu 81c65874a3 added the Auth tdd and a modal property autogenerator helpers 2023-01-19 09:39:15 +03:00
Martin Kiragu 79d29d9c7b Authentication TDD 2023-01-19 09:39:15 +03:00
Martin Kiragu 1e558b93af set up testig env codeception laravela and phpunit 2023-01-19 09:39:15 +03:00
edmondlang 6d3d52639e Merge branch 'multi-invoice-combined-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-19 00:33:37 +08:00
edmondlang a1d460aa6c Merge branch 'multi-invoice-combined-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-19 00:20:38 +08:00
edmondlang 5a0bc7aaea Merge branch 'multi-invoice-combined-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development
# Conflicts:
#	resources/views/pages/pdfs/shipping_invoices_combined.blade.php
2023-01-18 23:59:58 +08:00
Martin Kiragu c7962b4231 ed debug 2023-01-18 18:34:18 +03:00
Martin Kiragu d14bb39ae8 remove password related tests on auth test class 2023-01-18 09:11:30 +03:00
Martin Kiragu 5cc2f51c02 added the Auth tdd and a modal property autogenerator helpers 2023-01-18 08:17:05 +03:00
Martin Kiragu a185f73e8a Authentication TDD 2023-01-16 14:40:57 +03:00
edmondlang f9a9598210 Merge branch 'dillon/search-marking-by-email' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-15 14:20:38 +08:00
edmondlang 9976ccec41 Merge branch 'ChangeCompanie' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-11 22:39:58 +08:00
edmondlang 8bfb2d749a Merge branch 'dillon/multiple-invoices-combined' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-11 18:25:28 +08:00
Martin Kiragu 7bf9a570a1 set up testig env codeception laravela and phpunit 2023-01-11 12:44:32 +03:00
edmondlang b38df170e8 Merge branch 'multiple-payment-ui' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-09 22:58:10 +08:00
Dillon bf38ace70c Multiple invoices into one 2023-01-07 11:51:27 +08:00
edmondlang 66c008f97e Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into development 2023-01-03 13:49:15 +08:00
edmondlang 0298eb946f Merge branch 'master' of https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal into activity-route-log-dev 2023-01-02 17:41:29 +08:00
edmondlang 70fb35e37c api and web route logs 2023-01-02 17:41:00 +08:00
edmondlang 1a30877ca9 activity route log dev 2022-12-31 11:53:41 +08:00
WAKOYA_KUMSA\waqo1 569a22c0db route activity log 2022-12-28 13:15:15 +03:00
296 changed files with 13565 additions and 643 deletions
+4 -2
View File
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_DATABASE=shpping_portal
DB_USERNAME=root
DB_PASSWORD=
DB_PASSWORD=root
BROADCAST_DRIVER=log
CACHE_DRIVER=file
@@ -56,6 +56,8 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
YD_API_CODE=''
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
PERFEXCRM_BASE_URL=""
PERFEXCRM_API_KEY=""
PERFEXCRM_IS_ENABLED="false"
+59
View File
@@ -0,0 +1,59 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=shpping_portal
DB_USERNAME=root
DB_PASSWORD=P@ssw0rd
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
UNITY_APP_URL="https://unity.izyim.com"
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
YD_API_CODE=''
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
+2
View File
@@ -2,6 +2,8 @@
/public/hot
/public/storage
/storage/*.key
/tests/_output
/tests/_support
/vendor
**/.idea/
.env
+120
View File
@@ -0,0 +1,120 @@
image: php:7.4
stages:
- service_build
- node
- building_assets
- database
- unit_test
- acceptance_test
- code_quality
# Variables
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: mysql_password
MYSQL_PASSWORD: mysql_password
MYSQL_DATABASE: shpping_portal
DB_HOST: mysql
before_script:
- apt-get update -yqq
- apt-get install -yqq
- apt-get install -y libonig-dev
- apt-get install -y libxml2-dev
- apt-get install -y libzip-dev
- apt-get install -y libgd-dev
- apt-get install -y libgd-dev
# Install PDO MySQL extension
- docker-php-ext-install pdo_mysql
#install php dependencies
- docker-php-ext-install mbstring xml zip gd
# Install composer package manager
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
- chmod +x /usr/local/bin/composer
# Install MySQL client
- apt-get install -y default-mysql-client
#install node js
- apt-get update && apt-get install -y nodejs npm
#install gulp Js
- npm install -g gulp-cli
#jobs
#buld the backend
composer_php:
stage: service_build
script:
- composer install
- cp .env.example .env
- php artisan key:generate
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#build the UI
#node installation
npm:
stage: node
script:
- npm install # Install npm dependencies
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#building assets
building_assets:
stage: building_assets
# dependencies:
# - npm
script:
- npm install # Install npm dependencies
- gulp build # Build assets
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#mysql
database:
stage: database
services:
- name: mysql:8.0
command: [ "--default-authentication-plugin=mysql_native_password" ]
#dependencies:
# - composer_php
script:
- composer install
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:fresh
- php artisan db:seed
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
#mysql
unit_test:
stage: unit_test
services:
- name: mysql:8.0
command: [ "--default-authentication-plugin=mysql_native_password" ]
#dependencies:
# - database
script:
- npm install # Install npm dependencies
- gulp build # Build assets
- composer install
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:fresh
- php artisan db:seed
- php artisan test
rules:
- if: '$CI_COMMIT_BRANCH =~ /.*/'
+20 -43
View File
@@ -1,62 +1,39 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
## Shipping portal documentation
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
simple documentation on how to install, run, test, commit and deploy application
## About Laravel
## creating and running unit tests
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
Required Tools
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
- Chromium Driver / selenium
- add running and setting selenium on all OS if possible
Laravel is accessible, powerful, and provides tools required for large, robust applications.
Required Packages :
## Learning Laravel
- laravel/legacy-factories
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
- codeception/codeception
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
Or Simply Run
## Laravel Sponsors
``Composer install``
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
To create a unit test
### Premium Partners
``php artisan make test: Test Example --unit``
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
Running the tests :
## Contributing
Running a single Test
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
`` php artisan test --filter Example``
## Code of Conduct
Running Unit tests -
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
`` php artisan test ``
## Security Vulnerabilities
Running Codeception tests -
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
``vendor/bin/codecept run``
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,19 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class AmountExceed implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('amount', '>', $value);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class AmountShort implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('amount', '<', $value);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
class CreatedBefore implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('created_at', '<', Carbon::parse($value));
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use App\Classes\ValueObjects\Constants\TransactionType;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
class DoesNotHavePaymentStatusIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
$query->where('type', TransactionType::PAYMENT)->whereIn('status', $value);
});
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class EmailLike implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('email', 'LIKE', '%'.$value.'%');
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use App\Classes\ValueObjects\Constants\TransactionType;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
class HavePaymentStatusNotIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereHas('transactions', function (Builder $query) use($value) {
$query->where('type', TransactionType::PAYMENT)->whereNotIn('status', $value);
});
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class OwnerType implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('owner_type', $value);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class PaymentMethod implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('payment_method', $value);
}
}
+19 -2
View File
@@ -2,8 +2,8 @@
namespace App\Classes\General;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Log;
class Helper
{
@@ -24,4 +24,21 @@ class Helper
return array_slice(get_class_methods($className), 1);
}
}
/**
* @param $log
* @return none
*/
static function debugLoggerForPerfexCRM($log){
if($log){
$message = $log['message'];
$substring = 'No data were found';
if (isset($message)) {
if (strpos($message, $substring) !== false) {
// Log::info('Message exist');
} else {
Log::info($log['message']);
}
}
}
}
}
+9 -2
View File
@@ -11,15 +11,17 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
use App\Models\PackingList;
use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use App\Classes\General\Helper;
class UpdatePerfexCRMInvoice implements ShouldQueue
{
@@ -51,7 +53,12 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
if(is_null($invoice)){
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
$invoiceId = $result->payload['id'];
if ($result) {
$invoiceId = $result->payload['id'];
} else {
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
}
}
else{
$invoiceId = $invoice->id;
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\Accounts\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounts\Services\UpdatesUser;
use App\Classes\Modules\Accounts\Services\UpdatesUserFullName;
use App\Classes\Modules\Accounts\Services\FetchesUser;
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
@@ -29,8 +29,8 @@ class UpdateUserLogic extends AbstractControllerLogic
/** @var CanUpdateUser */
private $canUpdateUser;
/** @var UpdatesUser */
private $updatesUser;
/** @var UpdatesUserFullName */
private $updatesUserFullName;
/** @var FetchesUser */
private $fetchesUser;
@@ -38,13 +38,13 @@ class UpdateUserLogic extends AbstractControllerLogic
/**
* UpdateAddressLogic constructor.
* @param CanUpdateUser $canUpdateUser
* @param UpdatesUser $updatesUser
* @param UpdatesUserFullName $updatesUserFullName
* @param FetchesUser $fetchesUSer
*/
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser)
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUserFullName $updatesUserFullName, FetchesUser $fetchesUser)
{
$this->canUpdateUser = $canUpdateUser;
$this->updatesUser = $updatesUser;
$this->updatesUserFullName = $updatesUserFullName;
$this->fetchesUser = $fetchesUser;
}
@@ -64,7 +64,7 @@ class UpdateUserLogic extends AbstractControllerLogic
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
$query = $this->updatesUser->execute($query, $object);
$query = $this->updatesUserFullName->execute($query, $object);
return $this->resourceResponse(new UserResource($query));
@@ -0,0 +1,71 @@
<?php
namespace App\Classes\Modules\Accounts\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounts\Services\UpdatesUser;
use App\Classes\Modules\Accounts\Services\FetchesUser;
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
use App\Http\Resources\UserResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateUserRoleLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Updated Admin Role',
'message' => 'You have successfully updated the Admin Role'
];
}
/** @var CanUpdateUser */
private $canUpdateUser;
/** @var UpdatesUser */
private $updatesUser;
/** @var FetchesUser */
private $fetchesUser;
/**
* UpdateAddressLogic constructor.
* @param CanUpdateUser $canUpdateUser
* @param UpdatesUser $updatesUser
* @param FetchesUser $fetchesUSer
*/
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser)
{
$this->canUpdateUser = $canUpdateUser;
$this->updatesUser = $updatesUser;
$this->fetchesUser = $fetchesUser;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
$object = new UserObject($query->name, $request->input('type'));
$this->canUpdateUser->passes($object);
$query = $this->updatesUser->execute($query, $object);
return $this->resourceResponse(new UserResource($query));
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Classes\Modules\Accounts\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
class UserObject implements DataTransferObject
{
/** @var string */
private $name;
/** @var int */
private $type;
/**
* FullNameObject constructor.
* @param string $name
*/
public function __construct(string $name, int $type)
{
$this->name = $name;
$this->type = $type;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return int
*/
public function getType(): int
{
return $this->type;
}
}
@@ -3,7 +3,7 @@
namespace App\Classes\Modules\Accounts\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
use App\Models\User;
class UpdatesUser extends AbstractUpdateRecord
@@ -11,13 +11,14 @@ class UpdatesUser extends AbstractUpdateRecord
/**
* @param User $model
* @param FullNameObject $object
* @param UserObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(User $model, FullNameObject $object) {
public function execute(User $model, UserObject $object) {
$model->name = $object->getName();
$model->type = $object->getType();
return $this->handler($model);
}
@@ -0,0 +1,24 @@
<?php
namespace App\Classes\Modules\Accounts\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
use App\Models\User;
class UpdatesUserFullName extends AbstractUpdateRecord
{
/**
* @param User $model
* @param FullNameObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(User $model, FullNameObject $object) {
$model->name = $object->getName();
return $this->handler($model);
}
}
@@ -3,6 +3,9 @@
namespace App\Classes\Modules\Addresses\ControllersLogic;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\General\Interfaces\Contactable;
use App\Classes\Modules\Addresses\Services\CreatesAddress;
@@ -17,6 +20,7 @@ use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\AddressResource;
use App\Models\Address;
use App\Transformers\AddressTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -27,7 +31,8 @@ class CreateAddressLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Created Address',
'message' => 'You have successfully created a new Address'
@@ -74,11 +79,11 @@ class CreateAddressLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
@@ -90,16 +95,22 @@ class CreateAddressLogic extends AbstractControllerLogic
/** @var Address $address */
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
if($request->input('phone')){
if ($request->input('phone')) {
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
$this->createContactProcessor->execute($contactObject, $address);
}
if($request->input('remark')){
if ($request->input('remark')) {
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
$this->createRemarkProcessor->execute($address, $remarkObject);
}
/* return fractal()
->item($address, new AddressTransformer())
->parseIncludes('remark')
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new AddressResource($address));
}
@@ -3,6 +3,9 @@
namespace App\Classes\Modules\Addresses\ControllersLogic;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\Services\CreatesAddress;
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
@@ -14,6 +17,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\AddressResource;
use App\Models\Address;
use App\Models\CompanyModule;
use App\Transformers\AddressTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -23,7 +27,8 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Created Billing Address',
'message' => 'You have successfully created a new Billing Address'
@@ -60,27 +65,35 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
// delete all current billing address
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
// create addrress
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
// create new billing addrress
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
$this->canCreateAddress->passes($billingAddress);
$this->createsAddress->execute($companyModule, $billingAddress);
}
return $this->resourceResponse(new AddressResource($address));
//load address with only owner address
/* return fractal()
->item($billingAddressInputed, new AddressTransformer())
->parseIncludes('Owner_address')
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new AddressResource($billingAddressInputed));
}
}
@@ -3,6 +3,8 @@
namespace App\Classes\Modules\Addresses\ControllersLogic;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\Services\FetchesAddress;
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
@@ -17,7 +19,8 @@ class FetchAddressLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Retrieved Address',
'message' => 'You have successfully retrieved a Address'
@@ -45,15 +48,22 @@ class FetchAddressLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$this->canFetchAddress->passes();
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
//load address with no relationships
/* return fractal()
->item($address, new AddressTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new AddressResource($query));
}
@@ -3,10 +3,14 @@
namespace App\Classes\Modules\Addresses\ControllersLogic;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\Services\ListsAddresses;
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
use App\Http\Resources\AddressResource;
use App\Transformers\AddressTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,7 +21,8 @@ class ListAddressesLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Retrieved Addresses',
'message' => 'You have successfully retrieved a list of Addresses'
@@ -45,17 +50,25 @@ class ListAddressesLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$this->canListAddresses->passes();
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
//a collection of addresses with all incluides
/* return fractal()
->collection($query, new AddressTransformer)
->parseIncludes('Owner_address')
->parseIncludes('remark')
->parseIncludes('contact')
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->collectionResponse(AddressResource::collection($query));
}
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\Services\ListsAddresses;
use App\Classes\Modules\Addresses\Services\ListsDistricts;
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
use App\Http\Resources\AddressResource;
use App\Http\Resources\DistrictResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\Services\ListsAddresses;
use App\Classes\Modules\Addresses\Services\ListsStates;
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
use App\Http\Resources\AddressResource;
use App\Http\Resources\StateResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
@@ -9,6 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
use App\Models\Address;
use App\Transformers\AddressTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -33,7 +34,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
/** @var ResetsAddressesDefault */
private $resetsAddressesDefault;
/** @var SetsAddressToDefault*/
/** @var SetsAddressToDefault */
private $setsAddressToDefault;
@@ -64,7 +65,15 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
$this->resetsAddressesDefault->execute($address->owner, $address->type);
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
$setAddress = $this->setsAddressToDefault->execute($address);
//no relationships needed
/* return fractal()
->item($setAddress, new AddressTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new AddressResource($address));
}
}
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\AddressType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\AddressResource;
use App\Models\Address;
use App\Transformers\AddressTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -26,7 +27,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Updated Address',
'message' => 'You have successfully updated the Address'
@@ -77,7 +79,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
@@ -90,18 +92,25 @@ class UpdateAddressLogic extends AbstractControllerLogic
/** @var Address $address */
$address = $this->updatesAddress->execute($address, $object);
$address->contacts()->delete(); $address->remarks()->delete();
$address->contacts()->delete();
$address->remarks()->delete();
if($request->input('phone')){
if ($request->input('phone')) {
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
$this->createContactProcessor->execute($contactObject, $address);
}
if($request->input('remark')){
if ($request->input('remark')) {
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
$this->createRemarkProcessor->execute($address, $remarkObject);
}
//only remark relationship needed
/* return fractal()
->item($address, new AddressTransformer())
->parseIncludes('remark')
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new AddressResource($address));
}
@@ -10,7 +10,7 @@ use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
use App\Http\Resources\AnnouncementResource;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -66,8 +66,8 @@ class UpdateAnnouncementLogic extends AbstractControllerLogic
$annoucement_object = new AnnouncementObject(
$request->input('title'),
$request->input('description'),
$request->input('starting_on'),
$request->input('ending_on')
Carbon::createFromFormat('d-m-Y', $request->input('starting_on'))->format('Y-m-d H:i:s'),
Carbon::createFromFormat('d-m-Y', $request->input('ending_on'))->format('Y-m-d H:i:s')
);
$this->canUpdateAnnouncement->passes($annoucement_object);
@@ -45,6 +45,9 @@ class CallbackBillplzLogic
/** @var UpdateDoFromYDPortalProcessor */
private $updateDoFromYDPortalProcessor ;
/** @var UpdatesWalletBalance */
private $updatesWalletBalance;
/**
* CallbackBillplzLogic constructor.
* @param GetBillplzBill $getBillplzBill
@@ -53,13 +56,14 @@ class CallbackBillplzLogic
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
*/
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance)
{
$this->getBillplzBill = $getBillplzBill;
$this->fetchesTransaction = $fetchesTransaction;
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
$this->updatesWalletBalance = $updatesWalletBalance;
}
@@ -102,6 +106,11 @@ class CallbackBillplzLogic
$token = Auth::fromUser(User::find(1));
$request->headers->set('Authorization', 'Bearer '.$token);
// check if is wallet top up
if($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
}
$this->updatesTransactionStatus->execute($transaction, $status);
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
@@ -109,18 +118,28 @@ class CallbackBillplzLogic
if(($invoice->amount - $totalPaidAmount) < 0.01) {
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
$packingList->status = ApprovalStatus::APPROVED;
$packingList->save();
if(($invoice->amount - $totalPaidAmount) < 0.01) {
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
if(app()->environment('production')){
$this->updateDoFromVTPortalProcessor->execute($packingList);
$this->updateDoFromYDPortalProcessor->execute($packingList);
$packingList->status = ApprovalStatus::APPROVED;
$packingList->save();
if(app()->environment('production')){
$this->updateDoFromVTPortalProcessor->execute($packingList);
$this->updateDoFromYDPortalProcessor->execute($packingList);
}
}
}
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
if ($transaction->owner instanceof Wallet) {
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
} else {
$company_module_marking = $order->companyModule->connections? $order->companyModule->connections->first()->invitee_reference: null;
}
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference, 'transaction' => $transaction, 'status' => $status]);
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status]);
}
}
@@ -3,10 +3,14 @@
namespace App\Classes\Modules\Companies\ControllersLogic;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
use App\Http\Resources\CompanyModuleResource;
use App\Transformers\CompanyTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,7 +21,8 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Retrieved Company Moduels',
'message' => 'You have successfully retrieved a list of Companies'
@@ -45,15 +50,26 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$this->canListCompanies->passes();
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
/*include all relationships*/
/* return fractal()
->collection($query, new CompanyTransformer)
->parseIncludes('company')
->parseIncludes('contact')
->parseIncludes('remarks')
->parseIncludes('address')
->parseIncludes('billingAddress')
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->collectionResponse(CompanyModuleResource::collection($query));
}
@@ -0,0 +1,77 @@
<?php
namespace App\Classes\Modules\Contacts\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Contacts\Services\UpdatesContact;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
use App\Classes\Modules\Contacts\Services\FetchesContact;
use App\Http\Resources\ContactResource;
use App\Transformers\ContactTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateContactLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Updated Contact',
'message' => 'You have successfully updated the Contact'
];
}
/** @var UpdatesContact */
private $updatesContact;
/** @var FetchesContact */
private $fetchesContact;
/**
* UpdateContactLogic constructor.
* @param UpdatesContact $updatesContact
* @param FetchesContact $fetchesContact
*/
public function __construct(UpdatesContact $updatesContact, FetchesContact $fetchesContact)
{
$this->updatesContact = $updatesContact;
$this->fetchesContact = $fetchesContact;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$object = new ContactObject(
$request->input('reference'),
$request->input('phone'),
$request->input('email'),
$request->input('wechat_id')
);
// $this->canUpdateContact->passes($object);
$query = $this->fetchesContact->execute(['id' => $request->route('id')]);
$query = $this->updatesContact->execute($query, $object);
/*uniformity*/
/* return fractal()
->item($query, new ContactTransformer())
->parseIncludes('remark')
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContactResource($query));
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Classes\Modules\Contacts\Services;
use App\Classes\General\Eloquent\AbstractFetchRecord;
use Illuminate\Database\Eloquent\Builder;
use App\Models\Contact;
class FetchesContact extends AbstractFetchRecord
{
/** @var Contact */
private $repository;
/**
* FetchesContact constructor.
* @param Contact $repository
*/
public function __construct(Contact $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Classes\Modules\Contacts\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
use App\Models\Contact;
class UpdatesContact extends AbstractUpdateRecord
{
/**
* @param Contact $model
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Contact $model, ContactObject $object)
{
$model->reference = $object->getReference();
$model->phone = $object->getPhone();
$model->email = $object->getEmail();
$model->wechat_id = $object->getWechatId();
return $this->handler($model);
}
}
@@ -7,6 +7,7 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
use App\Classes\Modules\Orders\Services\FetchesOrder;
use App\Http\Resources\DeliveryOrderResource;
use App\Models\Order;
use App\Transformers\DeliveryOrderTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -52,6 +53,14 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
/** @var Order $order */
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
$order = $this->cancelsOrder->execute($order);
//no relationship needed
/* return fractal()
->item($order, new DeliveryOrderTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
}
@@ -172,6 +172,12 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
$this->createsPackage->execute($packageObject, $packingList);
//add relationship to order
/* return fractal()
->item($order, new DeliveryOrderTransformer())
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new DeliveryOrderResource($order));
}
@@ -48,6 +48,12 @@ class ListOrdersLogic extends AbstractControllerLogic
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
//no relationship needed
/* return fractal()
->collection($query, new DeliveryOrderTransformer)
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->collectionResponse(DeliveryOrderResource::collection($query));
}
@@ -7,9 +7,13 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Documents\Services\ListsDocuments;
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
use App\Http\Resources\DocumentResource;
use App\Models\Document;
use App\Transformers\DocumentTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use League\Fractal;
class ListDocumentLogic extends AbstractControllerLogic
{
@@ -58,6 +62,11 @@ class ListDocumentLogic extends AbstractControllerLogic
return $this->collectionResponse(DocumentResource::collection($query));
/* return fractal()
->collection($query, new DocumentTransformer)
->respond(200, [], JSON_PRETTY_PRINT);*/
}
}
@@ -39,7 +39,12 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
'ProjNo',
'DeptNo',
'Qty',
'UnitPrice'
'UnitPrice',
// 'marking',
// 'contact person',
// 'contact number',
// 'link',
// 'amount'
];
}
@@ -97,6 +102,10 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
$order = $transaction->owner->owner;
$company = $order->companyModule->company;
$shippingTransactionDetails = $transaction->transactionDetails()->where('reference', 'SHIPPING_FEE')->first();
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
$contact = $order->companyModule->company->contacts->first();
$userName = $order->companyModule->employees()->first();
$link = route('customer.payment-and-billing', $marking);
$furtherDescription = '';
@@ -123,7 +132,12 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
$container->reference,
'CIEF',
$shippingTransactionDetails->quantity,
$shippingTransactionDetails->price
$shippingTransactionDetails->price,
// $marking,
// $contact ? $contact->phone : '',
// $userName->name,
// $link,
// $transaction->amount
];
return [
'<<New>>',
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Exports\Services;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Models\Order;
use App\Models\State;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
@@ -32,10 +31,8 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
*/
public function query()
{
$johor_state_id = State::where('name', 'johor')->first()->id;
return Order::whereHas('addresses', function($address) use ($johor_state_id){
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
return Order::whereHas('addresses', function($address) {
$address->where('status', ApprovalStatus::APPROVED);
})->whereHas('packingLists', function($packingLists) {
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
});
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
use App\Http\Resources\AddressResource;
use App\Http\Resources\OrderResource;
use App\Transformers\AddressTransformer;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
@@ -39,6 +40,12 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
{
$address = $this->approveChangeOrderAddressProcessor->execute($request);
//load address with no relationships
/* return fractal()
->item($address, new AddressTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new AddressResource($address));
}
}
@@ -4,21 +4,28 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
use App\Classes\Modules\Addresses\Services\CreatesAddress;
use App\Classes\Modules\Addresses\Services\FetchesAddress;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
use App\Classes\ValueObjects\Constants\AddressType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\WarehouseReferences;
use App\Http\Resources\OrderResource;
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
use App\Models\Address;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class CreateOrderLogic extends AbstractControllerLogic
{
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Created Order',
'message' => 'You have successfully created a new Order'
@@ -40,6 +47,12 @@ class CreateOrderLogic extends AbstractControllerLogic
/** @var GeneratesOrderNumber */
private $generatesOrderNumber;
/** @var CreatesAddress */
private $createsAddress;
/** @var CanCreateAddress */
private $canCreateAddress;
/** @var NewLeadTaskToPerfexCRMProcessor */
private $newLeadTaskToPerfexCRMProcessor;
/**
@@ -50,31 +63,47 @@ class CreateOrderLogic extends AbstractControllerLogic
* @param FetchesCompanyModule $fetchesCompanyModule
* @param GeneratesOrderNumber $generatesOrderNumber
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
* @param CreatesAddress $createsAddress
* @param CanCreateAddress $canCreateAddress
*/
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, CreatesAddress $createsAddress, CanCreateAddress $canCreateAddress, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
{
$this->fetchesCompany = $fetchesCompany;
$this->fetchesAddress = $fetchesAddress;
$this->createOrderProcessor = $createOrderProcessor;
$this->fetchesCompanyModule = $fetchesCompanyModule;
$this->generatesOrderNumber = $generatesOrderNumber;
$this->createsAddress = $createsAddress;
$this->canCreateAddress = $canCreateAddress;
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
}
public function logic(Request $request) : JsonResponse {
public function logic(Request $request): JsonResponse
{
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
// todo-new: fix this
// if select warehouse foshan
if ($request->input('warehouse_id') === 'foshan') {
// 13 - sabah, 14 - sarawak
if (in_array($address->state->id, [13, 14])) {
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_FS_WEST_MALAYSIA]);
} else {
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_FS_WEST_MALAYSIA]);
}
} else {
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
if (!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)) {
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
}
}
if($originWarehouse->reference === WarehouseReferences::YD_YIWU && in_array($address->state_id, [5, 13, 14])) {
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
}
@@ -0,0 +1,60 @@
<?php
namespace App\Classes\Modules\Orders\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Orders\Services\FetchesOrder;
use App\Classes\Modules\Orders\Standards\Rules\CanFetchOrder;
use App\Http\Resources\OrderV2Resource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchOrderV2Logic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Order',
'message' => 'You have successfully retrieved an order'
];
}
/** @var CanFetchOrder */
private $canFetchOrder;
/** @var FetchesOrder */
private $fetchesOrder;
/**
* FetchOrderLogic constructor.
* @param CanFetchOrder $canFetchOrder
* @param FetchesOrder $fetchesOrder
*/
public function __construct(CanFetchOrder $canFetchOrder, FetchesOrder $fetchesOrder)
{
$this->canFetchOrder = $canFetchOrder;
$this->fetchesOrder = $fetchesOrder;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
{
$this->canFetchOrder->passes();
$query = $this->fetchesOrder->execute(['reference' => $request->route('id'), 'with_packing_lists' => true]);
return $this->resourceResponse(new OrderV2Resource($query));
}
}
@@ -0,0 +1,56 @@
<?php
namespace App\Classes\Modules\Orders\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Orders\Services\ListsOrders;
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
use App\Classes\ValueObjects\Constants\OrderType;
use App\Http\Resources\OrderV2Resource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListOrdersV2Logic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Orders',
'message' => 'You have successfully retrieved a list of Orders'
];
}
/** @var CanListOrders */
private $canListOrders;
/** @var ListsOrders */
private $listsOrders;
/**
* ListOrdersLogic constructor.
* @param CanListOrders $canListOrders
* @param ListsOrders $listsOrders
*/
public function __construct(CanListOrders $canListOrders, ListsOrders $listsOrders)
{
$this->canListOrders = $canListOrders;
$this->listsOrders = $listsOrders;
}
public function logic(Request $request) : JsonResponse
{
$this->canListOrders->passes();
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]));
return $this->collectionResponse(OrderV2Resource::collection($query));
}
}
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -56,6 +57,13 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
$container->packingLists()->attach($packing_list_item);
}
//only return with packing list relationship
/* return fractal()
->item($container, new ContainerTransformer())
->parseInclude(['packingLists'])
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
} catch (\Exception $exception){
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -19,7 +20,8 @@ class CompleteContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Updated Container',
'message' => 'You have successfully updated the Container'
@@ -51,10 +53,16 @@ class CompleteContainerLogic extends AbstractControllerLogic
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
//no relationships needed
/* return fractal()
->item($container, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
}
@@ -11,6 +11,7 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -70,6 +71,11 @@ class CreateContainerLogic extends AbstractControllerLogic
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
//no relationship needed
/* return fractal()
->item($query, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($query));
}
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -18,7 +19,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Created Container Remark',
'message' => 'You have successfully created a new Container Remark'
@@ -50,7 +52,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
@@ -59,6 +61,12 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
$this->createRemarkProcessor->execute($container, $object);
//load with remarks only
/* return fractal()
->item($container, new ContainerTransformer())
->parseIncludes(['remarks'])
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
}
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\TransportType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -28,7 +29,8 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Created Container',
'message' => 'You have successfully created a new Container'
@@ -41,7 +43,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
/** @var FetchesPackingList */
private $fetchesPackingList;
/** @var FetchesCompanyModule */
/** @var FetchesCompanyModule */
private $fetchesCompanyModule;
/** @var CreatesPackingList */
@@ -54,12 +56,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
private $createsSchedule;
public function __construct(
CanCreateContainer $canCreateContainer,
FetchesPackingList $fetchesPackingList,
FetchesCompanyModule $fetchesCompanyModule,
CreatesContainer $createsContainer,
CreatesTransport $createsTransport,
CreatesSchedule $createsSchedule
CanCreateContainer $canCreateContainer,
FetchesPackingList $fetchesPackingList,
FetchesCompanyModule $fetchesCompanyModule,
CreatesContainer $createsContainer,
CreatesTransport $createsTransport,
CreatesSchedule $createsSchedule
)
{
$this->canCreateContainer = $canCreateContainer;
@@ -77,11 +79,11 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$object = new ContainerObject(
$request->input('container_reference'),
$request->input('container_number'),
$request->input('container_reference'),
$request->input('container_number'),
$request->input('seal_reference'),
$request->input('container_type'),
ApprovalStatus::APPROVED
@@ -92,21 +94,27 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
$transportObject = new TransportObject(
TransportType::LAND, null,
$request->input('tracking'),
Carbon::parse($request->input('etd')),
Carbon::parse($request->input('eta')),
TransportType::LAND, null,
$request->input('tracking'),
Carbon::parse($request->input('etd')),
Carbon::parse($request->input('eta')),
ApprovalStatus::APPROVED
);
$transport = $this->createsTransport->execute($transportObject, $container);
$scheduleObject = new ScheduleObject(
Carbon::parse($request->input('etd')),
Carbon::parse($request->input('etd')),
Carbon::parse($request->input('eta')),
ApprovalStatus::APPROVED
);
);
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
//include transport
/* return fractal()
->item($container, new ContainerTransformer())
->parseIncludes(['transport'])
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
}
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,7 +18,8 @@ class FetchContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Retrieved Container',
'message' => 'You have successfully retrieved a Container'
@@ -48,12 +50,18 @@ class FetchContainerLogic extends AbstractControllerLogic
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$this->canFetchContainer->passes();
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
//load with packing lists
/* return fractal()
->item($query, new ContainerTransformer())
->parseIncludes(['packing_lists'])
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($query));
}
@@ -9,6 +9,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -19,7 +20,8 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Retrieved Containers',
'message' => 'You have successfully retrieved a list of Containers'
@@ -52,11 +54,16 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$query = $this->fetchInboundCustomCleared->execute();
//no relations required
/* return fractal()
->item($query, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->collectionResponse(ContainerResource::collection($query));
}
@@ -3,10 +3,14 @@
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,7 +21,8 @@ class ListContainersLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Retrieved Containers',
'message' => 'You have successfully retrieved a list of Containers'
@@ -45,16 +50,22 @@ class ListContainersLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$this->canListContainers->passes();
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
//load with no filters, a details page to be added to load one with all related data
/* return fractal()
->collection($query, new ContainerTransformer)
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->collectionResponse(ContainerResource::collection($query));
}
@@ -10,6 +10,7 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -20,7 +21,8 @@ class RescheduleContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Reschedule Container',
'message' => 'You have successfully Reschedule Container'
@@ -54,7 +56,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
try {
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
@@ -65,15 +67,20 @@ class RescheduleContainerLogic extends AbstractControllerLogic
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
$scheduleObject = new ScheduleObject(
Carbon::parse($request->input('etd')),
Carbon::parse($request->input('eta')),
Carbon::parse($request->input('etd')),
Carbon::parse($request->input('eta')),
ApprovalStatus::APPROVED
);
);
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
//no relationship
/* return fractal()
->item($container, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
} catch (\Exception $exception){
} catch (\Exception $exception) {
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
@@ -3,12 +3,16 @@
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
use App\Classes\Exceptions\AccessForbiddenException;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -19,7 +23,8 @@ class UpdateContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Updated Container',
'message' => 'You have successfully updated the Container'
@@ -52,19 +57,19 @@ class UpdateContainerLogic extends AbstractControllerLogic
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
* @throws AccessForbiddenException
* @throws MalformedRequestException
* @throws RequestValidationException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
$object = new ContainerObject(
$request->input('container_reference'),
$container->container_number,
$request->input('container_type'),
$object = new ContainerObject(
$request->input('container_reference'),
$container->container_number,
$request->input('container_type'),
$request->input('seal_reference'),
$request->input('loading_date'),
$container->status,
@@ -74,6 +79,12 @@ class UpdateContainerLogic extends AbstractControllerLogic
$query = $this->updatesContainer->execute($container, $object);
//no relationships
/*
return fractal()
->item($query, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($query));
}
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,7 +18,8 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Updated Dispatch Date Container',
'message' => 'You have successfully updated the Dispatch Date Container'
@@ -49,11 +51,18 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
$transport = $container->transports()->first();
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
//no relationships queried
/* return fractal()
->item($query, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
}
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
use App\Http\Resources\ContainerResource;
use App\Transformers\ContainerTransformer;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -17,7 +18,8 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Updated Drop Date Container',
'message' => 'You have successfully updated the Drop Date Container'
@@ -49,11 +51,17 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
$transport = $container->transports()->first();
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
//no relationship needed
/* return fractal()
->item($query, new ContainerTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new ContainerResource($container));
}
@@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Http\Resources\DeliverPackingListResource;
use App\Transformers\DeliverPackingListTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -24,7 +25,8 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
/**
* @return array
*/
protected function notification():array {
protected function notification(): array
{
return [
'title' => 'Created Deliver PackingList',
'message' => 'You have successfully created a new Deliver PackingList'
@@ -60,7 +62,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
* @param Request $request
* @return JsonResponse
*/
public function logic(Request $request) : JsonResponse
public function logic(Request $request): JsonResponse
{
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
$packing_list_id = $request->input('packing_list_id');
@@ -68,9 +70,9 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
$reference_number = $this->generatesPackingListReferenceNumber->execute();
$packingListObject = new PackingListObject(
$reference_number,
null,
PackingListType::DELIVERY_PACKING_LIST,
$reference_number,
null,
PackingListType::DELIVERY_PACKING_LIST,
ApprovalStatus::PENDING_SUBMISSION
);
@@ -82,6 +84,12 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
//no relationships required
/* return fractal()
->item($deliverPackingList, new DeliverPackingListTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
}
@@ -0,0 +1,81 @@
<?php
namespace App\Classes\Modules\PackingLists\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Models\PackingList;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DeletePackingListByPackageIdLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Deleted PackingList',
'message' => 'You have successfully deleted a PackingList'
];
}
/** @var CanDeletePackingList */
private $canDeletePackingList;
/** @var DeletesPackingList */
private $deletesPackingList;
/** @var FetchesPackingList */
private $fetchesPackingList;
/** @var FetchesPackage */
private $fetchesPackage;
/**
* DeletePackingListByPackageIdLogic constructor.
* @param CanDeletePackingList $canDeletePackingList
* @param DeletesPackingList $deletesPackingList
* @param FetchesPackingList $fetchesPackingList
* @param FetchesPackage $fetchesPackage
*/
public function __construct(CanDeletePackingList $canDeletePackingList, DeletesPackingList $deletesPackingList, FetchesPackingList $fetchesPackingList, FetchesPackage $fetchesPackage)
{
$this->canDeletePackingList = $canDeletePackingList;
$this->deletesPackingList = $deletesPackingList;
$this->fetchesPackingList = $fetchesPackingList;
$this->fetchesPackage = $fetchesPackage;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$this->canDeletePackingList->passes();
$package = $this->fetchesPackage->execute(['id' => $request->route('id')]);
$packingList = $package->packingList;
$packingList = PackingList::where('reference', $packingList->reference)->get();
$childPackingList = PackingList::where('owner_type', PackingList::class)->whereIn('owner_id', $packingList->pluck('id'))->get();
$packingList->each->delete();
$childPackingList->each->delete();
return $this->response([]);
}
}
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException;
use Illuminate\Support\Facades\Log;
use App\Classes\General\Helper;
class FetchesPerfexCRMTask
{
@@ -38,7 +39,7 @@ class FetchesPerfexCRMTask
return (object) $data;
}else{
Log::error($response);
Helper::debugLoggerForPerfexCRM($response);
return null;
}
}catch(\Exception $exception){
@@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException;
use Illuminate\Support\Facades\Log;
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
use App\Classes\General\Helper;
class UpdatesPerfexCRMCustomer
{
@@ -37,7 +38,7 @@ class UpdatesPerfexCRMCustomer
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Helper::debugLoggerForPerfexCRM($response);
return null;
}
}catch(\Exception $exception){
@@ -0,0 +1,104 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\Notifications\InvoiceIssuedEmail;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\Modules\Documents\Services\CreatesFiles;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Documents\Services\CreatesDocument;
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\Modules\Transactions\ControllersLogic\Document;
class CreateCombinedInvoicesLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Shipping Invoice Status',
'message' => 'You have successfully updated multiple shipping invoices status'
];
}
/** @var FetchesPackingList */
private $fetchesPackingList;
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/** @var CreatesDocument */
private $createsDocument;
/** @var CreatesFiles */
private $createsFiles;
/**
* ApprovePaymentVerificationLogic constructor.
* @param FetchesPackingList $fetchesPackingList
* @param UpdatesTransactionStatus $updatesTransactionStatus
* @param CreatesDocument $createsDocument
* @param CreatesFiles $createsFiles
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
*/
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
{
$this->fetchesPackingList = $fetchesPackingList;
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->createsDocument = $createsDocument;
$this->createsFiles = $createsFiles;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function logic(Request $request) : JsonResponse
{
$items = $request->input('ids');
$invoice_transactions=array();
foreach($items as $item){
$packing_list = $this->fetchesPackingList->execute(['id' => $item['id']]);
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
array_push($invoice_transactions, $invoice_transaction);
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
}
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $invoice_transactions]);
$document_object = new DocumentObject(
DocumentType::SHIPPING_INVOICE,
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
'',
ApprovalStatus::COMPLETED,
'shipping_invoice'
);
/** @var Document $document */
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
$this->createsFiles->execute($document, $document_object);
$user = $packing_list->owner->companyModule->employees()->first();
if(app()->environment(['production'])) {
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
}
return $this->response([]);
}
}
@@ -0,0 +1,254 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\TransactionResource;
use App\Models\Group;
use App\Models\Transaction;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Models\Wallet;
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
class CreateGroupsLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Create Group Transaction',
'message' => 'You have successfully created a group transaction'
];
}
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var GeneratesTransactionBillNumber */
private $generatesTransactionBillNumber;
/** @var CreatesTransactionableTransaction */
private $createsTransactionableTransaction;
/** @var CreatesBillplzBill */
private $createsBillplzBill;
/** @var UpdatesWalletBalance */
private $updatesWalletBalance;
/** @var CreatesTransaction */
private $createsTransaction;
/** @var CreatesPaymentTransaction */
private $createsPaymentTransaction;
/** @var UpdateDoFromVTPortalProcessor */
private $updateDoFromVTPortalProcessor;
/** @var UpdateDoFromYDPortalProcessor */
private $updateDoFromYDPortalProcessor ;
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus ;
public function __construct(
FetchesTransaction $fetchesTransaction,
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
CreatesTransactionableTransaction $createsTransactionableTransaction,
CreatesBillplzBill $createsBillplzBill,
UpdatesWalletBalance $updatesWalletBalance,
CreatesTransaction $createsTransaction,
CreatesPaymentTransaction $createsPaymentTransaction,
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
UpdatesTransactionStatus $updatesTransactionStatus
)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
$this->createsBillplzBill = $createsBillplzBill;
$this->updatesWalletBalance = $updatesWalletBalance;
$this->createsPaymentTransaction = $createsPaymentTransaction;
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
$this->updatesTransactionStatus = $updatesTransactionStatus;
}
public function logic(Request $request) : JsonResponse
{
$invoice_ids = json_decode($request->route('transaction_ids'));
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
if (count($invoice_ids) > 1) {
dd('more than 1 invoice');
// creates group transaction
$group = new Group();
$issuer = '';
$receiver = '';
$amount = 0;
$original_amount = 0;
$currency_id = 0;
$original_currency_id = '';
$currency_rate = '';
$tax = 0;
$service_charge = 0;
// todo-new: check why is this not working
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
foreach ($invoices as $invoice) {
// todo-new: attach transaction to the group id
// create one payment for each, then mark as pending_approval
$issuer = $invoice->issuer;
$receiver = $invoice->receiver;
$amount += $invoice->amount;
$original_amount += $invoice->original_amount;
$currency_id = $invoice->currency_id;
$original_currency_id = $invoice->original_currency_id;
$currency_rate = $invoice->currency_rate;
$tax += $invoice->tax;
$service_charge += $invoice->service_charge;
}
$group->issuer = $issuer;
$group->receiver = $receiver;
$group->reference = $billNumber;
$group->amount = $amount;
$group->original_amount = $original_amount;
$group->currency_id = $currency_id;
$group->original_currency_id = $original_currency_id;
$group->currency_rate = $currency_rate;
$group->tax = $tax;
$group->service_charge = $service_charge;
$group->save();
// attach payment on group transaction
// $invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids->first()]);
// $amount = $request->input('amount');
// $company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
$invoice_transaction = $group;
$transferDetails = $billNumber;
$company_module = $group->receiverCompany;
} else {
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids[0]]);
$amount = $request->input('amount');
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
$transferDetails = $invoice_transaction->bill_no;
}
$payment_reference = null;
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
// create billplz transaction
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
$billPlzBill = $this->createsBillplzBill->execute(
$company_module->name,
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
'This payment is for the invoice number . ' . $transferDetails,
$amount,
$billNumber,
$request->input('bank_code'),
true
);
$payment_reference = $billPlzBill->id;
}
else if ($payment_method === PaymentMethodType::WALLET) {
/** @var Wallet $wallet */
$wallet = $company_module->wallets()->first();
if((float) number_format(($wallet->amount - $amount),2) < 0){
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
}
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
$payment_reference = $walletPaymentBillNumber;
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
if (count($invoice_ids) > 1) {
// do one by one
// dd($invoices);
// todo-new: update all the transaction inside
} else {
// $invoice_transaction;
$packingList = $invoice_transaction->owner;
$order = $packingList->owner;
$packingList->status = ApprovalStatus::APPROVED;
$packingList->save();
}
if(app()->environment('production')){
$this->updateDoFromVTPortalProcessor->execute($packingList);
$this->updateDoFromYDPortalProcessor->execute($packingList);
}
$approvalStatus = ApprovalStatus::APPROVED;
// update invoice to completed
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::COMPLETED);
}
else {
$payment_method = PaymentMethodType::CASH;
}
// createsPaymentTransaction
$object = new TransactionObject(
$billNumber,
TransactionType::PAYMENT,
$company_module->id,
1,
1,
$payment_method,
$request->input('amount'),
$request->input('amount'),
1,
1,
0,
0,
0,
null,
$approvalStatus,
null,
$payment_reference
);
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
return $this->resourceResponse(new TransactionResource($payment_transaction));
}
}
@@ -0,0 +1,79 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\FetchesGroup;
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\GroupResource;
use App\Transformers\GroupTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DeleteGroupLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Delete Group Transaction',
'message' => 'You have successfully deleted this Group Transaction'
];
}
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/** @var FetchesGroup */
private $fetchesGroup;
/** @var DeletesTransaction */
private $deletesTransaction;
/**
* DeleteGroupLogic constructor.
* @param updatesTransactionStatus $updatesTransactionStatus
* @param FetchesGroup $fetchesGroup
* @param DeletesTransaction $deletesTransaction
*/
public function __construct(updatesTransactionStatus $updatesTransactionStatus, FetchesGroup $fetchesGroup, DeletesTransaction $deletesTransaction)
{
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->fetchesGroup = $fetchesGroup;
$this->deletesTransaction = $deletesTransaction;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function logic(Request $request) : JsonResponse
{
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
$items = $group->transactions()->get();
foreach($items as $item) {
$bill = $item;
$payment = $bill->owner;
$group->transactions()->detach($bill->id);
$this->updatesTransactionStatus->execute($payment, ApprovalStatus::APPROVED);
$this->deletesTransaction->execute($bill);
}
$group->delete();
//no relationship needed
/* return fractal()
->item($group, new GroupTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new GroupResource($group));
}
}
@@ -0,0 +1,52 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DeleteTransactionLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Delete Transaction',
'message' => 'You have successfully deleted the transaction'
];
}
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/**
* SuspendTransactionLogic constructor.
* @param FetchesTransaction $fetchesTransaction
* @param UpdatesTransactionStatus $updatesTransactionStatus
*/
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->updatesTransactionStatus = $updatesTransactionStatus;
}
public function logic(Request $request) : JsonResponse
{
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
$transaction->delete();
return $this->response([]);
}
}
@@ -0,0 +1,49 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\ListsGroups;
use App\Http\Resources\GroupResource;
use App\Transformers\GroupTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListGroupsLogic extends AbstractControllerLogic
{
/**
* ListTransactionsLogic constructor.
* @param ListsGroups $listsGroups
*/
public function __construct(ListsGroups $listsGroups)
{
$this->listsGroups = $listsGroups;
}
/**
* @return array
*/
protected function notification(): array
{
return [
'title' => 'Retrieved Groups',
'message' => 'You have successfully retrieved a list of groups'
];
}
/** @var ListsGroups */
private $listsGroups;
public function logic(Request $request): JsonResponse
{
$query = $this->listsGroups->execute($this->listsGroups->deserializeFilters($request->input('filters')));
//no relationship needed
/* return fractal()
->collection($query, new GroupTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->collectionResponse(GroupResource::collection($query));
}
}
@@ -0,0 +1,78 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Order;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use App\Classes\Modules\Documents\Services\CreatesDocument;
use App\Classes\Modules\Documents\Services\CreatesFiles;
use App\Models\Document;
class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Regenerate Shipping Invoice',
'message' => 'You have successfully regenerated shipping invoice'
];
}
/** @var CreatesDocument */
private $createsDocument;
/** @var CreatesFiles */
private $createsFiles;
/**
* @param CreatesDocument $createsDocument
*/
public function __construct(CreatesDocument $createsDocument, CreatesFiles $createsFiles)
{
$this->createsDocument = $createsDocument;
$this->createsFiles = $createsFiles;
}
public function logic(Request $request) : JsonResponse
{
$orders = Order::where('company_module_id', $request->route('company_module_id'))->get();
foreach ($orders as $order){
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
foreach ($invoices as $invoice){
$invoice->documents()->delete();
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
$document_object = new DocumentObject(
DocumentType::SHIPPING_INVOICE,
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
'',
ApprovalStatus::COMPLETED,
'shipping_invoice'
);
$document =$this->createsDocument->execute($invoice, $document_object);
$this->createsFiles->execute($document, $document_object);
// dump($document);
}
}
return $this->response([]);
}
}
@@ -0,0 +1,191 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\Modules\Documents\Services\CreatesDocument;
use App\Classes\Modules\Documents\Services\CreatesFiles;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Http\Resources\GroupResource;
use App\Models\Document;
use App\Models\SegmentConstant;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Transactions\Services\FetchesGroup;
use App\Classes\Modules\Transactions\Services\UpdatesTransaction;
use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use ErrorException;
use Illuminate\Support\Facades\DB;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
class UpdateGroupLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification(): array
{
return [
'title' => 'Update Group Transaction',
'message' => 'You have successfully updated this Group Transaction'
];
}
/** @var FetchesGroup */
private $fetchesGroup;
/** @var FetchesCompany */
private $fetchesCompany;
/** @var CalculatesTransactionServiceCharge */
private $calculatesTransactionServiceCharge;
/** @var UpdatesTransaction */
private $updatesTransaction;
/** @var CalculatesTransactionTransferFee */
private $calculatesTransactionTransferFee;
/** @var CreatesDocument */
private $createsDocument;
/** @var CreatesFiles */
private $createsFile;
/**
* UpdateGroupLogic constructor.
* @param FetchesGroup $fetchesGroup
* @param FetchesCompany $fetchesCompany
* @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge
* @param UpdatesTransaction $updatesTransaction
* @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee
* @param CreatesDocument $createsDocument
* @param CreatesFiles $createsFile
*/
public function __construct(FetchesGroup $fetchesGroup, FetchesCompany $fetchesCompany, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, UpdatesTransaction $updatesTransaction, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, CreatesDocument $createsDocument, CreatesFiles $createsFile)
{
$this->fetchesGroup = $fetchesGroup;
$this->fetchesCompany = $fetchesCompany;
$this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge;
$this->updatesTransaction = $updatesTransaction;
$this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee;
$this->createsDocument = $createsDocument;
$this->createsFile = $createsFile;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function logic(Request $request): JsonResponse
{
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
$transactions = $group->transactions()->get();
$rate = $request->input('rate');
$supplier = $this->fetchesCompany->execute(['id' => $request->input('supplier_id')]);
// $group->transactions()->update(['issuer' => $supplier->id, 'currency_rate' => $rate]);
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
foreach ($transactions as $transaction) {
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
$object = new TransactionObject(
$transaction->bill_no,
TransactionType::BILL,
$supplier->id,
1,
$supplier->banks()->where('default', true)->first()->id,
PaymentMethodType::CASH,
$transaction->original_amount * (1 / $rate),
$transaction->original_amount,
1,
$transaction->original_currency_id,
$rate,
0,
$serviceCharge,
null,
ApprovalStatus::PENDING_VERIFICATION
);
$billTransaction = $this->updatesTransaction->execute($transaction, $object);
$transferTransaction = $transaction->transactions()->where('type', TransactionType::TRANSFER_FEE)->first();
$transferFee = $this->calculatesTransactionTransferFee->execute($billTransaction->original_amount, $constant);
$object = new TransactionObject(
$transferTransaction->bill_no,
TransactionType::TRANSFER_FEE,
$supplier->id,
1,
$supplier->banks()->where('default', true)->first()->id,
PaymentMethodType::CASH,
$transaction->original_amount,
$transaction->original_amount,
$transaction->original_currency_id,
$transaction->original_currency_id,
1,
0,
$transferFee,
null,
ApprovalStatus::PENDING_VERIFICATION
);
$this->updatesTransaction->execute($transferTransaction, $object);
}
$group->issuer = $supplier->id;
$group->amount = $group->transactions()->sum('amount');
$group->currency_rate = $rate;
$group->tax = $group->transactions()->sum('tax');
$group->service_charge = $group->transactions()->sum('service_charge');
$group->save();
$group->documents()->delete();
$transferFeeTransactions = $group->transactions()->with([
'transactions' => function ($transaction) {
return $transaction->where('type', TransactionType::TRANSFER_FEE);
}])->get()->pluck('transactions')->flatten();
$pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $group->transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]);
$object = new DocumentObject(
DocumentType::CURRENCY_VENDOR_ORDER,
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
'',
ApprovalStatus::COMPLETED,
'currency_vendor_order'
);
/** @var Document $document */
$document = $this->createsDocument->execute($group, $object);
$this->createsFile->execute($document, $object);
//no relationship needed
/* return fractal()
->item($group, new GroupTransformer())
->respond(200, [], JSON_PRETTY_PRINT);*/
return $this->resourceResponse(new GroupResource($group));
}
}
@@ -0,0 +1,71 @@
<?php
namespace App\Classes\Modules\Transactions\Processors;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Wallets\Services\FetchesWallet;
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Models\Wallet;
class UpdateWalletTransactionProcessor
{
/** @var CreatesWalletTransaction */
private $createsWalletTransaction;
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var ListWallet */
private $fetchesWallet;
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/** @var UpdatesWallet */
private $updatesWallet;
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWallet $updatesWallet)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->updatesWallet = $updatesWallet;
}
/**
* @param Booking $booking
* @return void
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(int $transactionId, int $transactionStatus)
{
$transaction = $this->fetchesTransaction->execute(['id' => $transactionId]);
$wallet = $transaction->wallet;
switch($transaction->type){
case TransactionType::TOP_UP:
$updateWalletAmount = $transaction->amount + $wallet->amount;
break;
case TransactionType::WITHDRAW:
$updateWalletAmount = $wallet->amount - $transaction->amount;
break;
default:
break;
}
$walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
$this->updatesTransactionStatus->execute($transaction, $transactionStatus);
$this->updatesWallet->execute($wallet, $walletOject);
return $wallet;
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Classes\Modules\Transactions\Services;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\General\Interfaces\Transactionable;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Models\Transaction;
class CreatesTransactionableTransaction extends AbstractUpdateRelationshipRecord
{
/**
* @param Transactionable $transactionable
* @param TransactionObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Transactionable $transactionable, TransactionObject $object) {
$model = new Transaction();
$model->bill_no = $object->getBillNo();
$model->type = $object->getTransactionType();
$model->issuer = $object->getIssuer();
$model->receiver = $object->getReceiver();
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
$model->payment_method = $object->getPaymentMethod();
$model->amount = $object->getAmount();
$model->original_amount = $object->getOriginalAmount();
$model->currency_id = $object->getCurrencyId();
$model->original_currency_id = $object->getOriginalCurrencyId();
$model->currency_rate = $object->getCurrencyRate();
$model->tax = $object->getTax();
$model->service_charge = $object->getServiceCharge();
$model->expires_on = $object->getExpiresOn();
$model->status = $object->getStatus();
$model->payment_reference = $object->getPaymentReference();
return $this->handler($transactionable->transactions(), $model);
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Classes\Modules\Transactions\Services;
use App\Models\Group;
use Illuminate\Database\Eloquent\Builder;
use App\Classes\General\Eloquent\AbstractListRecord;
class ListsGroups extends AbstractListRecord
{
/** @var Group */
private $repository;
/**
* ListsBookings constructor.
* @param Group $repository
*/
public function __construct(Group $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
}
@@ -0,0 +1,73 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\CreatesWallet;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet;
use App\Http\Resources\WalletResource;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CreateWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Created Company Wallet',
'message' => 'You have successfully created a company wallet'
];
}
/** @var CreatesWallet */
private $createsWallet;
/** @var GeneratesWalletCode */
private $generatesWalletCode;
/** @var CanCreateCompanyWallet */
private $canCreateCompanyWallet;
/** @var FetchesCompanyModule */
private $fetchesCompanyModule;
/**
* CreateWalletLogic constructor.
* @param CreatesWallet $createsWallet
* @param GeneratesWalletCode $generatesWalletCode
* @param CanCreateCompanyWallet $canCreateCompanyWallet
*/
public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompanyModule $fetchesCompanyModule)
{
$this->fetchesCompanyModule = $fetchesCompanyModule;
$this->createsWallet = $createsWallet;
$this->generatesWalletCode = $generatesWalletCode;
$this->canCreateCompanyWallet = $canCreateCompanyWallet;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$object = new WalletObject($request->input('company_module_id'), $request->input('currency_id'), $this->generatesWalletCode->execute());
$this->canCreateCompanyWallet->passes($object);
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_id')]);
$wallet = $this->createsWallet->execute($object, $company_module);
return $this->resourceResponse(new WalletResource($wallet));
}
}
@@ -0,0 +1,132 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateWalletTransaction;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
use App\Classes\Modules\Wallets\Services\CreatesWalletTransaction;
use App\Classes\Modules\Wallets\Services\GeneratesWalletTransactionBillNo;
use App\Http\Resources\WalletTransactionResource;
use App\Classes\Modules\Wallets\Services\FetchesWallet;
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
use App\Classes\Modules\Currencies\Services\RateCalculatesCurrency;
/*
use App\Classes\Modules\Accounts\Standards\Rules\CanCreateUser;
use App\Classes\Modules\Accounts\Services\CreatesUser;
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
use App\Http\Resources\UserResource;
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
use App\Classes\Modules\Companies\Services\CreatesCompany;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
use App\Classes\Modules\Contacts\Services\CreatesContact;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompanyEmployee;
use App\Classes\Modules\Companies\Services\CreatesCompanyEmployee;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyEmployeeObject;
use App\Classes\Modules\SegmentCompanies\Standards\Rules\CanCreateSegmentCompany;
use App\Classes\Modules\SegmentCompanies\Services\CreatesSegmentCompany;
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
*/
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CreateWalletTransactionLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Created Wallet Transaction',
'message' => 'You have successfully created a wallet transaction'
];
}
/** @var CreatesWalletTransaction */
private $createsWalletTransaction;
/** @var GeneratesWalletTransactionBillNo */
private $generatesWalletTransactionBillNo;
/** @var CanCreateWalletTransaction */
private $canCreateWalletTransaction;
private $fetchesCurrency;
private $rateCalculatesCurrency;
private $fetchesWallet;
/**
* CreateWalletLogic constructor.
* @param CreatesWalletTransaction $createsWalletTransaction
* @param GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo
* @param CanCreateWalletTransaction $canCreateWalletTransaction
* @param FetchesCurrency $fetchesCurrency
* @param RateCalculatesCurrency $rateCalculatesCurrency
* @param FetchesWallet $fetchesWallet
*/
public function __construct(
CreatesWalletTransaction $createsWalletTransaction, GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo, CanCreateWalletTransaction $canCreateWalletTransaction,
FetchesCurrency $fetchesCurrency,RateCalculatesCurrency $rateCalculatesCurrency, FetchesWallet $fetchesWallet
)
{
$this->createsWalletTransaction = $createsWalletTransaction;
$this->generatesWalletTransactionBillNo = $generatesWalletTransactionBillNo;
$this->canCreateWalletTransaction = $canCreateWalletTransaction;
$this->fetchesCurrency = $fetchesCurrency;
$this->rateCalculatesCurrency = $rateCalculatesCurrency;
$this->fetchesWallet = $fetchesWallet;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
DB::beginTransaction();
$wallet = $this->fetchesWallet->execute(['id' => $request->route('id')]);
$conversion_currency = $this->fetchesCurrency->execute(['id' => $request->input('currency_id')]);
$convertable_currency = $this->fetchesCurrency->execute(['id' => $wallet->currency_id]);//MYR
$convert_amount = $this->rateCalculatesCurrency->execute($conversion_currency, $convertable_currency, $request->input('amount'));
$convert_rate = $this->rateCalculatesCurrency->execute_rate($conversion_currency, $convertable_currency);
$object = new WalletTransactionObject(
$wallet->id, $this->generatesWalletTransactionBillNo->execute(),$request->input('trans_type'),
number_format( (float) $convert_amount, 5, '.', ''), $wallet->currency_id , number_format( (float) $request->input('amount'), 5, '.', ''),
$request->input('currency_id'),number_format( (float) $convert_rate, 5, '.', '')
);
$this->canCreateWalletTransaction->passes($object);
$wallet_transaction = $this->createsWalletTransaction->execute($object);
DB::commit();
return $this->resourceResponse(new WalletTransactionResource($wallet_transaction));
} catch (\Exception $exception) {
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}
@@ -0,0 +1,101 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Http\Resources\WalletResource;
use App\Classes\Modules\Wallets\Services\CreatesWallet;
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
class CreditWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Credit into Company Wallet',
'message' => 'You have successfully credit company wallet'
];
}
/** @var FetchesCompany */
private $fetchesCompany;
/** @var GeneratesWalletCode */
private $generatesWalletCode;
/** @var CreatesWallet */
private $createsWallet;
/** @var GeneratesTransactionBillNumber */
private $generatesTransactionBillNumber;
/** @var CreatesTransaction */
private $createsTransaction;
/** @var UpdatesWallet */
private $updatesWallet;
/** @var CreditWalletProcessor */
private $creditWalletProcessor;
/**
* CreateWalletLogic constructor.
* @param FetchesCompany $fetchesCompany
* @param GeneratesWalletCode $generatesWalletCode
* @param CreatesWallet $createsWallet
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CreatesTransaction $createsTransaction
* @param UpdatesWallet $updatesWallet
* @param CreditWalletProcessor $creditWalletProcessor
*/
public function __construct(
FetchesCompany $fetchesCompany,
GeneratesWalletCode $generatesWalletCode,
CreatesWallet $createsWallet,
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
CreatesTransaction $createsTransaction,
UpdatesWallet $updatesWallet,
CreditWalletProcessor $creditWalletProcessor
)
{
$this->fetchesCompany = $fetchesCompany;
$this->generatesWalletCode = $generatesWalletCode;
$this->createsWallet = $createsWallet;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransaction = $createsTransaction;
$this->updatesWallet = $updatesWallet;
$this->creditWalletProcessor = $creditWalletProcessor;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function logic(Request $request) : JsonResponse
{
$amount = floatval(str_replace(',', '', $request->input('amount')));
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
$reference = $request->input('reference');
$type = $request->input('transaction_type');
$wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference);
return $this->resourceResponse(new WalletResource($wallet));
}
}
@@ -0,0 +1,117 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\WalletResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class DebitWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Debit into Company Wallet',
'message' => 'You have successfully debit company wallet'
];
}
/** @var FetchesCompany */
private $fetchesCompany;
/** @var GeneratesTransactionBillNumber */
private $generatesTransactionBillNumber;
/** @var CreatesTransaction */
private $createsTransaction;
/** @var UpdatesWallet */
private $updatesWallet;
/**
* CreateWalletLogic constructor.
* @param FetchesCompany $fetchesCompany
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CreatesTransaction $createsTransaction
* @param UpdatesWallet $updatesWallet
*/
public function __construct(
FetchesCompany $fetchesCompany,
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
CreatesTransaction $createsTransaction,
UpdatesWallet $updatesWallet
)
{
$this->fetchesCompany = $fetchesCompany;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransaction = $createsTransaction;
$this->updatesWallet = $updatesWallet;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function logic(Request $request) : JsonResponse
{
$amount = floatval(str_replace(',', '', $request->input('amount')));
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
$reference = $request->input('reference');
if (!$company->wallets()->first()) {
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
$wallet = $this->createsWallet->execute($object, $company);
}
$wallet = $company->wallets()->first();
$billNumber = $this->generatesTransactionBillNumber->execute('DEBIT-NOTE-');
$transaction_object = new TransactionObject(
$billNumber,
TransactionType::DEBIT_NOTE,
1,
$wallet->company->id,
1,
PaymentMethodType::CASH,
$amount,
$amount,
1,
1,
1,
0,
0,
null,
ApprovalStatus::APPROVED,
[],
$reference
);
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
$updateWalletAmount = $wallet->amount - $transaction->amount;
$walletOject = new WalletObject($wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
$wallet = $this->updatesWallet->execute($wallet, $walletOject);
return $this->resourceResponse(new WalletResource($wallet));
}
}
@@ -0,0 +1,89 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\CreatesWallet;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet;
use App\Http\Resources\WalletResource;
use App\Classes\Modules\Wallets\Services\FetchesWallet;
use App\Models\Wallet;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
class FetchWalletByCompanyModuleControllerLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Wallet',
'message' => 'You have successfully retrieved a wallet'
];
}
/** @var FetchesWallet */
private $fetchesWallet;
/** @var CreatesWallet */
private $createsWallet;
/** @var GeneratesWalletCode */
private $generatesWalletCode;
/** @var CanCreateCompanyWallet */
private $canCreateCompanyWallet;
/** @var FetchesCompanyModule */
private $fetchesCompanyModule;
/**
* CreateWalletLogic constructor.
* @param FetchesWallet $fetchesWallet
*/
public function __construct(FetchesWallet $fetchesWallet, CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompanyModule $fetchesCompanyModule)
{
$this->fetchesWallet = $fetchesWallet;
$this->fetchesCompanyModule = $fetchesCompanyModule;
$this->createsWallet = $createsWallet;
$this->generatesWalletCode = $generatesWalletCode;
$this->canCreateCompanyWallet = $canCreateCompanyWallet;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
// $this->canFetchWallet->passes();
if (!count(Wallet::where('owner_id', $request->route('company_module_id'))->get())) {
$object = new WalletObject($request->route('company_module_id'), $request->input('currency_id') ?? 1, $this->generatesWalletCode->execute());
$this->canCreateCompanyWallet->passes($object);
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->route('company_module_id')]);
$wallet = $this->createsWallet->execute($object, $company_module);
return $this->resourceResponse(new WalletResource($wallet));
}
$filters = $this->fetchesWallet->deserializeFilters($request->input('filters'));
$filters['owner_id'] = $request->route('company_module_id');
$query = $this->fetchesWallet->execute($filters);
return $this->resourceResponse(new WalletResource($query));
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\ListsWallet;
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
use App\Http\Resources\WalletResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ListWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'List Company Wallet',
'message' => 'You have successfully list company wallet'
];
}
/** @var ListWallet */
private $listsWallet;
/** @var CanCreateCompanyWallet */
private $canListWallet;
/**
* CreateWalletLogic constructor.
* @param CreatesWallet $createsWallet
* @param GeneratesWalletCode $generatesWalletCode
* @param CanCreateCompanyWallet $canCreateCompanyWallet
*/
public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
{
$this->canListWallet = $canListWallet;
$this->listsWallet = $listsWallet;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
//$this->canListWallet->passes();
$query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters')));
return $this->collectionResponse(WalletResource::collection($query));
}
}
@@ -0,0 +1,109 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
use App\Classes\Modules\Wallets\Services\CreatesWallet;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\WalletTransactionResource;
use App\Models\Wallet;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class TopUpWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'TopUp into Company Wallet',
'message' => 'You have successfully created a topup request for company\'s wallet'
];
}
/** @var FetchesCompanyModule */
private $fetchesCompanyModule;
/** @var GeneratesWalletCode */
private $generatesWalletCode;
/** @var CreatesWallet */
private $createsWallet;
/** @var GeneratesTransactionBillNumber */
private $generatesTransactionBillNumber;
/** @var CreatesBillplzBill */
private $createsBillplzBill;
/** @var CreatesTransactionableTransaction */
private $createsTransactionableTransaction;
/**
* TopUpWalletLogic constructor.
* @param FetchesCompanyModule $fetchesCompanyModule
* @param GeneratesWalletCode $generatesWalletCode
* @param CreatesWallet $createsWallet
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CreatesBillplzBill $createsBillplzBill
* @param CreatesTransaction $createsTransaction
*/
public function __construct(FetchesCompanyModule $fetchesCompanyModule, GeneratesWalletCode $generatesWalletCode, CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesBillplzBill $createsBillplzBill, CreatesTransactionableTransaction $createsTransactionableTransaction)
{
$this->fetchesCompanyModule = $fetchesCompanyModule;
$this->generatesWalletCode = $generatesWalletCode;
$this->createsWallet = $createsWallet;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsBillplzBill = $createsBillplzBill;
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function logic(Request $request) : JsonResponse
{
$amount = floatval(str_replace(',', '', $request->input('amount')));
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
/** @var Wallet $wallet */
$wallet = $companyModule->wallets()->first();
if (!$wallet) {
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
/** @var Wallet $wallet */
$wallet = $this->createsWallet->execute($object, $companyModule);
}
$user = $companyModule->employees()->first();
$billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-');
if($amount < 0) {
throw new MalformedRequestException('Top up credit value must be greater than zero.');
}
$billPlzBill = $this->createsBillplzBill->execute($companyModule->name, $user->email, 'This payment is credit topup for company ref. ' . $companyModule->reference, $amount, $billNumber, $request->input('bank_code'), true);
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $companyModule->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
return $this->resourceResponse(new WalletTransactionResource($transaction));
}
}
@@ -0,0 +1,69 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\ListsWallet;
use App\Classes\Modules\Wallets\Services\FetchesWallet;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
use App\Http\Resources\WalletResource;
use App\Classes\Modules\Transactions\Processors\UpdateWalletTransactionProcessor;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class UpdateStatusWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Update Status Transaction Company Wallet',
'message' => 'You have successfully status transaction company wallet'
];
}
/** @var ListWallet */
private $fetchesWallet;
/** @var CanCreateCompanyWallet */
private $canListWallet;
/** @var UpdateWalletTransactionProcessor */
private $updateWalletTransactionProcessor;
/**
* CreateWalletLogic constructor.
* @param CreatesWallet $createsWallet
* @param GeneratesWalletCode $generatesWalletCode
* @param CanCreateCompanyWallet $canCreateCompanyWallet
*/
public function __construct(FetchesWallet $fetchesWallet, UpdateWalletTransactionProcessor $updateWalletTransactionProcessor)
{
$this->fetchesWallet = $fetchesWallet;
$this->updateWalletTransactionProcessor = $updateWalletTransactionProcessor;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$status = ($request->route('status')=='approve') ? 2 : 4;
$wallet = $this->updateWalletTransactionProcessor->execute($request->route('transaction_id'), $status);
return $this->resourceResponse(new WalletResource($wallet));
}
}
@@ -0,0 +1,72 @@
<?php
namespace App\Classes\Modules\Wallets\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\ListsWallet;
use App\Classes\Modules\Wallets\Services\FetchesWallet;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\Modules\Wallets\Standards\Rules\CanWithdrawWallet;
use App\Http\Resources\WalletResource;
use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class WithdrawWalletLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Withdraw from Company Wallet',
'message' => 'You have successfully withdraw company wallet'
];
}
/** @var FetchesWallet */
private $fetchesWallet;
/** @var CanWithdrawWallet */
private $canWithdrawWallet;
/** @var CreateWalletTransactionProcessor */
private $createWalletTransactionProcessor;
/**
* CreateWalletLogic constructor.
* @param CreatesWallet $createsWallet
* @param GeneratesWalletCode $generatesWalletCode
* @param CanCreateCompanyWallet $canCreateCompanyWallet
*/
public function __construct(CanWithdrawWallet $canWithdrawWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor)
{
$this->canWithdrawWallet = $canWithdrawWallet;
$this->fetchesWallet = $fetchesWallet;
$this->createWalletTransactionProcessor = $createWalletTransactionProcessor;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]);
$walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount'));
$this->canWithdrawWallet->passes($walletOject);
$transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::WITHDRAW);
return $this->resourceResponse(new WalletResource($wallet));
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Classes\Modules\Wallets\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
class WalletObject implements DataTransferObject
{
/** @var int */
private $company_module_id;
/** @var int */
private $currency_id;
/** @var int */
private $code;
private $amount;
/**
* WalletObject constructor.
* @param int $company_module_id
* @param int $currency
* @param int $code
*/
public function __construct(int $company_module_id, int $currency, int $code, float $amount=0)
{
$this->company_module_id = $company_module_id;
$this->currency_id = $currency;
$this->code = $code;
$this->amount = $amount;
}
/**
* @return int
*/
public function getCompanyModuleId(): int
{
return $this->company_module_id;
}
/**
* @return int
*/
public function getCurrency(): int
{
return $this->currency_id;
}
/**
* @return int
*/
public function getCode(): int
{
return $this->code;
}
public function getAmount(): float
{
return $this->amount;
}
}
@@ -0,0 +1,94 @@
<?php
namespace App\Classes\Modules\Wallets\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
class WalletTransactionObject implements DataTransferObject
{
private $wallet_id;
private $bill_no;
private $trans_type;
private $amount;
private $currency_id;
private $original_amount;
private $original_currency_id;
private $currency_rate;
public function __construct(
int $wallet_id, int $bill_no,int $trans_type,
float $amount, int $currency_id, int $original_amount,
int $original_currency_id, float $currency_rate
){
$this->wallet_id = $wallet_id;
$this->bill_no = $bill_no;
$this->trans_type = $trans_type;
$this->amount= $amount;
$this->currency_id = $currency_id;
$this->original_amount = $original_amount;
$this->original_currency_id = $original_currency_id;
$this->currency_rate = $currency_rate;
}
/**
* @return int
*/
public function getWalletId(): int
{
return $this->wallet_id;
}
/**
* @return int
*/
public function getBillNo(): int
{
return $this->bill_no;
}
/**
* @return int
*/
public function getTransType(): int
{
return $this->trans_type;
}
public function getAmount(): float
{
return $this->amount;
}
/**
* @return int
*/
public function getCurrency(): int
{
return $this->currency_id;
}
public function getOriginalAmount(): float
{
return $this->original_amount;
}
public function getOriginalCurrency(): int
{
return $this->original_currency_id;
}
public function getCurrencyRate(): float
{
return $this->currency_rate;
}
}
@@ -0,0 +1,90 @@
<?php
namespace App\Classes\Modules\Wallets\Processors;
use App\Models\Wallet;
use App\Models\Company;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\Modules\Wallets\Services\CreatesWallet;
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
class CreditWalletProcessor
{
/** @var GeneratesWalletCode */
private $generatesWalletCode;
/** @var CreatesWallet */
private $createsWallet;
/** @var GeneratesTransactionBillNumber */
private $generatesTransactionBillNumber;
/** @var CreatesTransaction */
private $createsTransaction;
/** @var UpdatesWallet */
private $updatesWallet;
/**
* CreateWalletLogic constructor.
* @param GeneratesWalletCode $generatesWalletCode
* @param CreatesWallet $createsWallet
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CreatesTransaction $createsTransaction
* @param UpdatesWallet $updatesWallet
*/
public function __construct(
GeneratesWalletCode $generatesWalletCode,
CreatesWallet $createsWallet,
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
CreatesTransaction $createsTransaction,
UpdatesWallet $updatesWallet
)
{
$this->generatesWalletCode = $generatesWalletCode;
$this->createsWallet = $createsWallet;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransaction = $createsTransaction;
$this->updatesWallet = $updatesWallet;
}
/**
* @param Company $company
* @param int $transactionType
* @param float $amount
* @param string $reference
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Company $company, int $transactionType, float $amount, string $reference)
{
if (!$company->wallets()->first()) {
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
$this->createsWallet->execute($object, $company);
}
/** @var Wallet $wallet */
$wallet = $company->wallets()->first();
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
$walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
$wallet = $this->updatesWallet->execute($wallet, $walletObject);
return $wallet;
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Models\Wallet;
class ChecksIfWalletCodeExists
{
/** @var wallet */
private $repository;
/**
* ChecksIfWalletCodeExists constructor.
* @param Wallet $repository
*/
public function __construct(wallet $repository)
{
$this->repository = $repository;
}
public function execute(int $code): bool {
return $this->repository->where('code', $code)->exists();
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Models\WalletTransaction;
class ChecksIfWalletTransactionBillNoExists
{
private $repository;
public function __construct(WalletTransaction $repository)
{
$this->repository = $repository;
}
public function execute(int $bill_no): bool {
return $this->repository->where('bill_no', $bill_no)->exists();
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Models\Wallet;
use App\Models\Company;
use App\Models\CompanyModule;
class CreatesWallet extends AbstractUpdateRelationshipRecord
{
/**
* @param WalletObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(WalletObject $object, CompanyModule $companyModule) {
$model = new Wallet();
// $model->company_module_id = $object->getCompanyModuleId();
$model->code = $object->getCode();
$model->currency_id = $object->getCurrency();
return $this->handler($companyModule->wallets(), $model);
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
use App\Models\WalletTransaction;
class CreatesWalletTransaction extends AbstractUpdateRecord
{
/**
* @param WalletTransactionObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(WalletTransactionObject $object) {
$model = new WalletTransaction();
$model->wallet_id = $object->getWalletId();
$model->bill_no = $object->getBillNo();
$model->trans_type = $object->getTransType();
$model->amount = $object->getAmount();
$model->currency_id = $object->getCurrency();
$model->original_amount = $object->getOriginalAmount();
$model->original_currency_id = $object->getOriginalCurrency();
$model->currency_rate = $object->getCurrencyRate();
return $this->handler($model);
}
}
@@ -0,0 +1,34 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Classes\General\Eloquent\AbstractFetchRecord;
use Illuminate\Database\Eloquent\Builder;
use App\Models\Wallet;
class FetchesWallet extends AbstractFetchRecord
{
/** @var Wallet */
private $repository;
/**
* FetchesWallet constructor.
* @param Wallet $repository
*/
public function __construct(Wallet $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
class GeneratesWalletCode
{
/** @var ChecksIfWalletCodeExists */
private $walletCodeExists;
/**
* GeneratesWalletCode constructor.
* @param ChecksIfWalletCodeExists $walletCodeExists
*/
public function __construct(ChecksIfWalletCodeExists $walletCodeExists)
{
$this->walletCodeExists = $walletCodeExists;
}
/**
* @return int
*/
public function execute(): int {
$code = mt_rand(100000001, 999999999);
return !$this->walletCodeExists->execute($code) ? $code : self::execute();
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
class GeneratesWalletTransactionBillNo
{
private $walletTransationBillNoExists;
public function __construct(ChecksIfWalletTransactionBillNoExists $walletTransationBillNoExists)
{
$this->walletTransationBillNoExists = $walletTransationBillNoExists;
}
public function execute(): int {
$code = mt_rand(100000001, 999999999);
return !$this->walletTransationBillNoExists->execute($code) ? $code : self::execute();
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use Illuminate\Database\Eloquent\Builder;
use App\Classes\General\Eloquent\AbstractListRecord;
use App\Models\Wallet;
class ListsWallet extends AbstractListRecord
{
/** @var Booking */
private $repository;
/**
* ListsBookings constructor.
* @param Booking $repository
*/
public function __construct(Wallet $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Models\Wallet;
use App\Models\Company;
class UpdatesWallet extends AbstractUpdateRecord
{
/**
* @param WalletObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Wallet $model, WalletObject $object) {
$model->amount = $object->getAmount();
$model->code = $object->getCode();
$model->currency_id = $object->getCurrency();
return $this->handler($model);
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Classes\Modules\Wallets\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Models\Wallet;
use App\Models\Company;
class UpdatesWalletBalance extends AbstractUpdateRecord
{
/**
* @param Wallet $model
* @param $amount
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Wallet $model, $amount) {
$model->amount = $model->amount + $amount;
return $this->handler($model);
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Standards\Validators\CompanyWalletValidation;
class CanCreateCompanyWallet extends AbstractRule
{
/** @var CompanyWalletValidation */
private $companyWalletValidation;
/**
* CanCreateCompanyWallet constructor.
* @param CompanyWalletValidation $companyWalletValidation
*/
public function __construct(CompanyWalletValidation $companyWalletValidation)
{
$this->companyWalletValidation = $companyWalletValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
}
/**
* @param WalletObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->companyWalletValidation->validate($object);
}
/**
* @param WalletObject $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
use App\Classes\Modules\Wallets\Standards\Validators\WalletTransactionValidation;
class CanCreateWalletTransaction extends AbstractRule
{
/** @var WalletTransactionValidation */
private $walletTransactionValidation;
public function __construct(WalletTransactionValidation $walletTransactionValidation)
{
$this->walletTransactionValidation = $walletTransactionValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
}
/**
* @param WalletTransactionObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->walletTransactionValidation->validate($object);
}
/**
* @param WalletTransactionObject $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Standards\Validators\ListWalletValidation;
class CanListWallet extends AbstractRule
{
/** @var ListWalletValidation */
private $listWalletValidation;
public function __construct(ListWalletValidation $listWalletValidation)
{
$this->listWalletValidation = $listWalletValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
}
/**
* @param WalletObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->listWalletValidation->validate($object);
}
/**
* @param WalletTransactionObject $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Standards\Validators\TopUpWalletValidation;
class CanTopUpWallet extends AbstractRule
{
/** @var TopUpWalletValidation */
private $topUpWalletValidation;
public function __construct(TopUpWalletValidation $topUpWalletValidation)
{
$this->topUpWalletValidation = $topUpWalletValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
}
/**
* @param WalletObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->topUpWalletValidation->validate($object);
}
/**
* @param WalletTransactionObject $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Standards\Validators\WithdrawWalletValidation;
class CanWithdrawWallet extends AbstractRule
{
/** @var WithdrawWalletValidation */
private $witdrawWalletValidation;
public function __construct(WithdrawWalletValidation $witdrawWalletValidation)
{
$this->witdrawWalletValidation = $witdrawWalletValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
}
/**
* @param WalletObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->witdrawWalletValidation->validate($object);
}
/**
* @param WalletTransactionObject $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Validators;
use App\Classes\General\Abstracts\AbstractValidation;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
class CompanyWalletValidation extends AbstractValidation
{
/**
* @param WalletObject $object
* @return array
*/
protected function data($object): array
{
return [
'company_module_id' => $object->getCompanyModuleId(),
'currency_id' => $object->getCurrency(),
];
}
/**
* @return array
*/
protected function rules(): array
{
return [
'company_module_id' => 'required',
'currency_id' => 'required',
];
}
/**
* @return array
*/
protected function messages(): array
{
return [];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Validators;
use App\Classes\General\Abstracts\AbstractValidation;
class ListWalletValidation extends AbstractValidation
{
protected function data($object): array
{
return [];
}
/**
* @return array
*/
protected function rules(): array
{
return [];
}
/**
* @return array
*/
protected function messages(): array
{
return [];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Classes\Modules\Wallets\Standards\Validators;
use App\Classes\General\Abstracts\AbstractValidation;
class TopUpWalletValidation extends AbstractValidation
{
protected function data($object): array
{
return [];
}
/**
* @return array
*/
protected function rules(): array
{
return [];
}
/**
* @return array
*/
protected function messages(): array
{
return [];
}
}

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