mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 07:23:59 +00:00
import bank record
This commit is contained in:
@@ -8,6 +8,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\Group;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -30,6 +31,7 @@ class ImportBankRecordController
|
||||
<th>Bank</th>
|
||||
<th>Description</th>
|
||||
<th>Credit</th>
|
||||
<th>debit</th>
|
||||
<th>Pay For</th>
|
||||
<th>System Reference</th>
|
||||
<th>Human Reference</th>
|
||||
@@ -49,39 +51,70 @@ class ImportBankRecordController
|
||||
foreach ($sheet as $row) {
|
||||
$date = Date::excelToDateTimeObject($row['date']);
|
||||
$credit = (float) $row['credit'];
|
||||
$debit = (float) $row['debit'];
|
||||
$systemReference = null;
|
||||
$multiple = 'No';
|
||||
|
||||
$transactions = Transaction::whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->where(function ($query){
|
||||
return $query->where(function ($query){
|
||||
return $query->where('type', TransactionType::PAYMENT)->where('owner_type', Booking::class)->where('payment_method', '!=', PaymentMethodType::WALLET);
|
||||
})->orWhere(function ($query){
|
||||
$query->where('type', TransactionType::TOP_UP);
|
||||
});
|
||||
})
|
||||
->WhereDate('created_at', $date->format('Y-m-d'))
|
||||
->where('amount', '>', ($credit - 0.01))->where('amount', '<', ($credit + 0.01))
|
||||
->get();
|
||||
|
||||
if(count($transactions)) {
|
||||
foreach ($transactions as $transaction){
|
||||
if($transaction->owner instanceof Booking){
|
||||
$systemReference[] = $transaction->owner->marking;
|
||||
|
||||
if($credit){
|
||||
$payments = Transaction::whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->where(function ($query){
|
||||
return $query->where(function ($query){
|
||||
return $query->where('type', TransactionType::PAYMENT)->where('owner_type', Booking::class)->where('payment_method', '!=', PaymentMethodType::WALLET);
|
||||
})->orWhere(function ($query){
|
||||
$query->where('type', TransactionType::TOP_UP);
|
||||
});
|
||||
})
|
||||
->WhereDate('created_at', $date->format('Y-m-d'))
|
||||
->where('amount', '>', ($credit - 0.01))->where('amount', '<', ($credit + 0.01))
|
||||
->get();
|
||||
|
||||
if(count($payments)) {
|
||||
foreach ($payments as $transaction){
|
||||
if($transaction->owner instanceof Booking){
|
||||
$systemReference[] = $transaction->owner->marking;
|
||||
}
|
||||
|
||||
if($transaction->owner instanceof Wallet){
|
||||
$systemReference[] = $transaction->bill_no;
|
||||
}
|
||||
}
|
||||
|
||||
if($transaction->owner instanceof Wallet){
|
||||
$systemReference[] = $transaction->bill_no;
|
||||
if(count($systemReference) > 1) {
|
||||
$multiple = 'Yes';
|
||||
}
|
||||
}
|
||||
$systemReference = implode(',', $systemReference);
|
||||
|
||||
}
|
||||
}
|
||||
if($debit){
|
||||
$bills = Group::WhereDate('created_at', $date->format('Y-m-d'))
|
||||
->where('amount', '>', ($debit - 0.01))->where('amount', '<', ($debit + 0.01))
|
||||
->get();
|
||||
|
||||
if(count($bills)) {
|
||||
foreach ($bills as $transaction){
|
||||
if($transaction->owner instanceof Booking){
|
||||
$systemReference[] = $transaction->owner->marking;
|
||||
}
|
||||
|
||||
if($transaction->owner instanceof Wallet){
|
||||
$systemReference[] = $transaction->bill_no;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($systemReference) > 1) {
|
||||
$multiple = 'Yes';
|
||||
}
|
||||
$systemReference = implode(',', $systemReference);
|
||||
|
||||
if(count($systemReference) > 1) {
|
||||
$multiple = 'Yes';
|
||||
}
|
||||
$systemReference = implode(',', $systemReference);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$matches = $systemReference == $row['remarkreferences'] ? 'Yes' : 'No';
|
||||
|
||||
echo '<tr>
|
||||
@@ -89,6 +122,7 @@ class ImportBankRecordController
|
||||
<td>'.$branch.'</td>
|
||||
<td>'.$row['description'].'</td>
|
||||
<td>'.$credit.'</td>
|
||||
<td>'.$debit.'</td>
|
||||
<td>'.$row['pay_for'].'</td>
|
||||
<td>'.$systemReference.'</td>
|
||||
<td>'.$row['remarkreferences'].'</td>
|
||||
|
||||
Reference in New Issue
Block a user