Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating referencenumber for bank 1

Status
Not open for further replies.

jarla

Programmer
Jan 2, 2001
34
0
0
FI
Hi!
This could be hard to do, but I trust you professionals :)

I need to make so called referencenumber from deliverynumber to use for bank -payment. In Finland the formula to generate the referencenumber is like this:
Original number=1234
Those numbers must be multiply with the formula "7,3,1" from right to left. So in this case we must do the multiply 7*4, 3*3, 1*2, 7*1. We get numbers 28,9,2,7. Then we take the SUM 28+9+2+7 and we get number 46. Then we take the nearest FULL TEN upward, which is 50. Then we must do subtraction 50-46 and we get number 4. That "4" is the "checknumber" what we need. So the full referencenumber in this case is 12344 (Original number and checknumber)
How can I do this with Coldfusion -code? Original number can be longer than in this 4-digit example and it´s important to follow that multiply -system. First number from right with "7", next one with "3" etc.
AND if the last subtraction gives the number 10, it must be changed to "0".

I hope that somebody understood something from my question. I think it´s more harder to read than make ;)


 
This looks very nice... Only it's a bit long formula.
Please contact me if you want this have to be developed...

Wich version of Coldfusion do you use? Because this is a nice one for a component...

Good luck!

Some people can learn, some people can teach.
 
That was fun...

This works for me... It could probably be optimized a little but shh.. I'm at work..

I tossed it a few random numbers but you'll want to test it.

Code:
<cfset finumber=1234>
<cfset holdfin=finumber>

<cfset ArrFin=ListToArray("7,3,1")>

<cfset shavepos=1>
<cfset newfin="">

<cfloop from="1" to="#len(finumber)#" index="i">
  <cfset xnum=right(finumber,1)>
  <cfif len(finumber) neq 1><cfset finumber=left(finumber,len(finumber)-1)></cfif>
  <cfset newfin=listappend(newfin,xnum * ArrFin[shavepos],"+")>
  <cfset shavepos=shavepos+1>
  <cfif shavepos eq 4><cfset shavepos=1></cfif>
</cfloop>

<cfset sumfin=evaluate(newfin)>
<cfset roundfin=left(sumfin,len(sumfin)-1) + 1 & 0>
<cfset subfin=roundfin-sumfin>

<cfif subfin eq 10><cfset subfin=0></cfif>

<cfset refnum=holdfin & subfin>

<cfoutput>
<pre>
Number: #holdfin#
Numbers to Add: #newfin#
Sum of Numbers: #sumfin#
Rounded: #roundfin#
Total (Rounded - Sum): #subfin#
New Ref Number: #refnum#
</pre>
</cfoutput>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Can you tell me how you found out about this process?

Some net resource?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
webmigit: Your code worked great!! It´s just what I was looking for! Thank you very much!
I had a Javascript -code earlier what I was using when I was writing invoices to customers manually. But now I wanted to have a system that generates that reference number to customer immediately when the customer order something from our webshop and choose "directly to account" as a payment method. Finnish bank (how about other countries??) take extra 0,40 EUR costs from every payment which comes to account without reference number!!! Maybe it sounds little money, but if we have about five "directly to account" -payments every day, everyone can count how much extra our bank take from us during one year!!!
 
Do you know the formulas for other countries?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Unfortunately not. When I asked about other countries reference numbers from my bank, they said that this kind of formula is in use only in Finland. But it would be good to know also about other countries same kind of numbers.
I forgot to tell that that reference number in Finland must be at least 2 digit long and no longer than 19 digits (including the last checknumber).
 
Well it would be at least two digits long in all cases that I can think of..

As for limiting to ten digits, how long does the original ref number get and how you do handle numbers ten digits or longer?

Also I was pretty sure it was just a Finnish thing as I'd never heard of banks doing it that particular way and I work in finance, just hoped maybe there was something that I could build into my stuff.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top