Added Vatgroup & Vatrate
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user