mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
Compare commits
750 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 295072153d | |||
| e90aebd107 | |||
| b7c6c13bde | |||
| 01d666d92a | |||
| b3973b52d1 | |||
| 694876c31f | |||
| 499782bbec | |||
| f3eca3dd89 | |||
| 9c4c472a40 | |||
| a67afdc0ff | |||
| b30cdaba84 | |||
| 9ac0ca45be | |||
| 3fe98b24a4 | |||
| 7e7e43ee9c | |||
| 39892a0938 | |||
| 0ffe81d1cf | |||
| 5fd6e6a528 | |||
| 09ede52ecf | |||
| e5d6f3f581 | |||
| aa65b333c8 | |||
| 656c50e047 | |||
| 275157b243 | |||
| 0c9ffd2bf7 | |||
| d4dcae155d | |||
| bad8cadb3a | |||
| 3af32cc6e7 | |||
| 34bab6a45c | |||
| dd1eae1ea2 | |||
| b46bfb38bf | |||
| 19c4ee4fda | |||
| 13f13c7a0e | |||
| ffa63f611b | |||
| 82675ab80c | |||
| aac04c4135 | |||
| 56dca799f8 | |||
| 42d8f811c6 | |||
| 030136fd03 | |||
| c8b6e271e3 | |||
| f93997b858 | |||
| 6fbc23d7c4 | |||
| e0a264d58f | |||
| fec20b0947 | |||
| 0bf61d93c5 | |||
| bea24fb48e | |||
| 17a4522f50 | |||
| dfedb99c13 | |||
| 669cac9bd4 | |||
| d7625aece7 | |||
| a36c5c3063 | |||
| fd75da5778 | |||
| b593605c72 | |||
| 8d75012390 | |||
| 2d98757c1c | |||
| b329f232f2 | |||
| 713922d2ee | |||
| 74d11f8305 | |||
| ea920717a1 | |||
| e1b49f6be0 | |||
| 1be405ca93 | |||
| e63e3e707f | |||
| aeaec32dcb | |||
| b000c25e66 | |||
| 1e9af59b91 | |||
| a392b8a5eb | |||
| 30edc3eaba | |||
| b0eca18343 | |||
| 88e1b43f19 | |||
| fc9f6d6dde | |||
| 141dab15b6 | |||
| c9ac435e37 | |||
| 6d01bdfb60 | |||
| e2dc83e441 | |||
| e9daadaf60 | |||
| 7cace7e800 | |||
| 64fa56c02f | |||
| 3f962e774d | |||
| 4ba2144f02 | |||
| 69f2b384cf | |||
| f1a35299e6 | |||
| b15866ea16 | |||
| bd42f7213a | |||
| 2d92b1a8ab | |||
| 06e3049e50 | |||
| b0fa73a12b | |||
| 5d66761465 | |||
| 1ac4615c99 | |||
| 590960b5fd | |||
| 5f24f58480 | |||
| 4dec576aa0 | |||
| 4a41c89024 | |||
| a0997a4649 | |||
| b90dae882e | |||
| f361a7e185 | |||
| 29619625d1 | |||
| 1705b5c2e5 | |||
| 1813783d87 | |||
| 46a0e670ba | |||
| dcec8cb33b | |||
| 75037f6192 | |||
| 675324081b | |||
| a959e83f5b | |||
| 2802e3c366 | |||
| aac2a0666a | |||
| 19efba4b89 | |||
| 7d70c800db | |||
| 863dc94dad | |||
| 98e45e27e3 | |||
| df2916594b | |||
| a49920973e | |||
| d129f8f6bd | |||
| 55a82e52a4 | |||
| 1d4ac80b8f | |||
| 7cd376a9b5 | |||
| c7e3091f9b | |||
| 28feba2ae9 | |||
| 6176135f85 | |||
| 5f529965da | |||
| 924f4f2ace | |||
| 6369282b38 | |||
| 1991cf2c57 | |||
| 5f5bbe0c8c | |||
| a809aec9a7 | |||
| 68ce8373e9 | |||
| e5347f56b7 | |||
| 6673a44137 | |||
| 4d3345f613 | |||
| 60b8657773 | |||
| 9f7a8d0d4b | |||
| a87ab6c27f | |||
| 462a4776cd | |||
| 7e029c5610 | |||
| 0719285286 | |||
| 64400d1524 | |||
| be0279f56b | |||
| e15170bc7f | |||
| 59f527aee7 | |||
| d7aa248972 | |||
| 8e4ff6093e | |||
| 584169e173 | |||
| 1679d1ecf4 | |||
| 7ca48e9638 | |||
| 14278a888a | |||
| 5de2554d63 | |||
| 033a835fce | |||
| 66ddb5da23 | |||
| 65782ebf8a | |||
| 96a089df16 | |||
| f95545a985 | |||
| 9e8685bd02 | |||
| 1224735ba8 | |||
| 11e2390059 | |||
| c280da36d7 | |||
| 27529e90ca | |||
| 2e9b0f918c | |||
| 5565d0b39b | |||
| f1b8c6a556 | |||
| 6d210d3713 | |||
| 5dd2df02fd | |||
| b207b11336 | |||
| ffd95ee1cc | |||
| 73b3995367 | |||
| 45a2544b9d | |||
| 252636a7df | |||
| 3e679fef23 | |||
| 758498f486 | |||
| b55e32aece | |||
| 00bf7c0cf4 | |||
| 24a4d269b3 | |||
| f191979a53 | |||
| c9998029b0 | |||
| a442c78156 | |||
| 03c5ced77b | |||
| 5c6418cb1f | |||
| 5e636862bb | |||
| e97cbfa618 | |||
| a448172521 | |||
| 72ac055ec5 | |||
| 09383a45a6 | |||
| bb1540116c | |||
| 141062a7bf | |||
| 4179706e04 | |||
| eaa21beb83 | |||
| 1acc02eb93 | |||
| 1f2959a5d2 | |||
| 9b7b7068e1 | |||
| 41e1c346f6 | |||
| 74e9b23f91 | |||
| f949877a7f | |||
| 1e876dd103 | |||
| 3d79d0f5e5 | |||
| 2dc037c8fd | |||
| aaae8bcafa | |||
| b66dfa8649 | |||
| 2689296a2c | |||
| 62191c2711 | |||
| 02cb21bd5a | |||
| 78573db17d | |||
| af1b6ac373 | |||
| d807e5d4fd | |||
| c427ae42a0 | |||
| 8a7a4ce38a | |||
| 1b6fe7445e | |||
| 7b2d0c4e2b | |||
| 1bcad555a0 | |||
| 2973547e76 | |||
| 0b415e2e33 | |||
| 1110838e35 | |||
| 9d87987488 | |||
| 4c0984c9b8 | |||
| 5517f16684 | |||
| 4b967981dd | |||
| e63b959714 | |||
| a1751f274d | |||
| ef6538feca | |||
| de61d9a9fd | |||
| 2c1b857255 | |||
| 5b4a3507a3 | |||
| 3d6543e467 | |||
| 006a327a5f | |||
| 295e6454b1 | |||
| f389efa6af | |||
| f83c89b5f3 | |||
| 4ea3132334 | |||
| 8fc3ac1b55 | |||
| ed252e630b | |||
| b6c9c8843d | |||
| d80e996d02 | |||
| 064ee3e41a | |||
| 3bda84dac5 | |||
| e2b378e197 | |||
| 0f2e1297e1 | |||
| d034a285fc | |||
| ee94943d00 | |||
| a9e89a45bd | |||
| f6b10b5763 | |||
| 9b9057ea81 | |||
| 33d2d02cb0 | |||
| e5be6eaceb | |||
| a545e6bad6 | |||
| b64b25ff05 | |||
| d1426c7f05 | |||
| 3375934651 | |||
| c79f58d246 | |||
| ee17ac0b0c | |||
| 26742a7335 | |||
| 0e822ff1dd | |||
| 085b8b349f | |||
| c1164397e8 | |||
| 3c16253795 | |||
| 18a201611e | |||
| 7e754a9c7b | |||
| beb200fd6a | |||
| f0cb7828c3 | |||
| 1956a4095d | |||
| 71559701f4 | |||
| 9ceba30680 | |||
| 3b2d06ed8f | |||
| 81e04e9cb0 | |||
| 286ca64413 | |||
| 51a96812fd | |||
| 07459b9a1b | |||
| ee69f9123c | |||
| 7a2ed92147 | |||
| 894481591d | |||
| e5580c2abd | |||
| 47ee304da1 | |||
| 6427e2996f | |||
| f54aae5dc9 | |||
| f0ef9a5602 | |||
| 4d682c2ac6 | |||
| 8ea00e0383 | |||
| e0805a9601 | |||
| 6f36c4b7ee | |||
| 87194794f2 | |||
| b4eca67a2f | |||
| 1770b06498 | |||
| 5c9fd6e2a6 | |||
| 18df1c0c7b | |||
| 359c103d01 | |||
| ed7a636a18 | |||
| 19bd548127 | |||
| 55ac8064b1 | |||
| e7279ec4d0 | |||
| a7d4299897 | |||
| 2b507d1006 | |||
| 782a5c33ad | |||
| 6d3a2d9259 | |||
| 730b3d439a | |||
| 6b09d5facc | |||
| 138a4f1cf6 | |||
| b54d897060 | |||
| c12959b4a8 | |||
| f94f380c16 | |||
| f46ec19f01 | |||
| c7a6a5b020 | |||
| 8f64769214 | |||
| cb74228a68 | |||
| b22cc0f7e3 | |||
| 2e8ba4f630 | |||
| e987838d5a | |||
| 4c532deb4d | |||
| 12f05b7aa6 | |||
| 48fa67ae8c | |||
| 1e9e94b581 | |||
| 67653b60fb | |||
| 26fffb8af1 | |||
| 5cdbc09c5b | |||
| c9877bb53e | |||
| 0bf84fa7b1 | |||
| fb0c74d645 | |||
| 53293f26d6 | |||
| 56fe5520ad | |||
| 4c9235cc53 | |||
| babd492caa | |||
| 3d1d1cce11 | |||
| 820d96858f | |||
| 058ba592bf | |||
| d950ee3d68 | |||
| 61c801e216 | |||
| 6f0acec390 | |||
| 76e3668563 | |||
| ce94dd1393 | |||
| c1ea087c58 | |||
| 8595d0987f | |||
| 48d0460eef | |||
| 06751fdc78 | |||
| da6ec00dbd | |||
| 412dbd64d5 | |||
| 496df549f6 | |||
| 97eaefa45a | |||
| 68c9e0451a | |||
| b5bcd5c553 | |||
| 671c7a54fb | |||
| 2a28183426 | |||
| 0ebea79750 | |||
| a701242646 | |||
| 4bdeae997d | |||
| 36809f34cc | |||
| 032171bb18 | |||
| d41bd3db39 | |||
| 56bba0eaaf | |||
| af8444e0d9 | |||
| b2a7d1f73d | |||
| 9d2ff3fafa | |||
| 487d07e28c | |||
| 4176e09ea3 | |||
| c44bf46a42 | |||
| e687dd2b9a | |||
| 59951c4efd | |||
| c00a4712a0 | |||
| 1bb07e9402 | |||
| 683bdec1f7 | |||
| ee53a9438a | |||
| 2e2087f16e | |||
| 998b0b4da5 | |||
| dcf5c2e455 | |||
| 156b1dee07 | |||
| 544d7907c3 | |||
| 5b77f7baa6 | |||
| b33016aac4 | |||
| 2788e349ae | |||
| 04af87f640 | |||
| 5b190d5334 | |||
| 8f32769656 | |||
| 0e79bbfd6a | |||
| 3a411e8b9a | |||
| bffe438455 | |||
| d17beda04b | |||
| 7acc6932b5 | |||
| 2d175f4acc | |||
| 31905e56be | |||
| 6508155aea | |||
| 760f8684ea | |||
| 979b8b2ef9 | |||
| 9a0073e906 | |||
| 976e54bb4c | |||
| 87226377be | |||
| 674fd84fa0 | |||
| da1ed10740 | |||
| eb73d20b00 | |||
| 782aed06e4 | |||
| 158fa2eefe | |||
| fa4cfc0d75 | |||
| f87bcff930 | |||
| e774962c44 | |||
| f5482a29e4 | |||
| 0a14a64fbb | |||
| ee5051fc26 | |||
| 034c93091a | |||
| 8b184313cb | |||
| c2b097e6d1 | |||
| b0195a9640 | |||
| 38d69434fa | |||
| 1b559f91a2 | |||
| 05a21af5a6 | |||
| 3e7fbdbafc | |||
| 527eca50fe | |||
| d010a8f8c7 | |||
| 7bc2ca512a | |||
| b76e0ebeef | |||
| f595c43f2c | |||
| 5584d22376 | |||
| 42b6140df7 | |||
| 619fc25605 | |||
| 8c24c86c77 | |||
| 822046cc69 | |||
| d708b8b540 | |||
| 553d2c44aa | |||
| 0f7f5f7ab9 | |||
| a5c1ae14b7 | |||
| 8f5aa0a861 | |||
| 1bed7f1cc9 | |||
| 0a16e40a23 | |||
| 5c24b6f81e | |||
| b81f3e50ad | |||
| 3f1a8a6d12 | |||
| 2240c1723d | |||
| 5d07598c5e | |||
| c493b3786c | |||
| e4f60a7bff | |||
| fe000b7a6f | |||
| 707ef9d9f3 | |||
| b5abb04c63 | |||
| 1dbad7d6e5 | |||
| 25417ba5be | |||
| fe67cc6c5b | |||
| 90b85c0df1 | |||
| 0cdff7c544 | |||
| 42561a7c56 | |||
| 99f4699260 | |||
| 0ea52048e1 | |||
| a47bb95e50 | |||
| 431aed18d3 | |||
| 6ab289057b | |||
| c55a8e7af9 | |||
| 60fbe77829 | |||
| fbf097eb62 | |||
| 30c2673fdf | |||
| fd3709e103 | |||
| 08473d85ab | |||
| 489974ca5a | |||
| 6a6a0f0ee7 | |||
| 402f64364b | |||
| a3bff9d079 | |||
| 2a7a448059 | |||
| 7d855064da | |||
| efc0a3b94e | |||
| 01654ee0d3 | |||
| 23c2f92e6d | |||
| 3945c47f52 | |||
| 51ab6ce48b | |||
| ca8140a1ba | |||
| a84580c1dd | |||
| 63b212a66c | |||
| 7979d89997 | |||
| bc603fc125 | |||
| b55fd49830 | |||
| 60ceac645f | |||
| 90c599049b | |||
| f538fb7f2f | |||
| a45105f5ae | |||
| 2f1a8ee648 | |||
| aacf4ea53d | |||
| 1fa2b60871 | |||
| 203dc0c230 | |||
| fcc4da1a56 | |||
| c5a49bbc44 | |||
| f8131b3a1e | |||
| 336cc0b37f | |||
| 42f096b09c | |||
| 614167cac5 | |||
| e5421f8810 | |||
| 8dc84baee0 | |||
| a413533975 | |||
| 0a98f8a8c6 | |||
| aceed5f754 | |||
| 761d191c1d | |||
| d769be137e | |||
| d6a5dd56c6 | |||
| f279d39ddb | |||
| 2e1e8875b4 | |||
| c30c5a36f2 | |||
| 7d3901ee48 | |||
| 463398945f | |||
| d619862e63 | |||
| 9665a0e242 | |||
| 7ed6c11f37 | |||
| 3eaee0d122 | |||
| b7816873fe | |||
| 8809caa046 | |||
| b8b6910a45 | |||
| 64bfbac4f7 | |||
| a5b7e79964 | |||
| 03c9bec256 | |||
| 06134e006c | |||
| 7563b455ba | |||
| 26edb3bebd | |||
| 55e1a6ad02 | |||
| 381425c6bc | |||
| 09ab95faf8 | |||
| 8bb6f0317a | |||
| fe95db2605 | |||
| 02640e6ae8 | |||
| 104dd19a6f | |||
| 89117c0706 | |||
| bc650b0816 | |||
| a6a239c489 | |||
| 45b78465da | |||
| 71edeca994 | |||
| cd229c6a8f | |||
| ebc3e588ca | |||
| 80471acc5b | |||
| ea08774111 | |||
| 4a1f05e62a | |||
| 840fb86192 | |||
| 7a171685f6 | |||
| 096e039ffb | |||
| 2319393758 | |||
| 85ba9d66d5 | |||
| 626dff6137 | |||
| 99efce22db | |||
| 4a9e89c752 | |||
| 39e3398f8e | |||
| 7db77d619b | |||
| 8f390311af | |||
| 6502957021 | |||
| d6ddf6d607 | |||
| b368b1c0d1 | |||
| a2ef3ed1b1 | |||
| e1b712ad10 | |||
| ddbfc5fdfd | |||
| 1cdd511f67 | |||
| f7d0fe117e | |||
| 4dede50156 | |||
| 0d555eedc9 | |||
| 7f73ec14a5 | |||
| 408397e20e | |||
| ef37f1ebbe | |||
| 914e9a6f0f | |||
| 525e7a5dd1 | |||
| a3cad7816c | |||
| 2100c4a14a | |||
| 0d090b4eaf | |||
| 73801a5acd | |||
| 2c0eeab84e | |||
| 40c4a39927 | |||
| 866df52e52 | |||
| b34d909a09 | |||
| 26b3e968e9 | |||
| 7b127b2cba | |||
| 7488313a0e | |||
| 7589b5c553 | |||
| d8391fe479 | |||
| c01e8d6eb2 | |||
| 5aad5f1729 | |||
| 485a6e2e82 | |||
| 18579d5c1d | |||
| 1060401128 | |||
| 5b00b7b45f | |||
| e7c0e17ee4 | |||
| 569273c058 | |||
| 80f229c6ec | |||
| 56b6b59967 | |||
| 299d5fd4fe | |||
| d56abc78f7 | |||
| b3b7b67c66 | |||
| d6f29976c7 | |||
| 2bc43cbc8f | |||
| e0a02c7051 | |||
| 34a08563f3 | |||
| 9df1e158a4 | |||
| 33cd313950 | |||
| 2af5035e99 | |||
| acb7337b4a | |||
| 0a9bc29202 | |||
| 1568c7272a | |||
| 14f0560055 | |||
| fc339f1dec | |||
| 77f7e86a5f | |||
| 6970908b75 | |||
| 3f31d2d578 | |||
| 8d8c468b09 | |||
| 557ab483f8 | |||
| 4b0b88b5d8 | |||
| 1960cff426 | |||
| 0402fc67e2 | |||
| 4089683ab7 | |||
| 3fdd2a2b56 | |||
| 76193eeb9f | |||
| a696e1dab9 | |||
| c9642bd8f5 | |||
| a3d26bfb63 | |||
| 094f995dcf | |||
| 1a5db25285 | |||
| 2bb4afe426 | |||
| f7a9b2332c | |||
| fa0c97b1da | |||
| 43cd6f35be | |||
| 697c02ac8a | |||
| 3dd9dfe361 | |||
| 7c50dfbfc3 | |||
| e77e513bef | |||
| e173a9ddd3 | |||
| c40d563372 | |||
| 7f0de1c1e4 | |||
| c5477890d6 | |||
| 26027f5f3f | |||
| a28f735d8f | |||
| 225abaacb8 | |||
| 70fc8285f8 | |||
| 1f6eaa65a5 | |||
| 7e2428957e | |||
| 069c3cea35 | |||
| 07998c6850 | |||
| cd3e955f3e | |||
| 869397056c | |||
| c58cdde254 | |||
| 982a7c1d44 | |||
| c976319521 | |||
| 145bf3263a | |||
| 57eb1e147d | |||
| e1c69f2de4 | |||
| 90b2bffd19 | |||
| 562815f9fe | |||
| 401db91437 | |||
| 0d1a623512 | |||
| 548a50c14a | |||
| 299512ec08 | |||
| 7241db7743 | |||
| ce24deea18 | |||
| c4642c2042 | |||
| 3871d8c010 | |||
| cb65a1f29b | |||
| b1b13d7cbf | |||
| f6fa2fcf51 | |||
| 6c00a57446 | |||
| 48445020fb | |||
| 46f1368a92 | |||
| 82a16a5d9d | |||
| 23002f61da | |||
| 2355c74b65 | |||
| bd81560c3d | |||
| 575491e500 | |||
| 1c703489b9 | |||
| 30ef3a7e41 | |||
| f9b1289d28 | |||
| 9fe49d8658 | |||
| e265b069d2 | |||
| f90818dbca | |||
| bfd490854d | |||
| 94d96c96ea | |||
| feaab3cd8e | |||
| 094801abbe | |||
| 275d8880d9 | |||
| 98843d0688 | |||
| 317f4c2351 | |||
| 83c7d70551 | |||
| 20099c416f | |||
| 03b26e2af9 | |||
| eb399dcbae | |||
| d602200140 | |||
| 84028b5ed7 | |||
| 78ceb62dec | |||
| 27190868b4 | |||
| b897b00703 | |||
| 842614700a | |||
| cd93deac26 | |||
| a0ca37ec16 | |||
| 08b2ba1c63 | |||
| c7f8831555 | |||
| df31b801f3 | |||
| 946c9b6e3d | |||
| 0d0e147647 | |||
| bafc23bf6f | |||
| efba270ea5 | |||
| 2d13f69be6 | |||
| 69da484b72 | |||
| cb184c8f50 | |||
| b25adef107 | |||
| 329aa4b496 | |||
| a05609081b | |||
| 9d442c8cc4 | |||
| f5df1adff8 | |||
| 119e58c1c9 | |||
| b08ba3e716 | |||
| 2169f09ffe | |||
| 1dfbc71302 | |||
| b2a986b838 | |||
| 57cdedbdd0 | |||
| 160fa2b2d9 | |||
| e0d0dccb4c | |||
| fea03de5bd | |||
| 75babc9f38 | |||
| a36f7123e8 | |||
| f47c7ebc50 | |||
| fad56e30dc | |||
| 6b56899004 | |||
| 37444e6e30 | |||
| 32591273f8 | |||
| f73b1d7fe3 | |||
| 0d4f7e0ed5 | |||
| 9786198ca2 | |||
| 76a9af2dc8 | |||
| 3dcf3cff10 | |||
| f30a0cf7ee | |||
| f2a02230c7 | |||
| 2978eed61d | |||
| 37da620927 | |||
| 64ec76eed6 | |||
| ef3c738fb1 | |||
| 92b6e6dc3a | |||
| 0d330447eb | |||
| daeb376aa5 | |||
| f4d81cbde9 | |||
| 0fd3584af2 | |||
| c76c50466d | |||
| b4437c8907 | |||
| a2f70f266d | |||
| 432ce2d14a | |||
| 715384f4a4 | |||
| 8277b9d0fd | |||
| e7942731ad | |||
| 5db9d79cc1 | |||
| dff001c9b5 | |||
| 2353c637d7 | |||
| 4769541535 | |||
| fe8b6d0518 | |||
| 5934fbcb6c | |||
| c078a879d2 | |||
| c58f2e55d7 | |||
| eea8708b76 | |||
| 45c94321b1 | |||
| 4fbe771dce | |||
| 9f8ba5163c | |||
| b06cef4045 | |||
| 1c072d7b96 | |||
| eeb7bb77bb | |||
| 2de60c8262 | |||
| c8a2ce71e1 | |||
| 7e04580be0 | |||
| 3d15a8e312 | |||
| 9936e42574 | |||
| 16ffec01d4 | |||
| 7959f8c83c | |||
| 16b5660f12 | |||
| 023954db70 | |||
| 535b8a59b9 | |||
| dc4d7004a3 | |||
| 128c8083c3 | |||
| d52131d9df |
@@ -55,3 +55,11 @@ EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
|||||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||||
|
|
||||||
YD_API_CODE=''
|
YD_API_CODE=''
|
||||||
|
|
||||||
|
PERFEXCRM_BASE_URL=""
|
||||||
|
PERFEXCRM_API_KEY=""
|
||||||
|
PERFEXCRM_IS_ENABLED="false"
|
||||||
|
|
||||||
|
|
||||||
|
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
||||||
|
SST_START_DATE="2024-04-01 00:00:00"
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Exceptions;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
final class ConnectionErrorException extends ServiceApiException {
|
||||||
|
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
|
||||||
|
Log::error($message. ": ". $exceptionMessage);
|
||||||
|
if($payload){
|
||||||
|
Log::error('Payload: '.$payload);
|
||||||
|
}
|
||||||
|
if($exceptionTrace){
|
||||||
|
Log::error($exceptionTrace);
|
||||||
|
}
|
||||||
|
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
|
||||||
|
HttpStatus::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Exceptions;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||||
|
|
||||||
|
final class JobResourceNotFoundException extends ServiceApiException {
|
||||||
|
public function __construct(?string $message = null) {
|
||||||
|
parent::__construct($message ?? 'Unable to find the requested resource', HttpStatus::RESOURCE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Abstracts;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\ErrorException;
|
||||||
|
use App\Classes\Exceptions\InternalServerErrorException;
|
||||||
|
use App\Classes\ValueObjects\Constants\Notifications;
|
||||||
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||||
|
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||||
|
use ErrorException as GeneralExceptions;
|
||||||
|
use TypeError;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
abstract class Abstract2ControllerLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
abstract protected function notification(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getNotificationTitle():string {
|
||||||
|
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getNotificationMessage():string {
|
||||||
|
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return BinaryFileResponse
|
||||||
|
* @throws ErrorException
|
||||||
|
*/
|
||||||
|
abstract protected function logic(Request $request) : BinaryFileResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return BinaryFileResponse
|
||||||
|
*/
|
||||||
|
public function execute(Request $request) : BinaryFileResponse {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$response = $this->logic($request);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||||
|
abort(404, $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|null $data
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function response(?array $data = []) : JsonResponse {
|
||||||
|
|
||||||
|
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
|
||||||
|
$this->getNotificationMessage(),
|
||||||
|
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param JsonResource $resource
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function resourceResponse(JsonResource $resource){
|
||||||
|
return $this->response(['data' => $resource]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ResourceCollection $collection
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function collectionResponse(ResourceCollection $collection){
|
||||||
|
return $this->response(json_decode($collection->response()->getContent(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Classes\Exceptions\JobResourceNotFoundException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
abstract class AbstractControllerLogic
|
abstract class AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -62,6 +64,19 @@ abstract class AbstractControllerLogic
|
|||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||||
|
if ($exception instanceof JobResourceNotFoundException) {
|
||||||
|
Log::channel('vue_polling')->info(sprintf(
|
||||||
|
"Uncaught exception '%s' with message '%s' in %s:%d",
|
||||||
|
get_class($exception),
|
||||||
|
$exception->getMessage(),
|
||||||
|
$exception->getTrace()[0]['file'],
|
||||||
|
$exception->getTrace()[0]['line']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log::error($exception);
|
||||||
|
}
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
|||||||
abstract class AbstractRule
|
abstract class AbstractRule
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract protected function authorized(): bool;
|
abstract protected function authorized($object): bool;
|
||||||
|
|
||||||
abstract protected function validators($object): bool;
|
abstract protected function validators($object): bool;
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ abstract class AbstractRule
|
|||||||
*/
|
*/
|
||||||
public function passes(?DataTransferObject $object = null): bool {
|
public function passes(?DataTransferObject $object = null): bool {
|
||||||
try {
|
try {
|
||||||
if(!$this->authorized()){
|
if(!$this->authorized($object)){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators($object);
|
$this->validators($object);
|
||||||
@@ -36,11 +36,11 @@ abstract class AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch(AccessForbiddenException $exception){
|
} catch(AccessForbiddenException $exception){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
||||||
} catch(\Exception $exception){
|
} catch(\Exception $exception){
|
||||||
throw new RequestValidationException($exception->getMessage());
|
throw new RequestValidationException($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ namespace App\Classes\General\Eloquent;
|
|||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use App\Classes\Exceptions\JobResourceNotFoundException;
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractFetchRecord extends AbstractGetRecord
|
abstract class AbstractFetchRecord extends AbstractGetRecord
|
||||||
{
|
{
|
||||||
@@ -26,12 +28,18 @@ abstract class AbstractFetchRecord extends AbstractGetRecord
|
|||||||
* @return Model
|
* @return Model
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query): Model {
|
public function getResults(Builder $query, array $param = []): Model {
|
||||||
if(!$query->exists()){
|
if(!$query->exists()){
|
||||||
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
$table = $query->getModel()->getTable();
|
||||||
|
if($table ==='job_results'){
|
||||||
|
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->first();
|
return $query->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ abstract class AbstractGetRecord
|
|||||||
* @param array $filters
|
* @param array $filters
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handler(array $filters){
|
public function handler(array $filters, array $params = []){
|
||||||
$this->filters = collect($filters);
|
$this->filters = collect($filters);
|
||||||
return $this->getResults($this->applyFiltersToQuery());
|
return $this->getResults($this->applyFiltersToQuery(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +65,6 @@ abstract class AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract function getResults(Builder $query);
|
abstract function getResults(Builder $query, array $params = []);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(array $filters = []){
|
public function execute(array $filters = [], array $param = []){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
return $this->handler($filters, $param);
|
||||||
return $this->handler($filters);
|
|
||||||
|
|
||||||
} catch (QueryException $exception){
|
} catch (QueryException $exception){
|
||||||
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
||||||
@@ -32,7 +31,7 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query) {
|
public function getResults(Builder $query, array $param = []) {
|
||||||
$filters = $this->getDecorationFilters();
|
$filters = $this->getDecorationFilters();
|
||||||
|
|
||||||
if($filters->has('order_by')){
|
if($filters->has('order_by')){
|
||||||
@@ -44,8 +43,12 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dd($query->toSql());
|
//dd($query->toSql());
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
if(!empty($param)){
|
||||||
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page'), ['*'], 'page', $param['page']) : $query->get(); //page data from query parameters e.g ?page=1
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class BillNo implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('bill_no', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class CompanySegmentsIn implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
||||||
|
$module->whereHas('connections', function ($connection) use ($value) {
|
||||||
|
$connection->whereHas('connectionSegments', function ($segment) use ($value) {
|
||||||
|
$segment->whereIn('segment_id', $value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class CreatedAfterOrEqual implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
$table = $builder->getModel()->getTable();
|
||||||
|
$startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
|
||||||
|
return $builder->where("{$table}.created_at", '>=', $startDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class CreatedBeforeOrEqual implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
$table = $builder->getModel()->getTable();
|
||||||
|
$endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay();
|
||||||
|
return $builder->where("{$table}.created_at", '<=', $endDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class DoesNotHaveGroups implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereDoesntHave('groups');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
|
|||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||||
$query->where('type', $value);
|
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
|
||||||
})->whereHas('containers', function ($query){
|
})->whereHas('containers', function ($query){
|
||||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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 Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class HasQuestionnaireGroupIn implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereHas('question.questionnaire', function (Builder $query) use ($value) {
|
||||||
|
$query->whereIn('group', $value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,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,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class IdNext implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('id', '>', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class JobId implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('job_id', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class MarkingIn implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
||||||
|
$module->whereHas('connections', function ($connection) use ($value) {
|
||||||
|
$connection->whereIn('invitee_reference', $value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class NextMainQuestion implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('next_main_question', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class OrderByIdDesc implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->orderBy('id', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class OrderByUpdatedAtDesc implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->orderBy('updated_at', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ class OwnerId implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->where('owner_id', $value);
|
$table = $builder->getModel()->getTable();
|
||||||
|
return $builder->where("{$table}.owner_id", $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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)
|
||||||
|
{
|
||||||
|
$table = $builder->getModel()->getTable();
|
||||||
|
return $builder->where("{$table}.owner_type", $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\PackingList;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
||||||
|
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
||||||
|
$join->where('transactions.owner_type', '=', PackingList::class);
|
||||||
|
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
||||||
|
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
||||||
|
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
||||||
|
))');
|
||||||
|
})->orderBy('transactions.updated_at', 'DESC');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class PaymentMethodNotIn implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereNotIn('payment_method', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class PostcodeLike implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('postcode', 'LIKE', '%'.$value.'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class QuestionId implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('question_id', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class QuestionNumber implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('question_number', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class QuestionnaireSetId implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('questionnaire_set_id', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class RequestSignature implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('request_signature', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class ResultNotNull implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereNotNull('result');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class ShortUrl implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('short_url', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ class StatusIn implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->whereIn('status', $value);
|
$table = $builder->getModel()->getTable();
|
||||||
|
return $builder->whereIn("{$table}.status", $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class UserId implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('user_id', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class WithAgingColumn implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
$today = Carbon::now();
|
||||||
|
return $builder->select('packing_lists.*')
|
||||||
|
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
|
||||||
|
->addSelect(DB::raw("CASE
|
||||||
|
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
|
||||||
|
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
|
||||||
|
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
|
||||||
|
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
|
||||||
|
ELSE 4
|
||||||
|
END AS due_date_number"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class WithContainersPackages implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
// Log::info('WithContainersPackages: '.$value);
|
||||||
|
// return $builder->with(['containers', 'packages']);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class WithOrderReferenceLike implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no')
|
||||||
|
->join('transactions as t3', 't3.id', '=', 't2.owner_id')
|
||||||
|
->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id')
|
||||||
|
->join('orders', function ($join) use ($value) {
|
||||||
|
$join->on('orders.id', '=', 'packing_lists.owner_id')
|
||||||
|
->where('orders.reference', 'LIKE', '%'.$value.'%');
|
||||||
|
})
|
||||||
|
->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class WithTrashed implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->withTrashed();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Classes\General;
|
namespace App\Classes\General;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class Helper
|
class Helper
|
||||||
{
|
{
|
||||||
@@ -24,4 +25,28 @@ class Helper
|
|||||||
return array_slice(get_class_methods($className), 1);
|
return array_slice(get_class_methods($className), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* @param $log
|
||||||
|
*/
|
||||||
|
static function debugLogger($log){
|
||||||
|
if($log && isset($log['message'])){
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ResourceCollection $collection
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
static function collectionResponse(ResourceCollection $collection){
|
||||||
|
return json_decode($collection->response()->getContent(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMLead;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@@ -28,6 +30,12 @@ class CreatePerfexCRMCustomer implements ShouldQueue
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createLeadPerfexCRMObject->getEmail());
|
||||||
|
if(!is_null($lead)){
|
||||||
|
(App()->make(UpdatesPerfexCRMLead::class))->execute($lead, $this->createLeadPerfexCRMObject->getCompanyReference());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
|
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
|
||||||
|
class CreatePerfexCRMInvoice implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/** @var Transaction $transaction*/
|
||||||
|
private $transaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreatePerfexCRMInvoice constructor.
|
||||||
|
* @param Transaction $transaction
|
||||||
|
*/
|
||||||
|
public function __construct(Transaction $transaction)
|
||||||
|
{
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,12 +4,12 @@ namespace App\Classes\Jobs;
|
|||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatePerfexCRMSingleTask implements ShouldQueue
|
class CreatePerfexCRMSingleTask implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -29,12 +30,17 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
Log::info('FetchOrdersFromYDPortalJob starts');
|
||||||
|
Log::info('FetchPackingListsFromYdPortalProcessor starts');
|
||||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||||
|
Log::info('FetchContainersFromYdPortalProcessor starts');
|
||||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||||
|
Log::info('FetchContainersUpdatesFromYdPortalProcessor starts');
|
||||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||||
|
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor starts');
|
||||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||||
|
Log::info('FetchOrdersFromYDPortalJob ends');
|
||||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
|
||||||
|
|
||||||
class InitializePerfexCRM implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var InitialPerfexCRMObject */
|
|
||||||
private $initialPerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* InitializePerfexCRM constructor.
|
|
||||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(InitialPerfexCRMObject $initialPerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->initialPerfexCRMObject = $initialPerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
(App()->make(InitializePerfexCRMProcessor::class))->execute($this->initialPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
|
use App\Classes\Modules\PackingLists\Processors\ListPackingListsJobProcessor;
|
||||||
|
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
class ListPackingListsJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $timeout = 900;
|
||||||
|
|
||||||
|
/** @var ListGenericJobObject */
|
||||||
|
private $listGenericJobObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ListPackingListsJob constructor.
|
||||||
|
* @param ListGenericJobObject $listGenericJobObject
|
||||||
|
*/
|
||||||
|
public function __construct(ListGenericJobObject $listGenericJobObject)
|
||||||
|
{
|
||||||
|
$this->listGenericJobObject = $listGenericJobObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$rawPayload = $this->job->payload();
|
||||||
|
if(isset($rawPayload['data']['commandName'])){
|
||||||
|
$this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($rawPayload['data']['command'])){
|
||||||
|
$this->listGenericJobObject->setJobCommand($rawPayload['data']['command']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->listGenericJobObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,12 +3,17 @@
|
|||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
||||||
|
use App\Models\Transaction;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRM implements ShouldQueue
|
class UpdatePerfexCRM implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -17,17 +22,51 @@ class UpdatePerfexCRM implements ShouldQueue
|
|||||||
/** @var UpdatePerfexCRMObject */
|
/** @var UpdatePerfexCRMObject */
|
||||||
private $updatePerfexCRMObject;
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
|
/** @var */
|
||||||
|
private $transaction;
|
||||||
|
|
||||||
|
/** @var bool|null */
|
||||||
|
private $shouldCreateInvoice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdatePerfexCRM constructor.
|
* UpdatePerfexCRM constructor.
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @param bool|null $shouldCreateInvoice
|
||||||
*/
|
*/
|
||||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject)
|
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
|
||||||
{
|
{
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
(App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
//To use invoice as a reference to decide whether more tasks should be created
|
||||||
|
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
||||||
|
|
||||||
|
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||||
|
if($this->transaction != null && $this->shouldCreateInvoice){
|
||||||
|
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||||
|
$this->updatePerfexCRMObject->getContactEmail(),
|
||||||
|
$result->projectId,
|
||||||
|
$this->transaction,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getInvoiceIdOrCreateInvoice(){
|
||||||
|
if($this->transaction != null){
|
||||||
|
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
||||||
|
$this->updatePerfexCRMObject->getContactEmail(),
|
||||||
|
$this->transaction
|
||||||
|
);
|
||||||
|
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
||||||
|
return $invoiceId;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
|
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||||
|
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Classes\General\Helper;
|
||||||
|
|
||||||
|
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/** @var UpdatePerfexCRMInvoiceObject */
|
||||||
|
private $updatePerfexCRMInvoiceObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreatePerfexCRMSingleTask constructor.
|
||||||
|
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
||||||
|
*/
|
||||||
|
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||||
|
{
|
||||||
|
$this->updatePerfexCRMInvoiceObject = $updatePerfexCRMInvoiceObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//get the client id
|
||||||
|
$customer = (App()->make(FetchesPerfexCRMCustomer::class))->execute($this->updatePerfexCRMInvoiceObject->getEmail());
|
||||||
|
$transaction = $this->updatePerfexCRMInvoiceObject->getTransaction();
|
||||||
|
|
||||||
|
//get the invoice id
|
||||||
|
$invoiceId = 0;
|
||||||
|
$invoiceStatus = 0;
|
||||||
|
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||||
|
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||||
|
|
||||||
|
if(is_null($invoice)){
|
||||||
|
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||||
|
if ($result) {
|
||||||
|
$invoiceId = $result->payload['id'];
|
||||||
|
} else {
|
||||||
|
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||||
|
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$invoiceId = $invoice->id;
|
||||||
|
$invoiceStatus = $invoice->status;
|
||||||
|
|
||||||
|
//This only run when invoice already exist and the invoice does not have a PAID status
|
||||||
|
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||||
|
//update invoice
|
||||||
|
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//create invoice payment
|
||||||
|
if($invoiceId != 0 && $invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||||
|
|
||||||
|
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
||||||
|
|
||||||
|
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
||||||
|
$invoiceId,
|
||||||
|
"$transaction->amount",
|
||||||
|
$date,
|
||||||
|
1,
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
(App()->make(CreatesPerfexCRMInvoicePayment::class))->execute($invoicePaymentPerfexCRMObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delay($delay)
|
||||||
|
{
|
||||||
|
// Add delay in seconds to the job
|
||||||
|
$this->delay = $delay;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||||
|
use App\Models\PackingList;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
|
||||||
|
class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/** @var */
|
||||||
|
private $packingList;
|
||||||
|
|
||||||
|
/** @var */
|
||||||
|
private $transaction;
|
||||||
|
|
||||||
|
/** @var UpdatePerfexCRMObject */
|
||||||
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
|
/** @var bool|null */
|
||||||
|
private $shouldCreateInvoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdatePerfexCRMPrelude constructor.
|
||||||
|
* @param $packingList
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
|
* @param bool|null $shouldCreateInvoice
|
||||||
|
*/
|
||||||
|
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||||
|
{
|
||||||
|
$this->packingList = $packingList;
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
|
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if(is_null($this->packingList)){
|
||||||
|
$this->packingList = $this->transaction->owner->owner;
|
||||||
|
}
|
||||||
|
$amount = 0.00;
|
||||||
|
if(!is_null($this->transaction)){
|
||||||
|
$amount = $this->transaction->amount;
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'amount' => number_format($amount, 2, '.', ''),
|
||||||
|
'link_order' => config('app.url').'/order/show/'.$this->packingList->owner->reference,
|
||||||
|
'link_autocount_or' => 'https://docs.google.com/spreadsheets/d/1Q3rJBGQ9Bo04HZp5WR9zbLp7pIW2kfDYsabxG7JON-4/edit#gid=2013983170',
|
||||||
|
'link_perfex' => 'https://perfex.cief-malaysia.com/admin/projects/view/89',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||||
|
$this->updatePerfexCRMObject->setTasks($result);
|
||||||
|
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
function replacePlaceholders($template, $data, $prefix = '')
|
||||||
|
{
|
||||||
|
foreach ($template as $key => $value) {
|
||||||
|
foreach ($data as $dataKey => $dataValue) {
|
||||||
|
if (is_array($dataValue)) {
|
||||||
|
$template[$key] = $this->replacePlaceholders($template[$key], $dataValue, $dataKey);
|
||||||
|
} else {
|
||||||
|
if ($prefix != '') {
|
||||||
|
$template[$key] = str_replace('{' .$prefix. "." .$dataKey . '}', $dataValue, $template[$key]);
|
||||||
|
} else {
|
||||||
|
$template[$key] = str_replace('{' . $dataKey . '}', $dataValue, $template[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -36,6 +36,8 @@ use App\Models\User;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class CreateCustomerLogic extends AbstractControllerLogic
|
class CreateCustomerLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -161,11 +163,25 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
$request->input('name'),
|
$request->input('name'),
|
||||||
$request->input('email'),
|
$request->input('email'),
|
||||||
$request->input('phone'),
|
$request->input('phone'),
|
||||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name')
|
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name'),
|
||||||
|
$connection->invitee_reference
|
||||||
);
|
);
|
||||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(app()->environment(['production'])){
|
||||||
|
// call wac webhook
|
||||||
|
$url = config('wagWebhookUrl.account_registration_url');
|
||||||
|
$payload = [
|
||||||
|
'name' => $request->input('name'),
|
||||||
|
'email' => $request->input('email'),
|
||||||
|
'phone' => $request->input('phone'),
|
||||||
|
'portal' => 'izyim'
|
||||||
|
];
|
||||||
|
$response = Http::post($url, $payload);
|
||||||
|
Log::channel('wac_webhook')->info('Register Account: ' . json_encode($response));
|
||||||
|
}
|
||||||
|
|
||||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||||
|
|
||||||
return $this->response($this->authenticationProcessor->execute($request));
|
return $this->response($this->authenticationProcessor->execute($request));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\Accounts\ControllersLogic;
|
|||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
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\Services\FetchesUser;
|
||||||
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||||
@@ -29,8 +29,8 @@ class UpdateUserLogic extends AbstractControllerLogic
|
|||||||
/** @var CanUpdateUser */
|
/** @var CanUpdateUser */
|
||||||
private $canUpdateUser;
|
private $canUpdateUser;
|
||||||
|
|
||||||
/** @var UpdatesUser */
|
/** @var UpdatesUserFullName */
|
||||||
private $updatesUser;
|
private $updatesUserFullName;
|
||||||
|
|
||||||
/** @var FetchesUser */
|
/** @var FetchesUser */
|
||||||
private $fetchesUser;
|
private $fetchesUser;
|
||||||
@@ -38,13 +38,13 @@ class UpdateUserLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* UpdateAddressLogic constructor.
|
* UpdateAddressLogic constructor.
|
||||||
* @param CanUpdateUser $canUpdateUser
|
* @param CanUpdateUser $canUpdateUser
|
||||||
* @param UpdatesUser $updatesUser
|
* @param UpdatesUserFullName $updatesUserFullName
|
||||||
* @param FetchesUser $fetchesUSer
|
* @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->canUpdateUser = $canUpdateUser;
|
||||||
$this->updatesUser = $updatesUser;
|
$this->updatesUserFullName = $updatesUserFullName;
|
||||||
$this->fetchesUser = $fetchesUser;
|
$this->fetchesUser = $fetchesUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class UpdateUserLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
|
$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));
|
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;
|
namespace App\Classes\Modules\Accounts\Services;
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
class UpdatesUser extends AbstractUpdateRecord
|
class UpdatesUser extends AbstractUpdateRecord
|
||||||
@@ -11,13 +11,14 @@ class UpdatesUser extends AbstractUpdateRecord
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $model
|
* @param User $model
|
||||||
* @param FullNameObject $object
|
* @param UserObject $object
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
* @return \Illuminate\Database\Eloquent\Model
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(User $model, FullNameObject $object) {
|
public function execute(User $model, UserObject $object) {
|
||||||
|
|
||||||
$model->name = $object->getName();
|
$model->name = $object->getName();
|
||||||
|
$model->type = $object->getType();
|
||||||
return $this->handler($model);
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -54,4 +54,4 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanCreateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -51,4 +51,4 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ class CanFetchUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ class CanListUsers extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanRegisterUser extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ class CanResetPassword extends AbstractRule
|
|||||||
return $this->passwordResetTokenExists->execute($object->getToken());
|
return $this->passwordResetTokenExists->execute($object->getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanUpdateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanCreateAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanFetchAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanListAddresses extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
|||||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||||
|
|
||||||
use App\Http\Resources\AnnouncementResource;
|
use App\Http\Resources\AnnouncementResource;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ class UpdateAnnouncementLogic extends AbstractControllerLogic
|
|||||||
$annoucement_object = new AnnouncementObject(
|
$annoucement_object = new AnnouncementObject(
|
||||||
$request->input('title'),
|
$request->input('title'),
|
||||||
$request->input('description'),
|
$request->input('description'),
|
||||||
$request->input('starting_on'),
|
Carbon::createFromFormat('d-m-Y', $request->input('starting_on'))->format('Y-m-d H:i:s'),
|
||||||
$request->input('ending_on')
|
Carbon::createFromFormat('d-m-Y', $request->input('ending_on'))->format('Y-m-d H:i:s')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -47,4 +47,4 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -47,4 +47,4 @@ class CanCreateBank extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteBank extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -34,4 +34,4 @@ class CanListBanks extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanUpdateBank extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,25 +4,24 @@ namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
|||||||
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
|
||||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||||
use App\Http\Resources\TransactionResource;
|
|
||||||
use App\Models\Booking;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Wallet;
|
use App\Models\Wallet;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||||
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\Group;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -44,6 +43,18 @@ class CallbackBillplzLogic
|
|||||||
/** @var UpdateDoFromYDPortalProcessor */
|
/** @var UpdateDoFromYDPortalProcessor */
|
||||||
private $updateDoFromYDPortalProcessor ;
|
private $updateDoFromYDPortalProcessor ;
|
||||||
|
|
||||||
|
/** @var UpdatesWalletBalance */
|
||||||
|
private $updatesWalletBalance;
|
||||||
|
|
||||||
|
/** @var CreatePaymentTransactionProcessor */
|
||||||
|
private $createPaymentTransactionProcessor;
|
||||||
|
|
||||||
|
/** @var CallbackBillplzProcessor */
|
||||||
|
private $callbackBillplzProcessor;
|
||||||
|
|
||||||
|
/** @var CheckStorageInvoiceTransactionProcessor */
|
||||||
|
private $storageInvoiceTransactionProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CallbackBillplzLogic constructor.
|
* CallbackBillplzLogic constructor.
|
||||||
* @param GetBillplzBill $getBillplzBill
|
* @param GetBillplzBill $getBillplzBill
|
||||||
@@ -51,14 +62,21 @@ class CallbackBillplzLogic
|
|||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||||
|
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||||
|
* @param CallbackBillplzProcessor $callbackBillplzProcessor
|
||||||
|
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
||||||
*/
|
*/
|
||||||
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, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CallbackBillplzProcessor $callbackBillplzProcessor, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
||||||
{
|
{
|
||||||
$this->getBillplzBill = $getBillplzBill;
|
$this->getBillplzBill = $getBillplzBill;
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||||
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
|
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||||
|
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||||
|
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,26 +116,39 @@ class CallbackBillplzLogic
|
|||||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::info('Debug billPlz status: '.$status);
|
||||||
|
|
||||||
$token = Auth::fromUser(User::find(1));
|
$token = Auth::fromUser(User::find(1));
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||||
|
|
||||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
$this->storageInvoiceBackDoorPreventionCheck($transaction, $status);
|
||||||
|
$result = $this->callbackBillplzProcessor->execute($transaction, $status);
|
||||||
|
|
||||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
|
||||||
|
|
||||||
$packingList->status = ApprovalStatus::APPROVED;
|
if ($transaction->owner instanceof Wallet) {
|
||||||
$packingList->save();
|
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||||
|
} else {
|
||||||
|
|
||||||
if(app()->environment('production')){
|
$company_module_marking = $order->companyModule->connections? $order->companyModule->connections->first()->invitee_reference: null;
|
||||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
|
||||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status, 'result' => $result]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function storageInvoiceBackDoorPreventionCheck($transaction, $status){
|
||||||
|
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference, 'transaction' => $transaction, 'status' => $status]);
|
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||||
|
if ($group) {
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
$pL = $invoice->owner;
|
||||||
|
$order = $pL->owner;
|
||||||
|
if($order){
|
||||||
|
$this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Billplzs\Processors;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Wallet;
|
||||||
|
use App\Models\Group;
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||||
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
|
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||||
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||||
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
//Date: 20240817
|
||||||
|
//This Processor is used for one time data patching with OneTimeTransactionFixBillplzFailedCallback.php
|
||||||
|
class CallbackBillplzDataPatchProcessor
|
||||||
|
{
|
||||||
|
/** @var UpdatesTransactionStatus */
|
||||||
|
private $updatesTransactionStatus;
|
||||||
|
|
||||||
|
/** @var UpdateDoFromVTPortalProcessor */
|
||||||
|
private $updateDoFromVTPortalProcessor;
|
||||||
|
|
||||||
|
/** @var UpdateDoFromYDPortalProcessor */
|
||||||
|
private $updateDoFromYDPortalProcessor;
|
||||||
|
|
||||||
|
/** @var UpdatesWalletBalance */
|
||||||
|
private $updatesWalletBalance;
|
||||||
|
|
||||||
|
/** @var CreatePaymentTransactionProcessor */
|
||||||
|
private $createPaymentTransactionProcessor;
|
||||||
|
|
||||||
|
/** @var ReleaseGoodsToCustomerProcessor */
|
||||||
|
private $releaseGoodsToCustomerProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CallbackBillplzDataPatchProcessor constructor.
|
||||||
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
|
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||||
|
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||||
|
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||||
|
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||||
|
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||||
|
*/
|
||||||
|
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
||||||
|
{
|
||||||
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
|
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||||
|
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||||
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
|
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||||
|
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute($transaction, $status)
|
||||||
|
{
|
||||||
|
$invoice = $transaction->owner;
|
||||||
|
$packingList = $invoice->owner;
|
||||||
|
|
||||||
|
$proceed = $this->checkForGroupPayment($transaction);
|
||||||
|
if(!$proceed) return false;
|
||||||
|
|
||||||
|
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||||
|
|
||||||
|
Log::info('CallbackBillplzDataPatchProcessor 1');
|
||||||
|
|
||||||
|
// check if is wallet top up
|
||||||
|
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||||
|
|
||||||
|
Log::info('CallbackBillplzDataPatchProcessor 2');
|
||||||
|
|
||||||
|
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||||
|
|
||||||
|
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||||
|
|
||||||
|
// check if is group payment
|
||||||
|
if ($group) {
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
Log::info('CallbackBillplzDataPatchProcessor 3: '.json_encode($invoice));
|
||||||
|
|
||||||
|
//if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||||
|
// $paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||||
|
|
||||||
|
// if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||||
|
$pL = $invoice->owner;
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice, true);
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
$group->status = $status;
|
||||||
|
$group->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$transaction->owner instanceof Wallet) {
|
||||||
|
Log::info('CallbackBillplzDataPatchProcessor 3');
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkForGroupPayment($transaction){
|
||||||
|
//This check is targetting group payment that expired and soft deleted
|
||||||
|
//command:check-storage-invoices must already run for this part of the code to work properly
|
||||||
|
$group = Group::withTrashed()->where('reference', $transaction->payment_reference)->first();
|
||||||
|
if ($group) {
|
||||||
|
$totalAmountToBePaid = 0;
|
||||||
|
$actualAmountPaid = $transaction->amount;
|
||||||
|
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||||
|
$totalAmountToBePaid += $invoice->amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed
|
||||||
|
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Billplzs\Processors;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Wallet;
|
||||||
|
use App\Models\Group;
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||||
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
|
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||||
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||||
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CallbackBillplzProcessor
|
||||||
|
{
|
||||||
|
/** @var UpdatesTransactionStatus */
|
||||||
|
private $updatesTransactionStatus;
|
||||||
|
|
||||||
|
/** @var UpdateDoFromVTPortalProcessor */
|
||||||
|
private $updateDoFromVTPortalProcessor;
|
||||||
|
|
||||||
|
/** @var UpdateDoFromYDPortalProcessor */
|
||||||
|
private $updateDoFromYDPortalProcessor;
|
||||||
|
|
||||||
|
/** @var UpdatesWalletBalance */
|
||||||
|
private $updatesWalletBalance;
|
||||||
|
|
||||||
|
/** @var CreatePaymentTransactionProcessor */
|
||||||
|
private $createPaymentTransactionProcessor;
|
||||||
|
|
||||||
|
/** @var ReleaseGoodsToCustomerProcessor */
|
||||||
|
private $releaseGoodsToCustomerProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CallbackBillplzProcessor constructor.
|
||||||
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
|
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||||
|
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||||
|
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||||
|
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||||
|
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||||
|
*/
|
||||||
|
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
||||||
|
{
|
||||||
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
|
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||||
|
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||||
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
|
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||||
|
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute($transaction, $status)
|
||||||
|
{
|
||||||
|
$invoice = $transaction->owner;
|
||||||
|
$packingList = $invoice->owner;
|
||||||
|
|
||||||
|
$proceed = $this->checkForGroupPayment($transaction);
|
||||||
|
if(!$proceed) return false;
|
||||||
|
|
||||||
|
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||||
|
|
||||||
|
// check if is wallet top up
|
||||||
|
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||||
|
|
||||||
|
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||||
|
|
||||||
|
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||||
|
|
||||||
|
// check if is group payment
|
||||||
|
if ($group) {
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||||
|
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||||
|
|
||||||
|
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||||
|
$pL = $invoice->owner;
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$group->status = $status;
|
||||||
|
$group->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$transaction->owner instanceof Wallet) {
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkForGroupPayment($transaction){
|
||||||
|
//This check is targetting group payment that expired and soft deleted
|
||||||
|
//command:check-storage-invoices must already run for this part of the code to work properly
|
||||||
|
$group = Group::withTrashed()->where('reference', $transaction->payment_reference)->first();
|
||||||
|
if ($group) {
|
||||||
|
$totalAmountToBePaid = 0;
|
||||||
|
$actualAmountPaid = $transaction->amount;
|
||||||
|
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||||
|
$totalAmountToBePaid += $invoice->amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed
|
||||||
|
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\Services;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
class CreatesBillplzBill
|
class CreatesBillplzBill
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ class CreatesBillplzBill
|
|||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||||
'collection_id' => config('billplz.collection_id'),
|
'collection_id' => config('billplz.collection_id'),
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'email' => $email,
|
'email' => App::environment('production') ? $email : 'development@cief-malaysia.com',
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'amount' => $this->finalizeAmount($amount),
|
'amount' => $this->finalizeAmount($amount),
|
||||||
'redirect_url' => route('online_payment.redirect'),
|
'redirect_url' => route('online_payment.redirect'),
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Billplzs\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class DeletesBillplzBill
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $billID
|
||||||
|
* @throws MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute(string $billID) {
|
||||||
|
try{
|
||||||
|
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->delete(config('billplz.base_url').'/api/v3/bills/'.$billID);
|
||||||
|
Log::channel('storage_invoices')->info('DeletesBillplzBill response: '.json_encode($response));
|
||||||
|
|
||||||
|
if($response->successful()){
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
// $data['url'] = $data['url'].'?auto_submit=true';
|
||||||
|
|
||||||
|
return (object) $data;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}catch(\Exception $exception){
|
||||||
|
throw new MalformedRequestException('Unable to get correct response from billplz server: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-1
@@ -7,6 +7,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||||
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
use App\Http\Resources\CompanyResource;
|
use App\Http\Resources\CompanyResource;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -33,17 +35,22 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController
|
|||||||
/** @var AssignConnectionSegmentProcessor */
|
/** @var AssignConnectionSegmentProcessor */
|
||||||
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||||
|
|
||||||
|
/** @var CreateContactProcessor */
|
||||||
|
private $createContactProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssignCompanyToSegmentLogic constructor.
|
* AssignCompanyToSegmentLogic constructor.
|
||||||
* @param FetchesCompany $fetchesCompany
|
* @param FetchesCompany $fetchesCompany
|
||||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||||
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
||||||
|
* @param CreateContactProcessor $createContactProcessor
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor)
|
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor, CreateContactProcessor $createContactProcessor)
|
||||||
{
|
{
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||||
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||||
|
$this->createContactProcessor = $createContactProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,6 +69,11 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController
|
|||||||
|
|
||||||
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
||||||
|
|
||||||
|
if ($request->input('segment_id') == 10 || $request->input('segment_id') == 11) {
|
||||||
|
$contactObject = new ContactObject('Whatsapp: ' . $request->input('name'), $request->input('phone'), null, null);
|
||||||
|
$this->createContactProcessor->execute($contactObject, $company);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->resourceResponse(new CompanyResource($company));
|
return $this->resourceResponse(new CompanyResource($company));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+121
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
|
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm;
|
||||||
|
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule;
|
||||||
|
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||||
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\Order;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function notification():array {
|
||||||
|
return [
|
||||||
|
'title' => 'Update Company Credit Term Status',
|
||||||
|
'message' => 'You have successfully updated Company Credit Term Status'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var FetchesCompany */
|
||||||
|
private $fetchesCompany;
|
||||||
|
|
||||||
|
/** @var UpdatesCompanyModuleIsCreditTerm */
|
||||||
|
private $updatesCompanyModuleIsCreditTerm;
|
||||||
|
|
||||||
|
/** @var CanUpdateCompanyModule */
|
||||||
|
private $canUpdateCompanyModule;
|
||||||
|
|
||||||
|
/** @var ListsTransactions */
|
||||||
|
private $listsTransactions;
|
||||||
|
|
||||||
|
/** @var UpdatesTransactionIsWaived */
|
||||||
|
private $updatesTransactionIsWaived;
|
||||||
|
|
||||||
|
/** @var CheckStorageInvoiceTransactionProcessor */
|
||||||
|
private $storageInvoiceTransactionProcessor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateCompanyCreditTermStatusLogic constructor.
|
||||||
|
* @param FetchesCompany $fetchesCompany
|
||||||
|
* @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm
|
||||||
|
* @param CanUpdateCompanyModule $canUpdateCompanyModule
|
||||||
|
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
||||||
|
* @param ListsTransactions $listsTransactions
|
||||||
|
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
||||||
|
*/
|
||||||
|
public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, UpdatesTransactionIsWaived $updatesTransactionIsWaived, ListsTransactions $listsTransactions, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
||||||
|
{
|
||||||
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
|
$this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm;
|
||||||
|
$this->canUpdateCompanyModule = $canUpdateCompanyModule;
|
||||||
|
$this->listsTransactions = $listsTransactions;
|
||||||
|
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
||||||
|
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
|
*/
|
||||||
|
public function logic(Request $request) : JsonResponse
|
||||||
|
{
|
||||||
|
$this->canUpdateCompanyModule->passes();
|
||||||
|
|
||||||
|
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||||
|
$companyModule = $company->companyModules()->first();
|
||||||
|
$isCreditTerm = $companyModule->connections()->first()->is_credit_term;
|
||||||
|
|
||||||
|
if ($isCreditTerm == 1) {
|
||||||
|
$isCreditTerm = 0;
|
||||||
|
} else {
|
||||||
|
$isCreditTerm = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($isCreditTerm === 1){
|
||||||
|
//{"per_page":10,"order_by":{"column":"id","DESC":true},"status_in":[2],"receiver":190,"type_in":[1],"does_not_have_payment_status_in":[0,1],"does_not_have_groups":1,"check_for_storage_invoice":1}
|
||||||
|
|
||||||
|
$filters = [
|
||||||
|
'status_in' => [2],
|
||||||
|
'receiver' => $companyModule->id,
|
||||||
|
'type_in' => [TransactionType::STORAGE_INVOICE]
|
||||||
|
];
|
||||||
|
|
||||||
|
$transactions = $this->listsTransactions->execute($filters);
|
||||||
|
foreach($transactions as $transaction){
|
||||||
|
$this->updatesTransactionIsWaived->execute($transaction);
|
||||||
|
$packingList = $transaction->owner()->first();
|
||||||
|
if($packingList){
|
||||||
|
$order = $packingList->owner()->first();
|
||||||
|
if($order instanceof Order){
|
||||||
|
$storages = $this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updatesCompanyModuleIsCreditTerm->execute($company->companyModules()->first()->connections()->first(), $isCreditTerm);
|
||||||
|
Log::info(Auth::user()->email." updated credit term status for customer with id: " .$request->route('id'). " to status " . $isCreditTerm);
|
||||||
|
|
||||||
|
$result = ['is_credit_term' => $isCreditTerm];
|
||||||
|
return $this->response(['data' => $result]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
|
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||||
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
|
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||||
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||||
|
use App\Http\Resources\CompanyResource;
|
||||||
|
use ErrorException;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class UpdateCompanyTypeLogic extends AbstractControllerLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function notification():array {
|
||||||
|
return [
|
||||||
|
'title' => 'Updated Company Type',
|
||||||
|
'message' => 'You have successfully updated the Company Tyoe'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var CanUpdateCompany */
|
||||||
|
private $canUpdateCompany;
|
||||||
|
|
||||||
|
/** @var UpdatesCompany */
|
||||||
|
private $updatesCompany;
|
||||||
|
|
||||||
|
/** @var FetchesCompany */
|
||||||
|
private $fetchesCompany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateCompanyControllersLogic constructor.
|
||||||
|
* @param CanUpdateCompany $canUpdateCompany
|
||||||
|
* @param UpdatesCompany $updatesCompany
|
||||||
|
* @param FetchesCompany $fetchesCompany
|
||||||
|
*/
|
||||||
|
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany)
|
||||||
|
{
|
||||||
|
$this->canUpdateCompany = $canUpdateCompany;
|
||||||
|
$this->updatesCompany = $updatesCompany;
|
||||||
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws ErrorException
|
||||||
|
*/
|
||||||
|
public function logic(Request $request) : JsonResponse
|
||||||
|
{
|
||||||
|
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
$object = new CompanyObject($query->name, $query->reference, $request->input('type'));
|
||||||
|
|
||||||
|
$this->canUpdateCompany->passes($object);
|
||||||
|
|
||||||
|
$query = $this->updatesCompany->execute($query, $object);
|
||||||
|
|
||||||
|
return $this->resourceResponse(new CompanyResource($query));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Companies\Services;
|
||||||
|
|
||||||
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
|
use App\Models\CompanyConnection;
|
||||||
|
|
||||||
|
class UpdatesCompanyModuleIsCreditTerm extends AbstractUpdateRecord
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CompanyConnection $model
|
||||||
|
* @param int $isCreditTerm
|
||||||
|
* @return \Illuminate\Database\Eloquent\Model
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute(CompanyConnection $model, int $isCreditTerm)
|
||||||
|
{
|
||||||
|
$model->is_credit_term = $isCreditTerm;
|
||||||
|
|
||||||
|
return $this->handler($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanAssignEmployee extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanCreateCompany extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCompanyModule extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user