From b9b30a1555fff35a9eaf8e126c6920750c3ca029 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 16 Dec 2021 20:24:10 +0800 Subject: [PATCH 001/443] update wallet ui at dashboard --- .../customerDashboardSectionComponent.vue | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue index 8d48fc7e..2fc0ba02 100644 --- a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue @@ -536,8 +536,35 @@
- + +
+
+
+
+ +
MYR 0.00
+
+
+
+
+ Reload +
+
+ Transaction History +
+
+
+
+ + Transfer +
+
+ + Cash Out +
+
+
+
From f9db00356b57b506979c6b1d1b126ecf6bfd36ad Mon Sep 17 00:00:00 2001 From: glovetleong Date: Thu, 23 Dec 2021 21:57:08 +0800 Subject: [PATCH 002/443] bill transaction status update --- .../UpdatePaymentTransactionStatusLogic.php | 76 +++++++++++++++++++ ...datePaymentTransactionStatusController.php | 14 ++++ routes/transaction.php | 2 + 3 files changed, 92 insertions(+) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php create mode 100644 app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php new file mode 100644 index 00000000..11f0a377 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdatePaymentTransactionStatusLogic.php @@ -0,0 +1,76 @@ + 'Updated Transaction', + 'message' => 'You have successfully updated a transaction' + ]; + } + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + /** @var DeletesDocument */ + private $deletesDocument; + + /** + * CreatePaymentVerificationDocumentLogic constructor. + * @param FetchesTransaction $fetchesTransaction + * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param DeletesDocument $deletesDocument + */ + public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument) + { + $this->fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->deletesDocument = $deletesDocument; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); + $status = $request->route('status'); + + $this->updatesTransactionStatus->execute($transaction, $status === 'pending' ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::COMPLETED); + + if ($status == 'pending') { + $document = $transaction->documents()->first(); + if ($document) { + $this->deletesDocument->execute($document); + } + } + + return $this->response([]); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php b/app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php new file mode 100644 index 00000000..047bc1dc --- /dev/null +++ b/app/Http/Controllers/Transactions/UpdatePaymentTransactionStatusController.php @@ -0,0 +1,14 @@ +execute($request); + } +} \ No newline at end of file diff --git a/routes/transaction.php b/routes/transaction.php index 17502743..578b02c2 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -10,6 +10,8 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => route::post('/supplier/{id}/bill/create', 'CreateSupplierTransactionController@create')->name('supplier.create'); route::post('{id}/bill/verification', 'CreatePaymentProofDocumentController@verify')->name('bill.verification'); route::post('{id}/bill/pay', 'CreatePaymentProofDocumentController@pay')->name('bill.pay'); + Route::put('/{id}/bill/{status}', 'UpdatePaymentTransactionStatusController@update')->where('status', 'pending|complete')->name('bill.status'); + route::delete('{id}/bill/delete', 'DeletePaymentProofDocumentController@delete')->name('bill.delete'); Route::post('booking/{id}/details/update', 'CreatePurchaseOrderTransactionController@create')->name('po.create'); From 8bf6b69e63cc43dc55ff3ebdd0a879b1e1627473 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 25 Dec 2021 11:20:38 +0800 Subject: [PATCH 003/443] update PaymentProofComponent - add in function to delete transaction on currency_orders - VERIFICATION tab --- .../elements/PaymentProofComponent.vue | 8 +++++ .../forms/DeleteTransactionFormComponent.vue | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue diff --git a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue index 494427cb..415655a5 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue @@ -41,6 +41,14 @@ +
+
+ Cancel this order? +
+
+ + + diff --git a/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue b/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue new file mode 100644 index 00000000..cf618df1 --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file From da3408ad78eb5dd24c616b116fe7bb624be96e5c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 11:51:43 +0800 Subject: [PATCH 004/443] fix admin permission issues --- .../ControllersLogic/DeleteUserLogic.php | 21 ++++++------------- .../Standards/Rules/CanCreateSegment.php | 6 +++--- .../Standards/Rules/CanDeleteSegment.php | 6 +++--- .../Standards/Rules/CanUpdateSegment.php | 6 +++--- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php index 485e9cf3..eb5fcc62 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php @@ -53,24 +53,15 @@ 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); - - DB::commit(); - - return $this->resourceResponse(new UserResource($user)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + $user = $this->fetchesUser->execute(['id' => $request->route('id')]); + $this->canDeleteUser->passes(); + $this->deletesUser->execute($user); } } \ No newline at end of file diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php index 50f7e81d..f7bdf2ef 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php @@ -27,9 +27,9 @@ class CanCreateSegment extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules - if (!\Auth::user()->can('add segment')) { - return false; - } +// if (!\Auth::user()->can('add segment')) { +// return false; +// } return true; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php index 197b0a5f..9208f492 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php @@ -14,9 +14,9 @@ class CanDeleteSegment extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('delete segment')) { - return false; - } +// if (!\Auth::user()->can('delete segment')) { +// return false; +// } return true; diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php index 58a8c0ca..534f93ec 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php @@ -30,9 +30,9 @@ class CanUpdateSegment extends AbstractRule { // TODO Set Authorization rules - if (!\Auth::user()->can('edit segment')) { - return false; - } +// if (!\Auth::user()->can('edit segment')) { +// return false; +// } return true; } From a163af86be2874e6b84da2b943d5c8811cbc97db Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 27 Dec 2021 06:00:50 +0000 Subject: [PATCH 005/443] Revert "fix admin permission issues" This reverts commit da3408ad78eb5dd24c616b116fe7bb624be96e5c --- .../ControllersLogic/DeleteUserLogic.php | 21 +++++++++++++------ .../Standards/Rules/CanCreateSegment.php | 6 +++--- .../Standards/Rules/CanDeleteSegment.php | 6 +++--- .../Standards/Rules/CanUpdateSegment.php | 6 +++--- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php index eb5fcc62..485e9cf3 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/DeleteUserLogic.php @@ -53,15 +53,24 @@ class DeleteUserLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws \App\Classes\Exceptions\AccessForbiddenException - * @throws \App\Classes\Exceptions\MalformedRequestException - * @throws \App\Classes\Exceptions\RequestValidationException + * @throws ErrorException */ public function logic(Request $request) : JsonResponse { - $user = $this->fetchesUser->execute(['id' => $request->route('id')]); - $this->canDeleteUser->passes(); - $this->deletesUser->execute($user); + try { + DB::beginTransaction(); + + $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()); + } } } \ No newline at end of file diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php index f7bdf2ef..50f7e81d 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php @@ -27,9 +27,9 @@ class CanCreateSegment extends AbstractRule protected function authorized(): bool { // TODO Set Authorization rules -// if (!\Auth::user()->can('add segment')) { -// return false; -// } + if (!\Auth::user()->can('add segment')) { + return false; + } return true; } diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php index 9208f492..197b0a5f 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php @@ -14,9 +14,9 @@ class CanDeleteSegment extends AbstractRule { // TODO Set Authorization rules -// if (!\Auth::user()->can('delete segment')) { -// return false; -// } + if (!\Auth::user()->can('delete segment')) { + return false; + } return true; diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php index 534f93ec..58a8c0ca 100644 --- a/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php +++ b/app/Classes/Modules/Segments/Standards/Rules/CanUpdateSegment.php @@ -30,9 +30,9 @@ class CanUpdateSegment extends AbstractRule { // TODO Set Authorization rules -// if (!\Auth::user()->can('edit segment')) { -// return false; -// } + if (!\Auth::user()->can('edit segment')) { + return false; + } return true; } From 9068c334924fd6c77a88dddecc35cd67ffca96b8 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Mon, 27 Dec 2021 14:02:52 +0800 Subject: [PATCH 006/443] update delete transaction modal to default confirmation modal size --- .../vue/components/bookings/elements/PaymentProofComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue index 415655a5..980c50da 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue @@ -46,7 +46,7 @@ Cancel this order? - + From 7dc310258580a48f3bf9bc6659c522b356d8b529 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Mon, 27 Dec 2021 14:46:23 +0800 Subject: [PATCH 007/443] add in function to approve / reject transaction on currency_orders - VERIFICATION tab --- .../elements/PaymentProofComponent.vue | 14 ++++++++ ...ApprovePaymentTransactionFormComponent.vue | 33 +++++++++++++++++++ .../forms/DeleteTransactionFormComponent.vue | 2 +- .../RejectPaymentTransactionFormComponent.vue | 33 +++++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 resources/assets/vue/components/bookings/forms/ApprovePaymentTransactionFormComponent.vue create mode 100644 resources/assets/vue/components/bookings/forms/RejectPaymentTransactionFormComponent.vue diff --git a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue index 980c50da..e197ab6a 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue @@ -69,6 +69,20 @@ +
+ + + + + + + + +
diff --git a/resources/assets/vue/components/bookings/forms/ApprovePaymentTransactionFormComponent.vue b/resources/assets/vue/components/bookings/forms/ApprovePaymentTransactionFormComponent.vue new file mode 100644 index 00000000..7be579f2 --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/ApprovePaymentTransactionFormComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue b/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue index cf618df1..8ba13dba 100644 --- a/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/DeleteTransactionFormComponent.vue @@ -15,7 +15,7 @@
Cancel
-
Delete
+
Confirm
diff --git a/resources/assets/vue/components/bookings/forms/RejectPaymentTransactionFormComponent.vue b/resources/assets/vue/components/bookings/forms/RejectPaymentTransactionFormComponent.vue new file mode 100644 index 00000000..ad43890c --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/RejectPaymentTransactionFormComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file From 77b2d21e68300a1501935dce090e14980b843d23 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 2 Jan 2022 15:01:52 +0800 Subject: [PATCH 008/443] add calculation service charge for transaction bill --- .../CreateSupplierTransactionLogic.php | 49 +++++++++++-------- .../CalculatesTransactionServiceCharge.php | 19 +++++++ .../pdfs/currency_vendor_order.blade.php | 22 ++++++++- 3 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index f496ab4f..20dfa9da 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -3,31 +3,32 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; +use Carbon\Carbon; +use App\Models\Document; +use Barryvdh\DomPDF\PDF; +use App\Models\Transaction; +use Illuminate\Support\Str; +use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Storage; +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\ValueObjects\Constants\PaymentMethodType; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; +use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; +use App\Classes\Modules\Documents\Services\CreatesDocument; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\FetchesTransaction; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Documents\Services\CreatesDocument; -use App\Classes\Modules\Documents\Services\CreatesFiles; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\PaymentMethodType; -use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\ValueObjects\Constants\DocumentType; -use App\Models\Document; -use App\Models\Transaction; -use Barryvdh\DomPDF\PDF; -use Carbon\Carbon; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Storage; -use Illuminate\Support\Str; -use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; -use Meneses\LaravelMpdf\Facades\LaravelMpdf; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge; class CreateSupplierTransactionLogic extends AbstractControllerLogic { @@ -64,6 +65,9 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; + /** @var CalculatesTransactionServiceCharge */ + private $calculatesTransactionServiceCharge; + /** @var PDF */ private $pdf; @@ -74,9 +78,10 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic * @param UpdatesTransactionStatus $updatesTransactionStatus * @param CreatesTransaction $createsTransaction * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge * @param PDF $pdf */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, PDF $pdf) { $this->fetchesCompany = $fetchesCompany; @@ -86,6 +91,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; $this->pdf = $pdf; } @@ -106,10 +112,11 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate); $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); + $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); $transactions[] = $this->createsTransaction->execute($payment->booking, $object); } diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php new file mode 100644 index 00000000..3dbabc30 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -0,0 +1,19 @@ + - Total amount: + Sub total booking amount: + RMB {{number_format((float)$transactions->sum('original_amount'), 2, '.', '')}} + + + Transfer fee (0.002%): + RMB {{number_format((float)$transactions->sum('original_amount') * 0.002 / 100, 2, '.', '')}} + + + Total booking amount: + RMB {{number_format((float) ($transactions->sum('original_amount') +($transactions->sum('original_amount') * 0.002 / 100)), 2, '.', '')}} + + + Sub total amount: MYR {{number_format((float)$transactions->sum('amount'), 2, '.', '')}} + + Service charge ({{ $supplier->id == 2 ? 0 : '0.75%' }}): + MYR {{number_format((float)$transactions->sum('service_charge'), 2, '.', '')}} + + + Total amount: + MYR {{number_format((float) ($transactions->sum('amount') + $transactions->sum('service_charge')), 2, '.', '')}} + From 8801a943f03bcfb35bf92717dcde1e9aee607a98 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 4 Jan 2022 22:29:20 +0800 Subject: [PATCH 009/443] 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 d2d92f668e7d56d462c9dc2e3d6a681274c6def9 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sat, 8 Jan 2022 03:28:18 +0800 Subject: [PATCH 010/443] add transfer fee transaction and fixed currency_vendor_order pdf calculation --- .../CreateSupplierTransactionLogic.php | 20 ++- .../CalculatesTransactionServiceCharge.php | 6 +- .../CalculatesTransactionTransferFee.php | 17 +++ .../Constants/TransactionType.php | 2 + .../pdfs/currency_vendor_order.blade.php | 115 +++++++++++------- 5 files changed, 109 insertions(+), 51 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 20dfa9da..6b5110ec 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -28,6 +28,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee; use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge; class CreateSupplierTransactionLogic extends AbstractControllerLogic @@ -68,6 +69,9 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var CalculatesTransactionServiceCharge */ private $calculatesTransactionServiceCharge; + /** @var CalculatesTransactionTransferFee */ + private $calculatesTransactionTransferFee; + /** @var PDF */ private $pdf; @@ -79,9 +83,10 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic * @param CreatesTransaction $createsTransaction * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge + * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee * @param PDF $pdf */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, PDF $pdf) { $this->fetchesCompany = $fetchesCompany; @@ -92,6 +97,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->createsFile = $createsFile; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; + $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; $this->pdf = $pdf; } @@ -102,6 +108,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $rate = $request->input('rate'); $transactions = collect(); + $transferFeeTransactions = collect(); foreach($request->input('payments') as $payment){ @@ -119,11 +126,20 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); $transactions[] = $this->createsTransaction->execute($payment->booking, $object); + + $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); + $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); + $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, + 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); + + $transferFeeTransactions[] = $this->createsTransaction->execute($payment->booking, $object); } if(!count($transactions)) return $this->response([]); - $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'supplier' => $supplier]); + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]); $path = Str::studly($supplier->name).'_'.Carbon::now()->format('Y_m_d_h_s_i').'.pdf'; diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php index 3dbabc30..641e3903 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -8,12 +8,12 @@ class CalculatesTransactionServiceCharge /** * @param float $amount * @param float $rate - * @param float $transfer_fee * @param float $service_charge + * @param float $transfer_fee * @return float */ - public function execute(float $amount, float $rate, ?float $transfer_fee = 0.002, ?float $service_charge = 0.75) { - return (($amount + ($amount * $transfer_fee/100)) * (1/$rate)) * $service_charge / 100; + public function execute(float $amount, float $rate, ?float $service_charge = 0.75, ?float $transfer_fee = 0.00) { + return (($amount + $transfer_fee) * (1/$rate)) * $service_charge / 100; } } \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php new file mode 100644 index 00000000..14f77b84 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php @@ -0,0 +1,17 @@ + - table, th, td { - border: 1px solid black; - border-collapse: collapse; - } - th, td { - padding: 15px; - } - + +
+
- -
- - +
+ - -
{{$supplier->name}} {{\Carbon\Carbon::now('Asia/Singapore')->format('d-m-Y h:s')}}
-
-
- - + +
+
+
+ + @@ -32,50 +36,69 @@ @foreach($transactions as $transaction) - - - - - - - + + + + + + + @endforeach - -
Reference MarkingBank in Details
{{$transaction->booking->marking}}{{$transaction->booking->company->reference}}{{$transaction->currency_rate}}{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}Account Holder Name: {{$transaction->booking->bank->holder_name}}
{{$transaction->booking->bank->bank_name}}: {{$transaction->booking->bank->account_no}} -
Branch: {{$transaction->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}}
{{$transaction->booking->marking}}{{$transaction->booking->company->reference}}{{$transaction->currency_rate}}{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}Account Holder Name: {{$transaction->booking->bank->holder_name}}
{{$transaction->booking->bank->bank_name}}: {{$transaction->booking->bank->account_no}} +
Branch: {{$transaction->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} +
- - + +
+ + - + @php + $sub_total_booking_amount = number_format((float)$transactions->sum('original_amount'), 2, '.', ''); + @endphp + - + @php + $transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', ''); + @endphp + - + @php + $total_booking_amount = number_format((float) ($transactions->sum('original_amount') + $transfer_fee), 2, '.', ''); + @endphp + - + @php + $sub_total_amount = number_format((float)$transactions->sum('amount') + ($transfer_fee * 1/$transactions[0]->currency_rate), 2, '.', ''); + @endphp + - - + + @php + $service_charge = number_format((float)$sub_total_amount * 0.75 / 100, 2, '.', ''); + @endphp + - + @php + $total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', ''); + @endphp + + + +
Sub total booking amount: RMB {{number_format((float)$transactions->sum('original_amount'), 2, '.', '')}}RMB {{$sub_total_booking_amount}}
Transfer fee (0.002%): RMB {{number_format((float)$transactions->sum('original_amount') * 0.002 / 100, 2, '.', '')}}RMB {{$transfer_fee}}
Total booking amount: RMB {{number_format((float) ($transactions->sum('original_amount') +($transactions->sum('original_amount') * 0.002 / 100)), 2, '.', '')}}RMB {{$total_booking_amount}}
Sub total amount: MYR {{number_format((float)$transactions->sum('amount'), 2, '.', '')}}MYR {{$sub_total_amount}}
Service charge ({{ $supplier->id == 2 ? 0 : '0.75%' }}): MYR {{number_format((float)$transactions->sum('service_charge'), 2, '.', '')}}Service charge ({{ $supplier->id == 2 ? '0.00' : '0.75%' }}): MYR {{$service_charge}}
Total amount: MYR {{number_format((float) ($transactions->sum('amount') + $transactions->sum('service_charge')), 2, '.', '')}}MYR {{$total_amount}}
+ + + + -
Page {PAGENO} of {nbpg}
- - - - - -
Page {PAGENO} of {nbpg}
-
+
@endsection \ No newline at end of file From 8305b66e83ec5b2221821fe48813da8f039d2373 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Sun, 9 Jan 2022 22:40:41 +0800 Subject: [PATCH 011/443] auto generate product list --- .../AutoPackingListFillLogic.php | 116 ++++++++++++++++++ .../CreatePurchaseOrderTransactionLogic.php | 5 +- .../AutoPackingListFillController.php | 20 +++ routes/booking.php | 4 + 4 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php create mode 100644 app/Http/Controllers/Bookings/AutoPackingListFillController.php diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php new file mode 100644 index 00000000..949973b7 --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php @@ -0,0 +1,116 @@ + 'Purchase Order Approval', + 'message' => 'You have successfully updated the Purchase order status' + ]; + } + + /** @var CreatePurchaseOrderTransactionLogic */ + private $createPurchaseOrderTransactionLogic; + + /** + * AutoPackingListFillLogic constructor. + * @param CreatePurchaseOrderTransactionLogic $createPurchaseOrderTransactionLogic + */ + public function __construct(CreatePurchaseOrderTransactionLogic $createPurchaseOrderTransactionLogic) + { + $this->createPurchaseOrderTransactionLogic = $createPurchaseOrderTransactionLogic; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $booking = Booking::where('created_at', '>', '01-07-2021') + ->whereDoesntHave('transactions', function($q){ + $q->where('type', TransactionType::PURCHASE_ORDER); + $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); + }) + ->get(); + + + foreach ($booking as $key => $row) { + $amount = $row->fix_amount; + $other_transaction = Transaction:: + where('type', TransactionType::PURCHASE_ORDER) + ->where('status', ApprovalStatus::APPROVED) + ->where('amount', '<=', $amount) + ->where('issuer', $row->company_id) + ->first(); + + + if (!$other_transaction) { + $other_transaction = Transaction:: + where('type', TransactionType::PURCHASE_ORDER) + ->where('status', ApprovalStatus::APPROVED) + ->where('amount', '<=', $amount) + ->first(); + } + + if ($other_transaction) { + $other_transaction_detail = $other_transaction->transactionDetails()->get(); + + $other_amount = 0; + foreach ($other_transaction_detail as $key_2 => $row_2) { + + if ($amount > $other_amount) { + $other_amount += $row_2->amount; + $products[] = [ + 'description' => $row_2->product_name, + 'quantity' => (int) $row_2->quantity, + 'stockCode' => $row_2->product_code, + 'total' => $row_2->amount, + 'unit_price' => (int) $row_2->price, + ]; + } + } + + $remain_amount = $amount - $other_amount; + + if ($remain_amount > 0) { + $remain = [ + 'description' => 'other service charge', + 'quantity' => 1, + 'stockCode' => 'OTHER_SERVICE_CHARGE', + 'total' => $remain_amount, + 'unit_price' => $remain_amount, + ]; + + $products = array_merge([$remain], $products); + } + $request->request->add([ + 'products' => $products + ]); + + $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); + } + } + + return $this->response([]); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php index aa4c6f4d..afd589c6 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePurchaseOrderTransactionLogic.php @@ -83,16 +83,15 @@ class CreatePurchaseOrderTransactionLogic extends AbstractControllerLogic * @return JsonResponse * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function logic(Request $request) : JsonResponse + public function logic(Request $request, $id = '') : JsonResponse { /** @var Booking $booking */ - $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); + $booking = $this->fetchesBooking->execute(['id' => $request->route('id') ?? $id]); /** @var Transaction $transaction */ $transaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); $billNumber = $this->generatesTransactionBillNumber->execute('PO-'); - $total = collect($request->input('products'))->sum(function($product){ return $product['quantity'] * floatval(str_replace(',', '', $product['unit_price'])); }); diff --git a/app/Http/Controllers/Bookings/AutoPackingListFillController.php b/app/Http/Controllers/Bookings/AutoPackingListFillController.php new file mode 100644 index 00000000..3c6580c0 --- /dev/null +++ b/app/Http/Controllers/Bookings/AutoPackingListFillController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/routes/booking.php b/routes/booking.php index 44767438..e19add01 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -31,4 +31,8 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('/merge', 'MergeBookingController@merge')->name('merge'); Route::post('{id}/proforma/create', 'CreateProformaInvoiceTransaction@create')->name('proforma.create'); + + + Route::post('/auto-packing-list-fill', 'AutoPackingListFillController@auto')->name('assign'); + }); \ No newline at end of file From 0579be05d8be6af0f5d83b1b09e4012953b73fb1 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Mon, 10 Jan 2022 00:33:35 +0800 Subject: [PATCH 012/443] wallet updates --- .../CustomerProfileSectionComponent.vue | 5 + .../sections/WalletBalanceComponent.vue | 104 +++++++++++++++ .../customerDashboardSectionComponent.vue | 29 +---- resources/views/pages/wallet/index.blade.php | 4 + .../views/pages/wallet/transactions.blade.php | 121 ++++++++++++++++++ routes/web.php | 4 + 6 files changed, 239 insertions(+), 28 deletions(-) create mode 100644 resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue create mode 100644 resources/views/pages/wallet/index.blade.php create mode 100644 resources/views/pages/wallet/transactions.blade.php diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index 09876b9b..85502c97 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -139,6 +139,11 @@
+
+
+ +
+
diff --git a/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue b/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue new file mode 100644 index 00000000..dd100288 --- /dev/null +++ b/resources/assets/vue/components/companies/sections/WalletBalanceComponent.vue @@ -0,0 +1,104 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue index 2fc0ba02..f399c533 100644 --- a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue @@ -537,34 +537,7 @@
-
-
-
-
- -
MYR 0.00
-
-
-
-
- Reload -
-
- Transaction History -
-
-
-
- - Transfer -
-
- - Cash Out -
-
-
-
+
diff --git a/resources/views/pages/wallet/index.blade.php b/resources/views/pages/wallet/index.blade.php new file mode 100644 index 00000000..7a9b49ef --- /dev/null +++ b/resources/views/pages/wallet/index.blade.php @@ -0,0 +1,4 @@ +@extends('layouts.base_portal') +@section('inner_content') + @include('pages.wallet.transactions') +@endsection diff --git a/resources/views/pages/wallet/transactions.blade.php b/resources/views/pages/wallet/transactions.blade.php new file mode 100644 index 00000000..8fcb3a8a --- /dev/null +++ b/resources/views/pages/wallet/transactions.blade.php @@ -0,0 +1,121 @@ +
+
+
+
+
Transaction History
+
+
+ +
+
Date
+
Description
+
Incoming
+
Outgoing
+
Balance
+
+ +
+
25/11/2015
+
Payment to bill #121221121
+
+
2,123
+
12,123
+
+ +
+
115/11/2015
+
Top Up
+
1,234
+
+
14,246
+
+
+
+ +
+
+
+
+
Top Up Records
+
+
+ + +
+
+
+
+
+
+
+
+
+
Payment Method Success
+
+
+

