connector-magento icon indicating copy to clipboard operation
connector-magento copied to clipboard

Discount is applied in a wrong way to the synced order in Odoo

Open aignermi opened this issue 9 years ago • 14 comments

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

aignermi avatar Jul 06 '15 12:07 aignermi

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?

guewen avatar Jul 06 '15 12:07 guewen

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€.

aignermi avatar Jul 06 '15 12:07 aignermi

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.

guewen avatar Jul 06 '15 14:07 guewen

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!

aignermi avatar Jul 06 '15 14:07 aignermi

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.

guewen avatar Jul 06 '15 15:07 guewen

(record in the method contains the values from Magento)

guewen avatar Jul 06 '15 15:07 guewen

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 avatar Jul 08 '15 13:07 aignermi

@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, ...

guewen avatar Jul 08 '15 13:07 guewen

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 avatar Jul 08 '15 13:07 guewen

@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.

aignermi avatar Jul 08 '15 13:07 aignermi

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?

guewen avatar Jul 08 '15 13:07 guewen

Where would I set that?

aignermi avatar Jul 08 '15 13:07 aignermi

By activating "Tax included in Price" in the tax of your products

2015-07-08-152959_1650x894_scrot

guewen avatar Jul 08 '15 13:07 guewen

Thx, that did the trick!

aignermi avatar Jul 16 '15 08:07 aignermi