mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
673 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e25377d62d | |||
| c9570db825 | |||
| 807af317a1 | |||
| 5c60de2851 | |||
| 0c0dd30a1d | |||
| 4ed79659df | |||
| 0d5d5afbb0 | |||
| ee1bab12bf | |||
| b077730214 | |||
| eacf428c00 | |||
| 4faf3064d1 | |||
| 5b90c592e3 | |||
| 7b89a8bff8 | |||
| cc246046b5 | |||
| f03b60d93a | |||
| 9bc0d2890f | |||
| f3d502ea9b | |||
| e74bf4fc60 | |||
| 8f626230eb | |||
| bb273b6334 | |||
| d7ef783443 | |||
| 9f4c657122 | |||
| b7c6c13bde | |||
| 4c5483cb7c | |||
| 01d666d92a | |||
| b3973b52d1 | |||
| 694876c31f | |||
| ec3c596352 | |||
| 499782bbec | |||
| f3eca3dd89 | |||
| 4fc5a4a2d9 | |||
| 9c4c472a40 | |||
| a67afdc0ff | |||
| b30cdaba84 | |||
| 9ac0ca45be | |||
| 3fe98b24a4 | |||
| 7e7e43ee9c | |||
| 39892a0938 | |||
| cfb6270ae7 | |||
| 0ffe81d1cf | |||
| 09402a9c70 | |||
| 5fd6e6a528 | |||
| fec5f2f6dc | |||
| 09ede52ecf | |||
| b8686ff910 | |||
| e5d6f3f581 | |||
| a0a2c335ba | |||
| bcfeb49275 | |||
| b4c6e721fd | |||
| 514d3da73c | |||
| aa65b333c8 | |||
| 82a84157b6 | |||
| 656c50e047 | |||
| 58a64784db | |||
| 275157b243 | |||
| c5a71abf57 | |||
| 0c9ffd2bf7 | |||
| ae60f9ae49 | |||
| a953f78771 | |||
| 4a2c0db044 | |||
| cf3e7f04e4 | |||
| be0cd16285 | |||
| 50f6b664b9 | |||
| d4dcae155d | |||
| bad8cadb3a | |||
| 3af32cc6e7 | |||
| 34bab6a45c | |||
| 4769e0768b | |||
| ce4e8b174f | |||
| dd1eae1ea2 | |||
| b46bfb38bf | |||
| 19c4ee4fda | |||
| 13f13c7a0e | |||
| ffa63f611b | |||
| 82675ab80c | |||
| aac04c4135 | |||
| 56dca799f8 | |||
| 42d8f811c6 | |||
| 030136fd03 | |||
| c8b6e271e3 | |||
| f93997b858 | |||
| 6fbc23d7c4 | |||
| e0a264d58f | |||
| fec20b0947 | |||
| 0bf61d93c5 | |||
| bea24fb48e | |||
| 17a4522f50 | |||
| dfedb99c13 | |||
| b08e4c618f | |||
| 669cac9bd4 | |||
| d7625aece7 | |||
| 8c781a3362 | |||
| 57532e9afd | |||
| a36c5c3063 | |||
| 2f55821046 | |||
| 4a9ac3de02 | |||
| 1e6fafef28 | |||
| fd75da5778 | |||
| b593605c72 | |||
| 8d75012390 | |||
| 2d98757c1c | |||
| b329f232f2 | |||
| 713922d2ee | |||
| 74d11f8305 | |||
| ea920717a1 | |||
| e1b49f6be0 | |||
| 8ff459c373 | |||
| 707c48ab12 | |||
| 6d006ba60b | |||
| 1be405ca93 | |||
| 4087df6649 | |||
| 9d0924c674 | |||
| 4ac1fdb1ba | |||
| d21a930889 | |||
| 42d68a4357 | |||
| e63e3e707f | |||
| f32fc1976e | |||
| aeaec32dcb | |||
| cdf5e89a4a | |||
| b000c25e66 | |||
| a32e63b74f | |||
| 1e9af59b91 | |||
| 32d3aebf37 | |||
| a392b8a5eb | |||
| 1b2ae413e3 | |||
| 1059251b6b | |||
| c223aec7c9 | |||
| 3c622dc6ca | |||
| 819a29b227 | |||
| bbd48df118 | |||
| 353bf0ffbd | |||
| bb0ecc42c3 | |||
| df3024186b | |||
| e6486644a0 | |||
| 30edc3eaba | |||
| f8d191267b | |||
| b0eca18343 | |||
| 88e1b43f19 | |||
| fc9f6d6dde | |||
| 141dab15b6 | |||
| 83d7f20a48 | |||
| c9ac435e37 | |||
| 6d01bdfb60 | |||
| e2dc83e441 | |||
| e9daadaf60 | |||
| 7cace7e800 | |||
| 12f8391ca8 | |||
| 64fa56c02f | |||
| 3f962e774d | |||
| 4ba2144f02 | |||
| 69f2b384cf | |||
| 39017c5d8f | |||
| f1a35299e6 | |||
| b15866ea16 | |||
| bd42f7213a | |||
| c022ab6578 | |||
| 2d92b1a8ab | |||
| 8bfdc2431c | |||
| 06e3049e50 | |||
| ac1957bcb0 | |||
| b0fa73a12b | |||
| 61a0766e60 | |||
| 5d66761465 | |||
| 1ac4615c99 | |||
| 590960b5fd | |||
| 5f24f58480 | |||
| 4dec576aa0 | |||
| 4a41c89024 | |||
| a0997a4649 | |||
| b90dae882e | |||
| f3c7c042fc | |||
| f361a7e185 | |||
| 29619625d1 | |||
| 424e2b4e5e | |||
| 1705b5c2e5 | |||
| 1813783d87 | |||
| 46a0e670ba | |||
| dcec8cb33b | |||
| 75037f6192 | |||
| 675324081b | |||
| a959e83f5b | |||
| 2802e3c366 | |||
| aac2a0666a | |||
| 19efba4b89 | |||
| 7d70c800db | |||
| 863dc94dad | |||
| 98e45e27e3 | |||
| df2916594b | |||
| a49920973e | |||
| d129f8f6bd | |||
| 55a82e52a4 | |||
| 1d4ac80b8f | |||
| 7cd376a9b5 | |||
| c7e3091f9b | |||
| 28feba2ae9 | |||
| 7b897f8dce | |||
| 4d7adba8e8 | |||
| 3c91a7d099 | |||
| 0435464382 | |||
| 6878dbc518 | |||
| 3ec186da3b | |||
| 1301e8d1a4 | |||
| 75d2fc3d76 | |||
| 6176135f85 | |||
| ec6b768755 | |||
| 5f529965da | |||
| 924f4f2ace | |||
| 6369282b38 | |||
| 1991cf2c57 | |||
| b26fea9a49 | |||
| a809aec9a7 | |||
| 68ce8373e9 | |||
| b5efe6139d | |||
| 90793be9dc | |||
| 464160b526 | |||
| bf195bf3e3 | |||
| 6e5a18fd05 | |||
| 8d5edbd716 | |||
| 898b63cbd2 | |||
| 20f0d54844 | |||
| 2951800117 | |||
| 5ac8911fab | |||
| 0f1d247c51 | |||
| 73aa703658 | |||
| 8da81a4696 | |||
| 1291267805 | |||
| 406fe045fc | |||
| 4e0f04eae2 | |||
| 56aec95d50 | |||
| 0e3fedf56f | |||
| dadf7153d7 | |||
| 8fdc4168b1 | |||
| bf1cb09ece | |||
| a829bec73e | |||
| ff9cb8a9b6 | |||
| 939959193d | |||
| 6db98029d9 | |||
| 17ed9c3599 | |||
| 6aef08ee5e | |||
| 797c0a1bfd | |||
| de036f8c20 | |||
| b493dd1aaf | |||
| 3fb09a005f | |||
| cbfbebc32b | |||
| 86afc4aa66 | |||
| ca5a445df1 | |||
| 649e22cef0 | |||
| 873aaa8263 | |||
| 9148c9063d | |||
| 70688c4a4b | |||
| f9e8f4c852 | |||
| 476f5ba506 | |||
| 73dcc12b09 | |||
| ef934626d6 | |||
| 8fbf163d4b | |||
| 7236a80f68 | |||
| 014244f453 | |||
| a1eed0477f | |||
| d15c5d9bc9 | |||
| f052a95b4d | |||
| 6c12d4b436 | |||
| aad694ff2e | |||
| 1ad8f81080 | |||
| 27c990d903 | |||
| 8d80669eb3 | |||
| bc4b34f0a9 | |||
| 533977f353 | |||
| b293f84c38 | |||
| 1ceb2bd636 | |||
| bc6a31d458 | |||
| 687dc9f3fe | |||
| ee65e5fcd1 | |||
| bc0a0c64c4 | |||
| 378434dac4 | |||
| 28bba28034 | |||
| 7e1a0a1bc4 | |||
| e0e00ac962 | |||
| 0d8d35ab25 | |||
| a66c7990f0 | |||
| b4f8519102 | |||
| db8a1c0808 | |||
| ebc601b45e | |||
| ce86dda0b9 | |||
| c80c5965b1 | |||
| f7ac3715d0 | |||
| 871dbcfc87 | |||
| f3c8d65e03 | |||
| b9aa18c705 | |||
| 071858b55c | |||
| 7d6e342a79 | |||
| 8f695401d2 | |||
| 58c861b726 | |||
| 68940e6b6d | |||
| dbc57fdaac | |||
| 55f7637d9c | |||
| 1578085bab | |||
| 08090036fe | |||
| 9c9cf0f96e | |||
| 73f9418835 | |||
| b645bae1b1 | |||
| 8513309126 | |||
| 341fe0ff52 | |||
| 888fe3b6d3 | |||
| 1452cf2dee | |||
| 1e9af663ba | |||
| ae7072b3e3 | |||
| e74c26a2d4 | |||
| 54268b0683 | |||
| 3215638c87 | |||
| 4794251a0c | |||
| bef2c05c06 | |||
| 9384236294 | |||
| 2b1100b3e9 | |||
| 34103f00cd | |||
| a4de710b13 | |||
| 9b1ced0ade | |||
| bc973c113c | |||
| ee732eeb52 | |||
| 77bd84f61b | |||
| fcbb71de7e | |||
| d4e0827600 | |||
| 8532e73d26 | |||
| efd26f9bcf | |||
| 212e718377 | |||
| c519f34bac | |||
| 3098bc7d18 | |||
| f9995d6b2d | |||
| 5b5eb4b7c1 | |||
| c14a53a2c5 | |||
| 7a3610b58b | |||
| 0bc15bf4ae | |||
| 19f0eb5e9b | |||
| 045dbf9d86 | |||
| 9bcf3ca343 | |||
| de9dc5892b | |||
| 95ffac5c87 | |||
| ab4eca6d01 | |||
| d2b7cf3e1b | |||
| 1a1c40338c | |||
| 58a086ea46 | |||
| 8b8edeab36 | |||
| 0783ccfb58 | |||
| 1e3a3db02e | |||
| f47d579070 | |||
| 4c3dead6b7 | |||
| d61aea9956 | |||
| d8762bf0f2 | |||
| 3c567f2161 | |||
| acf7000580 | |||
| 20de400c16 | |||
| 575379adc0 | |||
| ce2af28766 | |||
| 74f4cfda0c | |||
| 16682965f9 | |||
| 96dc482422 | |||
| 0eb0f7805b | |||
| e92cd13bf8 | |||
| 1d3ab46cc7 | |||
| f54b451ac4 | |||
| a59508087c | |||
| 012ead1a8f | |||
| f865cd7180 | |||
| 8d4f05cd50 | |||
| 40371a9225 | |||
| 086f5f79ad | |||
| 5bb6c44967 | |||
| 15a4c8dc25 | |||
| fcd7fa655c | |||
| bd4598fac0 | |||
| 746f38a4f9 | |||
| ab4d01c728 | |||
| 4c47d88440 | |||
| 7ef3580b1b | |||
| 1b04d25a81 | |||
| a8c54abdd9 | |||
| 14c2ed8d89 | |||
| d5143dfbe3 | |||
| ad4675369e | |||
| 4b4c953b36 | |||
| 2dbf05d0dc | |||
| 55f18ebafc | |||
| 9f25b49b8c | |||
| 793cde03ac | |||
| 58daaa6095 | |||
| dd82f624c5 | |||
| 9f4cbd48f7 | |||
| af34391b58 | |||
| 4680b2d634 | |||
| 0d3ae2941c | |||
| e15c61e139 | |||
| 4907b8269e | |||
| f7124dc0e1 | |||
| 9e455f8fc7 | |||
| 3e72fb78d3 | |||
| 85a1605182 | |||
| a17ed000e1 | |||
| 3cc14e1e14 | |||
| 40e074c57a | |||
| ab7a9bf144 | |||
| fd1a8447fc | |||
| efa7657125 | |||
| 941da8c68d | |||
| 35aa074c41 | |||
| d3299aee60 | |||
| c90d994317 | |||
| 8dc6c4ebdc | |||
| 4dce3a7915 | |||
| 3f07b410b9 | |||
| 7db02b7688 | |||
| 7f8e0b1712 | |||
| 973c0f0924 | |||
| 7d156503fc | |||
| f38ed3be84 | |||
| 58dee4883b | |||
| 0e83fba98c | |||
| 1fbe8e61cb | |||
| 8307871aba | |||
| 71ed6b9950 | |||
| 3e3e19bed3 | |||
| aff9e35623 | |||
| 67e7f72f63 | |||
| f55beaff5f | |||
| 52083ee48a | |||
| f4f652aa97 | |||
| 43ccdd0700 | |||
| c7ce382424 | |||
| e9c3cf8f33 | |||
| ffede58dde | |||
| 9ff00a3df2 | |||
| 7b8eadd5d1 | |||
| 9d130e1531 | |||
| 893d10c7f6 | |||
| 68257952ab | |||
| 07a7901844 | |||
| 91fcb76863 | |||
| cac02b8ebe | |||
| 4370ba2f9c | |||
| 41db8f57f5 | |||
| 3497de9727 | |||
| 14a4c37fee | |||
| f27e0aa8c6 | |||
| 5c109d625c | |||
| 965dfb3098 | |||
| d6fad96d4d | |||
| 351447b1fc | |||
| a9910c5a12 | |||
| 4bee415d2d | |||
| 02f7adb1e9 | |||
| 039a6155ca | |||
| c8d806a51d | |||
| 4dbaf6a5dc | |||
| fcc0135843 | |||
| 4a922ac340 | |||
| c4d421db76 | |||
| 2816e80bee | |||
| 466e90a0af | |||
| 5e6ae2a905 | |||
| 3378d37ffb | |||
| fff3d948d0 | |||
| c181882145 | |||
| 2a333f7d19 | |||
| 8f8622aa10 | |||
| f88936c873 | |||
| 20f3004e22 | |||
| fd4bbe5d4f | |||
| a630b49867 | |||
| 75ce5bd752 | |||
| abb7bc2e4c | |||
| 857003b25b | |||
| 551119e313 | |||
| b567f50711 | |||
| 395b15af90 | |||
| 833ffdab8d | |||
| 2f6a30a512 | |||
| 4c433f74f1 | |||
| 852da05e24 | |||
| 1658b65484 | |||
| 8e9ff0cad5 | |||
| acee1a7884 | |||
| 0079d745ba | |||
| 0bd3464184 | |||
| 7ec1bc65a5 | |||
| c401d1e0d5 | |||
| a2983ec9f1 | |||
| 2421640c0a | |||
| 7dae2228f6 | |||
| 75039466ab | |||
| f3df5fbe9f | |||
| 362e47aaa0 | |||
| ba26cda598 | |||
| 8995a567d5 | |||
| 5eeec7806b | |||
| fd46a4fb7f | |||
| 1100267316 | |||
| e133f1fab8 | |||
| 5d5892ce07 | |||
| b26700ea6f | |||
| 589c2e01d9 | |||
| 9cf6058a65 | |||
| ff4d81966c | |||
| a4891aa0de | |||
| 05ba0ba6fd | |||
| 9217970237 | |||
| 828f424cfd | |||
| 057ca8480b | |||
| d07901f31b | |||
| c22638b29e | |||
| c292bfd1e0 | |||
| 85942eff1d | |||
| d69896f807 | |||
| 2c5c97488f | |||
| 99e38b96ce | |||
| 81a00a8195 | |||
| dbab7a9f8c | |||
| 046676d174 | |||
| 2b4f1ad570 | |||
| bcb78f2392 | |||
| 345a62fec6 | |||
| 6257b11a6e | |||
| 4b124ca96d | |||
| 4b25764fb3 | |||
| 422a0af465 | |||
| c73d65343b | |||
| 9e5784b6ec | |||
| 9a863e2143 | |||
| 8024865d5d | |||
| 66abe81e73 | |||
| ca178e1b31 | |||
| e52a27aedb | |||
| 6c2c28fb31 | |||
| 049da351ef | |||
| 0ce8709f70 | |||
| 1e5609bb1b | |||
| 8e7970a925 | |||
| 06b2c5166d | |||
| 6ba3b873a2 | |||
| 623fb1609b | |||
| 24be20a60d | |||
| 3535201481 | |||
| cdefd48d26 | |||
| 45fbcf1447 | |||
| 53805f3608 | |||
| 99e90ad357 | |||
| 5edb9b5cfe | |||
| 86a5a3b2d9 | |||
| a6590e3b81 | |||
| b1bb2b9f33 | |||
| 9318e7471f | |||
| e19ba1c9f3 | |||
| 8cffae079b | |||
| 594b25b71b | |||
| d142a86683 | |||
| 935f3e9bf5 | |||
| dedd6464f4 | |||
| 38aba65178 | |||
| 091119c244 | |||
| 4d095b5459 | |||
| 1c50181132 | |||
| 9e26c470f5 | |||
| 4c0bf164a0 | |||
| 8ab7f72e90 | |||
| 5772e30575 | |||
| 4b2daa62d7 | |||
| 2bd8700a61 | |||
| ad7e77c169 | |||
| e95c41bd3e | |||
| 903269e714 | |||
| 4120a50559 | |||
| 88b31f2d3f | |||
| a2f9bf83ce | |||
| dd2ac4c966 | |||
| c88f6890d6 | |||
| bf4b3fa97f | |||
| 6bcea5a8f1 | |||
| 2704ec1665 | |||
| 0c636d2156 | |||
| 1270ba3f43 | |||
| f2c32c5024 | |||
| ccb3bde260 | |||
| a7eb14c2b7 | |||
| abac96b1e5 | |||
| ecb48c8897 | |||
| 2686229a0f | |||
| 558fa7ae52 | |||
| 88e2136c07 | |||
| 70cdcded9b | |||
| 4022b640f9 | |||
| 0d780074b8 | |||
| 078f675a7f | |||
| 2b48a86f98 | |||
| 19f3aa18fc | |||
| 2b4c932fc8 | |||
| 89f0ca651a | |||
| c9fc5938c6 | |||
| 2ad8235c1b | |||
| dbf8301cb9 | |||
| 7d582c6bca | |||
| 3c4b6afcb2 | |||
| e4bc56d188 | |||
| 9a448d5a3d | |||
| 5c1074b244 | |||
| 49fcdfd89e | |||
| c900759234 | |||
| cd3b47ab1a | |||
| c5f95cdf61 | |||
| cc428a92b8 | |||
| 97bac45612 | |||
| 8048396a88 | |||
| 400ec31235 | |||
| 4d9346c62c | |||
| 94fd2069e8 | |||
| 1f401eb347 | |||
| 80e282bda0 | |||
| 65cd6aae3c | |||
| eba2a30024 | |||
| c103deb2a7 | |||
| dcef782587 | |||
| 10e7da4673 | |||
| faff35f241 | |||
| e2c1562f19 | |||
| df35ceb798 | |||
| cdb81a0bf4 | |||
| f1b1955190 | |||
| 860632b7a3 | |||
| bde7a61fb4 | |||
| b6600c5168 | |||
| 25f38ef7fe | |||
| ddeb44b920 | |||
| 02be710203 | |||
| 2ffbfc9f1c | |||
| 7b34f8116c | |||
| 8a9b6df255 | |||
| c881dd44d6 | |||
| 1cfaeaf8bb | |||
| 914f29184d | |||
| f510d57463 | |||
| 7833c17938 | |||
| 97fdffe6eb | |||
| b1f2900f1c | |||
| ddf015dc71 | |||
| 2a9d4fd212 | |||
| 2cacc23a38 | |||
| a7fd5a038e | |||
| 626b31084f | |||
| 4f3c25d5bd | |||
| 8da942e41e | |||
| b599c8a151 | |||
| d41f796825 | |||
| dd612e2660 | |||
| c503b5e677 | |||
| 0b433cfa18 | |||
| 75aba8c4ac | |||
| 81c65874a3 | |||
| 79d29d9c7b | |||
| 1e558b93af | |||
| 6d3d52639e | |||
| a1d460aa6c | |||
| 5a0bc7aaea | |||
| c7962b4231 | |||
| d14bb39ae8 | |||
| 5cc2f51c02 | |||
| a185f73e8a | |||
| f9a9598210 | |||
| 9976ccec41 | |||
| 8bfb2d749a | |||
| 7bf9a570a1 | |||
| b38df170e8 | |||
| bf38ace70c | |||
| 66c008f97e | |||
| 0298eb946f | |||
| 70fb35e37c | |||
| 1a30877ca9 | |||
| 569a22c0db |
+12
-2
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
DB_PASSWORD=root
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -56,6 +56,16 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
WEPOST_BASE_URL=https://wepost-uat.90warehouse.com/api/router
|
||||
WEPOST_CLIENT_ID=1234
|
||||
WEPOST_CLIENT_SECRET=cief-secret-temp
|
||||
WEPOST_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,59 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=P@ssw0rd
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
@@ -2,6 +2,8 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- service_build
|
||||
- node
|
||||
- building_assets
|
||||
- database
|
||||
- unit_test
|
||||
- acceptance_test
|
||||
- code_quality
|
||||
|
||||
# Variables
|
||||
variables:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: mysql_password
|
||||
MYSQL_PASSWORD: mysql_password
|
||||
MYSQL_DATABASE: shpping_portal
|
||||
DB_HOST: mysql
|
||||
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
#install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install MySQL client
|
||||
- apt-get install -y default-mysql-client
|
||||
|
||||
#install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
#install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
|
||||
|
||||
#jobs
|
||||
|
||||
#buld the backend
|
||||
composer_php:
|
||||
stage: service_build
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#build the UI
|
||||
#node installation
|
||||
npm:
|
||||
stage: node
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#building assets
|
||||
building_assets:
|
||||
stage: building_assets
|
||||
# dependencies:
|
||||
# - npm
|
||||
script:
|
||||
- npm install # Install npm dependencies
|
||||
- gulp build # Build assets
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
database:
|
||||
stage: database
|
||||
services:
|
||||
- name: mysql:8.0
|
||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - composer_php
|
||||
script:
|
||||
- composer install
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- php artisan migrate:fresh
|
||||
- php artisan db:seed
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
#mysql
|
||||
#unit_test:
|
||||
# stage: unit_test
|
||||
# services:
|
||||
# - name: mysql:8.0
|
||||
# command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||
#dependencies:
|
||||
# - database
|
||||
# script:
|
||||
# - npm install # Install npm dependencies
|
||||
# - gulp build # Build assets
|
||||
# - composer install
|
||||
# - cp .env.example .env
|
||||
# - php artisan key:generate
|
||||
# - php artisan migrate:fresh
|
||||
# - php artisan db:seed
|
||||
# - php artisan test
|
||||
# rules:
|
||||
# - if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,62 +1,39 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
||||
## Shipping portal documentation
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
simple documentation on how to install, run, test, commit and deploy application
|
||||
|
||||
## About Laravel
|
||||
## creating and running unit tests
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
Required Tools
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
- Chromium Driver / selenium
|
||||
- add running and setting selenium on all OS if possible
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
Required Packages :
|
||||
|
||||
## Learning Laravel
|
||||
- laravel/legacy-factories
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
- codeception/codeception
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
Or Simply Run
|
||||
|
||||
## Laravel Sponsors
|
||||
``Composer install``
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
To create a unit test
|
||||
|
||||
### Premium Partners
|
||||
``php artisan make test: Test Example --unit``
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
Running the tests :
|
||||
|
||||
## Contributing
|
||||
Running a single Test
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
`` php artisan test --filter Example``
|
||||
|
||||
## Code of Conduct
|
||||
Running Unit tests -
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
`` php artisan test ``
|
||||
|
||||
## Security Vulnerabilities
|
||||
Running Codeception tests -
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
``vendor/bin/codecept run``
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
@@ -64,22 +64,28 @@ abstract class AbstractControllerLogic
|
||||
return $response;
|
||||
|
||||
} 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{
|
||||
if ($request->has('isApiPub')) {
|
||||
Log::error($exception);
|
||||
}
|
||||
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', "Server Error",
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
|
||||
} else {
|
||||
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(),
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,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,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface KeyValueInterface
|
||||
{
|
||||
|
||||
public function attributes(): morphMany;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General;
|
||||
|
||||
|
||||
class WePostHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $clientId
|
||||
* @param string $clientSecrent
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
static function generateSignature(string $clientId, string $clientSecrent, string $type){
|
||||
// public parameters
|
||||
$timestamp = 1234; //time();
|
||||
|
||||
$params = [
|
||||
'client_id' => $clientId,
|
||||
'type' => $type,
|
||||
'timestamp' => $timestamp
|
||||
];
|
||||
|
||||
// $businessParams = [
|
||||
// 'test1' => '1',
|
||||
// ];
|
||||
|
||||
ksort($params);
|
||||
$str = '';
|
||||
foreach ($params as $key => $value) {
|
||||
if(is_array($value)) {
|
||||
$str .= $key.json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
continue;
|
||||
}
|
||||
$str .= $key. $value;
|
||||
}
|
||||
$str = $clientSecrent.$str.$clientSecrent;
|
||||
$signature = strtoupper(md5($str));
|
||||
return $signature;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
{
|
||||
@@ -29,12 +30,17 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info('FetchOrdersFromYDPortalJob starts');
|
||||
Log::info('FetchPackingListsFromYdPortalProcessor starts');
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchContainersFromYdPortalProcessor starts');
|
||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchContainersUpdatesFromYdPortalProcessor starts');
|
||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor starts');
|
||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchOrdersFromYDPortalJob ends');
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,14 +11,16 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
@@ -28,7 +28,8 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\RegisterOnExchangeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
@@ -36,6 +37,8 @@ use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateCustomerLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -87,6 +90,12 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var CreatePerfexCRMLeadProcessor */
|
||||
private $createPerfexCRMLeadProcessor;
|
||||
|
||||
/** @var RegisterOnExchangeProcessor */
|
||||
private $registerOnExchangeProcessor;
|
||||
|
||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
||||
private $connectCompanyModuleToExchangeCompany;
|
||||
|
||||
/**
|
||||
* CreateCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
@@ -101,8 +110,10 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
||||
* @param RegisterOnExchangeProcessor $registerOnExchangeProcessor
|
||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, RegisterOnExchangeProcessor $registerOnExchangeProcessor, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
@@ -116,6 +127,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
||||
$this->registerOnExchangeProcessor = $registerOnExchangeProcessor;
|
||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +166,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
// $this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
||||
@@ -167,8 +180,34 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
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);
|
||||
|
||||
$exchangeCompanyId = null;
|
||||
if ($request->input('exchange_company_id')) {
|
||||
$exchangeCompanyId = $request->input('exchange_company_id');
|
||||
} else {
|
||||
// register account on exchange portal if this registration not coming from exchange
|
||||
$exchangeCompanyId = $this->registerOnExchangeProcessor->execute($request, $companyModule->id);
|
||||
}
|
||||
|
||||
if ($exchangeCompanyId) {
|
||||
// create exchange company connection
|
||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $exchangeCompanyId);
|
||||
}
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationTokenWithExchangeBookingId;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoginThroughExchangeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Authentication',
|
||||
'message' => 'You have successfully logged in to your account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var AuthenticationProcessor */
|
||||
private $authenticationProcessor;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var GeneratesAuthenticationTokenWithExchangeBookingId */
|
||||
private $generatesAuthenticationTokenWithExchangeBookingId;
|
||||
|
||||
|
||||
/**
|
||||
* LoginThroughExchangeLogic constructor.
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId
|
||||
*/
|
||||
public function __construct(GeneratesAuthenticationToken $generatesAuthenticationToken, GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId)
|
||||
{
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->generatesAuthenticationTokenWithExchangeBookingId = $generatesAuthenticationTokenWithExchangeBookingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
$token = explode('.', $request->input("exchangeToken"))[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$exchangeCompanyId = $exchangeUser['company_id'];
|
||||
$connection = ExchangeCompanyConnection::where("exchange_company_id", $exchangeCompanyId)->first();
|
||||
if (!$connection) {
|
||||
throw new AccessUnauthorisedException('These credentials do not match our records.');
|
||||
}
|
||||
$companyModule = $connection->companyModule;
|
||||
$user = $companyModule->employees->last();
|
||||
|
||||
$exchangeBookingId = null;
|
||||
if (isset($exchangeUser['booking_id']) && $exchangeUser['booking_id']) {
|
||||
$exchangeBookingId = $exchangeUser['booking_id'];
|
||||
$token = $this->generatesAuthenticationTokenWithExchangeBookingId->execute($user, $exchangeBookingId);
|
||||
|
||||
return $this->response(['access_token' => $token, 'redirect_url' => route('dashboard') . "?createOrder=true"]);
|
||||
} else {
|
||||
$token = $this->generatesAuthenticationToken->execute($user);
|
||||
$order = Order::where('id', $request->input("orderId"))->first();
|
||||
|
||||
return $this->response(['access_token' => $token, 'redirect_url' => route('order.show' , $order->reference)]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class KeyValuePairObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $key;
|
||||
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
|
||||
/**
|
||||
* KeyValuePairObject constructor.
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct(string $key, string $value)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RegisterOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = 'https://exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = 'http://127.0.0.1:8000/api/v1/account/registration/registration';
|
||||
} else {
|
||||
$url = 'https://dev.exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$formParams = $request->toArray();
|
||||
$formParams['shipping_company_module_id'] = $companyModuleId;
|
||||
$response = $client->request('POST', $url, ['form_params' => $formParams]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
$payload = $contents['payload'];
|
||||
$token = explode('.', $payload['access_token'])[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
|
||||
return $exchangeUser['company_id'];
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\KeyValueInterface;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Models\KeyValuePair;
|
||||
|
||||
class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param KeyValueInterface $kv
|
||||
* @param KeyValuePairObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
|
||||
public function execute(KeyValueInterface $kv, KeyValuePairObject $object) {
|
||||
$model = new KeyValuePair();
|
||||
$model->key = $object->getKey();
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($kv->attributes(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Company;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\JWT;
|
||||
|
||||
class GeneratesAuthenticationTokenWithExchangeBookingId {
|
||||
|
||||
/** @var JWT */
|
||||
private $builder;
|
||||
|
||||
|
||||
/**
|
||||
* GeneratesAuthenticationTokenWithExchangeBookingId constructor.
|
||||
* @param JWT $builder
|
||||
*/
|
||||
public function __construct(JWT $builder) {
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param bool $rememberUser
|
||||
* @return string
|
||||
*/
|
||||
public function execute(User $user, $bookingId): string {
|
||||
|
||||
$this->builder->manager()->setBlacklistEnabled(false);
|
||||
|
||||
// generate token for the customer
|
||||
$this->builder->factory()->setTTL(Carbon::now()->addDay()->timestamp);
|
||||
|
||||
// set the claim based on the object
|
||||
$this->setTokenClaims($user, $bookingId);
|
||||
|
||||
return $this->builder->fromUser($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
private function setTokenClaims(User $user, $bookingId): void {
|
||||
|
||||
$claims = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'type' => $user->type,
|
||||
'status' => $user->status
|
||||
];
|
||||
|
||||
if($user->type === RoleTypes::USER) {
|
||||
|
||||
/** @var Company $companyModule */
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$claims = array_merge($claims, [
|
||||
'company_id' => $companyModule->company_id,
|
||||
'company_module_id' => $companyModule->id,
|
||||
'company_module_type' => $companyModule->type,
|
||||
'company_name' => $companyModule->name,
|
||||
'company_marking' => $companyModule->type !== 8 ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'HWT',
|
||||
'exchange_booking_id' => $bookingId
|
||||
]);
|
||||
}
|
||||
|
||||
$this->builder->factory()->customClaims(['user' => $claims]);
|
||||
|
||||
|
||||
$this->builder->factory()->buildClaimsCollection();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
@@ -15,8 +18,10 @@ use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -27,7 +32,8 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Address',
|
||||
'message' => 'You have successfully created a new Address'
|
||||
@@ -74,11 +80,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
@@ -90,16 +96,31 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||
|
||||
if($request->input('phone')){
|
||||
if ($request->input('phone')) {
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
if ($request->input('remark')) {
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
$addressExtraFields = [
|
||||
'property_type' => $request->input('property_type'),
|
||||
'tools_required_unload' => $request->input('tools_required_unload'),
|
||||
'pickup_time_from' => $request->input('pickup_time_from'),
|
||||
'pickup_time_to' => $request->input('pickup_time_to'),
|
||||
];
|
||||
|
||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
||||
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
@@ -14,6 +17,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -23,7 +27,8 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Billing Address',
|
||||
'message' => 'You have successfully created a new Billing Address'
|
||||
@@ -60,27 +65,35 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
// create new billing addrress
|
||||
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
//load address with only owner address
|
||||
|
||||
/* return fractal()
|
||||
->item($billingAddressInputed, new AddressTransformer())
|
||||
->parseIncludes('Owner_address')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||
@@ -17,7 +19,8 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Address',
|
||||
'message' => 'You have successfully retrieved a Address'
|
||||
@@ -45,15 +48,22 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchAddress->passes();
|
||||
|
||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
@@ -45,17 +50,25 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAddresses->passes();
|
||||
|
||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||
|
||||
//a collection of addresses with all incluides
|
||||
/* return fractal()
|
||||
->collection($query, new AddressTransformer)
|
||||
->parseIncludes('Owner_address')
|
||||
->parseIncludes('remark')
|
||||
->parseIncludes('contact')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(AddressResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\DistrictResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -33,7 +34,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
/** @var ResetsAddressesDefault */
|
||||
private $resetsAddressesDefault;
|
||||
|
||||
/** @var SetsAddressToDefault*/
|
||||
/** @var SetsAddressToDefault */
|
||||
private $setsAddressToDefault;
|
||||
|
||||
|
||||
@@ -64,7 +65,15 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
|
||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||
|
||||
$setAddress = $this->setsAddressToDefault->execute($address);
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($setAddress, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,13 @@ use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -26,7 +29,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Address',
|
||||
'message' => 'You have successfully updated the Address'
|
||||
@@ -77,7 +81,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
@@ -90,18 +94,44 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
$address->contacts()->delete();
|
||||
$address->remarks()->delete();
|
||||
|
||||
if($request->input('phone')){
|
||||
if ($request->input('phone')) {
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
if ($request->input('remark')) {
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
//only remark relationship needed
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
if ($request->input('pickup_time_to') <= $request->input('pickup_time_from')) {
|
||||
$pickupTimeFrom = Carbon::parse($request->input('pickup_time_from'));
|
||||
$request->merge([
|
||||
'pickup_time_to' => $pickupTimeFrom->addHour()->format('H:i') // Format to hh:mm
|
||||
]);
|
||||
}
|
||||
|
||||
$addressExtraFields = [
|
||||
'property_type' => $request->input('property_type'),
|
||||
'additional_request' => $request->input('additional_request'),
|
||||
'receive_goods_working_hours' => $request->input('receive_goods_working_hours'),
|
||||
'receive_goods_after_hours' => $request->input('receive_goods_after_hours'),
|
||||
'receive_goods_on_saturday' => $request->input('receive_goods_on_saturday'),
|
||||
];
|
||||
|
||||
$address->addressExtraFields()->delete();
|
||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
||||
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->attach($segment);
|
||||
$announcement->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
||||
|
||||
return $announcement;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class CallbackBillplzProcessor
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/**
|
||||
* CreateUserProcessor constructor.
|
||||
* CallbackBillplzProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
|
||||
+23
-4
@@ -10,16 +10,18 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Processors\ApproveIdentificationDocumentOnExchangeProcessor;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Document;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -55,6 +57,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var CreateNotificationProcessor */
|
||||
private $createNotificationProcessor;
|
||||
|
||||
/** @var ApproveIdentificationDocumentOnExchangeProcessor */
|
||||
private $approveIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
/**
|
||||
* ApproveIdentificationDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
@@ -64,8 +69,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||
* @param ApproveIdentificationDocumentOnExchangeProcessor $approveIdentificationDocumentOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor, ApproveIdentificationDocumentOnExchangeProcessor $approveIdentificationDocumentOnExchangeProcessor)
|
||||
{
|
||||
$this->canApproveDocument = $canApproveDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
@@ -74,6 +80,7 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||
$this->approveIdentificationDocumentOnExchangeProcessor = $approveIdentificationDocumentOnExchangeProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,11 +92,18 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$documentId = $request->route('document_id');
|
||||
|
||||
if ($request->route('exchange_company_id')) {
|
||||
$companyModule = ExchangeCompanyConnection::where('exchange_company_id', $request->route('exchange_company_id'))->first()->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$documentId = $company->documents()->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->where('status', ApprovalStatus::PENDING_VERIFICATION)->first()->id;
|
||||
}
|
||||
|
||||
$status = $request->route('status');
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('document_id')]);
|
||||
$document = $this->fetchesDocument->execute(['id' => $documentId]);
|
||||
|
||||
$this->canApproveDocument->passes();
|
||||
|
||||
@@ -111,6 +125,11 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
// if this request is not calling from exchange portal, then approve the document on exchange portal for this user
|
||||
$companyModule = $document->owner->companyModules()->first();
|
||||
if (!$request->route('exchange_company_id') && $companyModule->exchangeCompanyConnection()->first()) {
|
||||
$this->approveIdentificationDocumentOnExchangeProcessor->execute($request, $companyModule->id, $status);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document));
|
||||
|
||||
|
||||
+13
-1
@@ -7,6 +7,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
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 Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -33,17 +35,22 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController
|
||||
/** @var AssignConnectionSegmentProcessor */
|
||||
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @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->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,6 +69,11 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController
|
||||
|
||||
$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));
|
||||
}
|
||||
}
|
||||
+22
-2
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\CreateIdentificationDocumentOnExchangeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
@@ -14,6 +15,7 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Company;
|
||||
use App\Models\Document;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -42,6 +44,9 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesCompanyStatus */
|
||||
private $updatesCompanyStatus;
|
||||
|
||||
/** @var CreateIdentificationDocumentOnExchangeProcessor */
|
||||
private $createIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateIdentificationDocumentLogic constructor.
|
||||
@@ -49,13 +54,15 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param CreateIdentificationDocumentOnExchangeProcessor $createIdentificationDocumentOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesCompanyStatus $updatesCompanyStatus)
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesCompanyStatus $updatesCompanyStatus, CreateIdentificationDocumentOnExchangeProcessor $createIdentificationDocumentOnExchangeProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->createIdentificationDocumentOnExchangeProcessor = $createIdentificationDocumentOnExchangeProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,8 +73,15 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
if ($request->route('exchange_company_id')) {
|
||||
$companyModule = ExchangeCompanyConnection::where('exchange_company_id', $request->route('exchange_company_id'))->first()->companyModule;
|
||||
$companyId = $companyModule->company_id;
|
||||
} else {
|
||||
$companyId = $request->route('id');
|
||||
}
|
||||
|
||||
/** @var Company $company */
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$company = $this->fetchesCompany->execute(['id' => $companyId]);
|
||||
$object = new DocumentObject($company->type === CompanyType::COMPANY_BUSINESS ?
|
||||
DocumentType::SSM_REGISTRATION : DocumentType::IDENTITY_CARD, $request->input('files'),
|
||||
$request->input('identification_no'), ApprovalStatus::PENDING_VERIFICATION, 'identifications');
|
||||
@@ -78,6 +92,12 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->updatesCompanyStatus->execute($company, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
// create identification on exchange if this request not coming from exchange
|
||||
$companyModule = $company->companyModules()->first();
|
||||
if (!$request->route('exchange_company_id') && $companyModule->exchangeCompanyConnection()->first()) {
|
||||
$this->createIdentificationDocumentOnExchangeProcessor->execute($request, $companyModule->id);
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\LinkExchangeCompanyProcessor;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkExchangeCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Connect Exchange with Izyim Account',
|
||||
'message' => 'You have successfully connect your exchange account to Izyim Account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var LinkExchangeCompanyProcessor */
|
||||
private $linkExchangeCompanyProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* LinkExchangeCompanyLogic constructor.
|
||||
* @param LinkExchangeCompanyProcessor $linkExchangeCompanyProcessor
|
||||
*/
|
||||
public function __construct(LinkExchangeCompanyProcessor $linkExchangeCompanyProcessor)
|
||||
{
|
||||
$this->linkExchangeCompanyProcessor = $linkExchangeCompanyProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
return $this->response($this->linkExchangeCompanyProcessor->execute($request));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
@@ -45,15 +50,26 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||
|
||||
/*include all relationships*/
|
||||
/* return fractal()
|
||||
->collection($query, new CompanyTransformer)
|
||||
->parseIncludes('company')
|
||||
->parseIncludes('contact')
|
||||
->parseIncludes('remarks')
|
||||
->parseIncludes('address')
|
||||
->parseIncludes('billingAddress')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApproveIdentificationDocumentOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId, $status) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('PUT', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateIdentificationDocumentOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('POST', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticationRedirect;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanAuthenticateUser;
|
||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkExchangeCompanyProcessor
|
||||
{
|
||||
|
||||
/** @var CanAuthenticateUser */
|
||||
private $canAuthenticateUser;
|
||||
|
||||
/** @var AuthenticatesUser */
|
||||
private $authenticatesUser;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var AuthenticationRedirect */
|
||||
private $authenticationRedirect;
|
||||
|
||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
||||
private $connectCompanyModuleToExchangeCompany;
|
||||
|
||||
/**
|
||||
* AuthenticationProcessor constructor.
|
||||
* @param CanAuthenticateUser $canAuthenticateUser
|
||||
* @param AuthenticatesUser $authenticatesUser
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param AuthenticationRedirect $authenticationRedirect
|
||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
||||
*/
|
||||
public function __construct(CanAuthenticateUser $canAuthenticateUser, AuthenticatesUser $authenticatesUser, GeneratesAuthenticationToken $generatesAuthenticationToken, FetchesUser $fetchesUser, AuthenticationRedirect $authenticationRedirect, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
||||
{
|
||||
$this->canAuthenticateUser = $canAuthenticateUser;
|
||||
$this->authenticatesUser = $authenticatesUser;
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->authenticationRedirect = $authenticationRedirect;
|
||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request): array {
|
||||
|
||||
$object = new AuthenticationCredentialsObject($request->input('email'), $request->input('password'));
|
||||
|
||||
$this->canAuthenticateUser->passes($object);
|
||||
|
||||
$this->authenticatesUser->execute($object);
|
||||
|
||||
$user = $this->fetchesUser->execute(['email' => $object->getEmail()]);
|
||||
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $request->route('exchange_company_id'));
|
||||
|
||||
return ['shipping_company_module_id' => $companyModule->id];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -20,7 +20,7 @@ class AssignsCompanyConnectionToConnectionSegment extends AbstractUpdateRecord
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->attach($segment);
|
||||
$companyConnection->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
||||
|
||||
return $companyConnection;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class AssignsCompanyToSegment extends AbstractUpdateRecord
|
||||
try {
|
||||
$companyModule = $company->companyModules()->where('type', BusinessType::IMPORTER)->first();
|
||||
$connection = $companyModule->connections()->where('inviter_reference', 'CIEF');
|
||||
$connection->segments()->attach($segment);
|
||||
$connection->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
||||
|
||||
return $company;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class AssignsEmployee extends AbstractUpdateRecord
|
||||
{
|
||||
try {
|
||||
|
||||
$object->getCompanyModule()->employees()->attach($object->getUser(), ['status' => $object->getStatus(),'role_id' => $object->getRoleId()]);
|
||||
$object->getCompanyModule()->employees()->attach($object->getUser(), ['status' => $object->getStatus(), 'role_id' => $object->getRoleId(), 'created_at' => now(), 'updated_at' => now()]);
|
||||
|
||||
return $object->getCompanyModule();
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
|
||||
class ConnectCompanyModuleToExchangeCompany extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Company $company
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $companyModule, $exchangeCompanyId)
|
||||
{
|
||||
$model = new ExchangeCompanyConnection();
|
||||
$model->company_module_id = $companyModule->id;
|
||||
$model->exchange_company_id = $exchangeCompanyId;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Transformers\ContactTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -63,6 +64,13 @@ class UpdateContactLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContact->execute($query, $object);
|
||||
|
||||
/*uniformity*/
|
||||
/* return fractal()
|
||||
->item($query, new ContactTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new ContactResource($query));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Order;
|
||||
use App\Transformers\DeliveryOrderTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -52,6 +53,14 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$order = $this->cancelsOrder->execute($order);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||
|
||||
}
|
||||
|
||||
@@ -172,6 +172,12 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||
$this->createsPackage->execute($packageObject, $packingList);
|
||||
|
||||
//add relationship to order
|
||||
/* return fractal()
|
||||
->item($order, new DeliveryOrderTransformer())
|
||||
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new DeliveryOrderTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,13 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use League\Fractal;
|
||||
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -58,6 +62,11 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
/* return fractal()
|
||||
->collection($query, new DocumentTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Documents\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApprovesDocument extends AbstractUpdateRecord
|
||||
@@ -17,8 +18,19 @@ class ApprovesDocument extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
// if auth user is null, then this services is calling from exchange
|
||||
if (!$user) {
|
||||
$token = explode('.', request()->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$user = User::where('email', $exchangeUser['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::find(1);
|
||||
}
|
||||
}
|
||||
$model->status = ApprovalStatus::APPROVED;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approver = $user->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
@@ -5,7 +5,10 @@ namespace App\Classes\Modules\Documents\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RejectsDocument extends AbstractUpdateRecord
|
||||
{
|
||||
@@ -17,8 +20,19 @@ class RejectsDocument extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
// if auth user is null, then this services is calling from exchange
|
||||
if (!$user) {
|
||||
$token = explode('.', request()->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$user = User::where('email', $exchangeUser['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::find(1);
|
||||
}
|
||||
}
|
||||
$model->status = ApprovalStatus::REJECTED;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approver = $user->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
@@ -24,8 +24,8 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
{
|
||||
$this->filters = [
|
||||
"has_invoice_status_in" => [2],
|
||||
"packing_list_ordered_by_invoice_date" => true,
|
||||
"with_aging_column" => true
|
||||
// "packing_list_ordered_by_invoice_date" => true,
|
||||
// "with_aging_column" => true
|
||||
];
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
'Invoice Date',
|
||||
'Days',
|
||||
'Amount',
|
||||
'Credit Term Customer',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,9 +56,16 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
$invDate = 'n/a';
|
||||
$invNo = 'n/a';
|
||||
$days = 'n/a';
|
||||
$isCreditTermCustomer = false;
|
||||
|
||||
if ($list->owner instanceof Order) {
|
||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
$companyModule = $list->owner->companyModule;
|
||||
|
||||
$segment = $companyModule->connections()->first()->segments()->where('name', 'Credit Term Customer')->first();
|
||||
if ($segment) {
|
||||
$isCreditTermCustomer = true;
|
||||
}
|
||||
|
||||
if ($inviterPivotInviteeReference) {
|
||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
||||
@@ -87,6 +95,7 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
$invDate,
|
||||
$days,
|
||||
$amt,
|
||||
$isCreditTermCustomer ? 'TRUE' : 'FALSE',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsGroupTransactions implements
|
||||
FromQuery,
|
||||
WithHeadings,
|
||||
WithHeadingRow,
|
||||
WithMapping,
|
||||
ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'PaymentDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
'AccNo',
|
||||
'DetailDescription',
|
||||
'FurtherDescription',
|
||||
'ProjNo',
|
||||
'DeptNo',
|
||||
'Qty',
|
||||
'UnitPrice',
|
||||
'TaxType',
|
||||
'TaxableAmt',
|
||||
'TaxRate'
|
||||
];
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
$start_date = $this->parseDate($this->request->input('startDate'));
|
||||
$end_date = $this->parseDate($this->request->input('endDate'));
|
||||
|
||||
return Group::when($start_date && $end_date, function ($query) use ($start_date, $end_date) {
|
||||
$query->whereBetween('created_at', [
|
||||
$start_date->startOfDay(),
|
||||
$end_date->endOfDay()
|
||||
]);
|
||||
})
|
||||
->when($start_date && !$end_date, function ($query) use ($start_date) {
|
||||
$query->where('created_at', '>=', $start_date->startOfDay());
|
||||
})
|
||||
->when(!$start_date && $end_date, function ($query) use ($end_date) {
|
||||
$query->where('created_at', '<=', $end_date->endOfDay());
|
||||
});
|
||||
}
|
||||
|
||||
private function parseDate($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->startOfDay() : null;
|
||||
}
|
||||
|
||||
public function map($transaction): array
|
||||
{
|
||||
$company = $transaction->receiverCompany;
|
||||
return [
|
||||
'<<New>>', //'DocNo',
|
||||
'', //'DocDate',
|
||||
$transaction->created_at->format('m/d/Y H:m'), //'PaymentDate',
|
||||
$company->debtor, //'DebtorCode',
|
||||
$company->referece, //'Ref',
|
||||
$company->referece, //'ShipInfo',
|
||||
'500-0000', //'AccNo',
|
||||
'X1 Freight Service Charge', //'DetailDescription',
|
||||
'FurtherDescription', //'FurtherDescription',
|
||||
'M3', //'ProjNo',
|
||||
'CIEF', //'DeptNo',
|
||||
'', //'Qty',
|
||||
'', //'UnitPrice',
|
||||
'', //'TaxType',
|
||||
floatval($transaction->tax) > 0 ? number_format($transaction->tax, 2) : '0.00', //'TaxableAmt',
|
||||
'', //'TaxRate'
|
||||
];
|
||||
}
|
||||
|
||||
private function getTaxType($tax_percentage)
|
||||
{
|
||||
return floatval($tax_percentage) > 0 ? 'SV-6' : '';
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
return [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'PaymentDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
@@ -41,6 +42,9 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
'DeptNo',
|
||||
'Qty',
|
||||
'UnitPrice',
|
||||
'TaxType',
|
||||
'TaxableAmt',
|
||||
'TaxRate',
|
||||
// 'marking',
|
||||
// 'contact person',
|
||||
// 'contact number',
|
||||
@@ -56,12 +60,12 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
{
|
||||
$start_date = $this->request->input('startDate', null);
|
||||
if ($start_date) {
|
||||
$start_date = Carbon::parse($this->request->input('startDate'))->format('Y-m-d');
|
||||
$start_date = Carbon::parse($start_date)->startOfDay();
|
||||
}
|
||||
|
||||
$end_date = $this->request->input('endDate', null);
|
||||
if ($end_date) {
|
||||
$end_date = Carbon::parse($this->request->input('endDate'))->format('Y-m-d');
|
||||
$end_date = Carbon::parse($end_date)->endOfDay();
|
||||
}
|
||||
|
||||
$query = Transaction::query();
|
||||
@@ -74,30 +78,31 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
// $query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [$approvalStatus]);
|
||||
$query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->whereIn('status', [$approvalStatus]);
|
||||
// Adjusted the query to include both types and status
|
||||
$query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])
|
||||
->where('status', $approvalStatus);
|
||||
|
||||
if($start_date && $end_date) {
|
||||
$query->whereBetween('updated_at', [
|
||||
Carbon::parse($start_date)->format('Y-m-d 0:00:00'),
|
||||
Carbon::parse($end_date)->format('Y-m-d 23:59:59')
|
||||
]);
|
||||
}
|
||||
elseif($start_date && !$end_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($start_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00'));
|
||||
if ($start_date && $end_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($start_date, $end_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)
|
||||
->whereBetween('updated_at', [$start_date, $end_date]);
|
||||
});
|
||||
|
||||
}
|
||||
elseif(!$start_date && $end_date) {
|
||||
} elseif ($start_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($start_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)
|
||||
->where('updated_at', '>=', $start_date);
|
||||
});
|
||||
} elseif ($end_date) {
|
||||
$query->whereHas('transactions', function($transaction) use ($end_date) {
|
||||
$transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($end_date)->format('Y-m-d 0:00:00'));
|
||||
$transaction->where('type', TransactionType::PAYMENT)
|
||||
->where('updated_at', '<=', $end_date);
|
||||
});
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function map($transaction): array
|
||||
{
|
||||
$container = $transaction->owner->containers()->first();
|
||||
@@ -130,9 +135,41 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$furtherDescription .= $item->name.' '.$item->quantity.' X '.$item->price."\n";
|
||||
}
|
||||
|
||||
$transactionDetails = $transaction->transactionDetails;
|
||||
|
||||
$firstItem = true;
|
||||
$rows = [];
|
||||
foreach ($transactionDetails as $detail) {
|
||||
// Prepare each row based on the transaction detail
|
||||
$rows[] = [
|
||||
$firstItem ? '<<New>>' : '',
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$transaction->transactions()->where('type', TransactionType::PAYMENT)->first()->updated_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
$order->reference,
|
||||
'500-0000',
|
||||
str_replace('<br>', ' ', $detail->name),
|
||||
'',
|
||||
$container->reference,
|
||||
'CIEF',
|
||||
$detail->quantity,
|
||||
$detail->price,
|
||||
floatval($detail->tax_percentage) > 0 ? 'SV-6' : '',
|
||||
floatval($detail->tax_percentage) > 0 ? number_format($detail->amount, 2) : '0.00',
|
||||
$detail->tax_percentage,
|
||||
];
|
||||
|
||||
if($firstItem) {
|
||||
$firstItem = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
||||
return [
|
||||
'<<New>>',
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$transaction->transactions()->where('type', TransactionType::PAYMENT)->first()->updated_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
$order->reference,
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -32,10 +31,8 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -39,6 +40,12 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,25 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\ConnectOrderToExchangeBookingOnExchangeProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\ConnectOrderToExchangeBooking;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Models\Address;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -41,8 +52,25 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
/** @var ConnectOrderToExchangeBooking */
|
||||
private $connectOrderToExchangeBooking;
|
||||
|
||||
/** @var ConnectOrderToExchangeBookingOnExchangeProcessor */
|
||||
private $connectOrderToExchangeBookingOnExchangeProcessor;
|
||||
|
||||
/** @var CreatesKeyValuePair */
|
||||
private $createsKeyValuePair;
|
||||
|
||||
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -51,8 +79,10 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
* @param ConnectOrderToExchangeBooking $connectOrderToExchangeBooking
|
||||
* @param ConnectOrderToExchangeBookingOnExchangeProcessor $connectOrderToExchangeBookingOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor, ConnectOrderToExchangeBooking $connectOrderToExchangeBooking, ConnectOrderToExchangeBookingOnExchangeProcessor $connectOrderToExchangeBookingOnExchangeProcessor, CreatesKeyValuePair $createsKeyValuePair)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
@@ -60,12 +90,18 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
$this->connectOrderToExchangeBooking = $connectOrderToExchangeBooking;
|
||||
$this->connectOrderToExchangeBookingOnExchangeProcessor = $connectOrderToExchangeBookingOnExchangeProcessor;
|
||||
$this->createsKeyValuePair = $createsKeyValuePair;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$isTermsAgreed = $request->input('is_terms_agree');
|
||||
if(!$isTermsAgreed){
|
||||
throw new RequestValidationException('You must read and agree to our terms and conditions to proceed');
|
||||
}
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
@@ -91,12 +127,32 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
|
||||
}
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
$keyValuePairObject = new KeyValuePairObject(
|
||||
"TERMS_AND_CONDITIONS",
|
||||
$isTermsAgreed
|
||||
);
|
||||
$this->createsKeyValuePair->execute($order, $keyValuePairObject);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->newLeadTaskToPerfexCRMProcessor->execute($company);
|
||||
}
|
||||
|
||||
$token = explode('.', $request->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$exchangeBookingId = null;
|
||||
if (isset($exchangeUser['exchange_booking_id']) && $exchangeUser['exchange_booking_id']) {
|
||||
$exchangeBookingId = $exchangeUser['exchange_booking_id'];
|
||||
}
|
||||
|
||||
if ($exchangeBookingId) {
|
||||
$this->connectOrderToExchangeBooking->execute($order, $exchangeBookingId);
|
||||
$this->connectOrderToExchangeBookingOnExchangeProcessor->execute($request, $order->id, $exchangeBookingId);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ConnectOrderToExchangeBookingOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $orderId, $exchangeBookingId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/order/{$orderId}/booking/{$exchangeBookingId}/connect";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/order/{$orderId}/booking/{$exchangeBookingId}/connect";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/order/{$orderId}/booking/{$exchangeBookingId}/connect";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('POST', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class CreateOrderProcessor
|
||||
* @param CompanyModule $originWarehouse
|
||||
* @param Address $address
|
||||
* @param int|null $orderNumber
|
||||
* @return Addressable
|
||||
* @return Order
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\ExchangeBookingOrder;
|
||||
use App\Models\Order;
|
||||
|
||||
class ConnectOrderToExchangeBooking extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Order $order
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Order $order, $exchangeBookingId)
|
||||
{
|
||||
$model = new ExchangeBookingOrder();
|
||||
$model->order_id = $order->id;
|
||||
$model->exchange_booking_id = $exchangeBookingId;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -53,9 +54,16 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
|
||||
foreach ($packing_list as $key => $row) {
|
||||
$packing_list_item = $this->fetchesPackingList->execute(['id' => $row]);
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
$container->packingLists()->attach($packing_list_item, ['created_at' => now(), 'updated_at' => now()]);
|
||||
}
|
||||
|
||||
//only return with packing list relationship
|
||||
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseInclude(['packingLists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +20,8 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -51,10 +53,16 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -70,6 +71,11 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -18,7 +19,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
@@ -50,7 +52,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -59,6 +61,12 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
//load with remarks only
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['remarks'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
}
|
||||
|
||||
+25
-17
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -28,7 +29,8 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
@@ -41,7 +43,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
@@ -54,12 +56,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
@@ -77,11 +79,11 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -92,21 +94,27 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//include transport
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['transport'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Container',
|
||||
'message' => 'You have successfully retrieved a Container'
|
||||
@@ -48,12 +50,18 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
//load with packing lists
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->parseIncludes(['packing_lists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -9,6 +9,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +20,8 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -52,11 +54,16 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
//no relations required
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+16
-5
@@ -3,10 +3,14 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +21,8 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -45,16 +50,22 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
//load with no filters, a details page to be added to load one with all related data
|
||||
/* return fractal()
|
||||
->collection($query, new ContainerTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+15
-19
@@ -10,6 +10,7 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,7 +21,8 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
@@ -54,29 +56,23 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
$old_sechedule = $transport->schedules()->first();
|
||||
$old_schedule = $transport->schedules()->delete();
|
||||
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
// $this->updatesScheduleStatus->execute($old_schedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-10
@@ -3,12 +3,16 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,7 +23,8 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -52,19 +57,19 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
@@ -74,6 +79,12 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContainer->execute($container, $object);
|
||||
|
||||
//no relationships
|
||||
/*
|
||||
return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
@@ -49,11 +51,18 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
|
||||
|
||||
//no relationships queried
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,7 +18,8 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
@@ -49,11 +51,17 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+13
-5
@@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use App\Transformers\DeliverPackingListTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -24,7 +25,8 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
@@ -60,7 +62,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
@@ -68,9 +70,9 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
@@ -82,6 +84,12 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
//no relationships required
|
||||
/* return fractal()
|
||||
->item($deliverPackingList, new DeliverPackingListTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ class FetchContainersFromYdPortalProcessor
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
@@ -143,7 +143,7 @@ class FetchContainersFromYdPortalProcessor
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::LOAD_CONTAINER);
|
||||
|
||||
+2
-1
@@ -76,6 +76,7 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||
|
||||
Log::info('Delivery tracking sTrackingNo: '. $packingList->reference);
|
||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$packingList->reference.'&sOrgId=sti', ['timeout' => 3]);
|
||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||
@@ -119,7 +120,7 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor ends');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
}
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
$packingList->packages()->delete();
|
||||
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
$container->packingLists()->attach($packingList, ['created_at' => now(), 'updated_at' => now()]);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if (!$allow_contract) {
|
||||
|
||||
+10
-1
@@ -129,16 +129,25 @@ class FetchPackingListsFromYdPortalProcessor
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
|
||||
dump('Row Count: ' . count($rows->data));
|
||||
|
||||
if(!$rows->data) continue;
|
||||
|
||||
foreach($rows->data as $row){
|
||||
dump($row);
|
||||
if(!is_numeric($row->goodcount)) continue;
|
||||
|
||||
$time_start = microtime(true);
|
||||
|
||||
$receiveDate = Carbon::parse(substr(preg_replace("/[^0-9]/", "", $row->expressno), 0, 8));
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
$customerno = $row->customerno;
|
||||
// Check if $customerno contains '正确唛头YD' and extract the part after it
|
||||
if (strpos($customerno, '正确唛头YD') !== false) {
|
||||
$customerno = explode('正确唛头YD', $customerno)[1];
|
||||
}
|
||||
|
||||
$customerno = preg_split('/[-()\/]/', $customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
@@ -13,10 +13,14 @@ class RemarkObject implements DataTransferObject
|
||||
/** @var string*/
|
||||
private $content;
|
||||
|
||||
public function __construct(string $content, int $commenterID)
|
||||
/** @var int|null */
|
||||
private $type;
|
||||
|
||||
public function __construct(string $content, int $commenterID, int $type = null)
|
||||
{
|
||||
$this->commenterID = $commenterID;
|
||||
$this->content = $content;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,4 +39,12 @@ class RemarkObject implements DataTransferObject
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getType(): ?int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class CreatesRemark extends AbstractUpdateRelationshipRecord
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($remarkable->remarks(), $model);
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\Document;
|
||||
|
||||
class CreateCombinedInvoicesLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Shipping Invoice Status',
|
||||
'message' => 'You have successfully updated multiple shipping invoices status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$items = $request->input('ids');
|
||||
$invoice_transactions=array();
|
||||
foreach($items as $item){
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $item['id']]);
|
||||
|
||||
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
array_push($invoice_transactions, $invoice_transaction);
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $invoice_transactions]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
$user = $packing_list->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ use App\Models\GroupTransaction;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -200,7 +200,9 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
|
||||
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
||||
// create only one billplz payment for wallet top up
|
||||
$amount = floatval(str_replace(',', '', $reqAmount));
|
||||
$amount2 = floatval(str_replace(',', '', $reqAmount));
|
||||
Log::channel('storage_invoices')->info('CreateGroupsLogic reqAmount from client: ' .$amount2);
|
||||
Log::channel('storage_invoices')->info('CreateGroupsLogic amount from backend: ' .$amount); //the real amount should always be from backend
|
||||
$companyModuleId = $invoice->receiver;
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -22,7 +23,8 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved Groups',
|
||||
'message' => 'You have successfully retrieved a list of groups'
|
||||
@@ -32,10 +34,15 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/** @var ListsGroups */
|
||||
private $listsGroups;
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$query = $this->listsGroups->execute($this->listsGroups->deserializeFilters($request->input('filters')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(GroupResource::collection($query));
|
||||
}
|
||||
|
||||
|
||||
+15
-7
@@ -15,6 +15,7 @@ use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -51,11 +52,18 @@ class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
foreach ($orders as $order){
|
||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||
|
||||
|
||||
$view = 'pages.pdfs.shipping_invoice';
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice->created_at);
|
||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice->tax > 0) {
|
||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
@@ -63,11 +71,11 @@ class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
|
||||
$document =$this->createsDocument->execute($invoice, $document_object);
|
||||
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
|
||||
|
||||
// dump($document);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -16,6 +16,7 @@ use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class RegenerateSingleShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -54,7 +55,14 @@ class RegenerateSingleShippingInvoiceTransactionLogic extends AbstractController
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||
$view = 'pages.pdfs.shipping_invoice';
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice->created_at);
|
||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice->tax > 0) {
|
||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
|
||||
@@ -32,7 +32,8 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Group Transaction',
|
||||
'message' => 'You have successfully updated this Group Transaction'
|
||||
@@ -86,7 +87,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -100,7 +101,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
|
||||
|
||||
|
||||
foreach($transactions as $transaction) {
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
|
||||
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
||||
@@ -169,7 +170,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($pdf->output()))],
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'currency_vendor_order'
|
||||
@@ -179,6 +180,11 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
$document = $this->createsDocument->execute($group, $object);
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
|
||||
+28
-12
@@ -25,6 +25,8 @@ use App\Classes\Modules\Transactions\Services\DeletesTransactionDetails;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -60,9 +62,9 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
/** @var DeletesTransactionDetails */
|
||||
private $deletesTransactionDetails;
|
||||
|
||||
|
||||
public function __construct(
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
UpdatesTransaction $updatesTransaction,
|
||||
FetchesTransactionDetail $fetchesTransactionDetail,
|
||||
@@ -105,11 +107,25 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$transaction_detail = (object) $transaction_detail;
|
||||
|
||||
if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])){
|
||||
$reference = 'CUSTOM_CHARGES';
|
||||
$taxPercentage = TaxPercentage::DEFAULT;
|
||||
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare)) {
|
||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
||||
}
|
||||
|
||||
if($transaction_detail->reference === "PAY_ON_BEHALF"){
|
||||
$reference = "PAY_ON_BEHALF";
|
||||
$taxPercentage = TaxPercentage::NO_TAX;
|
||||
}
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'CUSTOM_CHARGES',
|
||||
$reference,
|
||||
isset($transaction_detail->name) ? $transaction_detail->name : TransactionDetailType::CUSTOM_CHARGES,
|
||||
$transaction_detail->quantity,
|
||||
$transaction_detail->price
|
||||
$transaction_detail->price,
|
||||
$taxPercentage
|
||||
);
|
||||
|
||||
if(isset($transaction_detail->id)){
|
||||
@@ -121,20 +137,20 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$invoice_transaction->bill_no,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
1,
|
||||
$invoice_transaction->bill_no,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
1,
|
||||
$invoice_transaction->issuer,
|
||||
1,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$invoice_transaction->transactionDetails()->sum('amount'),
|
||||
$invoice_transaction->transactionDetails()->sum('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
null,
|
||||
$invoice_transaction->transactionDetails()->sum('tax_amount'),
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_VERIFICATION
|
||||
);
|
||||
|
||||
|
||||
@@ -18,19 +18,25 @@ class TransactionDetailObject implements DataTransferObject
|
||||
/** @var float|null */
|
||||
private $price;
|
||||
|
||||
/** @var float|null */
|
||||
private $taxPercentage;
|
||||
|
||||
|
||||
/**
|
||||
* TransactionDetailObject constructor.
|
||||
* @param string $reference
|
||||
* @param string $name
|
||||
* @param float $quantity
|
||||
* @param float $price
|
||||
* @param float $taxPercentage
|
||||
*/
|
||||
public function __construct(?string $reference, ?string $name , ?float $quantity, ?float $price)
|
||||
public function __construct(?string $reference, ?string $name , ?float $quantity, ?float $price, ?float $taxPercentage)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->name = $name;
|
||||
$this->quantity = $quantity;
|
||||
$this->price = $price;
|
||||
$this->taxPercentage = $taxPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,9 +71,28 @@ class TransactionDetailObject implements DataTransferObject
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->getQuantity() * $this->getPrice();
|
||||
return ($this->getQuantity() * $this->getPrice()) + $this->getTaxAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTaxPercentage(): ?float
|
||||
{
|
||||
return $this->taxPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTaxAmount(): float
|
||||
{
|
||||
return ($this->getQuantity() * $this->getPrice()) * $this->getTaxPercentage() / 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,21 +80,21 @@ class TransactionObject implements DataTransferObject
|
||||
* @param array|null $details
|
||||
*/
|
||||
public function __construct(
|
||||
string $billNo,
|
||||
string $transactionType,
|
||||
int $issuer,
|
||||
int $receiver,
|
||||
int $recipientBankAccountId,
|
||||
int $paymentMethod,
|
||||
float $amount,
|
||||
float $originalAmount,
|
||||
string $billNo,
|
||||
string $transactionType,
|
||||
int $issuer,
|
||||
int $receiver,
|
||||
int $recipientBankAccountId,
|
||||
int $paymentMethod,
|
||||
float $amount,
|
||||
float $originalAmount,
|
||||
int $currencyId,
|
||||
int $originalCurrencyId,
|
||||
int $originalCurrencyId,
|
||||
float $currencyRate,
|
||||
float $tax,
|
||||
float $serviceCharge,
|
||||
?Carbon $expiresOn,
|
||||
?int $status = ApprovalStatus::PENDING_SUBMISSION,
|
||||
float $tax,
|
||||
float $serviceCharge,
|
||||
?Carbon $expiresOn,
|
||||
?int $status = ApprovalStatus::PENDING_SUBMISSION,
|
||||
?array $details = [],
|
||||
?string $paymentReference = null
|
||||
)
|
||||
@@ -241,10 +241,10 @@ class TransactionObject implements DataTransferObject
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDetails(): array
|
||||
public function getDetails(): array //cief todo: not in used as of 20240407
|
||||
{
|
||||
return array_map(function($product){
|
||||
return new TransactionDetailObject($product['stockCode'] ?? '', $product['description'] ?? '', $product['quantity'] ?? '', floatval(str_replace(',', '', $product['unit_price'])));
|
||||
return new TransactionDetailObject($product['stockCode'] ?? '', $product['description'] ?? '', $product['quantity'] ?? '', floatval(str_replace(',', '', $product['unit_price'])), 0.0 );
|
||||
}, $this->details);
|
||||
}
|
||||
|
||||
@@ -255,4 +255,4 @@ class TransactionObject implements DataTransferObject
|
||||
{
|
||||
return $this->paymentReference;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -19,6 +19,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApproveShippingInvoiceTransactionProcessor
|
||||
{
|
||||
@@ -59,9 +60,16 @@ class ApproveShippingInvoiceTransactionProcessor
|
||||
/** @var Transaction $invoice_transaction */
|
||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
|
||||
$view = 'pages.pdfs.shipping_invoice';
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice_transaction->tax > 0) {
|
||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
||||
}
|
||||
|
||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
|
||||
+68
-25
@@ -4,6 +4,7 @@
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\Filters\PaymentMethodType as FiltersPaymentMethodType;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
@@ -23,6 +24,7 @@ use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
use App\Http\Resources\TransactionWithStorageResource;
|
||||
use App\Models\Order;
|
||||
@@ -122,7 +124,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta);
|
||||
}
|
||||
else{
|
||||
$result = $this->isPaidOrWaivedStorageInvoiceExist($invoice_transaction, $packingList, $eta);
|
||||
$result = $this->isExistPaidOrWaivedStorageInvoice($invoice_transaction, $packingList, $eta);
|
||||
}
|
||||
if($result){
|
||||
$results[] = $result;
|
||||
@@ -163,6 +165,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
if ($transport) {
|
||||
$schedule = $transport->schedules->last();
|
||||
if ($schedule) {
|
||||
Log::channel('storage_invoices')->info('schedule: '.json_encode($schedule));
|
||||
return $schedule->eta;
|
||||
}
|
||||
}
|
||||
@@ -176,11 +179,14 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$pricePerCBM = 3;
|
||||
$resultNumberOfDaysFree = 10;
|
||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
||||
$resultStartDate = $dt1->format('Y-m-d');
|
||||
$currentDatetime = Carbon::now();
|
||||
$dt2 = $currentDatetime->copy()->addDay()->startOfDay();
|
||||
$resultCurrentDate = $dt2->format('Y-m-d H:i:s');
|
||||
$dt2 = Carbon::now()->copy()->addDay()->startOfDay();
|
||||
$interval = Carbon::parse($dt2)->diff($dt1);
|
||||
Log::channel('storage_invoices')->info('eta: '.json_encode($eta));
|
||||
Log::channel('storage_invoices')->info('dt1: '.json_encode($dt1));
|
||||
Log::channel('storage_invoices')->info('dt2: '.json_encode($dt2));
|
||||
Log::channel('storage_invoices')->info('interval: '.json_encode($interval));
|
||||
Log::channel('storage_invoices')->info('Carbon now: '.json_encode(Carbon::now()));
|
||||
|
||||
|
||||
$resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree;
|
||||
$storageInvoice = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->first();
|
||||
@@ -195,14 +201,26 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$cbm = $cbm + $quantity;
|
||||
}
|
||||
|
||||
$total_tax = 0;
|
||||
$taxPercentage = TaxPercentage::DEFAULT;
|
||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
||||
Log::channel('storage_invoices')->info('storageInvoice: '.json_encode($storageInvoice).', $transaction->status: '.$transaction->status);
|
||||
if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status != ApprovalStatus::COMPLETED){
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
|
||||
|
||||
Log::channel('storage_invoices')->info('dateToCompare: '.json_encode($dateToCompare));
|
||||
if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status !== ApprovalStatus::COMPLETED){
|
||||
Log::channel('storage_invoices')->info('Created $transaction->id: '.$transaction->id);
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('STOR-');
|
||||
$storageInvoice = $this->createStorageInvoiceTransaction($destinationWarehousePackage, $billNumber, $company_module_id, $price_cbm);
|
||||
|
||||
if (Carbon::now()->isAfter($dateToCompare)) {
|
||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
||||
$total_tax = $price_cbm * $taxPercentage / 100;
|
||||
$price_cbm = $price_cbm + $total_tax;
|
||||
}
|
||||
|
||||
$storageInvoice = $this->createStorageInvoiceTransaction($destinationWarehousePackage, $billNumber, $company_module_id, $price_cbm, $total_tax);
|
||||
$storageInvoiceId = $storageInvoice->id;
|
||||
$this->createStorageInvoiceTransactionDetails($storageInvoice, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded);
|
||||
$this->createStorageInvoiceTransactionDetails($storageInvoice, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded, $taxPercentage);
|
||||
}
|
||||
else if($storageInvoice){
|
||||
//Additional handling for giving selected storage invoice a waiver
|
||||
@@ -215,12 +233,18 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$paymentStorageTransaction = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::APPROVED)->first();
|
||||
if($paymentStorageTransaction){
|
||||
$dateStorageInvoicePaid = $paymentStorageTransaction->created_at->copy()->addDay()->startOfDay();
|
||||
Log::channel('storage_invoices')->info('dateStorageInvoicePaid: '.$dateStorageInvoicePaid.', resultCurrentDate: '.$resultCurrentDate);
|
||||
Log::channel('storage_invoices')->info('dateStorageInvoicePaid: '.$dateStorageInvoicePaid.', resultCurrentDate: '.$dt2->format('Y-m-d H:i:s'));
|
||||
$intervalRecalculate = Carbon::parse($dateStorageInvoicePaid)->diff($dt1);
|
||||
$resultNumberOfDaysExceeded = $intervalRecalculate->days - $resultNumberOfDaysFree;
|
||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
||||
}
|
||||
|
||||
if (Carbon::now()->isAfter($dateToCompare)) {
|
||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
||||
$total_tax = $price_cbm * $taxPercentage / 100;
|
||||
$price_cbm = $price_cbm + $total_tax;
|
||||
}
|
||||
|
||||
$amount = $storageInvoice->amount;
|
||||
$epsilon = 0.0001; // Tolerance for the comparison
|
||||
Log::channel('storage_invoices')->info('Update $transaction->id: '.$transaction->id);
|
||||
@@ -230,7 +254,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
|
||||
$proceedToUpdate = false;
|
||||
|
||||
if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED){
|
||||
if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED && !$this->isExistPendingVerificationManualPayment($storageInvoice)){
|
||||
$paymentTransactions = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
||||
// if(!$isBackDoorCheck){
|
||||
if(count($paymentTransactions) > 0){
|
||||
@@ -246,9 +270,10 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
|
||||
if($proceedToUpdate || ($pricePerCBM == 0 && $amount != 0)){
|
||||
Log::channel('storage_invoices')->info('proceedToUpdate');
|
||||
$storageInvoice = $this->updateStorageInvoiceTransaction($storageInvoice, $price_cbm);
|
||||
|
||||
$storageInvoice = $this->updateStorageInvoiceTransaction($storageInvoice, $price_cbm, $total_tax);
|
||||
$invoiceTransactionDetails = $storageInvoice->transactionDetails()->first();
|
||||
$this->updateStorageInvoiceTransactionDetails($invoiceTransactionDetails, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded);
|
||||
$this->updateStorageInvoiceTransactionDetails($invoiceTransactionDetails, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded, $taxPercentage);
|
||||
}
|
||||
|
||||
$storageInvoiceId = $storageInvoice->id;
|
||||
@@ -260,8 +285,8 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
'storageInvoiceId' => $storageInvoiceId,
|
||||
'numberOfDaysExceeded' => $resultNumberOfDaysExceeded,
|
||||
'numberOfDaysFree' => $resultNumberOfDaysFree,
|
||||
'startDate' => $resultStartDate,
|
||||
'currentDate' => $resultCurrentDate,
|
||||
'startDate' => $dt1->format('Y-m-d'),
|
||||
'currentDate' => $dt2->format('Y-m-d H:i:s'),
|
||||
'cbm' => $cbm,
|
||||
'pricePerCBM' => $pricePerCBM,
|
||||
'storageInvoice' => new TransactionWithStorageResource($storageInvoice)
|
||||
@@ -271,7 +296,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
|
||||
}
|
||||
|
||||
private function isPaidOrWaivedStorageInvoiceExist($transaction, $packingList, $eta){
|
||||
private function isExistPaidOrWaivedStorageInvoice($transaction, $packingList, $eta){
|
||||
$pricePerCBM = 3;
|
||||
$resultNumberOfDaysFree = 10;
|
||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
||||
@@ -326,6 +351,21 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
return [];
|
||||
}
|
||||
|
||||
private function isExistPendingVerificationManualPayment($storageInvoice){
|
||||
$g = $storageInvoice->groups()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])->where('payment_method', PaymentMethodType::CASH)->latest('updated_at')->first();
|
||||
Log::channel('storage_invoices')->info('group: ' .json_encode($g));
|
||||
if($g){
|
||||
$gr = $g->reference;
|
||||
$manualPaymentTransaction =Transaction::where('payment_reference', $gr)->first();
|
||||
Log::channel('storage_invoices')->info('manualPaymentTransaction: ' .json_encode($manualPaymentTransaction));
|
||||
if($manualPaymentTransaction->status === ApprovalStatus::PENDING_SUBMISSION || $manualPaymentTransaction->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
Log::channel('storage_invoices')->info('isExistPendingVerificationManualPayment');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function updatePaymentTransactionViaGroupPayment($storageInvoice){
|
||||
Log::channel('storage_invoices')->info('updatePaymentTransactionViaGroupPayment');
|
||||
$groups = $storageInvoice->groups()->whereNotIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])->get();
|
||||
@@ -339,7 +379,8 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
$this->updatesTransactionStatus->execute($walletTransaction, ApprovalStatus::EXPIRED);
|
||||
if($walletTransaction->payment_reference){
|
||||
$deletedBillplzBill = $this->deletesBillplzBill->execute($walletTransaction->payment_reference);
|
||||
Log::channel('storage_invoices')->info('deletedBillplzBill TransactionType::WALLET: '.json_encode($deletedBillplzBill));
|
||||
Log::channel('storage_invoices')->info('deletedBillplzBill with reference: '.$walletTransaction->payment_reference);
|
||||
Log::channel('storage_invoices')->info('deletedBillplzBill return response: '.json_encode($deletedBillplzBill));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,7 +397,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
}
|
||||
}
|
||||
|
||||
private function updateStorageInvoiceTransaction(Transaction $transaction, float $totalAmount){
|
||||
private function updateStorageInvoiceTransaction(Transaction $transaction, float $totalAmount, float $totalTax){
|
||||
|
||||
$object = new TransactionObject(
|
||||
$transaction->bill_no,
|
||||
@@ -370,7 +411,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
$totalTax,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -382,18 +423,19 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
return $invoice_transaction;
|
||||
}
|
||||
|
||||
private function updateStorageInvoiceTransactionDetails($invoice_transaction_details, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays){
|
||||
private function updateStorageInvoiceTransactionDetails($invoice_transaction_details, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays, $taxPercentage){
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'STORAGE_FEE',
|
||||
TransactionDetailType::STORAGE_FEE.' for '.$numberOfDays. ' days * RM'.$pricePerCBM.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||
$cbm,
|
||||
$pricePerCBM * $numberOfDays
|
||||
$pricePerCBM * $numberOfDays,
|
||||
$taxPercentage
|
||||
);
|
||||
|
||||
$this->updatesTransactionDetail->execute($invoice_transaction_details, $object_detail);
|
||||
}
|
||||
|
||||
private function createStorageInvoiceTransaction(PackingList $packing_list, string $billNumber, int $companyModuleId, float $totalAmount){
|
||||
private function createStorageInvoiceTransaction(PackingList $packing_list, string $billNumber, int $companyModuleId, float $totalAmount, float $totalTax){
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
@@ -407,7 +449,7 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
$totalTax,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -419,12 +461,13 @@ class CheckStorageInvoiceTransactionProcessor
|
||||
return $invoice_transaction;
|
||||
}
|
||||
|
||||
private function createStorageInvoiceTransactionDetails($invoice_transaction, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays){
|
||||
private function createStorageInvoiceTransactionDetails($invoice_transaction, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays, $taxPercentage){
|
||||
$object_detail = new TransactionDetailObject(
|
||||
'STORAGE_FEE',
|
||||
TransactionDetailType::STORAGE_FEE.' for '.$numberOfDays. ' days * RM'.$pricePerCBM.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||
$cbm,
|
||||
$pricePerCBM * $numberOfDays
|
||||
$pricePerCBM * $numberOfDays,
|
||||
$taxPercentage
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
|
||||
@@ -22,15 +22,19 @@ use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CreateInvoiceTransactionProcessor
|
||||
{
|
||||
@@ -71,6 +75,18 @@ class CreateInvoiceTransactionProcessor
|
||||
*/
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
$ori_packing_list = $packingList;
|
||||
// call wac webhook
|
||||
$hasInvoiceCreated = Transaction::withTrashed()
|
||||
->where('type', TransactionType::SHIPPING_INVOICE)
|
||||
->where('owner_type', PackingList::class)
|
||||
->where('owner_id', $ori_packing_list->id)
|
||||
->exists();
|
||||
|
||||
if ($hasInvoiceCreated) {
|
||||
Log::channel('wac_webhook')->info('Regenerating Invoice for PackingList: ' . $ori_packing_list->id . '. No call wac api.');
|
||||
}
|
||||
|
||||
$packing_list = PackingList::where('reference', $packingList->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
|
||||
|
||||
$billable_packing_list = $packing_list->packingLists()->first();
|
||||
@@ -93,6 +109,7 @@ class CreateInvoiceTransactionProcessor
|
||||
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
|
||||
$warehouse_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::WAREHOUSE_RATE]);
|
||||
$state_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::STATE_RATE]);
|
||||
Log::channel('priceCbmLog')->info(json_encode($state_rate_constant));
|
||||
$center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]);
|
||||
$outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]);
|
||||
|
||||
@@ -120,13 +137,18 @@ class CreateInvoiceTransactionProcessor
|
||||
$warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0;
|
||||
|
||||
$stateId = $address->state_id;
|
||||
Log::channel('priceCbmLog')->info('stateId: ' . $stateId);
|
||||
$state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId);
|
||||
Log::channel('priceCbmLog')->info('state_rate_constant: ' . json_encode($state_rate_constant));
|
||||
|
||||
// get $state_rate
|
||||
$postcode = $address->postcode;
|
||||
$this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ;
|
||||
Log::channel('priceCbmLog')->info('state_select: ' . $state_select);
|
||||
$this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ;
|
||||
Log::channel('priceCbmLog')->info('state_select: ' . $state_select);
|
||||
$state_rate_constant = (array)$state_rate_constant;
|
||||
Log::channel('priceCbmLog')->info('state_rate_constant: ' . json_encode($state_rate_constant));
|
||||
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
|
||||
|
||||
$container = $packing_list->containers()->first();
|
||||
@@ -165,12 +187,28 @@ class CreateInvoiceTransactionProcessor
|
||||
$minimum_charge = 0;
|
||||
}
|
||||
|
||||
Log::channel('priceCbmLog')->info('$base_price: ' . $base_price);
|
||||
Log::channel('priceCbmLog')->info('$segment_price: ' . $segment_price);
|
||||
Log::channel('priceCbmLog')->info('$warehouse_rate: ' . $warehouse_rate);
|
||||
Log::channel('priceCbmLog')->info('$state_rate: ' . $state_rate);
|
||||
$price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
|
||||
Log::channel('priceCbmLog')->info('$price_cbm: ' . $price_cbm);
|
||||
Log::channel('priceCbmLog')->info('');
|
||||
|
||||
$total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||
|
||||
$total_tax = 0;
|
||||
$taxPercentage = TaxPercentage::DEFAULT;
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
$shippingInvoiceTransactionCreatedDate = Carbon::now();
|
||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare)) {
|
||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
||||
$total_tax = $total_cbm * $taxPercentage / 100;
|
||||
$total_cbm = $total_cbm + $total_tax;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::SHIPPING_INVOICE,
|
||||
@@ -183,7 +221,7 @@ class CreateInvoiceTransactionProcessor
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
$total_tax,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
@@ -196,7 +234,8 @@ class CreateInvoiceTransactionProcessor
|
||||
'SHIPPING_FEE',
|
||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||
$cbm,
|
||||
$price_cbm
|
||||
$price_cbm,
|
||||
$taxPercentage
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
@@ -206,7 +245,8 @@ class CreateInvoiceTransactionProcessor
|
||||
'OVER_WEIGHT_CHARGES',
|
||||
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
||||
$over_weight_cbm,
|
||||
$price_cbm
|
||||
$price_cbm,
|
||||
$taxPercentage
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
@@ -217,11 +257,38 @@ class CreateInvoiceTransactionProcessor
|
||||
'MIN_CBM_CHARGES',
|
||||
TransactionDetailType::MIN_CBM_CHARGES,
|
||||
$minimum_charge,
|
||||
$price_cbm
|
||||
$price_cbm,
|
||||
$taxPercentage
|
||||
);
|
||||
|
||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||
}
|
||||
|
||||
if (app()->environment('production') && !$hasInvoiceCreated) {
|
||||
$order = $ori_packing_list->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$companyContact = $company->contacts()->first();
|
||||
$employee = $companyModule->employees()->first();
|
||||
|
||||
$invoiceCount = Transaction::where('type', TransactionType::SHIPPING_INVOICE)
|
||||
->where('receiver', $companyModule->id)
|
||||
->where('status', ApprovalStatus::APPROVED)
|
||||
->count();
|
||||
|
||||
$payload = [
|
||||
'name' => $employee->name,
|
||||
'email' => $employee->email,
|
||||
'phone' => $companyContact->phone,
|
||||
'order_reference' => $order->reference,
|
||||
'portal' => 'izyim',
|
||||
'invoice_count' => $invoiceCount,
|
||||
];
|
||||
|
||||
Log::channel('wac_webhook')->info('Attempt to send wac_webhook - Invoice Created: ' . json_encode($payload));
|
||||
$response = Http::post(config('wagWebhookUrl.invoice_created_url'), $payload);
|
||||
Log::channel('wac_webhook')->info('Invoice Created: ' . json_encode($response));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
//DATE: 20240616
|
||||
//THIS IS A ONE TIME FIX PROCESSOR MEANT TO FIX A GROUP PAYMENT THAT GOT STUCK: https://izyim.cief-malaysia.com/customer/943GCC/payment-and-billing
|
||||
//TRNASACTION WITH ID: 16803
|
||||
//GROUP WITH ID: 609
|
||||
|
||||
class CreatePaymentTransactionOneTimeFixProcessor
|
||||
{
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
/**
|
||||
* @param FetchesTransaction $fetchesTransaction,
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
* @param CreatesPaymentTransaction $createsPaymentTransaction
|
||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
||||
* @param CreatesBillplzBill $createsBillplzBil
|
||||
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $invoice, $payment_method, $bank_code, $date, $run = true)
|
||||
{
|
||||
$amount = $invoice->amount;
|
||||
Log::info($invoice->owner);
|
||||
$company_module = $invoice->owner->owner->companyModule()->first();
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $billNumber,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$bank_code,
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
|
||||
// if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
// throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
// }
|
||||
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
$transaction->created_at = $date;
|
||||
$transaction->updated_at = $date;
|
||||
$transaction->save();
|
||||
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
if($run)
|
||||
{
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
// later use this variabke to create a approved payment transaction
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
if($run){
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
|
||||
|
||||
return $payment_transaction;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
|
||||
class CreatePaymentTransactionProcessor
|
||||
{
|
||||
@@ -49,6 +50,9 @@ class CreatePaymentTransactionProcessor
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
/** @var CreditWalletProcessor */
|
||||
private $creditWalletProcessor ;
|
||||
|
||||
/**
|
||||
* @param FetchesTransaction $fetchesTransaction,
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
@@ -60,6 +64,7 @@ class CreatePaymentTransactionProcessor
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreditWalletProcessor $creditWalletProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
@@ -69,6 +74,7 @@ class CreatePaymentTransactionProcessor
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
CreditWalletProcessor $creditWalletProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
@@ -79,6 +85,7 @@ class CreatePaymentTransactionProcessor
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->creditWalletProcessor = $creditWalletProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
@@ -114,7 +121,7 @@ class CreatePaymentTransactionProcessor
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
if((float) number_format(($wallet->amount - $amount),2) < -0.01){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
@@ -174,6 +181,11 @@ class CreatePaymentTransactionProcessor
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
|
||||
|
||||
// cief coins
|
||||
if ($approvalStatus == ApprovalStatus::APPROVED) {
|
||||
$wallet = $this->creditWalletProcessor->execute($company_module, transactionType::CIEF_COINS_CREDIT, $amount, 'Cief Coins Credit', 3); // TODO-cief-coins: pls confirm the reference
|
||||
}
|
||||
|
||||
return $payment_transaction;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreateShippingCostTransactionProcessor
|
||||
@@ -57,7 +58,8 @@ class CreateShippingCostTransactionProcessor
|
||||
TransactionType::SHIPPING_COST,
|
||||
'Shipping Cost',
|
||||
$quantity,
|
||||
$totalShippingCost/$totalCBM
|
||||
$totalShippingCost/$totalCBM,
|
||||
TaxPercentage::SIX_PERCENT
|
||||
);
|
||||
|
||||
$shippingCostTransaction = $this->createsShippingCostTransaction->execute($order, $transactionObject, $transactionDetailObject);
|
||||
|
||||
+12
-2
@@ -16,6 +16,8 @@ use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateStorageInvoiceDocTransactionFixProcessor
|
||||
{
|
||||
@@ -51,9 +53,17 @@ class CreateStorageInvoiceDocTransactionFixProcessor
|
||||
/** @var Transaction $invoice_transaction */
|
||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED])->first();
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
$view = 'pages.pdfs.shipping_invoice';
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
Log::info('$dateToCompare 2: '.$dateToCompare);
|
||||
$storageInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
||||
Log::info('$storageInvoiceTransactionCreatedDate 2: '.$storageInvoiceTransactionCreatedDate);
|
||||
if ($storageInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice_transaction->tax > 0) {
|
||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::STORAGE_INVOICE,
|
||||
|
||||
+12
-1
@@ -16,6 +16,8 @@ use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateStorageInvoiceDocTransactionProcessor
|
||||
{
|
||||
@@ -53,7 +55,16 @@ class CreateStorageInvoiceDocTransactionProcessor
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||
$view = 'pages.pdfs.shipping_invoice';
|
||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
||||
Log::info('$dateToCompare: '.$dateToCompare);
|
||||
$storageInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
||||
Log::info('$storageInvoiceTransactionCreatedDate: '.$storageInvoiceTransactionCreatedDate);
|
||||
if ($storageInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice_transaction->tax > 0) {
|
||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::STORAGE_INVOICE,
|
||||
|
||||
@@ -44,24 +44,33 @@ class ReleaseGoodsToCustomerProcessor
|
||||
/**
|
||||
* @param $packingList
|
||||
* @param $invoice
|
||||
* @param $processCompletedInvoices
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($packingList, $invoice = null)
|
||||
public function execute($packingList, $invoice = null, $processCompletedInvoices = false)
|
||||
{
|
||||
$result = false;
|
||||
$totalInvoicesAmountPaid = 0.00;
|
||||
$totalInvoicesAmount = 0.00;
|
||||
$invoiceTransactions = $packingList->transactions()->where('status', [ApprovalStatus::APPROVED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
if($processCompletedInvoices){
|
||||
//processCompletedInvoices, for manual processing of invoices, e.g. incomplete payment gateway finish with storage invoice
|
||||
$invoiceTransactions = $packingList->transactions()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
}
|
||||
else{
|
||||
$invoiceTransactions = $packingList->transactions()->where('status', ApprovalStatus::APPROVED)->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
|
||||
}
|
||||
|
||||
//Part 1: Process each single invoice type and get the total of all invoices
|
||||
//Part 1: Process each single invoice type and get the total of all invoices (STORAGE + SHIPPING)
|
||||
foreach($invoiceTransactions as $invoiceTransaction){
|
||||
|
||||
$totalInvoiceAmountPaid = $invoiceTransaction->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
if ($invoice && $invoice->type == $invoiceTransaction->type) {
|
||||
if(($invoice->amount - $totalInvoiceAmountPaid) < 0.01){
|
||||
Log::channel('storage_invoices')->info('ReleaseGoodsToCustomerProcessor updatesTransactionStatus');
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
if($invoice->type == TransactionType::STORAGE_INVOICE){
|
||||
//cief todo: remove the following if block
|
||||
if($invoice->type === TransactionType::STORAGE_INVOICE){
|
||||
Log::channel('storage_invoices')->info('ReleaseGoodsToCustomerProcessor createStorageInvoiceDocTransactionProcessor');
|
||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ class CreatesShippingCostTransaction extends AbstractUpdateRelationshipRecord
|
||||
$model->quantity = $transactionDetailObject->getQuantity();
|
||||
$model->price = $transactionDetailObject->getPrice();
|
||||
$model->amount = $transactionDetailObject->getAmount();
|
||||
$model->tax_amount = $transactionDetailObject->getTaxAmount();
|
||||
$model->tax_percentage = $transactionDetailObject->getTaxPercentage();
|
||||
|
||||
return $this->handler($transaction->transactionDetails(), $model);
|
||||
|
||||
|
||||
@@ -35,11 +35,6 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord
|
||||
$model->expires_on = $object->getExpiresOn();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
if((int)$object->getTransactionType() === TransactionType::SHIPPING_INVOICE){
|
||||
$model->created_at = Carbon::now()->subDays(10);
|
||||
$model->updated_at = Carbon::now()->subDays(10);
|
||||
}
|
||||
|
||||
return $this->handler($packing_list->transactions(), $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ class CreatesTransactionDetail extends AbstractUpdateRelationshipRecord
|
||||
$model->quantity = $object->getQuantity();
|
||||
$model->price = $object->getPrice();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->tax_amount = $object->getTaxAmount();
|
||||
$model->tax_percentage = $object->getTaxPercentage();
|
||||
|
||||
return $this->handler($transaction->transactionDetails(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,10 @@ class UpdatesTransactionDetail extends AbstractUpdateRecord
|
||||
$transactionDetail->quantity = $object->getQuantity();
|
||||
$transactionDetail->price = $object->getPrice();
|
||||
$transactionDetail->amount = $object->getAmount();
|
||||
$transactionDetail->tax_amount = $object->getTaxAmount();
|
||||
$transactionDetail->tax_percentage = $object->getTaxPercentage();
|
||||
|
||||
return $this->handler($transactionDetail);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wac\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\HelpMenu\Standards\Rules\CanFetchHelpMenuQuestion;
|
||||
use App\Classes\Modules\HelpMenu\Processors\FetchFirstQuestionQAProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\HelpMenuQuestionResource;
|
||||
use App\Models\User;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class RegisterExchangeEmailLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Register Exchange Email',
|
||||
'message' => 'You have successfully registered an exchange email address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var CreatesUser */
|
||||
private $createsUser;
|
||||
|
||||
/**
|
||||
* RegisterEmailLogic constructor.
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
*/
|
||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, CreatesUser $createsUser)
|
||||
{
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->createsUser = $createsUser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
// Validate the request inputs
|
||||
$validator = Validator::make(
|
||||
$request->all(),
|
||||
[
|
||||
'izyim_email' => 'email|required',
|
||||
'exchange_email' => 'email|required',
|
||||
]
|
||||
);
|
||||
|
||||
if ($validator->fails()) {
|
||||
throw new RequestValidationException($validator->messages()->first());
|
||||
}
|
||||
|
||||
// Retrieve the validated emails from the request
|
||||
$izyimEmail = $request->input('izyim_email');
|
||||
$exchangeEmail = $request->input('exchange_email');
|
||||
|
||||
// Check if both emails are the same
|
||||
if ($izyimEmail === $exchangeEmail) {
|
||||
return response()->json([
|
||||
'message' => 'Both emails are the same.',
|
||||
'status' => 'ok',
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Check if the exchange email already exists in the system
|
||||
$existingUser = User::where('email', $exchangeEmail)->first();
|
||||
if ($existingUser) {
|
||||
return response()->json([
|
||||
'message' => 'The Exchange email already exists in the system.',
|
||||
'status' => 'error',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Retrieve the izyim user
|
||||
$izyimUser = User::where('email', $izyimEmail)->first();
|
||||
if (!$izyimUser) {
|
||||
return response()->json([
|
||||
'message' => 'The Izyim email not found in system.',
|
||||
'status' => 'error',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$newUser = new User();
|
||||
$newUser->name = $izyimUser->name;
|
||||
$newUser->email = $exchangeEmail;
|
||||
$newUser->password = $izyimUser->password;
|
||||
$newUser->type = RoleTypes::USER;
|
||||
$newUser->status = ApprovalStatus::APPROVED;
|
||||
$newUser->save();
|
||||
|
||||
Log::channel('wac_webhook')->info('Wac created user: ' . $exchangeEmail);
|
||||
|
||||
$companyModule = $izyimUser->companyModule->first();
|
||||
$Object = new EmploymentObject($companyModule, $newUser);
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Exchange email registered successfully.',
|
||||
'status' => 'success',
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user