Added fullcustomer (Xinonkunde) as addresstype, will create fibu account

This commit is contained in:
Frank Schubert
2025-01-07 15:07:43 +01:00
parent e20af3eca5
commit 0a48808cfe
5 changed files with 53 additions and 2 deletions

View File

@@ -20,7 +20,7 @@ class Address extends mfBaseModel {
private $creator;
private $editor;
protected function afterSave() {
public function afterSave() {
// prevent potential infinite loop
if($this->in_after_save) return true;
$this->in_after_save++;
@@ -91,13 +91,26 @@ class Address extends mfBaseModel {
} elseif(OrderModel::getFirst(["billingaddress_id" => $this->id])) {
$create_fibu_num = true;
}
if(is_array($this->getProperty("types")) && array_key_exists("fullcustomer", $this->getProperty("types")) && $this->getProperty("types")["fullcustomer"]) {
$create_fibu_num = true;
}
}
if(!$create_fibu_num) {
return false;
}
if(!$this->customer_number) {
// create customer number first
$new_custnum = $this->getNewCustomerNumber();
if(!$new_custnum) {
return false;
}
$this->customer_number = $new_custnum;
$this->save();
}
$fibu_account_number = Address::getNextFibuAccountNumber();
if(!$fibu_account_number) {

View File

@@ -461,6 +461,9 @@ class AddressController extends mfBaseController {
}
}
// run afterSave() again in case anything importand has changed
$address->afterSave();
$sq = "";
$query = [];