Jump to content

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

Recommended Posts

  • Newbies
Posted

The setup:

I'm in the process of building an invoice system for a computer repair company. On the actual invoices some products are covered under warranty and have a custom code for the total. Some products leave the shop with no charge, which also has a custom code. Everything else has a dollar amount.

I have a Total field which is defined as text so that the custom codes can be entered. The majority of time there will be a number total in $, but sometimes there will be the custom code. Thus the text field definition. The problem I'm having is that I can't seem to get the calculations to keep the trailing zero on amounts like $89.50. I don't want to write a huge case statement, or loop just to keep a zero on the end of an amount. And to this point I've not found a solution which allows me to format this field as a number with set decimal places when a number is in the field.

Any suggestions you might have would be helpful.

Posted (edited)

I got a bit lost in your explanation, but in any case you can add trailing zeros to a number this way:

Int ( Amount ) & "." & Right ( "00" & Amount * 100 ; 2 )

Note that this assumes Amount is rounded to 2 decimal places.

---

And not negative.

Edited by Guest
Forgot to mention the negative part.
Posted

Comment--

I think that the decimal portion of your calc could be simplified to:

Right ( Amount * 100 ; 2 )

since you're moving the decimal point to the right two spaces by the multiplication.

[i acknowledge the left-padding principle for this sort of thing in general; this example wouldn't need it, though.]

David

Posted

I'm afraid that wouldn't work when Amount is between 0 and 0.09 (inclusive).

True, it could be 'simplified' by using "0" instead of "00", since one zero is the most you'll ever need to pad. But the extra zero adds no complexity, and I like it better this way because it makes the purpose of the calc stand out.

Perhaps it would be better to use the dedicated function Filemaker provided for this very purpose:

SerialIncrement ( "00" ; 100 * Mod ( Amount ; 1 ) )

This topic is 6183 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.