WIP Contract/Billing 2024-07-04

This commit is contained in:
Frank Schubert
2024-07-05 10:45:22 +02:00
parent 0640babfa3
commit 92edb9c812
27 changed files with 8043 additions and 116 deletions

View File

@@ -27,6 +27,8 @@ class Contract extends mfBaseModel {
private $productchangeTo;
private $relocationFrom;
private $relocationTo;
private $vatgroup;
private $vatrate;
private $finisher;
private $canceler;
private $creator;
@@ -193,6 +195,15 @@ class Contract extends mfBaseModel {
}
public function getConfigValue($itemname) {
$configvalues = $this->getProperty("configvalues");
if(!$configvalues) return null;
if(!array_key_exists($itemname, $configvalues)) return null;
$confitem = $configvalues[$itemname];
return $confitem->value;
}
public function getProperty($name) {
if($this->$name == null) {
@@ -292,6 +303,19 @@ class Contract extends mfBaseModel {
return $this->contractConfigItems;
}*/
if($name == "vatrate") {
$vatgroup = $this->getProperty("vatgroup");
$country = $this->getProperty("country");
$vatrate = $vatgroup->rates["domestic"]->rate;
if($this->country_id && $country->is_eu) {
$vatrate = $vatgroup->rates["eu"]->rate;
} if($this->country_id && !$country->is_eu) {
$vatrate = $vatgroup->rates["other"]->rate;
}
$this->vatrate = $vatrate;
return $this->vatrate;
}
if($name == "journals") {
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));