Along with saying hello and wishing you a great weekend, I present the following query
I have a field called DIFERENCIA_DIVIDENDO which is of type string, where the data that said field has are the following OK, MTO REVISOR MAYOR MTO REVISOR and MTO MAYOR REVISOR MTO REVISOR.
What I need is:
If the data called OK appears, subtract the fields called MTO_DIVIDENDO_PENDIENTE_INTER_PENAL and CDT_MONTO_COBRO.
If the data called MTO REVISOR MAYOR MTO PANEL appears, subtract the fields called MTO_DIVIDENDO_PENDIENTE_INTER_PENAL and CDT_MONTO_COBRO
If the data called MTO REVISOR MTO REVISOR appears, subtract the fields CDT_MONTO_COBRO and MTO_DIVIDENDO_PENDIENTE_INTER_PENAL
The fields called MTO_DIVIDENDO_PENDIENTE_INTER_PENAL and CDT_MONTO_COBRO are of type int
For a better understanding, the formula that does not work for the rule engine node is detailed.
You are better of with the Column Expression or Java Snippet node. The Rule Engine is not really suitable for this.
Note: please double check rules since they are contradicting: the input being described as:
OK
MTO REVISOR MAYOR MTO REVISOR
MTO MAYOR REVISOR MTO REVISOR
while the described rules mention:
OK
MTO REVISOR MAYOR MTO PANEL
MTO REVISOR MTO REVISOR
I used the last group as input. The computation of the rules is basically the same in nature as you had within the Rule Engine.
if (column("DIFERENCIA_DIVIDENDO").equals("OK")) {
column("MTO_DIVIDENDO_PENDIENTE_INTER_PENAL") - column("CDT_MONTO_COBRO")
} else if (column("DIFERENCIA_DIVIDENDO").equals("MTO REVISOR MAYOR MTO PANEL")) {
column("MTO_DIVIDENDO_PENDIENTE_INTER_PENAL") - column("CDT_MONTO_COBRO")
} else {
column("CDT_MONTO_COBRO") - column("MTO_DIVIDENDO_PENDIENTE_INTER_PENAL")
}
Note1: since rule 1 and 2 have the same calculation logic, you can also merge the first and second if statements with an OR operator which is ||
Note2: if you want to leave the output empty for example whenever you input does not contain any of the 3 terms, convert the else statement to an if else with a proper rule similar to the other two and make a new else statement.