This maybe an odd question, but is it possible to make a field discount for % and $?
Let me see if I understand and then see if what I have done will suffice:
You have an amount field. Now you want to apply a discount AND
1. you want the option of applying a percentage off.
So presuming the discount has a number such as "5" and by display only would be 5%, but the multiplier would be .05
DISCOUNT_c = amount * (discount/100)
2. you want the option of apply a discount 'as is'.
So presuming the discount has a number such as "5" and by display only would be $5.00, but the standard would be:
DISCOUNT_c = discount
Any grandTotal would be:
amount - DISCOUNT_c
But this means there needs to be something that tell us the value is a number (as is) OR a percentage. I have client where this gets more complex, but if what you have is simply a TEXT field (not a number) where you enter: "5" or "5%", then it could be Evaluated to calculate correctly.
[ a = myTable:amount // number field
; d = myTable::discount // a text field
; t = If( PatternCount( d ; "%" ); ( GetAsNumber( d )/100 ) * a ; GetAsNumber( d ) )
]; t // return the discount for that amount, for example
// d = 5%, p = 5/100*amount
// d = 5, p = 5
// d = 10%, p = 10/100*amount
// d = 20, p = 20
or more simply (one line):
If ( PatternCount( myTable::discount ; "%" ) ;GetAsNumber( myTable::discount )/100 * myTable::amount ;GetAsNumber( myTable::discount ) )
If ( PatternCount( myTable::discount ; "%" ) ;
GetAsNumber( myTable::discount )/100 * myTable::amount ;
GetAsNumber( myTable::discount ) )
There are variations and it depends on what is easiest for your users to enter, I suppose!
Thats exactly what I was looking for, thanks!
Retrieving data ...