Sylius / InvoicingPlugin

Generate an Invoice for every placed order
MIT License
79 stars 82 forks source link

Unit price calculation is wrong on line item #311

Open laurentdabbb opened 8 months ago

laurentdabbb commented 8 months ago

Hi,

The "unit_price" stored in _sylius_invoicing_plugin_lineitem is wrong when a promotion is applied on the item. This unit_price is the unit net price stored on lineItem entity in OrderItemUnitsToLineItemsConverter service.

This unit net price is calculated from UnitNetPriceProvider service, but the calculation doesn't seem right.

image

You retrieve unitPrice from orderItem (unit sale price, before discount) and you substract orderItemUnit tax adjustments calculated on the discounted price... So tax amount is not related to the unit sale price.

To reproduce simply apply a cart promotion and compare unitPrice from the Sylius Admin Order page (gross unit sale price if tax are included in price) and the unit net price on the invoice. You can recalculate gross and net price, the amount is wrong.

An example with an order placed on the demo website (https://master.demo.sylius.com), so without custom developments.

image

image

Unit net price of the item "Off shoulder boho dress" should be 24,55$ and not 24,67.

24,67 = 26,27 (order item unit price) - 1,60 (tax amount of the discounted price)

Thanks

t-n-y commented 8 months ago

Hi, I noticed the same issue