Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0034275
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Discounts and Promotionsmajoralways2016-10-21 20:462016-12-21 11:50
ReporterrbianchiniView Statuspublic 
Assigned Tomarvintm 
PrioritynormalResolutionfixedFixed in VersionRR17Q1
StatusclosedFix in branchFixed in SCM revisionf6e478dd1789
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionRR16Q3.2SCM revision 
Review Assigned Toguilleaer
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0034275: Sell at cost discount wrong calculate if the sales price list includes tax

DescriptionWhen you sell at cost and the sales pricelist includes taxes, the total = cost = gross unit price and net unit price = gross unit price - taxes.
Also, in sales order line window, the field discount is set to 0, when it should be filled with the % discounted
Steps To Reproduce1 - Install the modules:
http://centralrepository.openbravo.com/openbravo/org.openbravo.forge.ui/ForgeModuleDetail/Product-Cost-For-WebPOS [^] and
http://centralrepository.openbravo.com/openbravo/org.openbravo.forge.ui/ForgeModuleDetail/Sell-At-Cost-Discretionary-Discount [^]
2 - Make sure that the product has a record in unit cost tab: http://wiki.openbravo.com/wiki/Projects:Stock_Valuation#Stock_Valuation [^] and the sales price list include taxes.
3 - Configure a new discount "sell at cost" with this link: http://wiki.openbravo.com/wiki/Modules:Sell_Cost_Price [^]
4 - In web pos, insert a product in the receipt, in the menu, select the option Receipt discount and apply the sell at cost discount created in step 3
5 - Go to ERP and open the Sales ordered created in previous step
6 - Realize that net unit price is less than the cost, and the cost is equals to the gross unit price. The right gross unit price should be cost + taxes and the net unit price should be the cost, other way the bussiness is loosing money.
7 - Also realize that the discount field is 0, when it should be filled with the % discounted
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0034084 newRetail Pending test to be developed 

-  Notes
(0091630)
marvintm (manager)
2016-11-17 11:57

The module was implemented with the idea that the discount can be computed directly by checking just the product price and the cost. This is correct when using price including taxes, but not when not using price not including taxes.

Implementing the discount as described would probably not be correct, as taxes are computed from the total of the line, not the price, and fixing this problem would involve changing the fundamental implementation of the module.
(0091634)
eugeni (reporter)
2016-11-17 13:47

@marvintm:

"This is correct when using price including taxes, but not when not using price not including taxes" --> I would say that is exactly the opposite, i.ed:

This is correct when using price excluding taxes, but not when using price including taxes. Using price including VAT is the regular way to deal with prices at point of sales for most retailers, therefore this module is basically useless for them. As a tip, take a look to margin indicator module, now it works properly with prices including taxes
(0091771)
marvintm (manager)
2016-11-24 09:06

Hi Eugeni,

Sorry, I wrote my comment in a bit of a rush. You are of course right, the module works correctly when using price not including taxes, but doesn't work in the case of price including taxes.

When we looked at this issue, we thought that the Margin Indicator module was a different situation, because it is computed when the taxes have already been calculated, and the net price is available.

In the case of the Sell at Cost discount, we originally misunderstood as we thought that the discount was applied automatically. Automatic discounts are applied before taxes are calculated, which meant that we didn't know which were the net amounts, and particularly the net price, as those were not computed yet.

However, this module actually adds a discretionary discount rule, which means that we do have access to the net amounts, so now we believe that we can fix the problem, and we will try to do so.
(0092136)
hgbot (developer)
2016-12-06 12:21

Repository: erp/pmods/org.openbravo.retail.discounts.cost
Changeset: ba618b2af8c43367048e8f11e9c9666dacee43a5
Author: Antonio Moreno <antonio.moreno <at> openbravo.com>
Date: Tue Dec 06 12:21:29 2016 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.cost/rev/ba618b2af8c43367048e8f11e9c9666dacee43a5 [^]

Fixed issue 34275. Discount will now be correct with price including taxes. Fixed async problem with latest Retail releases.
- Now when using price including taxes, the discount will be computed so that the final price without taxes is equal to the cost. This means that the final total amount will be the cost amount, plus the taxes.
- Additionally, a calculateGross call has been added at the end of the process, to fix an async problem with this module and the latest versions of Retail.

---
M web/org.openbravo.retail.discounts.cost/source/promotion-cost.js
---
(0092776)
guilleaer (manager)
2016-12-19 12:59
edited on: 2016-12-19 13:00

It seems that calculations are not working properly when line qty are incremeted or new lines are added to the receipt

I have added this log line to the code

definition.amt = OB.DEC.mul(price.subtract(OB.DEC.toBigDecimal(costPrice)).multiply(OB.DEC.toBigDecimal(rate)), line.get('qty'));
+ console.log("rate:" + rate + " price: " + price.toString() + " net: " + net.toString() + " def: " + definition.amt + " cost: " + costPrice + " lineGross: " + line.get('gross'));

