Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Please help me with this code, coz it executes strange.

Featured Replies

 

I am working with a water billing system.

so I have a field for a reading of a water consumption so this is the process flow,this is also a field in a portal (date billed  with due date and previous-present reading=consumption then consumption=amount due and there is a penalty field, when the consumer did'nt pay or paid after the due date then the calculation execute.)

after the 1st week that i have developed the aplication the calculation and the field is working fine, but when i try to enter new bill recently ,i have noticed that it is not working properly,like its always calculating even the result is false.

 

please help or please give other suggestion with this calculation.

Case ( IsEmpty ( DatePaid ) or DatePaid>Due Date;AmountDue*.05;0;Due_Date<Get (CurrentDate);AmountDue*.05;0)

Here is your case statement on a line-by-line basis

Case ( 
IsEmpty ( DatePaid ) or DatePaid>Due Date ; AmountDue*.05 ; 
0 ; Due_Date<Get (CurrentDate) ; 
AmountDue*.05 ; 0 
)

All I have done is put in some returns to separate the individual cases

Notice that case #2 starts with "0". This is not a comparative but will always be true and will yield either 0 or 1 based on Due_Date<Get(CurrentDate)

Should your statement actually be...

Case ( 
IsEmpty ( DatePaid ) or DatePaid>Due Date ; AmountDue*.05 ; 
Due_Date<Get (CurrentDate) ; AmountDue*.05 ; 

)

 

7 hours ago, Mark Pastoril said:

there is a penalty field, when the consumer did'nt pay or paid after the due date

Based on this description, I would expect the penalty to be calculated as something like:

If (
Get (CurrentDate) > Due Date and not DatePaid
or
DatePaid > Due Date
;
AmountDue *.05
)

However, this still has the flaw of hard-coding the penalty rate into the calculation formula. Ideally, the rate would be auto-entered into another field and referenced from there, so that you can change it without affecting previous records.

Note that the calculation must be unstored because it relies on current date.

 

22 minutes ago, IdealData said:

case #2 starts with "0". This is not a comparative but will always be true

A test of 0 will always be false, not true.
OTOH, the last test, AmountDue*.05, will always be true (unless the amount is 0).

 

Edited by comment

Quite right comment.

For the OPs benefit I was showing how to write the code in a simplified form which is easier to read and therefore debug.

  • Author

Really helps a lot, thank you it's working either way.

1 hour ago, Mark Pastoril said:

it's working either way.

Is it really? Compare the results in these cases:

1. Customer paid before due date. Due date has passed.

2. Customer has not paid. Due date has not yet passed.

 

  • Author

ok sir, i'll tried it today

  • Author
14 hours ago, comment said:

Based on this description, I would expect the penalty to be calculated as something like:


If (
Get (CurrentDate) > Due Date and not DatePaid
or
DatePaid > Due Date
;
AmountDue *.05
)

 

 

Tried this code today sir/madam and it really work, thanks a lot,.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.