$123,123

+
+
+
+
+ 12-03-2021 +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
Payment Method Failed
+
+
+

$123,123

+
+
+
+
+ 12-03-2021 +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
Payment Method Processing
+
+
+

$123,123

+
+
+
+
+ 12-03-2021 +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 84e1f2c1..23b4499c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -75,6 +75,10 @@ Route::get('/transfer/merge/{marking}', function ($marking) { return view('pages.bookings.merge', ['marking' => $marking]); })->name('booking.merge'); +Route::get('/wallet-transactions', function () { + return view('pages.wallet.index'); +})->name('wallet.transactions'); + Route::get('/test', function(){ // Auth::login(User::findOrFail(1)); From 2b150e9a75464a9f57cc6411b42482b230319596 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Mon, 10 Jan 2022 14:41:49 +0800 Subject: [PATCH 013/443] created at --- ...ngListFillLogic.php => AutoPurchaseOrderFillLogic.php} | 7 +++---- .../Bookings/AutoPackingListFillController.php | 8 ++++---- routes/booking.php | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) rename app/Classes/Modules/Bookings/ControllersLogic/{AutoPackingListFillLogic.php => AutoPurchaseOrderFillLogic.php} (95%) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php similarity index 95% rename from app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php rename to app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 949973b7..0db23bc0 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPackingListFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -14,7 +14,7 @@ use App\Models\Transaction; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -class AutoPackingListFillLogic extends AbstractControllerLogic +class AutoPurchaseOrderFillLogic extends AbstractControllerLogic { /** @@ -46,13 +46,12 @@ class AutoPackingListFillLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $booking = Booking::where('created_at', '>', '01-07-2021') + $booking = Booking::whereMonth('created_at', 7) + ->whereYear('created_at', 2021) ->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); }) - ->get(); - foreach ($booking as $key => $row) { $amount = $row->fix_amount; diff --git a/app/Http/Controllers/Bookings/AutoPackingListFillController.php b/app/Http/Controllers/Bookings/AutoPackingListFillController.php index 3c6580c0..45f5ebb1 100644 --- a/app/Http/Controllers/Bookings/AutoPackingListFillController.php +++ b/app/Http/Controllers/Bookings/AutoPackingListFillController.php @@ -2,18 +2,18 @@ namespace App\Http\Controllers\Bookings; -use App\Classes\Modules\Bookings\ControllersLogic\AutoPackingListFillLogic; +use App\Classes\Modules\Bookings\ControllersLogic\AutoPurchaseOrderFillLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -class AutoPackingListFillController +class AutoPurchaseOrderFillController { /** * @param Request $request - * @param AutoPackingListFillLogic $logic + * @param AutoPurchaseOrderFillLogic $logic * @return JsonResponse */ - public function auto(Request $request, AutoPackingListFillLogic $logic): JsonResponse { + public function auto(Request $request, AutoPurchaseOrderFillLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/routes/booking.php b/routes/booking.php index e19add01..69dff750 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -33,6 +33,6 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('{id}/proforma/create', 'CreateProformaInvoiceTransaction@create')->name('proforma.create'); - Route::post('/auto-packing-list-fill', 'AutoPackingListFillController@auto')->name('assign'); + Route::post('/auto-purchase-order-fill', 'AutoPurchaseOrderFillController@auto')->name('assign'); }); \ No newline at end of file From 36c659c84e58cc8982e68d8ffe169e4460ca0c3f Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Tue, 11 Jan 2022 23:07:49 +0800 Subject: [PATCH 014/443] Transfer Fee Transaction - Company Balance Account API --- .../CreateSupplierTransactionLogic.php | 4 +- .../FetchCompanyAccountBalanceLogic.php | 46 +++++++++++++++++++ .../GeneratesCompanyBalanceAccount.php | 41 +++++++++++++++++ .../FetchCompanyAccountBalanceController.php | 21 +++++++++ app/Models/Company.php | 7 +++ app/Models/Transaction.php | 11 ++++- routes/transaction.php | 1 + 7 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php create mode 100644 app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php create mode 100644 app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 6b5110ec..b524b3e9 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -125,7 +125,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); - $transactions[] = $this->createsTransaction->execute($payment->booking, $object); + $transactions[] = $billTransaction = $this->createsTransaction->execute($payment->booking, $object); $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); @@ -134,7 +134,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); - $transferFeeTransactions[] = $this->createsTransaction->execute($payment->booking, $object); + $transferFeeTransactions[] = $this->createsTransaction->execute($billTransaction, $object); } if(!count($transactions)) return $this->response([]); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php new file mode 100644 index 00000000..b73f5ca3 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php @@ -0,0 +1,46 @@ + 'Retrieved Company Balance Account', + 'message' => 'You have successfully retrieved company balance account' + ]; + } + + /** @var GeneratesCompanyBalanceAccount */ + private $generatesCompanyBalanceAccount; + + /** + * FetchCompanyAccountBalanceLogic constructor. + * @param GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount + */ + public function __construct(GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount) + { + $this->generatesCompanyBalanceAccount = $generatesCompanyBalanceAccount; + } + + public function logic(Request $request) : JsonResponse + { + $company = Company::find($request->route('id')); + + return $this->response(['data' => $this->generatesCompanyBalanceAccount->execute($company)]); + + } + + + +} diff --git a/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php new file mode 100644 index 00000000..51c71cb1 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php @@ -0,0 +1,41 @@ +checksIfTransactionBillNumberExists = $checksIfTransactionBillNumberExists; + } + + + /** + * @param Company $company + */ + public function execute(Company $company) { + $transferFeeTransactions = $company->issuerTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get(); + return [ + 'company' => new CompanyResource($company), + 'transferFeeTransactions' => $transferFeeTransactions, + 'account_balance' => $transferFeeTransactions->sum('amount'), + ]; + + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php b/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php new file mode 100644 index 00000000..d36b0605 --- /dev/null +++ b/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Models/Company.php b/app/Models/Company.php index 7b8e4387..e18bbf85 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -101,6 +101,13 @@ class Company extends AbstractModel implements Documentable { return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'owner_id'], ['id', 'id']); } + /** + * @return HasMany + */ + public function issuerTransactions(): HasMany + { + return $this->HasMany(Transaction::class, 'issuer'); + } /** * @return MorphMany diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index a3e16c79..450d9545 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; +use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use Carbon\Carbon; @@ -16,7 +17,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; -class Transaction extends AbstractModel implements Documentable +class Transaction extends AbstractModel implements Documentable, Transactionable { use SoftDeletes; @@ -27,6 +28,14 @@ class Transaction extends AbstractModel implements Documentable return $this->morphTo(); } + /** + * @return MorphMany + */ + public function transactions(): MorphMany + { + return $this->MorphMany(Transaction::class, 'owner'); + } + /** * @return MorphMany */ diff --git a/routes/transaction.php b/routes/transaction.php index 578b02c2..d3ce05b2 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -16,4 +16,5 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::post('booking/{id}/details/update', 'CreatePurchaseOrderTransactionController@create')->name('po.create'); + Route::get('/company/{id}/account/balance', 'FetchCompanyAccountBalanceController@fetch')->name('company.account.balance'); }); \ No newline at end of file From 7f6b254d30122181ca03b936ab912a188b0b28bb Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 04:14:10 +0800 Subject: [PATCH 015/443] 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 016/443] 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 0f18dcf11795c61ab9e7de2ed90011f254631e45 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:28:11 +0800 Subject: [PATCH 017/443] fix route name for xpo generator controller --- ...ListFillController.php => AutoPurchaseOrderFillController.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/Http/Controllers/Bookings/{AutoPackingListFillController.php => AutoPurchaseOrderFillController.php} (100%) diff --git a/app/Http/Controllers/Bookings/AutoPackingListFillController.php b/app/Http/Controllers/Bookings/AutoPurchaseOrderFillController.php similarity index 100% rename from app/Http/Controllers/Bookings/AutoPackingListFillController.php rename to app/Http/Controllers/Bookings/AutoPurchaseOrderFillController.php From 1096f9bb63c108da164a5bc0df55f7d01bc36ae2 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:29:14 +0800 Subject: [PATCH 018/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 0db23bc0..1797f99d 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -51,7 +51,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); - }) + }); foreach ($booking as $key => $row) { $amount = $row->fix_amount; From a06a8d58af265428bc1a9f3882fb95c505b5a7c3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:34:03 +0800 Subject: [PATCH 019/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 1797f99d..b12fc37f 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -105,6 +105,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic $request->request->add([ 'products' => $products ]); + dd($row->id, $products); $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); } From 9a8cf7188b702d7e00290b6f5a5cb68ebcf66377 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:35:02 +0800 Subject: [PATCH 020/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index b12fc37f..3951aab6 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -107,7 +107,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ]); dd($row->id, $products); - $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); +// $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); } } From dba0a1a59eebc186f239650d13edf081a8e06f01 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:35:46 +0800 Subject: [PATCH 021/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 3951aab6..9b6e5b23 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -52,7 +52,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); }); - +dd($booking); foreach ($booking as $key => $row) { $amount = $row->fix_amount; $other_transaction = Transaction:: From 559337313a4989af0898fa6072271359d2ee5bf2 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:36:17 +0800 Subject: [PATCH 022/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 9b6e5b23..23bba1fa 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -51,7 +51,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); - }); + })->get(); dd($booking); foreach ($booking as $key => $row) { $amount = $row->fix_amount; From 2a270b264e4de258390fc2bd6d7fb77b015dc8a5 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:36:48 +0800 Subject: [PATCH 023/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 23bba1fa..2d86eb99 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -52,7 +52,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); })->get(); -dd($booking); + foreach ($booking as $key => $row) { $amount = $row->fix_amount; $other_transaction = Transaction:: @@ -105,9 +105,8 @@ dd($booking); $request->request->add([ 'products' => $products ]); - dd($row->id, $products); -// $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); + $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); } } From 29250ae400060a0b5cee44e14abcb7b3b34e4689 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:43:17 +0800 Subject: [PATCH 024/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 2d86eb99..0ccdcd57 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -51,7 +51,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); - })->get(); + })->limit(20)->get(); foreach ($booking as $key => $row) { $amount = $row->fix_amount; From 2a534d564b63d301bf466bb1b215a8db06e18227 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:47:03 +0800 Subject: [PATCH 025/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 0ccdcd57..7ad87f46 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -51,7 +51,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); - })->limit(20)->get(); + })->limit(100)->get(); foreach ($booking as $key => $row) { $amount = $row->fix_amount; From 9b20734a045f43305ce88a76ae649a6a1a0cbe75 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:52:36 +0800 Subject: [PATCH 026/443] fix route name for xpo generator controller --- .../AutoPurchaseOrderFillLogic.php | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 7ad87f46..b1d38cb9 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -71,43 +71,41 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ->first(); } - if ($other_transaction) { - $other_transaction_detail = $other_transaction->transactionDetails()->get(); + $other_transaction_detail = $other_transaction->transactionDetails()->get(); - $other_amount = 0; - foreach ($other_transaction_detail as $key_2 => $row_2) { + $other_amount = 0; + foreach ($other_transaction_detail as $key_2 => $row_2) { - if ($amount > $other_amount) { - $other_amount += $row_2->amount; - $products[] = [ - 'description' => $row_2->product_name, - 'quantity' => (int) $row_2->quantity, - 'stockCode' => $row_2->product_code, - 'total' => $row_2->amount, - 'unit_price' => (int) $row_2->price, - ]; - } - } - - $remain_amount = $amount - $other_amount; - - if ($remain_amount > 0) { - $remain = [ - 'description' => 'other service charge', - 'quantity' => 1, - 'stockCode' => 'OTHER_SERVICE_CHARGE', - 'total' => $remain_amount, - 'unit_price' => $remain_amount, + if ($amount > $other_amount) { + $other_amount += $row_2->amount; + $products[] = [ + 'description' => $row_2->product_name, + 'quantity' => (int) $row_2->quantity, + 'stockCode' => $row_2->product_code, + 'total' => $row_2->amount, + 'unit_price' => (int) $row_2->price, ]; - - $products = array_merge([$remain], $products); } - $request->request->add([ - 'products' => $products - ]); - - $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); } + + $remain_amount = $amount - $other_amount; + + if ($remain_amount > 0) { + $remain = [ + 'description' => 'other service charge', + 'quantity' => 1, + 'stockCode' => 'OTHER_SERVICE_CHARGE', + 'total' => $remain_amount, + 'unit_price' => $remain_amount, + ]; + + $products = array_merge([$remain], $products); + } + $request->request->add([ + 'products' => $products + ]); + + $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); } return $this->response([]); From 2e3d002dc6145108c89cb28835000c6574538c28 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 12 Jan 2022 15:53:14 +0800 Subject: [PATCH 027/443] fix route name for xpo generator controller --- .../Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index b1d38cb9..79f56916 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -51,7 +51,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic ->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); - })->limit(100)->get(); + })->limit(10)->get(); foreach ($booking as $key => $row) { $amount = $row->fix_amount; @@ -105,7 +105,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic 'products' => $products ]); - $create_transaction = $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); + $this->createPurchaseOrderTransactionLogic->logic($request, $row->id); } return $this->response([]); From f56369d707eb1d9f62d2a56603e8fa7daf720e5b Mon Sep 17 00:00:00 2001 From: glovetleong Date: Thu, 13 Jan 2022 22:49:02 +0800 Subject: [PATCH 028/443] transaction bill --- .../CreateSupplierTransactionLogic.php | 3 +- app/Http/Resources/TransactionResource.php | 2 +- app/Models/Booking.php | 6 ++- app/Models/Transaction.php | 11 ++++- .../UpdateTransactionBillOwnerSeeder.php | 42 +++++++++++++++++++ .../pdfs/currency_vendor_order.blade.php | 8 ++-- 6 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 database/seeds/UpdateTransactionBillOwnerSeeder.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index f496ab4f..16fc76d3 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -91,6 +91,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { + $supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]); $rate = $request->input('rate'); @@ -111,7 +112,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, $rate, 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); - $transactions[] = $this->createsTransaction->execute($payment->booking, $object); + $transactions[] = $this->createsTransaction->execute($payment, $object); } if(!count($transactions)) return $this->response([]); diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 633985cf..b75aebe1 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -35,7 +35,7 @@ class TransactionResource extends JsonResource 'status' => (int) $this->status, 'details' => TransactionDetailResource::collection($this->transactionDetails), '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())), + 'customer_booking' => new TransactionResource($this->when((int) $this->type === TransactionType::BILL, $this->owner)), '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') ]; diff --git a/app/Models/Booking.php b/app/Models/Booking.php index ea01b302..524e0e0c 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -96,8 +96,10 @@ class Booking extends AbstractModel implements Documentable, Transactionable protected static function booted() { - if (auth()->user()->type === RoleTypes::USER) { - static::addGlobalScope(new CustomerBookingsScope); + if (auth()->user()) { + if (auth()->user()->type === RoleTypes::USER) { + static::addGlobalScope(new CustomerBookingsScope); + } } } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index a3e16c79..0428888d 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; +use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use Carbon\Carbon; @@ -16,7 +17,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; -class Transaction extends AbstractModel implements Documentable +class Transaction extends AbstractModel implements Documentable, Transactionable { use SoftDeletes; @@ -51,6 +52,14 @@ class Transaction extends AbstractModel implements Documentable return $this->BelongsTo(Wallet::class, 'owner_id', 'id'); } + /** + * @return MorphMany + */ + public function transactions(): MorphMany + { + return $this->MorphMany(Transaction::class, 'owner'); + } + /** * @return BelongsTo */ diff --git a/database/seeds/UpdateTransactionBillOwnerSeeder.php b/database/seeds/UpdateTransactionBillOwnerSeeder.php new file mode 100644 index 00000000..4ca20454 --- /dev/null +++ b/database/seeds/UpdateTransactionBillOwnerSeeder.php @@ -0,0 +1,42 @@ +get(); + + foreach ($transaction as $key => $row) { + $booking = $row->booking()->first(); + $payment_trsanction = $row->booking()->first()->transactions()->payments()->complete()->where('original_amount', '=', $row->original_amount)->where('id', '<', $row->id)->orderByDesc('id')->first(); + + $row->owner_type = 'App\Models\Transaction'; + $row->owner_id = $payment_trsanction->id; + $row->update(); + } + + DB::commit(); + } +} diff --git a/resources/views/pages/pdfs/currency_vendor_order.blade.php b/resources/views/pages/pdfs/currency_vendor_order.blade.php index fdad834a..9ca3b7be 100644 --- a/resources/views/pages/pdfs/currency_vendor_order.blade.php +++ b/resources/views/pages/pdfs/currency_vendor_order.blade.php @@ -33,12 +33,12 @@ @foreach($transactions as $transaction) - {{$transaction->booking->marking}} - {{$transaction->booking->company->reference}} + {{$transaction->owner()->first()->booking->marking}} + {{$transaction->owner()->first()->booking->company->reference}} {{$transaction->currency_rate}} {{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}} - Account Holder Name: {{$transaction->booking->bank->holder_name}}
{{$transaction->booking->bank->bank_name}}: {{$transaction->booking->bank->account_no}} -
Branch: {{$transaction->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} + Account Holder Name: {{$transaction->owner()->first()->booking->bank->holder_name}}
{{$transaction->owner()->first()->booking->bank->bank_name}}: {{$transaction->owner()->first()->booking->bank->account_no}} +
Branch: {{$transaction->owner()->first()->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} @endforeach From a3d3d73267b330b48b3eba067cae2efb80a1e8fc Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 14 Jan 2022 19:29:15 +0800 Subject: [PATCH 029/443] 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 030/443] 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 031/443] 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 @@ -