-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Core] Shipment taxes #3907
[Core] Shipment taxes #3907
Conversation
efa9bff
to
4e7700b
Compare
And the following payment methods exist: | ||
| code | name | gateway | enabled | calculator | calculator_configuration | | ||
| PM1 | Dummy | dummy | yes | fixed | amount: 0 | | ||
| code | name | gateway | enabled | calculator | calculator_configuration | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? :)
4e7700b
to
5830f45
Compare
* @param string $label | ||
* @param bool $included | ||
*/ | ||
private function addAdjustment($order, $taxAmount, $label, $included) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addAdjustment
method is a duplicate of what appears in the Sylius\Bundle\CoreBundle\OrderProcessing\OrderShipmentTaxesApplicator
service. Consider moving this out into an adjustment factory service.
Thank you for adding this feature @Zales0123 👍 |
@tristanbes My pleasure ;) Hope, that together with other tax-related features and whole order logic refactoring it will be useful and powerful solution. |
@Zales0123 required rebase, as it will make the review easier. |
5830f45
to
e0de8b1
Compare
|
||
$percentageAmount = $taxRate->getAmountAsPercentage(); | ||
$taxAmount = $this->calculator->calculate($lastShipping->getAmount(), $taxRate); | ||
$label = sprintf('%s (%s%%)', $taxRate->getName(), (float) $percentageAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to getLabel
method on TaxRate
model.
I see it this way:
and then two implementations of
Then in
@Zales0123 WDYT? |
* @param OrderInterface $order | ||
* @param ZoneInterface $zone | ||
*/ | ||
protected function processUnitsTaxes(OrderInterface $order, ZoneInterface $zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be extracted to OrderItemsByZoneTaxesApplicator
} | ||
|
||
$units = $item->getUnits(); | ||
if ($units->isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (0 === $item->getQuantity())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for now but we need to rethink the behavior of isEmpty
method on the order. Normally we should use it here, but it checks if there are any items.
086f990
to
c65077d
Compare
/** | ||
* @author Mateusz Zalewski <[email protected]> | ||
*/ | ||
class OrderItemsByZoneTaxesApplicator implements OrderTaxesByZoneApplicatorInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO better name OrderItemsTaxesByZoneApplicator
It should implement OrderItemsByZoneTaxesApplicatorInterface
edc90a4
to
190369d
Compare
190369d
to
78253d3
Compare
Wooo, great work Mateusz! 👍 |
This PR is based on #3868.
Here there comes some next improvements with taxes ;)
ShippingMethod
becomes taxable so no we can apply some new taxes based on shipping fee. For now, taxes are applied onOrder
level. There are also two new servicesOrderUnitsTaxesApplicator
andOrderShipmentTaxesApplicator
(I think naming should be discussed), which are injected to mainOrderTaxesApplicator
, to split taxes-application logic.