From f7ba84acf0b3a3e73870601c2cf904c5d597cbf5 Mon Sep 17 00:00:00 2001 From: JiaSheng Date: Thu, 7 Dec 2023 11:05:41 +0800 Subject: [PATCH 1/4] fix customer page booking component transfer type alignment issue --- .../vue/components/bookings/elements/BookingComponent.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/BookingComponent.vue b/resources/assets/vue/components/bookings/elements/BookingComponent.vue index 9ff3fe9c..7e675646 100644 --- a/resources/assets/vue/components/bookings/elements/BookingComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingComponent.vue @@ -22,7 +22,7 @@ -
+
Marking
{{this.item.company.reference}} @@ -34,7 +34,7 @@ {{this.item.convertible_currency.short_code}}
-
+
Transfer Type
{{this.item.service.name}}
From 7ab1cd47e54b4af7adc1f4b80a3f769a371f706a Mon Sep 17 00:00:00 2001 From: Steve Ng Date: Tue, 12 Dec 2023 16:24:36 +0800 Subject: [PATCH 2/4] change where condition for import receipts --- .../GroupApproveStatementTransactionLogic.php | 2 +- .../ImportStatementReceiptsController.php | 69 ++++++++++--------- .../StatementTransactionComponent.vue | 4 ++ 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/app/Classes/Modules/Accounting/ControllersLogic/GroupApproveStatementTransactionLogic.php b/app/Classes/Modules/Accounting/ControllersLogic/GroupApproveStatementTransactionLogic.php index f9eb9c7b..7ae8a2ae 100644 --- a/app/Classes/Modules/Accounting/ControllersLogic/GroupApproveStatementTransactionLogic.php +++ b/app/Classes/Modules/Accounting/ControllersLogic/GroupApproveStatementTransactionLogic.php @@ -62,7 +62,7 @@ class GroupApproveStatementTransactionLogic extends AbstractControllerLogic $statementTransactions = $this->listsBankStatementTransactions->execute($filters); foreach ($statementTransactions as $statementTransaction) { - $owners = $statementTransaction->owners; + $owners = $statementTransaction->owners()->where('status', ApprovalStatus::PENDING_VERIFICATION)->get(); if (count($owners)) { $this->updatesBankStatementTransactionOwnerStatus->execute($owners->first(), ApprovalStatus::APPROVED); diff --git a/app/Http/Controllers/Imports/ImportStatementReceiptsController.php b/app/Http/Controllers/Imports/ImportStatementReceiptsController.php index 2cafeac0..a43f2dda 100644 --- a/app/Http/Controllers/Imports/ImportStatementReceiptsController.php +++ b/app/Http/Controllers/Imports/ImportStatementReceiptsController.php @@ -2,32 +2,35 @@ namespace App\Http\Controllers\Imports; -use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; -use App\Classes\Modules\Imports\Services\GenericImport; -use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Models\Segment; -use App\Models\User; -use Carbon\Carbon; use DateTime; -use Illuminate\Http\Request; -use Maatwebsite\Excel\Facades\Excel; -use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment; -use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor; +use Carbon\Carbon; +use App\Models\User; use App\Models\Company; -use App\Models\SeasonalSegment; +use App\Models\Segment; use App\Models\Transaction; -use App\Models\TransactionMappingLog; -use App\Classes\ValueObjects\Response\ApiResponseObject; -use App\Classes\ValueObjects\Constants\HttpStatus; +use Illuminate\Http\Request; +use App\Models\SeasonalSegment; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\DB; +use Maatwebsite\Excel\Facades\Excel; +use App\Models\TransactionMappingLog; +use App\Models\StatementTransactionOwner; +use App\Classes\ValueObjects\Constants\HttpStatus; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\Modules\Imports\Services\GenericImport; +use App\Classes\ValueObjects\Response\ApiResponseObject; +use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment; +use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor; +use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; +use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject; class ImportStatementReceiptsController { private $responseTitle; private $responseMessage; + private $removeStr = 'Payment for '; + public function __construct() { $this->responseTitle = 'Import Receipt Mapping'; $this->responseMessage = 'You have successfully imported receipt mapping'; @@ -56,11 +59,13 @@ class ImportStatementReceiptsController $row['mapped_status'] = 'failed'; $row['date'] = in_array(gettype($row['doc_date']), ['integer', 'double']) ? $this->changeExcelDate($row['doc_date']) : date('Y-m-d', strtotime($row['doc_date'])); - $returnReference = $this->mappingExchange($row); - if ($returnReference) { - $row['mapped_result_reference'] = $returnReference; - $row['mapped_status'] = 'success'; - } + if ($invRefer = $this->getInvoiceReference($row['description'])) { + $returnReference = $this->mappingExchange($invRefer, $row['doc_no']); + if ($returnReference) { + $row['mapped_result_reference'] = $returnReference; + $row['mapped_status'] = 'success'; + } + } TransactionMappingLog::create([ 'imported_date'=>$importDate, @@ -75,28 +80,26 @@ class ImportStatementReceiptsController } } + private function getInvoiceReference($invRefer) { + $arrStr = explode($this->removeStr, $invRefer); + if (isset($arrStr[1])) return $arrStr[1]; + return null; + } + public function response(String $responseTitle, String $responseMessage, int $httpStatus, ?array $data = []) : JsonResponse { return (new ApiResponseObject($responseTitle, $responseMessage, $httpStatus, $data))->handler(); } - private function mappingExchange(Array $row) { - $date = $row['date']; - $transactions = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where('statement_transactions.amount', $row['payment_amount'])->whereRaw("DATE(posting_date) = '$date'")->get(); + private function mappingExchange($invRefer, $docNo) { + $transactionOwner = StatementTransactionOwner::where('invoice_reference',$invRefer)->whereNull('receipt_reference')->where('status', ApprovalStatus::COMPLETED)->first(); - if ($transactions && $transactions->count() == 0) { - $transactions = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where(DB::raw('FLOOR(statement_transactions.amount)'), floor($row['payment_amount']))->whereRaw("DATE(posting_date) = '$date'")->get(); - } - - if ($transactions && $transactions->count() == 1) { - foreach ($transactions as $key => $transaction) { - return $this->updateTransactionOwnerReference($transaction, $row['doc_no']); - } + if ($transactionOwner) { + return $this->updateTransactionOwnerReference($transactionOwner, $docNo); } return false; } - public function updateTransactionOwnerReference($transaction, String $docNo) { - $transactionOwner = $transaction->transaction_owner; + public function updateTransactionOwnerReference($transactionOwner, String $docNo) { if ($transactionOwner) { $transactionOwner->update([ 'receipt_reference'=>$docNo, diff --git a/resources/assets/vue/components/accounting/elements/StatementTransactionComponent.vue b/resources/assets/vue/components/accounting/elements/StatementTransactionComponent.vue index b09b9a56..0c193871 100644 --- a/resources/assets/vue/components/accounting/elements/StatementTransactionComponent.vue +++ b/resources/assets/vue/components/accounting/elements/StatementTransactionComponent.vue @@ -4,6 +4,8 @@
{{ item.posting_date }}
{{ item.transaction_description_1 + ' - ' + item.transaction_description_2 }}
+ +
{{item.owners.pending_verification[0].system}}
@@ -51,6 +53,7 @@
+
@@ -93,6 +96,7 @@
+
From 7aedaa3c174cfd75f2df353abb1e0748fe579a48 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Wed, 13 Dec 2023 13:36:54 +0800 Subject: [PATCH 3/4] show all active services for suppliers when not in segment --- app/Models/Company.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index 8b2e6081..a1416ebb 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -109,7 +109,7 @@ class Company extends AbstractModel implements Documentable { return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'owner_id'], ['id', 'id']); } - + /** * @return HasMany */ @@ -130,13 +130,25 @@ class Company extends AbstractModel implements Documentable * @return Builder */ public function services(): Builder { - return ServiceType::where('status', ApprovalStatus::APPROVED)->whereHas('constants', function($query) { - $query->Where(function($query){ - $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_active', true); - })->orWhere(function($query) { - $query->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE)->where('detail->is_active', true)->whereIn('segment_id', $this->segments->pluck('id')); + + if ($this->type === 3) { + return ServiceType::where('status', ApprovalStatus::APPROVED)->whereHas('constants', function($query) { + $query->where(function($query) { + $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_active', true); + })->orWhere(function($query) { + $query->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE)->where('detail->is_active', true); + }); }); - }); + } else { + // Existing logic for other company types + return ServiceType::where('status', ApprovalStatus::APPROVED)->whereHas('constants', function($query) { + $query->Where(function($query){ + $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_active', true); + })->orWhere(function($query) { + $query->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE)->where('detail->is_active', true)->whereIn('segment_id', $this->segments->pluck('id')); + }); + }); + } } public function servicesConfigurations(): Collection { From 1ddf7923a51cd041986e57799c35737e19b2fbcf Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Wed, 13 Dec 2023 13:38:54 +0800 Subject: [PATCH 4/4] show all active services for suppliers when not in segment --- app/Models/Company.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index a1416ebb..54ae1e23 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -131,7 +131,7 @@ class Company extends AbstractModel implements Documentable */ public function services(): Builder { - if ($this->type === 3) { + if ($this->business_type === 3) { return ServiceType::where('status', ApprovalStatus::APPROVED)->whereHas('constants', function($query) { $query->where(function($query) { $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_active', true);