Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.

Company account with multiple users#15

Merged
Miroslav-Stopka merged 12 commits into
masterfrom
msa-company-with-users
Sep 10, 2018
Merged

Company account with multiple users#15
Miroslav-Stopka merged 12 commits into
masterfrom
msa-company-with-users

Conversation

@Miroslav-Stopka
Copy link
Copy Markdown
Contributor

Q A
Description, reason for the PR
The administrator needs to be able to create user accounts grouped under one company account. Individual company users have separate login credentials but they will share some attributes - for example a billing address.
New feature Yes
BC breaks No
Fixes issues
Standards and tests pass Yes
Have you read and signed our License Agreement for contributions? Yes

Copy link
Copy Markdown
Contributor

@vitek-rostislav vitek-rostislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, the review is done 🙂 Hats off to you! 🥇

*
* New state:
* - Mapping of child class property is overriden only if:
* - or mapping of child class property is equal to mapping of parent class property
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the first "or" 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be change to either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/Shopsys/ShopBundle/Component/EntityExtension/LoadORMMetadataSubscriber.php Outdated
$overriddingClassReflection = new \ReflectionClass($class);
$overiddingClassProperties = $overriddingClassReflection->getProperties();

$isOverridenPropertyInChildClass = $this->checkIsOverridenPropertyInChildClass($overiddingClassProperties, $name, $class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the word is correctly spelled "overridden" - both in the variable and the private method name...
#nitpick 😇

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and in the comment above the method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @param \Shopsys\ShopBundle\Model\Customer\User[] $users
* @return \Shopsys\ShopBundle\Model\Customer\UserData[]
*/
public function createMultipleUserDataFromUsers(array $users)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is never used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right and removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong and returned :D It is used in CustomerController :D

Comment thread src/Shopsys/ShopBundle/Model/Customer/UserRepository.php
use Shopsys\FrameworkBundle\Model\Order\Item\OrderProduct;
use Shopsys\FrameworkBundle\Model\Order\Item\OrderTransport;
use Shopsys\FrameworkBundle\Model\Order\Order;
use Shopsys\FrameworkBundle\Model\Order\Order as ExtendedOrder;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it not working before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im thinking, both ways are functional. Should I change to ShopBundle?

Comment thread src/Shopsys/ShopBundle/Twig/FormThemeExtension.php Outdated
Copy link
Copy Markdown
Contributor

@vitek-rostislav vitek-rostislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, just a few final notes from CR, please check them out.

I also tested it and:

  • when dynamically adding new company users in admin, javascript validation does not work for the fields (Shopsys.register.registerCallback and Shopsys.register.registerNewContent should help you here 🙂 )
  • there is an unhandled exception (UniqueConstraintViolationException) when trying to add new company user with already registered email
  • company users created on company edit page are not visible in the customers list admin/customer/list/ - is this intended? How can I get on an admin detail page of those customers?
  • is it ok that a particular company customer sees all company orders (even those that were not created by himself?) (on FE customer/orders/)


if (!$('.js-is-company-with-multiple-users').prop('checked')) {
Shopsys.companyData.changeSetUpCompanyWithMultipleUsers(false);
Shopsys.companyData.unsetUpCompanyWithMultipleUsers();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please rename to unsetCompanyWithMultipleUsers? That "Up" is weird there 😇


Shopsys\FrameworkBundle\Model\Customer\CustomerFacade: '@Shopsys\ShopBundle\Model\Customer\CustomerFacade'

Shopsys\ShopBundle\Model\Customer\UserRepository: ~
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove OrderRepository as well 🙂

- after the change it is possible to overwrite the already existing property of an entity even with the possibility of overwriting the orm associations of this property
- before the change the final associations of the new property were automatically taken over from the original property
…t is a company with multiple users

- customer with a billing address that belongs to a company with multiple users, can not edit the billing address in a personal data or in the order
- billing address represents a company, so multiple customers of the same billing address mean multiple users of the same company
…des all the orders of the customers from the same company
- customer section in admin displays list of billing addresses instead of users because on billing address can have multiple users
- customers list in admin is simplified because of company accounts with multiple users
- in the case of request for standard account - isCompanyWithMultipleUsers === false - is displayed standard edit form for customer
- in the case of request for multiple users companz account - isCompanyWithMultipleUsers === true - is displayed company edit form for with list of company users
- UserData contains new property id to allow efective and clear manipulation with entries of users in the list of company users
- in the case of cancellation of setup of company with multiple users, they are removed all company users except one for preserving company account
- js code is part of twig templates because of problems with adding new custom js for admin
- EntityExtensionTest merge original extension map with tested custom extended entities
@Miroslav-Stopka Miroslav-Stopka merged commit e7c2d84 into master Sep 10, 2018
@Miroslav-Stopka Miroslav-Stopka deleted the msa-company-with-users branch December 11, 2018 15:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants