Skip to content

Commit

Permalink
fix customer cron with empty address (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Memurame authored Jun 21, 2024
1 parent 9cbcbf0 commit 0d1b82e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/Controllers/CronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@ public function abacusSync(){
}

$customer->syncWithAbacus();

model('CustomerModel')->save($customer);
if($customer->hasChanged()){
model('CustomerModel')->save($customer);
}

}
}
}
4 changes: 2 additions & 2 deletions app/Controllers/CustomersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function addAbacus($addressnumber){
return redirect()->route("customer.index")->with("msg_error", "Kein Abacus Eintrag zu dieser Nummer gefunden. Erstellen eines Kunden kann nicht ausgeführt werden.");
}

$customer = $customerModel->where('addressnumber', $address->abacus)->first();
if($customer){
$checkCustomer = $customerModel->where('addressnumber', $address->abacus)->first();
if($checkCustomer){
return redirect()->route("customer.index")->with("msg_error", "Es existiert bereits ein Kunde mit dieser Adressnumer.");
}

Expand Down
2 changes: 2 additions & 0 deletions app/Entities/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public function syncwithAbacus($addressnumber = null){
$address = model('AbaAddressModel')
->where('abacus', $this->addressnumber)
->first();
if(!$address) return;


$name = $address->lastname;
if($address->firstname) $name .= ' ' . $address->firstname;
Expand Down

0 comments on commit 0d1b82e

Please sign in to comment.