Skip to content
Code-Schnipsel Gruppen Projekte
Commit 9b9d532f erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'next-3.x' into 'main'

fix: customer id was not passed on correctly

See merge request !141
Übergeordnete fc57ac5b c8d97918
No related branches found
Tags 3.7.5
2 Merge Requests!141fix: customer id was not passed on correctly,!140Update 'next-4.x' with latest changes from 'main'
Pipeline #11309 mit Warnungen bestanden mit Phase
in 1 Minute und 8 Sekunden
......@@ -7,7 +7,6 @@
namespace QUI\ERP;
use QUI;
use QUI\Countries\Country;
use QUI\ERP\Customer\NumberRange as CustomerNumberRange;
use QUI\Groups\Group;
use QUI\Interfaces\Users\User as UserInterface;
......@@ -87,7 +86,6 @@ class User extends QUI\QDOM implements UserInterface
* User constructor.
*
* @param array $attributes
* @throws QUI\ERP\Exception
*/
public function __construct(array $attributes)
{
......@@ -152,6 +150,24 @@ public function __construct(array $attributes)
}
$this->isNetto = $this->isNetto();
// if no customer number exists, check whether a customer exists and the customer has a customer number
// this is a fallback (by hen & mor)
if (!$this->getAttribute('customerId')) {
if ($this->uuid) {
try {
$User = QUI::getUsers()->get($this->uuid);
$this->setAttribute('customerId', $User->getAttribute('customerId'));
} catch (QUI\Exception) {
}
} elseif ($this->id) {
try {
$User = QUI::getUsers()->get($this->id);
$this->setAttribute('customerId', $User->getAttribute('customerId'));
} catch (QUI\Exception) {
}
}
}
}
/**
......@@ -221,6 +237,7 @@ public static function convertUserToErpUser(UserInterface $User): User
return new self([
'id' => $User->getId(),
'customerId' => $User->getAttribute('customerId'),
'uuid' => $User->getUUID(),
'country' => $country,
'username' => $User->getUsername(),
......
......@@ -324,6 +324,7 @@ public static function filterCustomerAttributes(array $attributes = []): array
$needle = [
'uuid',
'id',
'customerId',
'email',
'lang',
'usergroup',
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren