Set up price calculation based on conditions

Hey all,

I’m looking for help to build the price calculation based on several conditions.

I have a range of price depending on the time periods.

For example:
Price for using a service per month is 5000 excluding taxes
Including taxes the price for using a service per month is 5000 * 1.18
Price for using a service per quarter is 13474 excluding taxes.
Including taxes the price for using a service per quarter is 13474+18% or 13474 * 1.18

and so on.
Although I have setup the price calculations correctly and it shows in the input provided for the purpose (Amount Payable) but it doesn’t update in the database.

When I put the conditions in a ‘Placeholder’ then it shows in the input but is not updated in DB, so I tried putting the conditions in ‘Initial content’ but this neither shows in the input not does it update in DB, any ideas how to sort this out?

Hi there, @Ankur… if i am reading your post correctly, it sounds like you have the calculations working, and you are able to get the correct amount to show up in the Amount Payable input on the screen. If that’s right, that’s great… but it’s not really about how you get the correct calculation to show up in that input on the screen (well, it is, but not in your case if you already have that working)… it’s about how you are saving the value of that input to the database.

I assume you have a workflow tied to the Submit button that creates a new thing, right? Does that workflow include a step that takes the value in the Amount Payable input and writes it to a field in the database?

Best…
Mike

Try adding hidden Input X on the page which is referring Input Total Patable and in the workflow refer to Input X.

But it should work the way you have it, but of course you have to have the setup done right - like Mike said. Check with the debugger what value Input has when saving the data in DB.

Yes @mikeloc
I am having that workflow in place.

@bartek.dev I have already tried that but doesn’t work.
Showing a recreation to confirm this is what you mean.

1

Hmm, try this… put the part you circled in red in your response to me in a new step after the first step, and have that step make changes to the thing in the first step.

Edit: Strike that… I was thinking of something else.

Not in placeholder. In the initial content.

@bartek.dev And should the placeholders be empty in both the inputs? (Input amount payable and hidden input)

@mikeloc You mean create a thing> type entry form> Total payable= Input amount payable’s value

Have already tried that, but failed.

It doesn’t matter. Placeholders are for the inputs where value is empty. So if you have the calculation in the placeholder field it will not get saved in DB.

Have run in debug mode, Original input (Amount payable) is showing in debug mode but not in the input itself.

Second screenshot shows hidden input is not grabbing anything from original input.
This is actually surprising.


I think you might have issue with formatting. Using “formatting as” is converting the value into text I believe.

The second input has content format as integer which is number.

Also check in you DB what format is the field “Total Payable no.”.

Yup, @bartek.dev… I was just about to go down the formatting path, too. :slight_smile:

I have this exact same setup in one of my apps, @Ankur … an input where the initial content is calculated on the fly, and then the value is saved to a field in the DB, and it works like a charm. So, that’s why I was heading down the mismatched formats path, too.

Here is the screenshot of DB

6

I have also tried removing all the formatting. Had also tried with text (Number only)

Try removing “formatted as XXXX” from the input calculation + check if the Input Total Payable is formatted as integer or decimal - whatever you want.

Now that worked after I removed all the formatting this time, I had tried that earlier also, I believe must have overlooked something.

Thanks a lot guys, that’s why I love this community. :smiling_face_with_three_hearts:

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.