Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into fix-po

This commit is contained in:
edmondlang
2024-01-08 17:49:06 +08:00
6 changed files with 103 additions and 73 deletions
@@ -2,16 +2,14 @@
namespace App\Classes\Modules\Accounting\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounting\Services\FetchesBankStatementTransaction;
use App\Http\Resources\BankStatementTransactionResource;
use App\Classes\Modules\Accounting\Services\UpdatesBankStatementTransactionOwnerStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use Illuminate\Http\JsonResponse;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Http\Resources\BankStatementTransactionOwnerResource;
use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
use App\Classes\Modules\Accounting\Services\FetchesBankStatementTransactionOwner;
use App\Classes\Modules\Accounting\Services\UpdatesBankStatementTransactionOwnerStatus;
class UpdateStatementTransactionStatusLogic extends AbstractControllerLogic
{
@@ -27,29 +25,23 @@ class UpdateStatementTransactionStatusLogic extends AbstractControllerLogic
];
}
/** @var FetchesBankStatementTransaction */
private $fetchesBankStatementTransaction;
/** @var FetchesBankStatementTransactionOwner */
private $fetchesBankStatementTransactionOwner;
/** @var UpdatesBankStatementTransactionOwnerStatus */
private $updatesBankStatementTransactionOwnerStatus;
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/**
* UpdateAnnouncementLogic constructor.
* @param FetchesBankStatementTransaction $fetchesBankStatementTransaction
* @param FetchesBankStatementTransactionOwner $fetchesBankStatementTransactionOwner
* @param UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
* @param UpdatesTransactionStatus $updatesTransactionStatus
*/
public function __construct(
FetchesBankStatementTransaction $fetchesBankStatementTransaction,
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus,
UpdatesTransactionStatus $updatesTransactionStatus
FetchesBankStatementTransactionOwner $fetchesBankStatementTransactionOwner,
UpdatesBankStatementTransactionOwnerStatus $updatesBankStatementTransactionOwnerStatus
) {
$this->fetchesBankStatementTransaction = $fetchesBankStatementTransaction;
$this->fetchesBankStatementTransactionOwner = $fetchesBankStatementTransactionOwner;
$this->updatesBankStatementTransactionOwnerStatus = $updatesBankStatementTransactionOwnerStatus;
$this->updatesTransactionStatus = $updatesTransactionStatus;
}
/**
@@ -61,21 +53,10 @@ class UpdateStatementTransactionStatusLogic extends AbstractControllerLogic
*/
public function logic(Request $request): JsonResponse
{
$statementTrasaction = $this->fetchesBankStatementTransaction->execute(['id' => $request->route('id')]);
$statementTrasactionOwner = $statementTrasaction->owners->first();
$statementTrasactionOwner = $this->fetchesBankStatementTransactionOwner->execute(['id' => $request->route('id')]);
$this->updatesBankStatementTransactionOwnerStatus->execute($statementTrasactionOwner, $request->route('status') == 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
// todo-new: approve payments status, need to check the owner(if system is shipping, need to api with shipping portal)
// if ($request->route('status') == 'approve') {
// if ($statementTrasactionOwner->transaction->type === StatementTransactionOwnerType::SALES) {
// if ($statementTrasactionOwner->owner->status === ApprovalStatus::PENDING_VERIFICATION) {
// $this->updatesTransactionStatus->execute($statementTrasactionOwner->owner, ApprovalStatus::APPROVED);
// }
// }
// }
return $this->resourceResponse(new BankStatementTransactionResource($statementTrasaction));
return $this->resourceResponse(new BankStatementTransactionOwnerResource($statementTrasactionOwner));
}
}
@@ -13,6 +13,7 @@ class ListShippingPortalTransactions
{
try {
$url = 'https://izyim.cief-malaysia.com/public/api/v1/transactions/mappable/query/with-details';
// $url = 'http://127.0.0.1:8001/public/api/v1/transactions/mappable/query/with-details';
$client = new \GuzzleHttp\Client(['verify' => false]);
$response = $client->request('GET', $url . '?api-key=510acd13d8d24375cf038ad626c282565451461a9c2399357e0b65365300787e&filters=' . json_encode($filters));
$body = $response->getBody();
@@ -0,0 +1,31 @@
<?php
namespace App\Classes\Modules\Accounting\Services;
use App\Models\StatementTransactionOwner;
use Illuminate\Database\Eloquent\Builder;
use App\Classes\General\Eloquent\AbstractFetchRecord;
class FetchesBankStatementTransactionOwner extends AbstractFetchRecord
{
/** @var StatementTransactionOwner */
private $repository;
/**
* FetchesBankStatementDetails constructor.
* @param StatementTransactionOwner $repository
*/
public function __construct(StatementTransactionOwner $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
}
@@ -108,13 +108,13 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
'500-0000',
'CIEF'
];
} else {
} elseif ($statementTransactionOwner->owner_id) {
$row = (App()->make(ListShippingPortalTransactions::class))->execute([
'id' => $statementTransactionOwner->owner_id,
'with_company' => true,
]);
if (empty($row) || $row[0]['status'] != 'success') {
if (!empty($row) && $row[0]['status'] != 'success') {
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Fetch Shipping Transaction Fail ' . json_encode([
'id' => $statementTransactionOwner->owner_id,
'with_company' => true,
@@ -125,46 +125,44 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' Shipping Portal Respnose ' . json_encode($row) . PHP_EOL;
file_put_contents($errorFilePath, $textToAppend, FILE_APPEND);
Log::info('Error in Exports Invoice Transactions ' . $this->counter);
return [
'Transaction Not Found',
$transaction->posting_date->format('m/d/Y H:m'),
$transaction->transaction_description.' - '.$transaction->transaction_description_2,
$statementTransactionOwner->system,
'<<New>>',
Carbon::parse($row['created_at'])->format('m/d/Y H:m'),
$row['debtor_code'],
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['marking'],
'',
'MYR',
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['bill_no'],
$row['type'] === ShippingTransactionType::PAYMENT ? '' : 'W1',
$row['type'] === ShippingTransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF `' . $row['order_reference'] : 'CREDIT SALES',
'',
'',
'',
'',
'',
0,
$transaction->amount,
'',
'',
'',
''
1,
round($row['amount'], 2),
'500-0000',
'CIEF'
];
}
$row = $row[0];
return [
'<<New>>',
Carbon::parse($row['updated_at'])->format('m/d/Y H:m'),
$row['debtor_code'],
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['marking'],
'',
'MYR',
$row['type'] === ShippingTransactionType::PAYMENT ? $row['order_reference'] : $row['bill_no'],
$row['type'] === ShippingTransactionType::PAYMENT ? '' : 'W1',
$row['type'] === ShippingTransactionType::PAYMENT ? 'PLEASE REFER TO THE ATTACHED APPENDIX REF `' . $row['order_reference'] : 'CREDIT SALES',
'',
1,
round($row['amount'], 2),
'500-0000',
'CIEF'
];
}
return [
'Transaction Not Found',
$transaction->posting_date->format('m/d/Y H:m'),
$transaction->transaction_description.' - '.$transaction->transaction_description_2,
$statementTransactionOwner->system,
'',
'',
'',
'',
'',
'',
0,
$transaction->amount,
'',
'',
'',
''
];
}
}
+4
View File
@@ -104,6 +104,10 @@ return [
'path' => storage_path('logs/regenerateInvoice.log'),
'level' => 'info',
],
'guzzleShippingPortal' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
];
@@ -74,7 +74,7 @@
<div class="row parentContainer" v-for="owner in item.owners.pending_verification">
<div class="col d-flex justify-content-between">
<a :href="owner.reference_link" target="_blank">{{ owner.reference }}</a>
<div v-if="stage === 2">
<div v-if="stage === 2" style="display: flex;">
<button class="btn btn-xs btn-outline-primary b-rad-none m-r-5 requestModal" data-type="approveCorrectMappingTransaction">
<i class="fa fa-check fa-fw"></i>
</button>
@@ -89,6 +89,21 @@
>
</general-confirmation-form-component>
</modal-component>
<button class="btn btn-xs btn-outline-danger b-rad-none m-r-5 requestModal" data-type="revertPendingMappingTransaction">
<i class="fa fa-times fa-fw"></i>
</button>
<modal-component class="animate__animated animate__fast animate__fadeIn" type="revertPendingMappingTransaction">
<general-confirmation-form-component
contentText="Are you sure you want to reject this mapping?"
modalType="delete"
class="text-center"
:apiRoute="route('api.accounting.statement_transaction.owner.status.update', owner.id, 'reject')"
apiMethod="post"
:section="section"
>
</general-confirmation-form-component>
</modal-component>
</div>
</div>
</div>
@@ -143,7 +158,7 @@
contentText="Are you sure you want to reject this mapping?"
modalType="delete"
class="text-center"
:apiRoute="route('api.accounting.statement_transaction.owner.status.update', item.id, 'reject')"
:apiRoute="route('api.accounting.statement_transaction.owner.status.update', item.owners.pending_verification[0].id, 'reject')"
apiMethod="post"
:section="section"
>