Rule doesn't match when the amount is between 8.7 and 8.89 - drools

The drl's when condition looks something like below. The equals operator for the amount works fine for any amount except in the range from 8.7 to 8.89. It works for 1.01, 4.45, 8.55 or 8.69. But the mentioned range doesn't work only for equals operator. Other operators like <= or >= works. Anyone faced this issue before? if so, why is it happening for that range?
txnRuleInfo: TransactionRuleInfo(
transactionInfo.transactionAmount==8.7,
transactionInfo.transactionType==TransactionType.SALE
)

Related

Cannot properly array googlefinance formula with dates

I am trying to convert money amounts in USD to EUR, but I want to do it in relation to date of transaction taking place due to dyncamic exchange rates.
Idea is to use googlefinance function with index function, along with date function, which will be made of right, mid, and left functions. All of that should be wrapped with arrayformula. Numbers should be rounded using round.
Non-working example:
Don't mind ;, this is instead of , in my google sheets language settings.
Formula: =ARRAYFORMULA(IF(B2:B="";"";ROUND(INDEX(B2:B*GOOGLEFINANCE("CURRENCY:USDEUR";"price";DATE(RIGHT(A2:A;4);MID(A2:A;4;2);LEFT(A2:A;2)));2;2);2)))
Formula (with , instead of ;):
=ARRAYFORMULA(IF(B2:B="","",ROUND(INDEX(B2:B*GOOGLEFINANCE("CURRENCY:USDEUR","price",DATE(RIGHT(A2:A,4),MID(A2:A,4,2),LEFT(A2:A,2))),2,2),2)))
Since I'm pretty sure this formula should work in "normal circumstances", I've replicated it leaving out arrayformula, and full ranges (such as B2:B, etc), and it works once I drag down the formula.
Working example:
Formula: =IF(F2="";"";ROUND(INDEX(F2*GOOGLEFINANCE("CURRENCY:USDEUR";"price";DATE(RIGHT(E2;4);MID(E2;4;2);LEFT(E2;2)));2;2);2))
Formula (with , instead of ;):
=IF(F2="","",ROUND(INDEX(F2*GOOGLEFINANCE("CURRENCY:USDEUR","price",DATE(RIGHT(E2,4),MID(E2,4,2),LEFT(E2,2))),2,2),2))
Does anyone have idea what's going on with the first case, i.e. why it doesn't work? I believe it has to be something with those full ranges (e.g. B2:B, A2:B, etc), but not sure why...
GOOGLEFINANCE is already an ARRAYFORMULA type formula so try like this:
=ARRAYFORMULA(IF(B2:B="";;ROUND(B2:B*IFNA(VLOOKUP(A2:A+0,9986111111;
GOOGLEFINANCE("CURRENCY:USDEUR"; "price"; MIN(A2:A); MAX(A2:A)+1); 2; 1)); 2)))

Maple incorrect calculation with ShowSolution function

Maple solves the following problem incorrectly when using ShowSolution function which is in student.calculus1 package. It's works fine when the power of x variable is odd or when I write sin(n*x) but when I wrote x^(even number)cos(nx) it's calculated incorrectly. Or when I put a number instead of n it's calculated correctly. Do I miss something? :|
It looks like a bug (and I have submitted a bug report), going wrong at the first step.
As workaround, you could do this as a first step,
restart;
with(Student:-Calculus1):
ee := Int( x^2*cos(n*x), x=-Pi..Pi ):
new := rhs( Rule[parts, x^2, sin(n*x)/n]( ee ) ) assuming n::integer;
-(Int(2*sin(n*x)*x/n, x = -Pi .. Pi))
ShowSolution( new ) assuming n::integer;
which produces 4*(-1)^n*Pi/n^2 at the final step.
Or do those steps without the assumptions on n, and then simplify the final result under assuming n::integer.

MongoDB $lte strange results

I am trying to implement a (semi-) random result from MongoDB; I know, Q/A's a plenty, here on SO to. But... As I tried to query MongoDB, just for fun to see what I would get, $lte gives me some very strange results. Consider this dataset:
1. 0.011224885703995824
2. 0.01718393270857632
3. 0.03377954219467938
4. 0.09617210761643946
5. 0.10130057414062321
6. 0.13116577989421785
7. 0.25664394721388817
8. 0.27124307211488485
9. 0.3029055509250611
10. 0.31508319173008204
11. 0.3163822046481073
12. 0.34581731259822845
13. 0.5077376591507345
14. 0.5806738587561995
15. 0.5997774603310972
16. 0.6492975174915045
17. 0.710568506969139
18. 0.7257499841507524
19. 0.7275129975751042
20. 0.771076871547848
stored in a field called random, and filled with the rand-function. There is a index on this field, but with 20 records, I think that does not matter. But. If I query with: .findOne( {'random': { $lte : 0.59 }} ) I get the result: "random" : 0.34581731259822845 (number 12), while expecting number 14...?
When I tried some more queries, the result is very strange. Sometimes it is what I expect, but most of the time it seems to... well, I don't know. I do not understand how the query above leads to the result it gives...
Ah! I think I get it now - that is wat Yogesh meant: findOne takes the first document in the natural order that statisfies the criteria! Right. I did not get that. So that means that if the random number is high, it will often return the same number. So Yogeshes answer is correct - although he might have elaborated a bit :-)

Sphinx SetSortMode EXPR

I am trying to sort using Sphinx (PHP) to show in order of price but when I do it will show £10 before £1.75 so I need to use ABS like in mySQL.
I have tried this:
$s->SetSortMode (SPH_SORT_EXPR, "ABS(display_price) ASC" );
It doesnt seem to work though.
Can anybody help?
Check, if display_price attribute treated as a decimal in search index
Probably you have
sql_attr_string = display_price
instead of
sql_attr_float = display_price
or
sql_attr_bigint = display_price
updated
SPH_SORT_EXPR is ALWAYS descending order. the ASC/DESC are for use with EXTENDED mode only.
To 'invert' it to become acsending, can build it into the expression.
$s->SetSortMode (SPH_SORT_EXPR, "1000000-CEIL(ABS(display_price*100.0))" );

Else part never getting executed in crystal report formula field

I have a simple formula in crystal syntax which looks something like this :
if isdate(totext({Absence Details.Return to Work Interview Date})) = true
and {Absence Details.Return to Work Interview required} = true then
1
else
0;
This is the actual code of the formula
but the else part is never getting executed, when the condition is not true report just shows blank. I am not sure what I am doing wrong here.
Thanks in Advance.
- Amit
Maybe you have some null value in your fields - in such case crystal just returns null. You then need either "convert null values to default" setting for report or explicit testing against nulls.
Edit: NM, code was posted to the comments. Doesn't look like this is the issue.
My guess, assuming you've debugged correctly is that you've got a semicolon somewhere you shouldn't.
if {something} = x then
do something;
else
do something different;
instead of
if {something} = x then
do something
else
do something different;
This would cause the behaviour, assuming it doesn't choke on the orphaned else clause. But as the comments say, short of posting real code, we can only guess at what's going on. It could be as simple as your evaluation is always true.
Change the 0 to a 7 and see if it actually prints 7. Some report generation tools (and I have little experience with Crystal but quite a bit with others) will leave fields blank if they're zero - this often helps in reading the report by reducing unnecessary clutter.
If the 7's print out, then that's what the problem is, and it's a matter of figuring out how to get Crystal to output an actual 0.
That may be a matter of configuring the output field or even stting it to a textual "0" instead of numeric 0.
Of course, if that doesn't print out 7's, then feel free to let me know.