mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
import bank record
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Company;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
@@ -32,6 +33,7 @@ class ImportBankRecordController
|
||||
'Human Reference',
|
||||
'Multiple',
|
||||
'Match?',
|
||||
'System Amount'
|
||||
];
|
||||
|
||||
$branches = [
|
||||
@@ -50,29 +52,46 @@ class ImportBankRecordController
|
||||
$branch = $branches[$key];
|
||||
foreach ($sheet as $row) {
|
||||
$date = Date::excelToDateTimeObject($row['date']);
|
||||
$description = $row['description'];
|
||||
$credit = (float) $row['credit'];
|
||||
$debit = (float) $row['debit'];
|
||||
$creditTransactions = [];
|
||||
$debitTransactions = [];
|
||||
|
||||
$systemReference = null;
|
||||
$systemAmount = null;
|
||||
|
||||
if($credit){
|
||||
$creditTransactions = $this->getTransactions($date, $credit, TransactionType::PAYMENT, Booking::class, PaymentMethodType::WALLET, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
foreach ($creditTransactions as $transaction) {
|
||||
$systemReference[] = $transaction->owner instanceof Booking ? $transaction->owner->marking : $transaction->bill_no;
|
||||
$systemAmount[] = $transaction->amount;
|
||||
}
|
||||
|
||||
$creditTransactions = $this->getTransactions($date, $credit, TransactionType::TOP_UP, Wallet::class, null, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
foreach ($creditTransactions as $transaction) {
|
||||
$systemReference[] = $transaction->owner instanceof Booking ? $transaction->owner->marking : $transaction->bill_no;
|
||||
$systemAmount[] = $transaction->amount;
|
||||
}
|
||||
}
|
||||
|
||||
if($debit){
|
||||
$debitTransactions = $this->getTransactions($date, $debit, null, null, null, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED], Group::class);
|
||||
|
||||
if(!$debitTransactions) {
|
||||
foreach (['YSN', 'HCK', 'AVANTIC', 'HIGH HILL'] as $reference){
|
||||
if(str_contains($description, $reference)) {
|
||||
$issuer = Company::where('name', 'like', '%'.$reference.'%')->get()->pluck('id');
|
||||
$debitTransactions = Group::whereIn('issuer', $issuer)->whereDate('created_at', $date->format('Y-m-d'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($debitTransactions as $transaction) {
|
||||
$systemReference[] = $transaction->reference;
|
||||
$systemAmount[] = $transaction->amount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,13 +103,14 @@ class ImportBankRecordController
|
||||
|
||||
|
||||
$systemReference = $systemReference ? implode(',', $systemReference) : null;
|
||||
$systemAmount = $systemAmount ? implode(',', $systemAmount) : null;
|
||||
|
||||
$matches = $systemReference == $row['remarkreferences'] ? $yes : $no;
|
||||
|
||||
$table .= '<tr>
|
||||
<td>'.$date->format('d-m-Y').'</td>
|
||||
<td>'.$branch.'</td>
|
||||
<td>'.$row['description'].'</td>
|
||||
<td>'.$description.'</td>
|
||||
<td>'.$credit.'</td>
|
||||
<td>'.$debit.'</td>
|
||||
<td>'.$row['pay_for'].'</td>
|
||||
@@ -98,6 +118,7 @@ class ImportBankRecordController
|
||||
<td>'.$row['remarkreferences'].'</td>
|
||||
<td>'.$multiple.'</td>
|
||||
<td>'.$matches.'</td>
|
||||
<td>'.$systemAmount.'</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user