Getting a Live calculator

Hi everyone!
hope you a having a great day :slight_smile:
I’m struggling to make a live calculator and get the users to understand the fees attached to a service.

So here it goes …

User should be able to enter a value for what they want to earn for a service:
Recibe // #input1
Then it should add +1 that corresponds to bank transfers
and provide a subtotal without taxes.

Based on what they want to earn + the bank fees = it should give a number. from this number, we should calculate taxes (IVA).
from then on, we should add a donation of 1.

Once we have this IVA we should consider 2 types of final prices: for Co, for NonCo.

Co price is: subtotal + IVA + 1
Non Co price is: subtotal + IVA + 1 + 5

This is what I’ve done so far. I’ve checked different forum posts but I’m still struggling on adding up the numbers.

anyone can help me out with this? I can’t sem make it work.
I’m no coder, just giving a hand to an NGO. Thanks!

export function buttoncalcular_click(event) {
let Recibe = Number($w('#input1').value);
let Comisiones = Number(1);
let Aportaciones= Number(1);
let Subtotal = Number (Comisiones + Recibe)
let IVA = Number (Subtotal *21/100);
let NoCo= Number(5)

$w('#subtotal').text = "" + Recibe + Comisiones;
$w('#Iva').text = ""+ IVA;
$w('#outputCo').text = "" + Subtotal + IVA + Aportaciones;
$w('#outputCo').text = "" + Subtotal + IVA + Aportaciones+ NoCo;

}

Hi… anyone out there?? :frowning:

You need to supply more information in order for us to help you. You don’t say what isn’t working. From what I see of your code, you might have an issue where you are trying to “convert” a Number to a Number. Your code should be something like this:

export function buttoncalcular_click(event) {
 let Recibe = Number($w('#input1').value);
 let Comisiones = 1;
 let Aportaciones = 1;
 let Subtotal = Comisiones + Recibe
 let IVA = Subtotal * 21 / 100;
 let NoCo = 5

 $w('#subtotal').text = "" + Recibe + Comisiones;
 $w('#Iva').text = "" + IVA;
 $w('#outputCo').text = "" + Subtotal + IVA + Aportaciones;
 $w('#outputCo').text = "" + Subtotal + IVA + Aportaciones + NoCo;
}

If this still doesn’t work, then explain what you are getting, and what should be happening.

Hi @yisrael-wix , thank you for getting back on me.

I’ve used the code you shared and
Here’s whats happening:

subtotal should be 21 (20+1)
IVA is ok
(outputCo)Cociudadanos should be 26,41
(OutpuNoCo)NoCoCiudadanos should be 31,41

It seems “to add” the number at the end, instead of considering “adding” the number.

export function buttoncalcular_click(event) {
 let Recibe = Number($w('#input1').value);
 let Comisiones = 1;
 let Aportaciones = 1;
 let Subtotal = Comisiones + Recibe
 let IVA = Subtotal * 21 / 100;
 let NoCo = 5

 $w('#subtotal').text = "" + Recibe + Comisiones;
 $w('#Iva').text = "" + IVA;
 $w('#outputCo').text = "" + Subtotal + IVA + Aportaciones;
 $w('#OutputNoCo').text = "" + Subtotal + IVA + Aportaciones + NoCo;
}

I cant seem to make the code “add” (20+1) instead of “add” (201).

Thank you very much for taking a look at this.

This line:

$w('#subtotal').text = "" + Recibe + Comisiones;

should probably be:

$w('#subtotal').text = "" + (Recibe + Comisiones);

First add the two numbers, and then let “” turn it into a string.

Same with these lines of code:

$w('#outputCo').text = "" + (Subtotal +IVA+ Aportaciones);
$w('#OutputNoCo').text = "" + (Subtotal +IVA+ Aportaciones + NoCo);

I didn’t test my code, but it should work - at least it’s the general idea.
Javascript is a bit fussy.

It works!!!
It Lives! Lives!!! (quoting Frankenstein)

:))))))))))))))))))))))))

Thank you!!!