connector-magento
connector-magento copied to clipboard
Discount is applied in a wrong way to the synced order in Odoo
Hi,
I just stumbled across an issue with fixed amount discounts in Magento. For example, I have an order with one product in Magento: 85€ sales price incl. tax, 75€ voucher which results in a 10€ total. In Odoo this orders was translated into the following: 104.998% discount and a total of -4,25€. The problem here is that Odoo takes the 75€ voucher from the net price(71.43€) and not the gross price (85€).
Is there a setting that can fix that - if not I would like to file a bug.
Thanks, Michael
On the backend, there is an option that indicates if tax is included in price or not and I think it changes this behavior. Could you check that?
I tried that before, but then I have the problem that the imported sales orders are completely wrong. Our products in Magento have prices incl. tax. The synced orders with that option calculate the tax on top of the products which already have tax incl. For example: product price is 69€ incl. tax, sales order with this product total is 82.11€ - but it should be 69€.
Pity. Getting all the options working together in all possible ways is really tricky with incl. and excl. taxes. I have no clue for that yet.
Ok, thats unfortunate. Can you tell me where you handle the tax calculations - then I'll have a look at it in the code, as the rules itself are pretty straight forward.
Is there a documentation for the connector where I can have a look how you handle various cases? I'm especially interested in the order syncing mechanism!
Here is the mapping for the discount: https://github.com/OCA/connector-magento/blob/8.0/magentoerpconnect/sale.py#L961-L972
And a test which proves to be insufficient here: https://github.com/OCA/connector-magento/blob/8.0/magentoerpconnect/tests/test_synchronization.py#L240-L266
There is no general documentation for that.
(record
in the method contains the values from Magento)
Thanks, I just had a look at the code and the problem is the self.options.tax_include parameter and how it is used. To every order that is imported from Magento, Odoo calculates the tax on top, so in our case (our prices in Magento include the tax already) if I set the parameter to yes, I would have the double tax value in Odoo, but the correct discount logic. If I set it to no, I have correct imported orders but wrong discount logic. Therefore this parameter makes no sense at the discount logic step.
@aignermi does it depend on a configuration on Magento perhaps? I know Magento had a handful of options such as compute discount after total, before taxes, ...
I mean we can remove this logic in the discount, but I don't want to break other scenario, if it was there at a first place, I think (I hope) it was working for the one who wrote this part
@guewen yep I understand that. Let me check our settings there and let me check how Magento behaves with different settings and how the base_row_total_incl_tax field is calculated then. I'll try it out by removing that section too.
if I set the parameter to yes, I would have the double tax value in Odoo
Why not set tax include taxes on the products?
Where would I set that?
By activating "Tax included in Price" in the tax of your products
Thx, that did the trick!