Address::syncToFibuMerge() knows about > 900000 customer numbers now

This commit is contained in:
Frank Schubert
2024-01-18 20:10:22 +01:00
parent e9f52190e0
commit d2297ab0a9
2 changed files with 17 additions and 6 deletions

View File

@@ -69,12 +69,17 @@ class Address extends mfBaseModel {
$me->loadMe();
if($this->fibu_account_number) {
$fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $this->customer_number]);
$old_custnum = $this->customer_number;
if($old_custnum > 900000) {
$old_custnum -= 900000;
}
$fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $old_custnum]);
if(!$fibumerge) {
// create fibu merge
$fibumerge = XinonFibuMergeModel::create([
"source" => "t",
"old_custnum" => $this->customer_number,
"old_custnum" => $old_custnum,
"new_custnum" => $this->fibu_account_number,
"name" => ($this->company) ? $this->company : $this->lastname,
"vorname" => ($this->company) ? "" : $this->firstname,
@@ -87,7 +92,7 @@ class Address extends mfBaseModel {
$fibumerge->save();
return true;
}
if($fibumerge->new_custnum != $this->fibu_account_number) {
$fibumerge->new_custnum = $this->fibu_account_number;
$fibumerge->save();