mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
working on data matching
This commit is contained in:
parent
3b1d0e07e2
commit
de33548908
@ -48,38 +48,61 @@ class BankService implements ShouldQueue
|
|||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$this->match();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function match($transactions): array
|
private function match()
|
||||||
{
|
{
|
||||||
|
BankTransaction::where('company_id', $this->company->id)
|
||||||
|
->where('is_matched', false)
|
||||||
|
->cursor()
|
||||||
|
->each(function ($bt){
|
||||||
|
|
||||||
|
$invoice = $this->invoices->first(function ($value, $key) use ($bt){
|
||||||
|
|
||||||
foreach($transactions as $transaction)
|
return str_contains($value->number, $bt->description);
|
||||||
{
|
|
||||||
$this->matchIncome($transaction);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return $transactions;
|
if($invoice)
|
||||||
|
{
|
||||||
|
$bt->invoice_id = $invoice->id;
|
||||||
|
$bt->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function matchExpense()
|
// public function match($transactions): array
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// foreach($transactions as $transaction)
|
||||||
|
// {
|
||||||
|
// $this->matchIncome($transaction);
|
||||||
|
// }
|
||||||
|
|
||||||
private function matchIncome($transaction)
|
// return $transactions;
|
||||||
{
|
// }
|
||||||
$description = str_replace(" ", "", $transaction->description);
|
|
||||||
|
|
||||||
$invoice = $this->invoices->first(function ($value, $key) use ($description){
|
// private function matchExpense()
|
||||||
|
// {
|
||||||
|
|
||||||
return str_contains($value->number, $description);
|
// }
|
||||||
|
|
||||||
|
// private function matchIncome($transaction)
|
||||||
|
// {
|
||||||
|
// $description = str_replace(" ", "", $transaction->description);
|
||||||
|
|
||||||
|
// $invoice = $this->invoices->first(function ($value, $key) use ($description){
|
||||||
|
|
||||||
|
// return str_contains($value->number, $description);
|
||||||
|
|
||||||
});
|
// });
|
||||||
|
|
||||||
if($invoice)
|
// if($invoice)
|
||||||
$transaction['invocie_id'] = $invoice->hashed_id;
|
// $transaction['invocie_id'] = $invoice->hashed_id;
|
||||||
|
|
||||||
return $transaction;
|
// return $transaction;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user