mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 06:54:02 +00:00
Merge branch 'import-ambank-cief-lite-statement' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\StatementTransactionOwnerType;
|
||||
use App\Models\AccountStatement;
|
||||
use App\Models\StatementAccount;
|
||||
use App\Models\StatementTransaction;
|
||||
@@ -45,77 +46,28 @@ class ImportCiefLiteStatementLogic extends AbstractControllerLogic
|
||||
|
||||
$sheet = $collection->first()->skip(1);
|
||||
|
||||
$dateTo = $sheet->first()[10];
|
||||
$dateFrom = $sheet->last()[10];
|
||||
$totalTransaction = $sheet->count();
|
||||
|
||||
$offset = 1;
|
||||
do {
|
||||
$dateFrom = $sheet->offsetGet($sheet->count() - $offset)[10];
|
||||
$offset += 1;
|
||||
} while(!$dateFrom);
|
||||
|
||||
|
||||
$dateFrom = carbon::parse($dateFrom);
|
||||
$dateTo = carbon::parse($dateTo);
|
||||
|
||||
$statement = AccountStatement::whereDate('date_from', $dateFrom)
|
||||
->whereDate('date_to', $dateTo)
|
||||
->where('total_amount', $totalTransaction)
|
||||
->first();
|
||||
|
||||
if(!$statement){
|
||||
$statement = new AccountStatement([
|
||||
'date_from' => $dateFrom,
|
||||
'date_to' => $dateTo,
|
||||
'total_amount' => $totalTransaction,
|
||||
]);
|
||||
}
|
||||
|
||||
$account = StatementAccount::where("name", "CIEF LITE")->first();
|
||||
|
||||
if (!$account) {
|
||||
throw new Exception("Statement Account for CIEF LITE not found.");
|
||||
}
|
||||
|
||||
$account->statements()->save($statement);
|
||||
|
||||
$sheet->map(function ($row) use ($statement) {
|
||||
if (!$row[0]) {
|
||||
$sheet->map(function ($row) {
|
||||
if (!$row[0] || trim($row[8]) !== "已审核") {
|
||||
return;
|
||||
}
|
||||
$postingDate = $row[10];
|
||||
$transactionDescription = trim($row[1]);
|
||||
$description2 = trim($row[2]);
|
||||
$description3 = "Fee " . $row[6];
|
||||
$description4 = trim($row[8]);
|
||||
$transactionRef = trim($row[12]);
|
||||
$postingDate =date('Y-m-d', strtotime($row[10]));
|
||||
$amount = ((float) str_replace(',', '', $row[7]));
|
||||
$transactionCode = $row[0];
|
||||
$transaction = new StatementTransaction([
|
||||
'posting_date' => $postingDate,
|
||||
'transaction_description' => $transactionDescription,
|
||||
'transaction_description_2' => $description2,
|
||||
'transaction_description_3' => $description3,
|
||||
'transaction_description_4' => $description4,
|
||||
'transaction_ref' => $transactionRef,
|
||||
'amount' => $amount,
|
||||
'transaction_code' => $transactionCode,
|
||||
]);
|
||||
|
||||
$statementTransaction = StatementTransaction::whereHas('account', function($query) {
|
||||
$query->where('statement_accounts.number', 8881040198515);
|
||||
})->whereDate('posting_date', $postingDate)->where('amount', $amount)->first();
|
||||
|
||||
// Check if the transaction already exists for this statement
|
||||
$existingTransaction = StatementTransaction::where('transaction_ref', $transactionRef)
|
||||
->where('posting_date', $postingDate)
|
||||
->where('amount', $amount)
|
||||
->where('transaction_description', $transactionDescription)
|
||||
->where('transaction_code', $transactionCode)
|
||||
->first();
|
||||
|
||||
if (!$existingTransaction) {
|
||||
$statement->transactions()->save($transaction);
|
||||
if (!$statementTransaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $transaction;
|
||||
$owner = $statementTransaction->owners()->firstOrCreate([
|
||||
'type' => StatementTransactionOwnerType::WALLET_TOP_UP,
|
||||
'system' => 'LITE',
|
||||
'owner_reference'=> $row[0],
|
||||
]);
|
||||
|
||||
return $owner;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class UpdateStatementTransactionStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
$statementTrasaction = $this->fetchesBankStatementTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$statementTrasactionOwner = $statementTrasaction->owners->first();
|
||||
$statementTrasactionOwner = $statementTrasaction->owners()->where('status', '!=', ApprovalStatus::REJECTED)->first();
|
||||
|
||||
$this->updatesBankStatementTransactionOwnerStatus->execute($statementTrasactionOwner, $request->route('status') == 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
|
||||
@@ -56,7 +56,9 @@ class StatementTransaction extends Model
|
||||
|
||||
public function scopeDoesntMapStatement($query)
|
||||
{
|
||||
$query->whereDoesntHave('owners', function($query){
|
||||
$query->whereHas('account', function($query) {
|
||||
$query->where('statement_accounts.number', 568603010762);
|
||||
})->whereDoesntHave('owners', function($query){
|
||||
return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
})->orderBy('posting_date');
|
||||
}
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@
|
||||
case 'Sales':
|
||||
return ['Exchange', 'Izyim', 'Lite', 'Cntr', 'Probashi', 'Pets'];
|
||||
case 'Top Up':
|
||||
return ['Exchange', 'Izyim'];
|
||||
return ['Exchange', 'Izyim', 'Lite'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@
|
||||
<div class="row">
|
||||
<div class="col">{{item.owners.pending_verification[0].system}}</div>
|
||||
<div class="col">{{ typeString(item.owners.pending_verification[0].type) }}</div>
|
||||
<div class="col"><a :href="item.owners.pending_verification[0].reference_link" target="_blank">{{item.owners.pending_verification[0].reference}}</a></div>
|
||||
<div class="col" v-if="item.owners.pending_verification[0].system === 'LITE' && typeString(item.owners.pending_verification[0].type) == 'Wallet Top Up'"><a :href="'https://lite.cief-malaysia.com/admin/index.php?route=sale/topup&filter_topup_id=' + item.owners.pending_verification[0].reference" target="_blank">{{item.owners.pending_verification[0].reference}}</a></div>
|
||||
<div class="col" v-else><a :href="item.owners.pending_verification[0].reference_link" target="_blank">{{item.owners.pending_verification[0].reference}}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user