rechnungsanhang handlign

charts bugfix only empty database
This commit is contained in:
Markus
2026-06-08 15:58:11 +02:00
parent aedd66202a
commit 6457f38f01
7 changed files with 117 additions and 96 deletions

View File

@@ -6,12 +6,17 @@ use App\Models\Mcategories;
class mBills extends Model {
protected $table = 'budget_bills';
protected $primaryKey = 'id';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'object';
protected $useSoftDeletes = false;
//TODO timestamps aktivieren
// protected $createdField = 'created_at';
// protected $updatedField = 'updated_at';
// protected $deletedField = 'deleted_at';
protected $allowedFields = ['renummer','datum','receiver','source_id','amount','type','comment','validate','lkz','rechnung'];
@@ -131,45 +136,19 @@ class mBills extends Model {
return $result;
}
function getAccountsBalance(){
// $this->select('SUM(amount) as amount, source_id as idd, budget_accounts.description',FALSE);
// $this->groupby('source_id')->asArray();
// $this->join('budget_accounts', 'budget_accounts.id = budget_bills.source_id', 'left');
// $this->where('budget_accounts.type','account');
// $this->where('budget_accounts.lkz',null);
// $this->where('budget_bills.validate',false);
// $result1 = $this->where('budget_bills.lkz',null)->findAll();
// $assoc1 = array();
// foreach ($result1 as $value) {
// $assoc1[$value['idd']] = $value;
// }
// $details = model('App\Models\mBillDetails');
// $details->select('SUM((-1)*subamount) as amount, account_id as idd, budget_accounts.description',FALSE);
// $details->groupby('account_id')->asArray();
// $details->join('budget_accounts', 'budget_accounts.id = budget_billdetails.account_id', 'left');
// $details->join('budget_bills', 'budget_bills.id = budget_billdetails.bill_id', 'left');
// $details->where('budget_accounts.type','account');
// $details->where('budget_bills.validate',false);
// $details->where('budget_accounts.lkz',NULL);
// $result3 = $details->where('budget_billdetails.lkz',NULL)->findAll();
// $assoc3 = array();
// foreach ($result3 as $value) {
// $assoc3[$value['idd']] = $value;
// }
// $sums = array();
// foreach (array_keys($assoc1 + $assoc3) as $key) {
// $obj = new \stdClass;
// $obj->amount = (isset($assoc1[$key]) ? floatval($assoc1[$key]['amount']) : 0) + (isset($assoc3[$key]) ? floatval($assoc3[$key]['amount']) : 0);
// $obj->description = isset($assoc1[$key]) ? $assoc1[$key]['description'] : $assoc3[$key]['description'];
// $sums[] = $obj;
// }
$sums = $this->db->query("SELECT * FROM get_account_balance4()");
//$this->from("get_account_balance4()")->findAll();
// $this->groupby('source_id')->asArray();
return $sums->getResult();
}
public function saveBill($data){
public function storeBillFile(int $billId, string $filename){
$this->update($billId, [ 'rechnung' => $filename ]);
}
public function deleteBillFile(int $billId){
$this->set('rechnung', 'NULL',false);
$this->update($billId);
}
public function saveBill($data) : int {
$details = model('App\Models\mBillDetails');
$accounts = model('App\Models\mAccounts');
$this->set('datum', date( "Y-m-d", strtotime($data['datum'] ) ));
@@ -201,7 +180,7 @@ class mBills extends Model {
$this->update($data['id']);
}
$details->saveEntries($data, $billId);
return $billId;
}
/**