<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Use of type, trans_no and ref in system]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=701&amp;type=atom" />
	<updated>2009-06-13T09:28:10Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=701</id>
		<entry>
			<title type="html"><![CDATA[Re: Use of type, trans_no and ref in system]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=2864#p2864" />
			<content type="html"><![CDATA[<p>A very good idea, Pete. I will include it at once to go with 2.1.3.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2009-06-13T09:28:10Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=2864#p2864</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of type, trans_no and ref in system]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=2855#p2855" />
			<content type="html"><![CDATA[<p>Thanks Joe. While reading your answer, I thought up (coded up) a possible enhancement to cater for eg. INV0034 or DPA11023 type references that still allows for &#039;counting up&#039; as payments etc are made.</p><p>Basically, if the ref ends in digits (and digits only), then the function will increment by 1, while still keeping the alpha prefix.<br />So: DPA0023 becomes DPA0024, INV0000332 becomes INV0000333 and 45TR34P009 becomes 45TR34P010.</p><p>Here&#039;s the new references.inc class method for increment($reference) (line 72)</p><p>&nbsp; &nbsp; function increment($reference) {<br />&nbsp; &nbsp; &nbsp; &nbsp; // If $reference is trailed by digits, and digits only,<br />&nbsp; &nbsp; &nbsp; &nbsp; // extract them and add 1, then put the alpha prefix back on<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // NB. preg_match returns 1 if the regex matches completely <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // also $result[0] holds entire string, 1 the first captured, 2 the 2nd etc.<br />&nbsp; &nbsp; &nbsp; &nbsp; if(preg_match(&#039;/^(.*?)(\d+)$/&#039;,$reference,$result)==1) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $dig_count = strlen($result[2]); // How many digits? eg. 0003 = 4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $fmt = &#039;%0&#039; . $dig_count . &#039;d&#039;; // Make a format string - leading zeroes<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $nextval =&nbsp; $result[1] . sprintf($fmt, intval($result[2]+1)); // Add one on, and put prefix back on<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $nextval;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; else <br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return $reference;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; //------------------------------------<br />}</p><p>You can get rid of comments, or do anything (or even ignore it if you think it&#039;s not worth it). I&#039;m using it because my pre-printed stationery has a 3-letter alpha code at the front.</p><p>Cheers<br />Pete</p>]]></content>
			<author>
				<name><![CDATA[p2409]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=267</uri>
			</author>
			<updated>2009-06-12T09:00:36Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=2855#p2855</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of type, trans_no and ref in system]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=2851#p2851" />
			<content type="html"><![CDATA[<p>Hello Pete,<br />You are quite right in your assumptions.<br />The type and trans_no are unique for the docuemnts and other operations and this type and trans_no follow the transactions all the way down to GL Entries.<br />The &#039;refs&#039; are for your convenience. You an use an alternative numberserie starting f.i. from 1000. You can also use a combination of letters and/or digits. In case of only numbers, the refs are automatically increased everytime you use it. Otherwise you see the last one.<br />This is very handy for documents like invoices.</p><p>/Joe<br />BTW. in the file /gl/includes/db/gl_db_trans.inc, a bit down,&nbsp; you can see how to insert a complete Journal Entry.</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2009-06-12T06:51:08Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=2851#p2851</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Use of type, trans_no and ref in system]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=2850#p2850" />
			<content type="html"><![CDATA[<p>Hello fellas</p><p>I&#039;m looking into the beginnings of an API to post transactions. I&#039;ve seen the downloads for customer and item importation on this site in the download section - these are relatively straightforward, however sys_type updates are obviously more complex as counters, next refs, taxes etc need to kept up to date. I don&#039;t think anyone&#039;s done this yet through an API-style interface.</p><p>A few questions for the experts:</p><p>1) In the 1_sys_types table, what is the difference between &#039;type_no&#039; and &#039;next reference&#039;? I note that sometimes they are in sync, but in the empty US SQL import file, they aren&#039;t always. </p><p>2) Am I right in saying that sys_type and type_no are THE definitive keys for any transaction in the system. Does this mean that type_no and next_reference should stay in sync? How would they get out of sync?</p><p>3) Is 1_refs table? just a text &#039;reference&#039; information field against a transaction keyed by a sys_type and id number?</p><p>Thanks boys I&#039;ll let you know how I go.....</p><p>Pete</p>]]></content>
			<author>
				<name><![CDATA[p2409]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=267</uri>
			</author>
			<updated>2009-06-12T05:42:05Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=2850#p2850</id>
		</entry>
</feed>
