From c75fe27e13964b277f63407b8c74e3efd97ee3ce Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 11:55:27 +0800 Subject: [PATCH 01/72] fix admin permission issues --- .../ControllersLogic/DeleteUserLogic.php | 20 +++++++------------ .../Standards/Rules/CanDeleteBooking.php | 3 ++- .../Standards/Rules/CanUpdateBooking.php | 3 ++- .../Standards/Rules/Rates/CanCreateRate.php | 3 ++- .../Standards/Rules/Rates/CanDeleteRate.php | 3 ++- .../Standards/Rules/Rates/CanListRates.php | 3 ++- .../Standards/Rules/Rates/CanUpdateRate.php | 3 ++- .../Standards/Rules/CanCreateSegment.php | 3 ++- .../Standards/Rules/CanDeleteSegment.php | 3 ++- .../Standards/Rules/CanUpdateSegment.php | 3 ++- 10 files changed, 25 insertions(+), 22 deletions(-) diff --git a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php index 485e9cf3..e7aa57f8 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php @@ -53,24 +53,18 @@ class DeleteUserLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { - try { - DB::beginTransaction(); + $user = $this->fetchesUser->execute(['id' => $request->route('id')]); + $this->canDeleteUser->passes(); + $this->deletesUser->execute($user); - $user = $this->fetchesUser->execute(['id' => $request->route('id')]); - $this->canDeleteUser->passes(); - $this->deletesUser->execute($user); - - DB::commit(); - return $this->resourceResponse(new UserResource($user)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->resourceResponse(new UserResource($user)); } } \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php b/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php index dfd307bc..d1fcfe15 100644 --- a/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php +++ b/app/Classes/Modules/Bookings/Standards/Rules/CanDeleteBooking.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Bookings\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject; +use Illuminate\Support\Facades\Auth; class CanDeleteBooking extends AbstractRule { @@ -14,7 +15,7 @@ class CanDeleteBooking extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete booking')) { + if (!Auth::user()->can('delete booking')) { return false; } diff --git a/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php b/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php index bf5c022c..7158a825 100644 --- a/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php +++ b/app/Classes/Modules/Bookings/Standards/Rules/CanUpdateBooking.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Bookings\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Bookings\Standards\Validators\BookingValidation; +use Illuminate\Support\Facades\Auth; class CanUpdateBooking extends AbstractRule { @@ -29,7 +30,7 @@ class CanUpdateBooking extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('edit booking')) { + if (!Auth::user()->can('edit booking')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php index 842a548b..cf63f89c 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanCreateRate.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\Standards\Validators\Rates\RateValidation; use App\Classes\Modules\Currencies\DataTransferObjects\RateObject; +use Illuminate\Support\Facades\Auth; class CanCreateRate extends AbstractRule { @@ -27,7 +28,7 @@ class CanCreateRate extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules - if (!\Auth::user()->can('add currency_rate')) { + if (!Auth::user()->can('add currency_rate')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php index 4ebefb9e..37fff506 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanDeleteRate.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\DataTransferObjects\RateObject; +use Illuminate\Support\Facades\Auth; class CanDeleteRate extends AbstractRule { @@ -14,7 +15,7 @@ class CanDeleteRate extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete currency_rate')) { + if (!Auth::user()->can('delete currency_rate')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php index 496ba1e5..bd49c263 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanListRates.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyObject; +use Illuminate\Support\Facades\Auth; class CanListRates extends AbstractRule { @@ -14,7 +15,7 @@ class CanListRates extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('view currency_rate')) { + if (!Auth::user()->can('view currency_rate')) { return false; } diff --git a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php index 59564725..8a153c54 100644 --- a/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php +++ b/app/Classes/Modules/Currencies/Standards/Rules/Rates/CanUpdateRate.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Currencies\Standards\Rules\Rates; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Currencies\Standards\Validators\Rates\RateValidation; use App\Classes\Modules\Currencies\DataTransferObjects\RateObject; +use Illuminate\Support\Facades\Auth; class CanUpdateRate extends AbstractRule { @@ -29,7 +30,7 @@ class CanUpdateRate extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('view currency_rate')) { + if (!Auth::user()->can('view currency_rate')) { return false; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php index 50f7e81d..f7b05a10 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Segments\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject; use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation; +use Illuminate\Support\Facades\Auth; class CanCreateSegment extends AbstractRule { @@ -27,7 +28,7 @@ class CanCreateSegment extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules - if (!\Auth::user()->can('add segment')) { + if (!Auth::user()->can('add segment')) { return false; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php index 197b0a5f..9faf4da6 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Segments\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject; +use Illuminate\Support\Facades\Auth; class CanDeleteSegment extends AbstractRule { @@ -14,7 +15,7 @@ class CanDeleteSegment extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete segment')) { + if (!Auth::user()->can('delete segment')) { return false; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php index 58a8c0ca..8287dfd6 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Segments\Standards\Rules; use App\Classes\General\Abstracts\AbstractRule; use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject; use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation; +use Illuminate\Support\Facades\Auth; class CanUpdateSegment extends AbstractRule { @@ -30,7 +31,7 @@ class CanUpdateSegment extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('edit segment')) { + if (!Auth::user()->can('edit segment')) { return false; } From f31eba15fc6875e24569bdd58237ef397e675866 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 11:56:10 +0800 Subject: [PATCH 02/72] fix admin permission issues --- .../Modules/Accounts/ControllersLogic/DeleteUserLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php index e7aa57f8..283292dc 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php @@ -60,6 +60,7 @@ class DeleteUserLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { $user = $this->fetchesUser->execute(['id' => $request->route('id')]); + dd($user); $this->canDeleteUser->passes(); $this->deletesUser->execute($user); From c48cb3be88e1e01df566af413bafeae80132395b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 11:56:52 +0800 Subject: [PATCH 03/72] fix admin permission issues --- app/Classes/General/Eloquent/AbstractDeleteRecord.php | 1 + .../Modules/Accounts/ControllersLogic/DeleteUserLogic.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/General/Eloquent/AbstractDeleteRecord.php b/app/Classes/General/Eloquent/AbstractDeleteRecord.php index 963df421..fb078a3a 100644 --- a/app/Classes/General/Eloquent/AbstractDeleteRecord.php +++ b/app/Classes/General/Eloquent/AbstractDeleteRecord.php @@ -22,6 +22,7 @@ abstract class AbstractDeleteRecord } } catch (QueryException|\Exception $exception){ + dd($exception); throw new MalformedRequestException('Unable to update the record due to unexpected error'); } } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php index 283292dc..e7aa57f8 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php @@ -60,7 +60,6 @@ class DeleteUserLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { $user = $this->fetchesUser->execute(['id' => $request->route('id')]); - dd($user); $this->canDeleteUser->passes(); $this->deletesUser->execute($user); From f3dfb5ed7c151787fd9dbb0916b25d5c859b4bdf Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 11:58:32 +0800 Subject: [PATCH 04/72] fix admin permission issues --- app/Classes/General/Eloquent/AbstractDeleteRecord.php | 1 - app/Models/User.php | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Classes/General/Eloquent/AbstractDeleteRecord.php b/app/Classes/General/Eloquent/AbstractDeleteRecord.php index fb078a3a..963df421 100644 --- a/app/Classes/General/Eloquent/AbstractDeleteRecord.php +++ b/app/Classes/General/Eloquent/AbstractDeleteRecord.php @@ -22,7 +22,6 @@ abstract class AbstractDeleteRecord } } catch (QueryException|\Exception $exception){ - dd($exception); throw new MalformedRequestException('Unable to update the record due to unexpected error'); } } diff --git a/app/Models/User.php b/app/Models/User.php index d41cbb7f..6fd8b6b0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\Permission\Traits\HasRoles; use Tymon\JWTAuth\Contracts\JWTSubject; @@ -23,7 +24,7 @@ class User extends AbstractModel implements AuthorizableContract, CanResetPasswordContract { - use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail; + use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes; /** From d0bee3da8c68e970a69a4b34c06a129aedd44937 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 12:01:34 +0800 Subject: [PATCH 05/72] fix admin permission issues --- .../Modules/Segments/Standards/Rules/CanCreateSegment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php index f7b05a10..ca83e3ac 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php @@ -28,6 +28,7 @@ class CanCreateSegment extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules + dd(Auth::user()->can('add segment')); if (!Auth::user()->can('add segment')) { return false; } From 313d31927276844e424fc63d2730a7ca983ee344 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 12:06:38 +0800 Subject: [PATCH 06/72] fix admin permission issues --- .../Modules/Segments/Standards/Rules/CanCreateSegment.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php index ca83e3ac..f7b05a10 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php @@ -28,7 +28,6 @@ class CanCreateSegment extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules - dd(Auth::user()->can('add segment')); if (!Auth::user()->can('add segment')) { return false; } From 1d0271d2e344b529e1f253dfec693099de85913f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 30 Dec 2021 12:56:08 +0800 Subject: [PATCH 07/72] change postcode to string to keep leading zero --- .../Addresses/DataTransferObjects/AddressObject.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php index 8c164317..48e3bb62 100644 --- a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php +++ b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php @@ -22,7 +22,7 @@ class AddressObject implements DataTransferObject /** @var int */ private $districtId; - /** @var int */ + /** @var string */ private $postCode; /** @@ -32,9 +32,9 @@ class AddressObject implements DataTransferObject * @param int $countryId * @param int $stateId * @param int $districtId - * @param int $postCode + * @param string $postCode */ - public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode) + public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, string $postCode) { $this->streetOne = $streetOne; $this->streetTwo = $streetTwo; @@ -85,9 +85,9 @@ class AddressObject implements DataTransferObject } /** - * @return int + * @return string */ - public function getPostCode(): int + public function getPostCode(): string { return $this->postCode; } From 2ffd59fd17bec1f666a8b3864d4f4e69139576f0 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 14:35:53 +0800 Subject: [PATCH 08/72] 1688 data --- routes/web.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/routes/web.php b/routes/web.php index 238505b3..0fca35d1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -85,4 +85,21 @@ Route::get('/x2/data', function (Request $request) { dd(\App\Models\Booking::whereDoesntHave('transactions', function($query){ $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::PENDING_VERIFICATION, \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED]); })->groupBy('company_id')->get()); +})->name('x2.data'); + + +Route::get('/1688', function (Request $request) { + $token = Auth::fromUser(User::find(1)); + $request->headers->set('Authorization', 'Bearer '.$token); + $bookings = \App\Models\Booking::whereHas('bank', function ($query){ + return $query->where('bank_name', 'like', '%浙江网商银行%'); + })->get(); + + $sum = 0; + foreach ($bookings as $booking){ + $sum += $booking->transactions()->where('type', 1)->sum('amount'); + } + + dd($sum); + })->name('x2.data'); \ No newline at end of file From 22b4cf2f14202bbda8da37c0b16faf44b2ca74b1 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 14:39:41 +0800 Subject: [PATCH 09/72] 1688 data --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 0fca35d1..e412f1c0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,7 +97,7 @@ Route::get('/1688', function (Request $request) { $sum = 0; foreach ($bookings as $booking){ - $sum += $booking->transactions()->where('type', 1)->sum('amount'); + $sum += $booking->transactions()->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); } dd($sum); From a0991645247fd9c69ca7ab1af100de7176b42c74 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 18:00:49 +0800 Subject: [PATCH 10/72] 1688 data --- routes/web.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index e412f1c0..d542f7ff 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,9 +97,8 @@ Route::get('/1688', function (Request $request) { $sum = 0; foreach ($bookings as $booking){ - $sum += $booking->transactions()->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); + $sum += $booking->transactions()->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->whereMonth('created_at', 11)->sum('amount'); } - dd($sum); })->name('x2.data'); \ No newline at end of file From d9e9c5029aab87c45b602e74efec46f088b703cd Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 18:14:16 +0800 Subject: [PATCH 11/72] 1688 data --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index d542f7ff..109c6c17 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,7 +97,7 @@ Route::get('/1688', function (Request $request) { $sum = 0; foreach ($bookings as $booking){ - $sum += $booking->transactions()->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->whereMonth('created_at', 11)->sum('amount'); + $sum += $booking->transactions()->whereMonth('created_at', 11)->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); } From 7e3ff2b7cda0c702827b1d0c95780967a909008b Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 18:17:07 +0800 Subject: [PATCH 12/72] 1688 data --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 109c6c17..aa98a370 100644 --- a/routes/web.php +++ b/routes/web.php @@ -99,6 +99,6 @@ Route::get('/1688', function (Request $request) { foreach ($bookings as $booking){ $sum += $booking->transactions()->whereMonth('created_at', 11)->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); } - +; })->name('x2.data'); \ No newline at end of file From 4f405fdec05a29b6a65ed22e611f4cff452d474c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 18:18:03 +0800 Subject: [PATCH 13/72] 1688 data --- routes/web.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index aa98a370..b8baf641 100644 --- a/routes/web.php +++ b/routes/web.php @@ -99,6 +99,7 @@ Route::get('/1688', function (Request $request) { foreach ($bookings as $booking){ $sum += $booking->transactions()->whereMonth('created_at', 11)->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); } -; + + dd($sum); })->name('x2.data'); \ No newline at end of file From 5332bace525e447b965c07b1e3f2381f35c2743e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 3 Jan 2022 18:23:03 +0800 Subject: [PATCH 14/72] 1688 data --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index b8baf641..367ea0c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,7 +97,7 @@ Route::get('/1688', function (Request $request) { $sum = 0; foreach ($bookings as $booking){ - $sum += $booking->transactions()->whereMonth('created_at', 11)->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); + $sum += $booking->transactions()->whereMonth('created_at', 12)->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount'); } dd($sum); From 8801a943f03bcfb35bf92717dcde1e9aee607a98 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 4 Jan 2022 22:29:20 +0800 Subject: [PATCH 15/72] update-service-content --- app/Http/Resources/TransactionResource.php | 6 +- .../elements/PaymentVerificationComponent.vue | 8 +++ .../SupplierPendingOrderComponent.vue | 16 ++++- .../SupplierPendingOrdersSectionComponent.vue | 72 +++++++++++++++---- 4 files changed, 88 insertions(+), 14 deletions(-) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 633985cf..9a9d8a7a 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -37,7 +37,11 @@ class TransactionResource extends JsonResource 'documents' => new DocumentResource($this->documents()->first()), 'customer_booking' => new TransactionResource($this->when((int) $this->type === TransactionType::BILL, $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->where('id', '<', $this->id)->orderByDesc('id')->first())), 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'), - 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A') + 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), + 'interval' => [ + 'value' => (Carbon::parse($this->created_at)->addDays(3)->gt(Carbon::now()) ) ? '+' : '-' , + 'duration' => Carbon::parse($this->created_at)->addDays(3)->diff(Carbon::now())->format('%d'), + ], ]; } } diff --git a/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue index 9acdab65..24dcaea0 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentVerificationComponent.vue @@ -68,6 +68,14 @@ {{item.original_currency.short_code}} {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} +
+
Service
+
+ {{item.booking.service.name}} +
+
+ +
+
+
Service
+
+ {{item.booking.service.name}} +
+
@@ -60,12 +66,20 @@ {{item.original_currency.short_code}}
-
+
Amount
{{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
timer
+
+ {{item.interval.value}} + {{item.interval.duration}} + days +
+
diff --git a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue index 81e17c37..23e3116f 100644 --- a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue @@ -8,30 +8,30 @@
-
-
+
+
-
- {{selectedSupplier.name}} +
+ {{selectedService.name}}
-
+
- +
-
+
-
-
+
+
-
{{supplier.name}}
+
{{service.name}}
@@ -41,7 +41,7 @@
-
+
@@ -75,11 +75,46 @@
+
+
+
+
+
+ {{selectedSupplier.name}} +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
{{supplier.name}}
+
+
+
+
+
+
+
+
+
+
- + @@ -124,6 +159,14 @@ currencyDropdownLaunch: { status: false }, + serviceDropdownLaunch: { + status: false + }, + selectedService: { + id: 1, + name: '', + status: false + }, payments: [] } }, @@ -135,6 +178,7 @@ this.suppliers = response.payload.data; this.updateSupplier(this.suppliers[0]); this.updateCurrency(this.suppliers[0].currencies[0]); + this.updateService(this.suppliers[0].services[0]); }, updateSupplier(supplier){ this.selectedSupplier = supplier; @@ -151,6 +195,10 @@ this.payments = []; }, + updateService(service){ + this.selectedService = service; + this.serviceDropdownLaunch.status = false; + }, updateOrder(payment){ this.payments.includes(payment) ? this.payments.splice(this.payments.indexOf(payment), 1) : this.payments.push(payment); } From 7f6b254d30122181ca03b936ab912a188b0b28bb Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 04:14:10 +0800 Subject: [PATCH 16/72] fix regenerate invoice function --- .../RegenerateInvoiceBookingLogic.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php index d1cdbada..efe97767 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php @@ -78,6 +78,7 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse @@ -92,15 +93,9 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic $this->updatesBookingStatus->execute($booking, ApprovalStatus::APPROVED); - $transaction = $booking->transactions()->whereIn('type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->get(); - foreach ($transaction as $key => $row) { - $this->deletesTransaction->execute($row); - } + $booking->transactions()->whereIn('type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete(); - $document = $booking->documents()->get(); - foreach ($document as $key => $row) { - $this->deletesDocument->execute($row); - } + $booking->documents()->delete(); $this->createInvoiceTransactionProcessor->execute($booking); From a9aabc781e5b88b2070be79142e1ac0efab0ba8e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 04:15:32 +0800 Subject: [PATCH 17/72] fix regenerate invoice function --- .../ControllersLogic/RegenerateInvoiceBookingLogic.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php index efe97767..71ea7ba1 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php @@ -93,9 +93,15 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic $this->updatesBookingStatus->execute($booking, ApprovalStatus::APPROVED); - $booking->transactions()->whereIn('type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete(); + $transaction = $booking->transactions()->whereIn('type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->get(); + foreach ($transaction as $key => $row) { + $this->deletesTransaction->execute($row); + } - $booking->documents()->delete(); + $document = $booking->documents()->get(); + foreach ($document as $key => $row) { + $this->deletesDocument->execute($row); + } $this->createInvoiceTransactionProcessor->execute($booking); From a3d3d73267b330b48b3eba067cae2efb80a1e8fc Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 14 Jan 2022 19:29:15 +0800 Subject: [PATCH 18/72] export products list --- .../Exports/Services/ExportsProducts.php | 51 +++++++++++++++++++ routes/web.php | 11 ++-- 2 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 app/Classes/Modules/Exports/Services/ExportsProducts.php diff --git a/app/Classes/Modules/Exports/Services/ExportsProducts.php b/app/Classes/Modules/Exports/Services/ExportsProducts.php new file mode 100644 index 00000000..541f1d21 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsProducts.php @@ -0,0 +1,51 @@ +whereHas('transaction', function($query){ + return $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->where('status', ApprovalStatus::APPROVED); + })->limit(50); + } + + /** + * @param $product + * @return array + */ + public function map($product): array + { + + return [ + $product->product_code, + $product->product_name, + $product->price, + ]; + } +} \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 238505b3..7d39e036 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; +use Maatwebsite\Excel\Excel; /* |-------------------------------------------------------------------------- @@ -79,10 +80,6 @@ Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callba Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); -Route::get('/x2/data', function (Request $request) { - $token = Auth::fromUser(User::find(1)); - $request->headers->set('Authorization', 'Bearer '.$token); - dd(\App\Models\Booking::whereDoesntHave('transactions', function($query){ - $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::PENDING_VERIFICATION, \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED]); - })->groupBy('company_id')->get()); -})->name('x2.data'); \ No newline at end of file +Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { + return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); +})->name('products.random'); \ No newline at end of file From ce885693e1d30d55c1f20b629a75bbdfb9ac76e8 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 14 Jan 2022 19:32:39 +0800 Subject: [PATCH 19/72] export random products to excel --- .../Exports/Services/ExportsProducts.php | 51 +++++++++++++++++++ routes/web.php | 11 ++-- 2 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 app/Classes/Modules/Exports/Services/ExportsProducts.php diff --git a/app/Classes/Modules/Exports/Services/ExportsProducts.php b/app/Classes/Modules/Exports/Services/ExportsProducts.php new file mode 100644 index 00000000..541f1d21 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsProducts.php @@ -0,0 +1,51 @@ +whereHas('transaction', function($query){ + return $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->where('status', ApprovalStatus::APPROVED); + })->limit(50); + } + + /** + * @param $product + * @return array + */ + public function map($product): array + { + + return [ + $product->product_code, + $product->product_name, + $product->price, + ]; + } +} \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 367ea0c8..104ebe18 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; +use Maatwebsite\Excel\Excel; /* |-------------------------------------------------------------------------- @@ -79,13 +80,9 @@ Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callba Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); -Route::get('/x2/data', function (Request $request) { - $token = Auth::fromUser(User::find(1)); - $request->headers->set('Authorization', 'Bearer '.$token); - dd(\App\Models\Booking::whereDoesntHave('transactions', function($query){ - $query->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::PENDING_VERIFICATION, \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED]); - })->groupBy('company_id')->get()); -})->name('x2.data'); +Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { + return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); +})->name('products.random'); Route::get('/1688', function (Request $request) { From 0a0da91c21df708af164f9e911fc2a3171a3d058 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 16 Jan 2022 20:33:55 +0800 Subject: [PATCH 20/72] update wallet-ui --- .../accounts/forms/TopUpAccountComponent.vue | 196 ------------------ .../CustomerProfileSectionComponent.vue | 2 +- .../customerDashboardSectionComponent.vue | 2 +- .../elements/WalletComponent.vue} | 30 ++- .../elements/WalletTopUpHistoryComponent.vue | 73 +++++++ .../forms/WalletTopUpFormComponent.vue | 41 ++++ .../views/pages/wallet/transactions.blade.php | 15 +- resources/views/partials/header.blade.php | 8 - routes/web.php | 5 +- 9 files changed, 145 insertions(+), 227 deletions(-) delete mode 100644 resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue rename resources/assets/vue/components/{companies/sections/WalletBalanceComponent.vue => wallets/elements/WalletComponent.vue} (93%) create mode 100644 resources/assets/vue/components/wallets/elements/WalletTopUpHistoryComponent.vue create mode 100644 resources/assets/vue/components/wallets/forms/WalletTopUpFormComponent.vue diff --git a/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue b/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue deleted file mode 100644 index af8a43b7..00000000 --- a/resources/assets/vue/components/accounts/forms/TopUpAccountComponent.vue +++ /dev/null @@ -1,196 +0,0 @@ - - \ No newline at end of file diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index 85502c97..b95f385f 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -141,7 +141,7 @@
- +
diff --git a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue index f399c533..cce6e90f 100644 --- a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue @@ -537,7 +537,7 @@
- +
diff --git a/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue b/resources/assets/vue/components/wallets/elements/WalletComponent.vue similarity index 93% rename from resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue rename to resources/assets/vue/components/wallets/elements/WalletComponent.vue index dd100288..af0398d5 100644 --- a/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue +++ b/resources/assets/vue/components/wallets/elements/WalletComponent.vue @@ -1,4 +1,4 @@ -