Adding a negative number in a business rule
I am working with a form that was designed as a GL coding form. The behavior is this:
An invoice total is put on the form in the "Inv. Total" field.
There are line items that are added in a grid-like format along the bottom of the form. The way the rule is written is such that we are subtracting the number (money data type) in the line item control from the 'Inv. Total' field. This gives us the 'Total Dismemberment' (mDistributionTotal) value. Therefore showing us how much is left to disperse.
Here is my code:
var totalDist=0;
for (var i=0; i < DistAmt.value.length; i++) {
if (DistAmt[i].value) {
totalDist = totalDist + parseFloat(DistAmt[i].value.replace(/,/g,""));
}
}
mDistributionTotal.value = totalDist;
It works beautifully as long as the value input into the line items is a positive number.
What I am trying to do now is make this work for when there is a 'credit' posted to the invoice. Such as in a credit memo. This would actually be reflected as an addition of a negative number.
When I do this, the value in the line item changes from '-5.00' to (5.00) automatically. But it also blanks out the distribution total (mDistributionTotal).
I have been researching ways to do this in JavaScript, but I have not been able to get any of them to actually work.
Any ideas how I could accomplish this task?
I thought about creating another column on the form for credits and writing a whole other business rule. But if I can get the code to work and keep it in the same rule, that would be preferred.
-
Hi Eric,
What is your frevvo version? And can you download your form and attach it here in a comment?
0 -
The Frevvo version is 4.1.13.24102.
GLCodingForm_form.zip0 -
Hi Jim,
This seems to be happening because Format As property of 'Dist Amt' field is set to Money. This was a bug in frevvo v4 which is already fixed in newer versions of frevvo.
Is it possible for you to change the Format As property of your field to Text? The rule should work correctly after that.
Note that frevvo v4 will reach end of life on October 5, 2014. Please see this frevvo blog article. We strongly recommend that you upgrade your frevvo server to latest frevvo v5.3.5 as soon as possible. There have been many upgrades and fixes in frevvo since v4 including the fix for your current issue.
Thanks,
Prajakta
0 -
WOW. I really appreciate the assistance, as always. I was also unaware of the 'end of life' of the v4 product. I will forward this information immediately.
0
Please sign in to leave a comment.
Comments
4 comments