
I added this calculation into my app, but for some reason it only ever pulls through the below numbers or doesn't do the calculation.
OnCheck:
Set(
totalIncVAT,
Value(Textbox_Expensetotal.Value)
);
Set(
VAT,
totalIncVAT - (totalIncVAT/1.2)
);
Set(
totalExclVAT,
totalIncVAT - VAT
);
OnUncheck:
Set(totalIncVAT, Value(Textbox_Expensetotal.Value));
Set(VAT, (0));
Set(totalExclVAT, (0));
When I uncheck it comes up as blank - I want it to come up with £0.00
This is for the submit button.
UpdateContext(
{
varID:
Patch(
'All data #3',
Defaults('All data #3'),
{
'Amount incl. VAT': totalIncVAT,
'Amount Excl. VAT': totalExclVAT,
'VAT (20%)': VAT
} ).ID
thank you
It looks like when you leave it unchecked its not setting the variables, this is likely because the unchecked function hasn't run yet because that is only run when the value was previously Checked.
I would instead remove the functions from your OnCheck/Check and instead have them on the patch:
UpdateContext(
{
varID:
Patch(
'All data #3',
Defaults('All data #3'),
{
'Amount incl. VAT': Value(Textbox_Expensetotal.Value),
'Amount Excl. VAT': Value(Textbox_Expensetotal.Value) - (Value(Textbox_Expensetotal.Value) * 20%),
'VAT (20%)': Value(Textbox_Expensetotal.Value) * 20%
}
).ID
}
)
Could you please give that a try?