Jump to content

Creating a simple script to add a late fee


This topic is 7575 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

This is my first post. Please let me know if I should be in another forum.

I own a small business and I use FileMakerPro6 to keep all of my records on individual clients. I am looking for previously designed scripts that I can use. For instance I have a field called "late fee". Numerical entires are 0 and 1. I want my script to say that if "late fee" = 1, the add 5 to the field called "Balance Due" . Any way that I word this in the calculation box, it comes up with some error like "not enough separators" or "this field does not exist". What should be soooo simple is so complicated and there is no help offered anywhere that I can find on line or in books.

Can anyone help me with this simple script?

Thanks,

MB confused.gif

Link to comment
Share on other sites

  • Newbies

Ok, Lee, I was able to see your post to Queue. Mine is so much more simple. See, I just enter a 1 or a 0 in the late fee field, and then I want a calculation that says if "late fee" = 1, the add 5 to the field called "Balance Due" . My calculation English is obvously remiss................any thoughts?

Thanks,

MB

Link to comment
Share on other sites

Well, not sure it's that simple depending on your exact needs. Is your 1,0 flag supposed to constantly increment the "Balance Due" by 5 anytime you input a 1, or is it that you only want to flag once a late customer, and have 5 added to the current balance due.

And would switching to 0 revert the process by 5 ?

The simliest :(

BalanceDue = ???:Related dues + choose(late,0,5)

Link to comment
Share on other sites

Hi:

As with many things in FM, there is more than 1 way to skin a cat. If you want a script, you could use a find and set field script:

Set Error Capture [on]

Enter Find Mode [ ]

Set Field [Late fee , "1"]

Perform Find [ ]

If [status(CurrentFoundCount) = 0]

Show Message ["No Records found"]

Show all records

else

Go to Record/Request/Page [first]

Set field [balanceDue , BalanceDue + 5]

Go to Record/Request/Page [exit after last, next]

End Loop

Show all records

It's off the top of my head, but you could try it if you want.

BUT, I would not suggest it smile.gif

I would suggest having the late fee added as a line item. That way it can be tracked better. You could have a script find late invoices and add this late fee to the invoices. If you have questions on this, please post.

Ken

Link to comment
Share on other sites

Hi MB! Welcome to the Forum. smile.gif

You've asked for a calculation (even though you accidently said script). Subconsciously, you were correct in using a script but not quite in the way you might think. wink.gif

The errors you describe indicate that you probably have a data type error. For example: If you get the error 'Field Cannot Be Found', FM thinks the 1 or 5 is a field because somewhere it's expecting quotes around them - indicating that you have a text field. If all associated fields are number, FM correctly assumes they are numbers and not fields. You haven't indicated what calculation you've tried but I would suggest you consider three things before you proceed with this:

1) Your Late Fee field should be a calculation (number). Something like: (InvoiceDate + 30) <= Status(CurrentDate). In this way, you won't be having to enter the 0 or 1 in the fields. 1 will flag if it's past due. 0 if it's fine (you may need to adjust this overdue date).

2) Your BalanceDue field should be a numeric calculation - a summary of all charges less all payments - an automatic running balance.

3) Ken is right that you should be using a script to set the Late Fee. It should be a new separate charge and cleary indicate its purpose. It would upset many customers to have their balance jump by $5.00 but not know why. crazy.gif

Your Late Charge script could be:

Set Error Capture [on]

Allow User Abort [Off]

Enter Find Mode [] ... uncheck Restore and Pause

Set Field [LateFee, 1]

Perform Find [Replace Found Set ] ... uncheck Restore

If not [status(CurrentFoundCount)]

Show Message ["No Records found"] ... only have a default OK

Show all records

End If

Loop

Set Field [itemCharge, 5.00 ]

Set Field [ChargeDate, Status(CurrentDate ]

Set Field [ChargeDescription, "Late Fee for month of " & Month(Status(CurrentDate)-1 & ", " & Year(Status(CurrentDate) ]

Go to Record/Request/Page

[ Next, Exit after last ]

End Loop

Show Message ["Late charges have been applied"] ... only have a default OK

Show all records

Let us know how it goes for you, okay? As you can see, there are many wonderful people here willing to help. smile.gif

Cheers,

LaRetta

Link to comment
Share on other sites

This topic is 7575 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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