Welcome!

This community is for professionals and enthusiasts of the Genio platform.
Share your questions and challenges, and help your partners!

0

0
Andre Marques
On 11/24/22, 2:49 PM

I did exactly like you said, but still not working.
How you can see, "euro" is the main currency, and the commission is 400 but the calculation Euro to Dollar is not working


I'm not using OPREG anymore, so is OPORT the main table
Apparently it's correct:



Hi Sónia! I've tried it many ways, and this happens:

This is how i did in Functions:


"@moeda" is "E" or "D" because is how is in the enumeration. I tried with "Euro" and "Dolar" too. Is "PC0CAMB" because my table doesn't have the "I" (CAMBI) and is CONVERSE, not CONVERSA. So thats why I'm thinking is ok

My table is like this:


There's no error when generate, but this error appear when compilate:


I clicked "Yes" just to see what happens, and when I tried to to the Database Maintenance, that's the message:


I changed "PC0CAMB" to "CODCAMB" just to test, but the error persists

  • Flag

The value of CAMB->CONVERS should be the code of enumeration, are you using the code of the enumeration element?

Sonia Fernandes
on 11/24/22, 6:22 PM

Yes, I'm doing this. The code for Euro x Dólar is "ED"

Andre Marques
on 11/25/22, 9:15 AM

As an alternative to the Last value, try using the CT Lookup formula. It works the same way but doesn't need to be related.

Sonia Fernandes
on 11/25/22, 2:29 PM

Still not working :(

Andre Marques
on 11/28/22, 9:53 AM

Ok, you first need to add different fields to get all the different last values of Cambios, then you need to use arithmetic to calculate.

And, only then you can do the arithmetic formula. The formula will be something like [OPREG->COMIDOLA]*[OPREG->CAMBED]

NOTE: CAMBED is the field that you need to create with the CT formula to get the Last Value of the Cambio between Euro x Dollar.

Sonia Fernandes
on 11/28/22, 2:23 PM

I think i already did it Sónia.

I created "EURXDOL" which is the fild that will get the last "Euro x Dolar" cambio

Then, I created another field named "EDCALC" to do the arithmetc formula: "EUROXDOL * The real commission value(Which is COMIDOLA)"

Andre Marques
on 11/28/22, 2:56 PM

I wrote a new solution for you in the last answer post. Try if this will work.

Sonia Fernandes
on 11/30/22, 10:55 AM

0
Sonia Fernandes
On 11/24/22, 12:52 PM

I don't know if I understood everything that you want.

However, it seems that you want the last value of the Cambio value, depending on the conversion type.  For that, you can use the Last Value formula, see below. The last value formula can be used in Parent tables, this means that CAMBIO needs to be below OPREG to work.



_______________________________________________________________________________________________________________________

30.11.2022

In the meantime, I realized why it wasn't working. Your Cambio table had a relation with the Opportunity table but nowhere was the relation between the two tables empty, so the returned value was always 0. 

What you should do is first pay the relation (FK) of opportunity in Exchange. Ideally, you should use CT Lookup but you can't add conditions to the data. So you can use a manual function. 

In the OPPORT table your field DOLKWAN you can use a manual function I called "LastValueEuro()", inside the parentheses you can put the coin (your MOEDA field) and then multiply this value with the commissions' value.



  1. In Function button add a new function. 

  2. Give the name that you want. (E.g. LastValueCambio)

  3. Set the data type of the return value (the with should be the same that the conversion value from cambio table)

  4. Choose the Execution type (in the example you just need execute in Database.

  5. Enter the parameters that you want, I thing you just need the coin parameters for this function.

  6. Insert an implementation, in the example T-SQL works. 

In T-SQL you need to use the Transact SQL Language. 

\https://learn.microsoft.com/en-us/sql/t-sql/language-reference?view=sql-server-ver16 

The next code solve the issue in my example, you need to change it for your reality. My suggestion: try execute the code inside the return in the SQL Server Management Studio, if it will returns that you want it will works.

  • If you want declare a new variable use: DECLARE myVariable VARCHAR(100) 

  • If you want refers some parameter, use @parameter (E.g. @moeda)


RETURN (
SELECT TOP(1 ) VALUE  FROM PC0CAMBI 
WHERE CONVERSA = CASE   
WHEN @moeda='Euro' THEN 'ED'   
WHEN @moeda='Dolar' THEN  'DE'
END
ORDER BY DATA DESC)




Keep Informed

About the Community

This platform is for beginners and experts willing to share their Genio knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers. Read Guidelines

Question tools

45 follower(s)

Stats

Asked: 11/16/22, 3:20 PM
Seen: 10143 times
Last updated: 11/24/22, 2:49 PM