import bank record

This commit is contained in:
Omair Saleh
2023-03-13 01:35:40 +08:00
parent fd4cb62126
commit 106252897f
@@ -24,6 +24,7 @@ class ImportsBankRecord implements ToModel, WithHeadingRow, WithBatchInserts, Wi
{
$date = Date::excelToDateTimeObject($row['date']);
$credit = (float) $row['credit'];
$systemReference = null;
$transaction = Transaction::whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->where('type', TransactionType::PAYMENT)->where('owner_type', Booking::class)
@@ -31,13 +32,25 @@ class ImportsBankRecord implements ToModel, WithHeadingRow, WithBatchInserts, Wi
->where('amount', '>=', $credit)->where('amount', '<', ($credit + 0.01))
->get();
if(!count($transaction)) return;
if(count($transaction)) {
$systemReference = $transaction->pluck('owner.marking')->flatten()->implode(', ');
}
echo '<tr>
<td>'.$date->format('d-m-Y').'</td>
<td>'.$row['description'].'</td>
<td>'.$credit.'</td>
<td>'.$systemReference.'</td>
<td>'.$row['remarkreferences'].'</td>
<td>'.($systemReference === $row['remarkreferences']) ? 'true':'false'.'</td>
</tr>';
// dump([
// 'date' => $date->format('d-m-Y'),
// 'credit' => $credit,
// 'payments' =>
// ]);
dump([
'date' => $date->format('d-m-Y'),
'credit' => $credit,
'payments' => $transaction->pluck('owner.marking')->flatten()->implode(', ')
]);
// try {
// preg_match_all('/([0-9]{3,4}[a-zA-Z]{3,4})/', $row['desc2'], $matches);