Sylius / InvoicingPlugin

Generate an Invoice for every placed order
MIT License
80 stars 84 forks source link

catalog unit price #273

Closed laurentdabbb closed 2 years ago

laurentdabbb commented 2 years ago

Hi,

I try to adapt invoices to comply with French rules : https://www.economie.gouv.fr/entreprises/factures-mentions-obligatoires (in french).

According to French rules, an invoice must include the catalog unit price : the price of an item before discount application. Unless I make a mistake, I don't believe that's currently possible.

Within the scope of immutable data, we can't access to the taxRate, so we don't know if the orderItem unitPrice is a net price or a gross price, because the value of "included in price" option is unknown in this context...

I also thought added the amount ot total adjustments to the gross price. But this calculation is not perfect for a free item : the amount of adjustments can be greater than unit price...

The only way I see to get the information is to add the net unit price on the orderItem and to calculate this net unit price in the OrderPricesRecalculator of the OrderProcessor. Next during invoice generation I store this netUnitPrice on the LineItem entity.

What do you think about storing net unit price on the orderItem and LineItem in a next release ? If not, how could we recover the value of the net catalog unit price (within the scope of immutable data) ?

Thx

vvasiloi commented 2 years ago

You're right, currently the line item's unit price, subtotal and total, all include discounts. Discounts aren't handled in any way.

GSadee commented 2 years ago

Hi @laurentdabbb, if I think correctly, the unitPrice field on invoice is always a net price as it is calculated as the difference between gross value and tax amount.

And as for the original unit price, it is already stored on order item entity, but not used here in the plugin for line items. And I'm not sure if it will be from the business point of view, wdyt @CoderMaggie? But it is something that you can already change without having to customize order processing.

laurentdabbb commented 2 years ago

Hi @GSadee,

Thank you and sorry for the delay in replying, I hadn't seen your reply.

I agree with you, but I'm not talking about the same price ;-) The net price calculated and displayed on the invoice is OK. But it's a net price including discounts.

I want to add a column on invoices to comply with french rules. I had to display the net sale price : the net price before discount application. But I can't with data stored on lineItem or orderItem. On orderItem I don't konw if the unitPrice stored is a price including taxes or not (depending on taxRate configuration). TaxRate configuration is not stored as an immutable data so I can't retrieve this configuration for invoice generation.

I resolved this problem by storing a netSaleUnitPrice and a grossSaleUnitPrice on orderItem (in OrderPricesRecalculator). But, I think this could be implemented natively.

Thx.

Prometee commented 2 years ago

Hi everybody, since the catalog promotion is not creating adjustments but instead provides an original_unit_price field on the OrderItem how are we suppose to display it in the invoice ?

I don't see any service providing a way to be sure there is a discount on a particular item, except for this twig extension : OrderItemOriginalPriceToDisplayExtension. Do catalog promotions have to be able to create an adjustment when adding to cart or there is a story behind the creation of the original_unit_price field ?

GSadee commented 2 years ago

Hi @GSadee,

Thank you and sorry for the delay in replying, I hadn't seen your reply.

I agree with you, but I'm not talking about the same price ;-) The net price calculated and displayed on the invoice is OK. But it's a net price including discounts.

I want to add a column on invoices to comply with french rules. I had to display the net sale price : the net price before discount application. But I can't with data stored on lineItem or orderItem. On orderItem I don't konw if the unitPrice stored is a price including taxes or not (depending on taxRate configuration). TaxRate configuration is not stored as an immutable data so I can't retrieve this configuration for invoice generation.

I resolved this problem by storing a netSaleUnitPrice and a grossSaleUnitPrice on orderItem (in OrderPricesRecalculator). But, I think this could be implemented natively.

Thx.

About tax rate, it is indeed a mutable entity, but in tax adjustments there are information about tax rate code, name, amount and if it is included in price or not and they are immutable, so there is a possibility to get the needed information.

Hi everybody, since the catalog promotion is not creating adjustments but instead provides an original_unit_price field on the OrderItem how are we suppose to display it in the invoice ?

I don't see any service providing a way to be sure there is a discount on a particular item, except for this twig extension : OrderItemOriginalPriceToDisplayExtension. Do catalog promotions have to be able to create an adjustment when adding to cart or there is a story behind the creation of the original_unit_price field ?

From our perspective, there is no need for creating an adjustment, because the price discounted by catalog promotion is the base price for the item. So when there is a difference between the original unit price and the unit price of item, there is a case that the catalog promotion is applied. If you need this information on invoice, please, customize that for your usecase.