Normal Topic Check Printing (Read 6923 times)
Andy
Member
*
Offline



Posts: 39
Location: Massachusetts
Joined: Aug 26th, 2014
Check Printing
Feb 19th, 2021 at 3:06pm
Print Post Print Post  
We have been using Sesame for many years.  We have some code in a routine that will convert money to text (@MoneyToWords). 

The problem we are having is when attempting to print a check in the amount of $100,000.00 it displays as: ONE HUNDRED AND 00/100 DOLLARS. If I were to change the amount to $101,000.00 it displays properly as: ONE HUNDRED ONE THOUSAND AND 00/100 DOLLARS
« Last Edit: Feb 20th, 2021 at 2:41pm by Andy »  
Back to top
 
IP Logged
 
Andy
Member
*
Offline



Posts: 39
Location: Massachusetts
Joined: Aug 26th, 2014
Re: Check Printing
Reply #1 - Feb 20th, 2021 at 2:46pm
Print Post Print Post  
I made a mistake on the post yesterday. 
Instead of posting @MoneytoWords I posted @MoneyToText.  I now realize @MoneyToWords is a built in Sesame programming function. I think there is a bug when printing $100,000.00.  I am able to print $101,000.00. 

Any input would be helpful.
  
Back to top
 
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 107
Joined: Mar 22nd, 2018
Re: Check Printing
Reply #2 - Feb 22nd, 2021 at 1:35pm
Print Post Print Post  
I had an issue with Rounding which sounds similar to yours.

If we are making a sale for $50 including the 15% tax, the final price would be $49.  If I add 1 cent to the pre-tax price, it works out $50.01.  I corrected it by created a vCheck variable in the program for that field.

Var vCheck as Money
vCheck = @Round(Check,2)

Try this to see if it works.

This way the function is working with the variable instead of the layout element.  Even for basic calculations, Sesame can be unpredictable using layout elements directly.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Check Printing
Reply #3 - Feb 22nd, 2021 at 3:03pm
Print Post Print Post  
Hi Andy,

Thank you for bringing this to our attention, I'll have to dig into the source code of Sesame to fix this. In the meantime you can put this code in Global Code, and call MoneyToText instead.

Code
Select All
Stat BigOnes as array[9] of String
Stat SmallOnes as array[19] of String

Subroutine ParseChunk(Var vChunk as String, Var vWords as String) //##########
Var vLeftDigit as Int
Var vRightDigit as Int
Var vDigits as Int

	vLeftDigit = 0
	vRightDigit = 0

	vDigits = @Left(vChunk, 1)
	If vDigits > 0 Then
	{
		If vWords <> "" Then
		{
			vWords = vWords + " "
		}
		vWords = vWords + SmallOnes[vDigits] + " Hundred"
	}
	vDigits = @Mid(vChunk, 2, 2)
	If vDigits > 19 Then
	{
		vLeftDigit = @Mid(vChunk, 2, 1)
		vRightDigit = @Mid(vChunk, 3, 1)
		If vWords <> "" Then
		{
			vWords = vWords + " "
		}
		vWords = vWords + BigOnes[vLeftDigit]
	}
	If vRightDigit > 0 Then
	{
		If vWords <> "" Then
		{
			vWords = vWords + " "
		}
		vWords = vWords + SmallOnes[vRightDigit]
	}
	Else
	{
		If (vDigits <= 19) and (vDigits > 0) Then
		{
			If vWords <> "" Then
			{
				vWords = vWords + " "
			}
			vWords = vWords + SmallOnes[vDigits]
		}
	}
End Subroutine //##################

Function MoneyToText(vAmount as Money) as String
var vWords as String
var vDollars as String
var vCents as String
var vChunk as String

	vWords = ""

	If vAmount <> 0 Then
	{
		If @Int(vAmount) > 999999 Then
		{
			@Msgbox("","Dollar amount too large.","")
		}
		Else
		{
			// Separate the dollars from the cents
			// Format incoming number to ensure 6 digits
			// to the left of the decimal & 2 to the right
			vDollars = @Int(vAmount)
			vDollars = @Right("000000" + vDollars, 6)
			vCents = @Frac(vAmount)
			vCents = @Right("00" + vCents, 2)

			// Separate the dollars into chunks
			If @Int(vDollars) = 0 Then
			{
				vWords = "Zero"
			}
			Else
			{
				// First do the thousands
				vChunk = @Left(vDollars, 3)
				If @Int(vChunk) > 0 Then
				{
					ParseChunk(vChunk, vWords)
					vWords = vWords + " Thousand"
				}

				// Do the rest of the dollars
				vChunk = @Right(vDollars, 3)
				If @Int(vChunk) > 0 Then
				{
					ParseChunk(vChunk, vWords)
				}
			}

			vWords = vWords + " and " + vCents + "/100"
		}
	}
	Return(vWords)
End Function

BigOnes[1] = "Ten"
BigOnes[2] = "Twenty"
BigOnes[3] = "Thirty"
BigOnes[4] = "Forty"
BigOnes[5] = "Fifty"
BigOnes[6] = "Sixty"
BigOnes[7] = "Seventy"
BigOnes[8] = "Eighty"
BigOnes[9] = "Ninety"
SmallOnes[1] = "One"
SmallOnes[2] = "Two"
SmallOnes[3] = "Three"
SmallOnes[4] = "Four"
SmallOnes[5] = "Five"
SmallOnes[6] = "Six"
SmallOnes[7] = "Seven"
SmallOnes[8] = "Eight"
SmallOnes[9] = "Nine"
SmallOnes[10] = "Ten"
SmallOnes[11] = "Eleven"
SmallOnes[12] = "Twelve"
SmallOnes[13] = "Thirteen"
SmallOnes[14] = "Fourteen"
SmallOnes[15] = "Fifteen"
SmallOnes[16] = "Sixteen"
SmallOnes[17] = "Seventeen"
SmallOnes[18] = "Eighteen"
SmallOnes[19] = "Nineteen"
 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged