protected function updateFromParent(CustomerInterface $customer)
    {
        if (!$customer->hasParent()) {
            // Make sure default invoice and delivery address exists.
            if (null === $customer->getDefaultInvoiceAddress()) {
                /** @var \Ekyna\Component\Commerce\Customer\Model\CustomerAddressInterface $address */
                if (false !== $address = $customer->getAddresses()->first()) {
                    $address->setInvoiceDefault(true);
                    $this->persistenceHelper->persistAndRecompute($address, false);
                }
            }
            if (null === $customer->getDefaultDeliveryAddress()) {
                /** @var \Ekyna\Component\Commerce\Customer\Model\CustomerAddressInterface $address */
                if (false !== $address = $customer->getAddresses()->first()) {
                    $address->setDeliveryDefault(true);
                    $this->persistenceHelper->persistAndRecompute($address, false);
                }
            }
            return false;
        }

        $parent = $customer->getParent();
        $changed = false;

        // Company
        if (empty($customer->getCompany())) {
            $company = $parent->getCompany();
            if ($company != $customer->getCompany()) {
                $customer->setCompany($company);
                $changed = true;
            }
        }

        // Customer group
        $group = $parent->getCustomerGroup();
        if ($group !== $customer->getCustomerGroup()) {
            $customer->setCustomerGroup($group);
            $changed = true;
        }

        // Clear VAT info
        if (!empty($customer->getVatNumber())) {
            $customer->setVatNumber(null);
            $changed = true;
        }
        if (!empty($customer->getVatDetails())) {
            $customer->setVatDetails([]);
            $changed = true;
        }
        if ($customer->isVatValid()) {
            $customer->setVatValid(false);
            $changed = true;
        }

        // Clear payment term
        if (null !== $customer->getPaymentTerm()) {
            $customer->setPaymentTerm(null);
            $changed = true;
        }
        // Clear outstanding
        if (0 !== $customer->getOutstandingLimit()) {
            $customer->setOutstandingLimit(0);
            $changed = true;
        }
        // TODO (?) Clear balance
        /*if (0 !== $customer->getOutstandingBalance()) {
            $customer->setOutstandingBalance(0);
            $changed = true;
        }*/

        return $changed;
    }
protected function updateFromParent(CustomerInterface $customer)
    {
        if (!$customer->hasParent()) {
            // Make sure default invoice and delivery address exists.
            if (null === $customer->getDefaultInvoiceAddress()) {
                /** @var \Ekyna\Component\Commerce\Customer\Model\CustomerAddressInterface $address */
                if (false !== $address = $customer->getAddresses()->first()) {
                    $address->setInvoiceDefault(true);
                    $this->persistenceHelper->persistAndRecompute($address, false);
                }
            }
            if (null === $customer->getDefaultDeliveryAddress()) {
                /** @var \Ekyna\Component\Commerce\Customer\Model\CustomerAddressInterface $address */
                if (false !== $address = $customer->getAddresses()->first()) {
                    $address->setDeliveryDefault(true);
                    $this->persistenceHelper->persistAndRecompute($address, false);
                }
            }
            return false;
        }

        $parent = $customer->getParent();
        $changed = false;

        // Company
        if (empty($customer->getCompany())) {
            $company = $parent->getCompany();
            if ($company != $customer->getCompany()) {
                $customer->setCompany($company);
                $changed = true;
            }
        }

        // Customer group
        $group = $parent->getCustomerGroup();
        if ($group !== $customer->getCustomerGroup()) {
            $customer->setCustomerGroup($group);
            $changed = true;
        }

        // Clear VAT info
        if (!empty($customer->getVatNumber())) {
            $customer->setVatNumber(null);
            $changed = true;
        }
        if (!empty($customer->getVatDetails())) {
            $customer->setVatDetails([]);
            $changed = true;
        }
        if ($customer->isVatValid()) {
            $customer->setVatValid(false);
            $changed = true;
        }

        // Clear payment term
        if (null !== $customer->getPaymentTerm()) {
            $customer->setPaymentTerm(null);
            $changed = true;
        }
        // Clear outstanding
        if (0 !== $customer->getOutstandingLimit()) {
            $customer->setOutstandingLimit(0);
            $changed = true;
        }
        // TODO (?) Clear balance
        /*if (0 !== $customer->getOutstandingBalance()) {
            $customer->setOutstandingBalance(0);
            $changed = true;
        }*/

        return $changed;
    }
protected function updateFromParent ( CustomerInterface $ customer ) { if ( ! $ customer -> hasParent ( ) ) { // Make sure default invoice and delivery address exists. if ( null === $ customer -> getDefaultInvoiceAddress ( ) ) { /** @var \Ekyna\Component\Commerce\Customer\Model\CustomerAddressInterface $address */ if ( false !== $ address = $ customer -> getAddresses ( ) -> first ( ) ) { $ address -> setInvoiceDefault ( true ) ; $ this -> persistenceHelper -> persistAndRecompute ( $ address , false ) ; } } if ( null === $ customer -> getDefaultDeliveryAddress ( ) ) { /** @var \Ekyna\Component\Commerce\Customer\Model\CustomerAddressInterface $address */ if ( false !== $ address = $ customer -> getAddresses ( ) -> first ( ) ) { $ address -> setDeliveryDefault ( true ) ; $ this -> persistenceHelper -> persistAndRecompute ( $ address , false ) ; } } return false ; } $ parent = $ customer -> getParent ( ) ; $ changed = false ; // Company if ( empty ( $ customer -> getCompany ( ) ) ) { $ company = $ parent -> getCompany ( ) ; if ( $ company != $ customer -> getCompany ( ) ) { $ customer -> setCompany ( $ company ) ; $ changed = true ; } } // Customer group $ group = $ parent -> getCustomerGroup ( ) ; if ( $ group !== $ customer -> getCustomerGroup ( ) ) { $ customer -> setCustomerGroup ( $ group ) ; $ changed = true ; } // Clear VAT info if ( ! empty ( $ customer -> getVatNumber ( ) ) ) { $ customer -> setVatNumber ( null ) ; $ changed = true ; } if ( ! empty ( $ customer -> getVatDetails ( ) ) ) { $ customer -> setVatDetails ( [ ] ) ; $ changed = true ; } if ( $ customer -> isVatValid ( ) ) { $ customer -> setVatValid ( false ) ; $ changed = true ; } // Clear payment term if ( null !== $ customer -> getPaymentTerm ( ) ) { $ customer -> setPaymentTerm ( null ) ; $ changed = true ; } // Clear outstanding if ( 0 !== $ customer -> getOutstandingLimit ( ) ) { $ customer -> setOutstandingLimit ( 0 ) ; $ changed = true ; } // TODO (?) Clear balance /*if (0 !== $customer->getOutstandingBalance()) {
            $customer->setOutstandingBalance(0);
            $changed = true;
        }*/ return $ changed ; }
Updates from parent.

@param CustomerInterface $customer

@return bool
Updates from parent .