enhance import invoice mapping conditions

This commit is contained in:
Steve Ng
2023-10-15 22:42:47 +08:00
parent 521260d69f
commit 829ea9ad17
3 changed files with 21 additions and 16 deletions
@@ -140,8 +140,14 @@ class ImportStatementInvoiceController
$transactions = Transaction::where('original_amount', $row['net_total'])->whereRaw("DATE(created_at) = '$date'")
->whereHas('receiverCompany', function($q) use($row) {
$q->where('debtor',$row['debtor_code']);
})
->get();
})->get();
if ($transactions && $transactions->count() == 0) {
$transactions = Transaction::where(DB::raw('FLOOR(original_amount)'), floor($row['net_total']))->whereRaw("DATE(created_at) = '$date'")
->whereHas('receiverCompany', function($q) use($row) {
$q->where('debtor',$row['debtor_code']);
})->get();
}
if ($transactions && $transactions->count() == 1) {
foreach ($transactions as $key => $transaction) {