Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC][Order] Introduce OrderItemUnit #3771

Merged
merged 11 commits into from
Jan 13, 2016

Conversation

Zales0123
Copy link
Member

Hello everybody!

This is a Proof of Concept PR that illustrates idea how to resolve issues with how adjustments (thus taxes, shipping fees and discounts) are handled on the Order model. It is based on excellent work and research of Peter from REISS.

See corresponding PRs/Issues:

Overview of how Adjustments are handled currently:

  • every adjustment can be set on Order or OrderItem
  • each tax/promotion/etc. can be applied on these two levels

Full rationale for why this is wrong is available in the issues listed above.

Solution:
To fix this problem, we’ve created completely new OrderItemUnit. In this highly preliminary PR, there is a proper model and interface introduced and used as InventoryUnit and ShipmentItem in sylius.yml.

The logic of splitting OrderItem’s quantity into separate OrderItemUnits will be part of Order Component. In Core, to avoid duplication and for performance reasons, OrderItemUnit will implement ShipmentItemInterface and InventoryUnitInterface, thus our current logic regarding shipping and inventory can remain untouched.

Having OrderItemUnits will allow us to apply adjustments more precisely and get the financials right. We can also provide two implementations for any service, like 2 TaxationProcessors, one which applies taxes on OrderItemUnit level (default) and optional for simpler use-cases that applies taxes to Order level.

There is plenty of work with adjustments to make them perfect and suitable for modern e-commerce system which Sylius obviously is, but it can be first, important step to do this. When we do this, we also want to finally clean up the way that totals are calculated and remove this non-sense with setTotal() method. :)

Let me hear your thoughts!

UPDATE:
Related docs PR: Sylius/Sylius-Docs#394

@pjedrzejewski pjedrzejewski added RFC Discussions about potential changes or new features. New Feature labels Dec 23, 2015
@@ -24,7 +24,7 @@

<field name="inventoryState" column="inventory_state" type="string" />

<many-to-one field="stockable" target-entity="Sylius\Component\Inventory\Model\StockableInterface">
<many-to-one field="stockable" target-entity="Sylius\Component\Core\Model\ProductVariant">
Copy link
Contributor

Choose a reason for hiding this comment

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

InventoryBundle shouldn't know about Core :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure it should not! I'm aware about some decoupling issues that can appear in this PR and I will be grateful for pointing them out - it will make my work much easier ;)

Copy link
Member

Choose a reason for hiding this comment

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

This relation should be just removed from here.

@Zales0123 Zales0123 force-pushed the order-item-unit branch 2 times, most recently from 47c865b to f38baa4 Compare December 23, 2015 14:56
@Zales0123 Zales0123 changed the title [RFC][WIP][Order] Introduce OrderItemUnit [RFC][Order] Introduce OrderItemUnit Dec 24, 2015
@Zales0123 Zales0123 force-pushed the order-item-unit branch 3 times, most recently from 7a0b307 to e1538c0 Compare December 28, 2015 15:16
@@ -1,6 +1,6 @@
Sylius\Component\Core\Model\InventoryUnit:
Sylius\Component\Core\Model\OrderItemUnit:
Copy link
Contributor

Choose a reason for hiding this comment

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

File name should be Model.OrderItemUnit.yml

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@Zales0123 Zales0123 force-pushed the order-item-unit branch 2 times, most recently from 94f9f66 to 96a45ab Compare December 29, 2015 14:23

namespace Sylius\Component\Core\Model;

use Sylius\Component\Inventory\Model\InventoryUnitInterface as BaseInventoryUnitInterface;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to make an alias here?

@peteward
Copy link

peteward commented Jan 7, 2016

👍

### Order and SyliusOrderBundle

* Introduced ``OrderItemUnit``, which represents every single unit in ``Order``
* Removed ``InventoryUnit``, as it's replaced by ``OrderItemUnit``, which can be used both as ``InventoryUnit`` and ``ShipmentItem``
Copy link
Member

Choose a reason for hiding this comment

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

Replaced InventoryUnit with OrderItemUnit in the core. This entity will be used as InventoryUnit and ShipmentItem;

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

pjedrzejewski pushed a commit that referenced this pull request Jan 13, 2016
[RFC][Order] Introduce OrderItemUnit
@pjedrzejewski pjedrzejewski merged commit ad032e8 into Sylius:master Jan 13, 2016
@pjedrzejewski
Copy link
Member

Thank you Mateusz and the 2 additional brains behind making sure that Sylius handles $ well - @peteward and @michalmarcinkowski. 👍 Happy rebasing of related PRs. :D

@peteward
Copy link

👍 👍 👍

Great work all.

@PWalkow
Copy link
Contributor

PWalkow commented Jan 22, 2016

Great to see that this one is on such a good path to be finished :)

@Zales0123 Zales0123 deleted the order-item-unit branch October 28, 2016 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Discussions about potential changes or new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants