bugfix if no results in subquery for BillDetails

This commit is contained in:
Markus 2023-11-03 21:20:36 +01:00
parent ae3ae2df5d
commit 77d4fd938c

View File

@ -27,18 +27,30 @@ class mBills extends Model {
$quelle = model('App\Models\mAccounts');
$this->where('datum >=', date( 'Y-m-d', strtotime($start)));
$this->where('datum <=', date( 'Y-m-d', strtotime($ende)));
// alle Detailsbuchungen wo account id übereinstimmt
if ($source > 0) {
$subs = $details->select('bill_id')->where('account_id',$source)->findAll();
$keys=array();
foreach ($subs as $value) {
$keys[] = intval($value->bill_id);
// log_message('error', 'Get Entries Det {msg}', ['msg'=>(string)$this->db->getLastQuery()]);
if (0 < sizeof($subs)){
$keys=array();
foreach ($subs as $value) {
$keys[] = intval($value->bill_id);
}
$this->groupStart();
$this->where('source_id', $source );
$this->orWhereIn('id', $keys );
$this->groupEnd();
} else {
$this->where('source_id', $source );
}
$this->groupStart();
$this->where('source_id', $source );
$this->orWhereIn('id', $keys );
$this->groupEnd();
}
$result = $this->orderBy('datum','desc')->where('lkz',null)->findAll();
if (0 == sizeof($result)){
return $result;
}
$keys=array();
foreach ($result as $value) {
$keys[] = intval($value->id);