Estimates yielding negative values
Greetings All...
I've run into an issue that I thought I could take care with a simple template fix. Maybe I still can with a bit of additional guidance.
We have produced an estimate for a client who receives a blanket discount on products and services. In producing an estimate, some items were given a low-quantity of 0 and a positive value for high-quantity. For those items with 0 low-quantity, OVPMS is applying the item discount resulting in negative values for the "low-amount" instead of defaulting to 0. This of course affects the low-total-value for the estimate.
As the estimate does not have any real invoicing effect, I have modified the estimateItems template to print 0.00 for the low-amount when low-amount is negative using the following conditional clause:
($F{target.lowTotal}.compareTo(java.math.BigDecimal.ZERO) <= 0)?
$F{target.lowTotal}.valueOf( 0.0 )
:$F{target.lowTotal}
The conditional clause does take care of the negative value display issue. I thought that this would fix the low-total-value for the report as well, however, it does not. The value of
$V{SUM_target.lowTotal} is remaining unchanged.
While I think that estimates for 0-quantity items should probably not be reflecting negative values in OVPMS, can anyone suggest a template change that can make the SUM_target.lowTotal use my reassigned $0.00 target.lowTotals?
Thanks,
Sam
Kamloops, BC
Re: Estimates yielding negative values
Actually... I now see that the problem is more involved than just a template tweak. I'm getting rather bogus values for all low-amount calculations when a discount is applied.
Example:
"Anesthesia Inhalation per 10 Min" has a unit price of $52.82. Client receives 25% blanket discount. Estimate low quantity is 1.0 unit, estimate high-quantity is 2.0 units. OVPMS Customer-Estimate page reports the following:
Low Quantity : 1.00
High Quantity : 2.00
Fixed Price : 0.00
Low Unit Price: $52.82
High Unit Price: $52.82
Discount : $26.41
Low Total : $26.41
High Total : $79.23
The routine is failing to calculate the Low Total correctly. It is calculating the discount amount as (High Quantity * High Unit Price * Discount %) = $26.41 and subtracting $26.41 from both the pre-discount High Total and Low Total amounts. While the High Total is correct, the Low Total is not. The low total discount should be (Low Quantity * Low Unit Price * Discount %) = (1.0 * $52.82 * 0.25) = $13.21. The Low Total with 1.0 unit should then be ($52.82 - $13.21) = $39.61.
So I'm sort of stuck here for the time being. I guess the estimateItems sub-report could be entirely rewritten to redo all the math at report time, but perhaps it's just something wrong in the way we are doing the pricing? Or something else I'm not doing correctly? I'm sure this has been noticed before but don't see any mention of it in the forums. Is OVPMS giving what we really need when it is reporting only a single discount value in estimates?
Thanks,
Sam
Re: Estimates yielding negative values
There are some significant changes to discounting , including bug fixes and new methods arriving in 1.8
https://openvpms.atlassian.net/browse/OVPMS-1521
https://openvpms.atlassian.net/browse/OVPMS-1517
https://openvpms.atlassian.net/browse/OVPMS-1538
Check if these resolve the problem as you see it and let us know.
I suspect they will.
Re: Estimates yielding negative values
If you need it Sam I might be able to partially patch 1.7.1 with the patches we applied to 1.8 regarding calculations but the archtype changes would be held until 1.8 - I think a better option would be to manually change the estimates until 1.8 is released and then see what sort of mileage you get.
Re: Estimates yielding negative values
The issue is that the discount is calculated from the high quantity and unit prices, and then used to calculate both the low and high totals.
There really needs to be separate discounts:
Raised as OVPMS-1564
Re: Estimates yielding negative values
Hi Tim,
Thanks for raising this as a new JIRA. I looked through the JIRAs that Ben referred me to and thought that OVPMS-1521 might address the issue but I wasn't sure.
Thanks for taking a look.
Sam
Re: Estimates yielding negative values
This has been fixed for 1.8.
-Tim
Re: Estimates yielding negative values
Thanks Ben,
It sounds like you guys are already all over this problem. I'll look through the JIRA's and see if they would help in this case. At least I've been able to point out the issue I'm having here. Let me know if it's not clear and I can perhaps document it better.
Also, thanks for your offer of the patch. Very generous! But as you say, it might be better to wait until 1.8 is out and proceed from there. I already have my own changes incorporated into the code I'll need to deal with.
We've been discussing this and I think for the time being, we will create a new shadow customer... one without the blanket discount. We'll then just generate a normal estimate and make a note on it that the client can subtract 25% from the estimated amounts. We can then see how 1.8 handles this situation and proceed from there... maybe with template tweaking as required.
Thanks for the information. Looking forward to 1.8!
Sam