If you add a product, then apply cost discount to that product and then you add a new unit to this line... calculations are wrong

rate:1.21 price: 2.39669421487603305785 net: 2.39669421487603305785 def: 1.77 cost: 0.93 lineGross: 2.9 -->> OK
VM7903:1 add unit
8345fcf…_WebPOS.js:71719 rate:3.12 price: 0.46474358974358974359 net: 0.92948717948717948718 def: -2.9 cost: 0.93 lineGross: 2.9 -->> WRONG

it seems that rate value is causing the issue.

Some strange problems are also happening if you add new lines to the ticket after apply the discount to the line

(0092869)
hgbot (developer)
2016-12-20 19:41

Repository: erp/pmods/org.openbravo.retail.discounts.cost
Changeset: f6e478dd178936d661d0eebab7ecceddace3d426
Author: Antonio Moreno <antonio.moreno <at> openbravo.com>
Date: Tue Dec 20 19:41:41 2016 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.cost/rev/f6e478dd178936d661d0eebab7ecceddace3d426 [^]

Fixed issue 34275. Several additional changes have been made:
- Removed unnecessary calculateGross.
- Find has been replaced fin findUsingCache. This improves performance, and removes asynchronous behavior, indirectly fixing a problem with asynchronous execution of the manual discount rule by the automatic discounts engine.
- Replaced linerate by linerateWithPrecision. This property has the correct value in all circumstances, and has greater precision, which is better for our purposes.
- Gross will be computed from the quantity and price. Standard gross property may not have the final value in this case, as calculateGross has not been executed yet (it comes after the discounts engine has finished), but quantity has the right value.

---
M web/org.openbravo.retail.discounts.cost/source/promotion-cost.js
---

- Issue History
Date Modified Username Field Change
2016-10-21 20:46 rbianchini New Issue
2016-10-21 20:46 rbianchini Assigned To => Retail
2016-10-21 20:46 rbianchini Resolution time => 1478833200
2016-10-21 20:46 rbianchini Triggers an Emergency Pack => No
2016-10-22 21:25 eugeni Issue Monitored: eugeni
2016-10-29 01:02 rbianchini Description Updated View Revisions
2016-10-29 01:02 rbianchini Steps to Reproduce Updated View Revisions
2016-11-15 17:38 jorge-garcia Assigned To Retail => jorge-garcia
2016-11-17 11:57 marvintm Resolution time 1478833200 =>
2016-11-17 11:57 marvintm Note Added: 0091630
2016-11-17 11:57 marvintm Type defect => design defect
2016-11-17 12:10 jorge-garcia Assigned To jorge-garcia => Retail
2016-11-17 13:47 eugeni Note Added: 0091634
2016-11-24 09:06 marvintm Note Added: 0091771
2016-11-24 09:07 marvintm Regression date => 2016-12-08
2016-11-24 09:07 marvintm Type design defect => defect
2016-11-28 12:53 maite Resolution time => 1481151600
2016-11-28 12:53 maite Regression date 2016-12-08 =>
2016-11-30 18:55 marvintm Status new => scheduled
2016-11-30 18:55 marvintm Assigned To Retail => marvintm
2016-12-06 12:21 hgbot Checkin
2016-12-06 12:21 hgbot Note Added: 0092136
2016-12-06 12:21 hgbot Status scheduled => resolved
2016-12-06 12:21 hgbot Resolution open => fixed
2016-12-06 12:21 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.cost/rev/ba618b2af8c43367048e8f11e9c9666dacee43a5 [^]
2016-12-06 12:23 marvintm Relationship added related to 0034084
2016-12-19 12:59 guilleaer Note Added: 0092776
2016-12-19 12:59 guilleaer Status resolved => new
2016-12-19 12:59 guilleaer Resolution fixed => open
2016-12-19 12:59 guilleaer Note Edited: 0092776 View Revisions
2016-12-19 13:00 guilleaer Note Edited: 0092776 View Revisions
2016-12-20 19:41 hgbot Checkin
2016-12-20 19:41 hgbot Note Added: 0092869
2016-12-20 19:41 hgbot Status new => resolved
2016-12-20 19:41 hgbot Resolution open => fixed
2016-12-20 19:41 hgbot Fixed in SCM revision http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.cost/rev/ba618b2af8c43367048e8f11e9c9666dacee43a5 [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.cost/rev/f6e478dd178936d661d0eebab7ecceddace3d426 [^]
2016-12-21 11:50 guilleaer Review Assigned To => guilleaer
2016-12-21 11:50 guilleaer Status resolved => closed
2016-12-21 11:50 guilleaer Fixed in Version => RR17Q1


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker