<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — New Year reference resetting]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=7922</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7922&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in New Year reference resetting.]]></description>
		<lastBuildDate>Sun, 13 Jan 2019 12:27:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33938#p33938</link>
			<description><![CDATA[<p>For those who want the Fiscal Year Ending {EE}/{EEEE} format as well, it is available in my <a href="https://github.com/apmuthu/frontac24/commit/1da4ead10164987f2dd992e7974eb4364a4239ba">commit</a>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 13 Jan 2019 12:27:53 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33938#p33938</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33923#p33923</link>
			<description><![CDATA[<p>Thanks Janusz and apmuthu</p>]]></description>
			<author><![CDATA[null@example.com (anoopmb)]]></author>
			<pubDate>Wed, 09 Jan 2019 14:30:13 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33923#p33923</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33916#p33916</link>
			<description><![CDATA[<p>Then we can also have the fiscal year end date as {EE} and {EEEE} as well so that we can have ###/2018-19 if we use {NNN}/{FFFF}-{EE}.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Wed, 09 Jan 2019 08:45:46 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33916#p33916</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33915#p33915</link>
			<description><![CDATA[<p>I have added fix solving this problem to frontaccounting code base.<br />The number templates for short and long form of fiscal year number is {FF} and {FFFF} respectively, which seems to be more intuitive. Thank you for the idea. This will be available with next minor release.<br />Janusz</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Wed, 09 Jan 2019 08:34:30 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33915#p33915</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33889#p33889</link>
			<description><![CDATA[<p>@joe: This can be included. <a href="https://github.com/anoopmb/FA/commit/34e2e21901742b20ab7ee9433014d2f50f5a3629#diff-a0a0f2644dfd8504e5989eb2191b6f8e">Commit Diff</a>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Tue, 08 Jan 2019 03:24:17 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33889#p33889</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33882#p33882</link>
			<description><![CDATA[<p>@apmuthu</p><p>you&nbsp; can see my changes on my fork over </p><p><a href="https://github.com/anoopmb/FA/blob/master/includes/references.inc"> here</a></p><p>update is on 2.4.6 /includes/references.inc file</p><p>1. line no 55 updated the placeholder array to</p><div class="codebox"><pre><code>$refline_placeholders = array(
    &#039;MM&#039; =&gt; &#039;date&#039;,
    &#039;Y&#039; =&gt; &#039;date&#039;,
    &#039;YY&#039; =&gt; &#039;date&#039;,
    &#039;YYY&#039; =&gt; &#039;date&#039;,
    &#039;YYYY&#039; =&gt; &#039;date&#039;,
    &#039;UU&#039; =&gt; &#039;user&#039;,
    &#039;P&#039; =&gt; &#039;pos&#039;,
//     FIXME:  for placeholders below all the code should work, but as the ref length is variable,
//       length specification in placeholder format should be implemented.
//    &#039;C&#039; =&gt; &#039;customer&#039;,
//    &#039;B&#039; =&gt; &#039;branch&#039;,
//    &#039;S&#039; =&gt; &#039;supplier&#039;,
//    &#039;L&#039; =&gt; &#039;location&#039;
);</code></pre></div><br /><p>2. added new template in switch case line no 124</p><div class="codebox"><pre><code>                        case &#039;Y&#039;:
                        case &#039;YYY&#039;:
                            list($begin_day, $begin_month, $begin_year) = explode_date_to_dmy(begin_fiscalyear());
                            list($end_day, $end_month, $end_year) = explode_date_to_dmy(end_fiscalyear());
                            $out .= $ph == &#039;Y&#039; ? sprintf(&#039;%04d&#039;, $begin_year) : sprintf(&#039;%04d&#039;, $begin_year) . &quot;-&quot; . sprintf(&#039;%02d&#039;, $end_year % 100);
                            break;</code></pre></div><p>3. updated is_valid function line no 266</p><br /><div class="codebox"><pre><code>function is_valid($reference, $type, $context=null, $line=null)
    {
         if (!isset($line))
             $line = $this-&gt;reflines-&gt;find_refline_id($reference, $type, true);

         if (!isset($line))
             return false;

        $refline = $this-&gt;reflines-&gt;get($line);

        if ($this-&gt;_legacy_line($refline))    //legacy non-templated line
            return strlen(trim($reference)) &gt; 0;

        $regex = preg_quote($refline[&#039;prefix&#039;].$refline[&#039;pattern&#039;]);
        if (!is_array($context))
            $context = array(&#039;date&#039;=&gt;$context);

         $context[&#039;pos&#039;] = $_SESSION[&quot;wa_current_user&quot;]-&gt;pos;

        if (is_date(@$context[&#039;date&#039;]))
        {
            list($year4, $month, $day) = explode(&quot;-&quot;, date2sql($context[&#039;date&#039;]));
            list($begin_year, $begin_month, $begin_day) = explode(&quot;-&quot;, date2sql(begin_fiscalyear()));
            list($end_year, $end_month, $end_day) = explode(&quot;-&quot;, date2sql(end_fiscalyear()));
            $year2 = substr($year4, 2);
            $year3 = $begin_year.&quot;-&quot;.substr($end_year, 2);
        } else
        {
            $month = &#039;\d{2,}&#039;;
            $year2 = &#039;\d{2,}&#039;;
            $year4 = &#039;\d{4,}&#039;;
            $begin_year = &#039;\d{4,}&#039;;
            $year3 = &#039;\d{4,}-\d{2,}&#039;;
        }
        $cust = @$context[&#039;customer&#039;] ? $context[&#039;customer&#039;] : &#039;\d+&#039;;
        $supp = @$context[&#039;supplier&#039;] ? $context[&#039;supplier&#039;] : &#039;\d+&#039;;
        $branch = @$context[&#039;branch&#039;] ? $context[&#039;branch&#039;] : &#039;\d+&#039;;
        $location = @$context[&#039;location&#039;] ? $context[&#039;location&#039;] : &#039;[a-z0-9]+&#039;;
         $pos = @$context[&#039;pos&#039;] ? $context[&#039;pos&#039;] : &#039;\d+&#039;;
        $user = sprintf(&quot;%02d&quot;, $_SESSION[&#039;wa_current_user&#039;]-&gt;user);

        $regex = preg_replace(
            array(
                &#039;/\\\{/&#039;,    // unquote placeholders
                &#039;/\\\}/&#039;,
                &#039;/\{MM\}/&#039;,
                &#039;/\{Y\}/&#039;,
                &#039;/\{YY\}/&#039;,
                &#039;/\{YYY\}/&#039;,
                &#039;/\{YYYY\}/&#039;,
                &#039;/\{C\}/&#039;,
                &#039;/\{B\}/&#039;,
                &#039;/\{S\}/&#039;,
                &#039;/\{L\}/&#039;,
                &#039;/\{UU\}/&#039;,
                 &#039;/\{P\}/&#039;,
                &#039;/\{\d+}/&#039;,
            ),
            array(
                &#039;{&#039;,
                &#039;}&#039;,
                $month,
                $begin_year,
                $year2,
                $year3,
                $year4,
                $cust,
                $branch,
                $supp,
                $location,
                $user,
                 $pos,
                &#039;\d+&#039;,
            ), $regex);

        $regex = &#039;&quot;^&#039;.$regex.&#039;&quot;i&#039;;

        return preg_match($regex, $reference, $match) ? 1 : 0;
    }</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (anoopmb)]]></author>
			<pubDate>Mon, 07 Jan 2019 04:13:38 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33882#p33882</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33881#p33881</link>
			<description><![CDATA[<p>@anoopmb: kindly submit your tested code changes for peer review and inclusion in the core for both {Y} and {YYY}.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Mon, 07 Jan 2019 02:44:58 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33881#p33881</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33880#p33880</link>
			<description><![CDATA[<p>i have made some changes to my code for now <br />expecting new format will come shortly</p>]]></description>
			<author><![CDATA[null@example.com (anoopmb)]]></author>
			<pubDate>Mon, 07 Jan 2019 02:42:18 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33880#p33880</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33877#p33877</link>
			<description><![CDATA[<p>This <a href="https://frontaccounting.com/fawiki/index.php?n=Help.FormsSetup">Wiki page</a> points to this thread.</p><p>@joe: Along with {Y}, try to include {YYY} to indicate both years if they lie in different calendar years like <strong>/2018-19</strong>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 06 Jan 2019 16:16:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33877#p33877</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33873#p33873</link>
			<description><![CDATA[<p>By the way the wiki is not updated with these patterns for Transaction References. How to use it?</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Sun, 06 Jan 2019 14:46:39 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33873#p33873</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33869#p33869</link>
			<description><![CDATA[<p>I will have Janusz to look at this.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sat, 05 Jan 2019 17:27:11 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33869#p33869</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33866#p33866</link>
			<description><![CDATA[<p>@joe: This will be desirable to include in the core - {Y}.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sat, 05 Jan 2019 16:07:26 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33866#p33866</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33857#p33857</link>
			<description><![CDATA[<p>@apmuthu</p><p>Thanks and its very easy to do by calling begin fiscal year method</p>]]></description>
			<author><![CDATA[null@example.com (anoopmb)]]></author>
			<pubDate>Sat, 05 Jan 2019 10:10:51 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33857#p33857</guid>
		</item>
		<item>
			<title><![CDATA[Re: New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33851#p33851</link>
			<description><![CDATA[<p>Your <strong>includes/references.inc</strong> line number 99 is for FA 2.3.x.<br />Lines 121, 122 are for FA 2.4.x.</p><p>Just take the Year of the fiscal year beginning only!</p><p>Besides, this will all go wrong if the template is created with all the date elements for when there are too many transactions each day and a template like {DD}{MM}{YYYY} is used! A separate template like {Y} may be used for this kind of resetting of the year each fiscal beginning.</p><p>There is a <strong>function get_fiscalyear_begin_for_date($date)</strong> that obtains the financial year beginning in the file <strong>admin/db/fiscalyears_db.inc</strong>. Also available in it is <strong>get_current_fiscalyear()</strong>. These functions return the MySQL date format whilst taking the user date format as input where needed.</p><p>There is another <strong>function begin_fiscalyear()</strong> that gets the current fiscal year&#039;s begin date in user date format in <strong>includes/date_functions.inc</strong>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sat, 05 Jan 2019 07:00:53 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33851#p33851</guid>
		</item>
		<item>
			<title><![CDATA[New Year reference resetting]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33843#p33843</link>
			<description><![CDATA[<p>hi,<br />I found one issue that , in India fiscal year end is 31st March of every year, so if I use {YYYY) template on reference, the reference number will reset to start from one on 1st of January.</p><p>for eg. 31st December reference was SO201800080 but on January 1st it became SO201900001 which cant be accepted because current fiscal year is not closed and it should be continuation of last reference (SO201800081)&nbsp; till 31st March.</p><p>My ugly hack to resolve this is</p><p>1. get current fiscal year begin<br />2. check context date is in fiscal year and both year is not same<br />3. if its matching create a new date with previous year and set it as date in reference context</p><div class="codebox"><pre><code>        list($day, $month, $year) = explode_date_to_dmy(begin_fiscalyear());
        list($day1, $month1, $year1) = explode_date_to_dmy($context[&#039;date&#039;]);

    if(is_date_in_fiscalyear($context[&#039;date&#039;])&amp;&amp;$year!=$year1){
            $mdate=sql2date($year.&quot;-&quot;.$month1.&quot;-&quot;.$day1);
            $context[&#039;date&#039;]=$mdate;
        }</code></pre></div><p>added above code in reference.inc line number 99</p><p>Please suggest me if there is better way to resolve this</p>]]></description>
			<author><![CDATA[null@example.com (anoopmb)]]></author>
			<pubDate>Sat, 05 Jan 2019 01:46:27 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33843#p33843</guid>
		</item>
	</channel>
</rss>
