Added Vatgroup & Vatrate

This commit is contained in:
Frank Schubert
2024-02-20 22:12:59 +01:00
parent cdb1f1fef7
commit 7cb5ac6329
10 changed files with 613 additions and 30 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
class Vatgroup extends mfBaseModel {
private $rates;
private function loadRates() {
foreach(VatrateModel::search(["vatgroup_id" => $this->id]) as $rate) {
$this->rates[$rate->area] = $rate;
}
return $this->rates;
}
public function getProperty($name) {
if($this->$name == null) {
if(!$this->id) {
return null;
}
if($name == "rates") {
return $this->loadRates();
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}