Merge lp:~sebastien.beau/magentoerpconnect/magentoerpconnect-oerp6.1-stable-fix-discount-computation into lp:magentoerpconnect/oerp6.1-stable

Proposed by Sébastien BEAU - http://www.akretion.com
Status: Merged
Merged at revision: 692
Proposed branch: lp:~sebastien.beau/magentoerpconnect/magentoerpconnect-oerp6.1-stable-fix-discount-computation
Merge into: lp:magentoerpconnect/oerp6.1-stable
Diff against target: 16 lines (+5/-2)
1 file modified
magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv (+5/-2)
To merge this branch: bzr merge lp:~sebastien.beau/magentoerpconnect/magentoerpconnect-oerp6.1-stable-fix-discount-computation
Reviewer Review Type Date Requested Status
achraf el ammouri (community) Needs Fixing
Guewen Baconnier @ Camptocamp no test, code review Approve
Review via email: mp+144748@code.launchpad.net

Description of the change

Hi
With 1.6.1.0 version of magento, when you use discount it seem that Magento fail to compute the price.
Indeed I just check the reponse of magento for my customer and the result was really strange.
The price of the product with the discount was 13.30€ instead of 13.40€ (2 products with a price of 15.90€ and a discount on the line of 5€ => 31.80-5=26.80 =>(/2) => 13.40 and not 13.30)

I think it's better (and simplier) to use the total of the line in order to compute the discount rate

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Isn't it related to the discount including tax or not ?

`(total-discount)/total` is a bit hard to read without spaces. (anyway it's hard to read in a CSV file :-D)

Otherwise LGTM.

review: Approve (no test, code review)
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

No the problem is that we can not trust the field price. I don't know how magento compute it but the value is just totaly wrong.
For the discount, I not really sure at 100% that it always include the tax (this can be a problem) and there is no fields discount_with_tax discount_without_taxe.

Can somebody can test it with a customer that sell in exclude taxe on magento side? If not I will test it want I will have the time before merging it.

Regarding the csv => there are going aways in the next version ! yeaaahh

Revision history for this message
achraf el ammouri (achrafelammouri) wrote :

Hello Sébastien,

I can confim that the problem still exist (mail sent to you).

I've tried all the combinations in magento (inc/exl taxe XOR applying tax before/after discount).

After import, the price||discount||unit-price||tax is different each time.

This is really blocking for all the sales discount !

Regards,
Achraf

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv'
2--- magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv 2012-10-21 18:32:59 +0000
3+++ magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv 2013-01-24 16:45:30 +0000
4@@ -1,7 +1,10 @@
5 id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format
6 mag1500_sale_order_line_qty_ordered=>,,in,direct,qty_ordered,sale.field_sale_order_line_product_uos_qty,float,False,mag1500_sale_order_line,,,,,
7-mag1500_sale_order_line_discount_amount=>,,in,function,discount_amount,,float,False,mag1500_sale_order_line,discount_amount,"if ifield:
8- result=[('discount', float(data['price']) != 0 and float(data['qty_ordered']) != 0 and float(100*ifield)/(float(data['price'])*float(data['qty_ordered'])) or 0)]",,,
9+mag1500_sale_order_line_discount_amount=>,,in,function,discount_amount,,float,False,mag1500_sale_order_line,discount_amount,"if resource.get('discount_amount'):
10+ total = float(resource['base_row_total_incl_tax'])
11+ discount = float(resource['discount_amount'])
12+ discount_rate = 100 * (1 - (total-discount)/total)
13+ result = [('discount', discount_rate)]",,,
14 mag1500_sale_order_line_name=>,,in,direct,name,sale.field_sale_order_line_name,unicode,False,mag1500_sale_order_line,,,,,
15 mag1500_sale_order_line_option=>,,in,function,product_options,,unicode,False,mag1500_sale_order_line,option,"if ifield:
16 import re