<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Deleting a fiscal year problem]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=8793</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=8793&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Deleting a fiscal year problem.]]></description>
		<lastBuildDate>Thu, 03 Sep 2020 15:43:16 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=38266#p38266</link>
			<description><![CDATA[<p>Hi all again,<br />Unfortunately i couldn&#039;t solve this problem yet. I modified sql to find invoices, payments and credit notes which allocated in year to delete. </p><div class="codebox"><pre><code>$sql = &quot;SELECT trans_no, type 
            FROM &quot;.TB_PREF.&quot;debtor_trans 
            WHERE tran_date &lt;= &#039;$to&#039; 
            AND (round((ov_amount + ov_gst + ov_freight + ov_freight_tax + ov_discount), 3) = round((SELECT SUM(amt) FROM &quot;.TB_PREF.&quot;cust_allocations WHERE date_alloc &lt;= &#039;$to&#039; AND trans_no = trans_no_to AND    type = trans_type_to), 3) 
            OR round((ov_amount + ov_gst + ov_freight + ov_freight_tax + ov_discount), 3) = round((SELECT SUM(amt) FROM &quot;.TB_PREF.&quot;cust_allocations WHERE date_alloc &lt;= &#039;$to&#039; AND trans_no = trans_no_from AND    type = trans_type_from), 3))&quot;;</code></pre></div><br /><p>But it&#039;s not enough to find right transactions to delete. Still I have to separate some invoices and payment. <br />So I have an invoice (1800$) invoiced in 2015 and i have a payment (800$) paid in 2015. This payment is fully allocated to this invoice but remaining balance of this invoice (1000$) paid in 2016. <br />This sql find 800$ payment to delete because this payment is fully allocated in 2015 but invoice is still alive because it&#039;s not fully allocated in 2015.&nbsp; I have to keep this payment to find right balance at the end of 2015. <br />How can i do this? Hope i could explain the problem which i couldn&#039;t solve.</p><p>Thanks in advance.</p>]]></description>
			<author><![CDATA[null@example.com (madosk)]]></author>
			<pubDate>Thu, 03 Sep 2020 15:43:16 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=38266#p38266</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37558#p37558</link>
			<description><![CDATA[<p>This fix only delete allocation. Payment must be deleted too. </p><div class="codebox"><pre><code>$sql = &quot;SELECT trans_no, type FROM &quot;.TB_PREF.&quot;debtor_trans WHERE tran_date &lt;= &#039;$to&#039; AND 
        (ov_amount + ov_gst + ov_freight + ov_freight_tax + ov_discount) = 
        (SELECT SUM(amt) FROM &quot;.TB_PREF.&quot;cust_allocations WHERE date_alloc &lt;= &#039;$to&#039; AND trans_no = trans_no_to AND
        type = trans_type_to)&quot;;</code></pre></div><p>This sql can not find the payment to delete.</p>]]></description>
			<author><![CDATA[null@example.com (madosk)]]></author>
			<pubDate>Wed, 20 May 2020 16:27:58 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37558#p37558</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37557#p37557</link>
			<description><![CDATA[<p>Looks like this is a strange issue. I feel the below code is missing the cust allocation. </p><div class="codebox"><pre><code>  while ($row = db_fetch($result))
    {
        if ($row[&#039;type&#039;] == ST_SALESINVOICE)
        {
            $deliveries = get_sales_parent_numbers($row[&#039;type&#039;], $row[&#039;trans_no&#039;]);
            foreach ($deliveries as $delivery)
            {
                $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;debtor_trans_details WHERE debtor_trans_no = $delivery AND debtor_trans_type = &quot;.ST_CUSTDELIVERY;
                db_query($sql, &quot;Could not delete debtor trans details&quot;);
                $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;debtor_trans WHERE trans_no = $delivery AND type = &quot;.ST_CUSTDELIVERY;
                db_query($sql, &quot;Could not delete debtor trans&quot;);
                delete_attachments_and_comments(ST_CUSTDELIVERY, $delivery);
            }        
        }    
        $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;cust_allocations WHERE trans_no_from = {$row[&#039;trans_no&#039;]} AND trans_type_from = {$row[&#039;type&#039;]}&quot;;
        db_query($sql, &quot;Could not delete cust allocations&quot;);
.
.
.
}</code></pre></div><p>And may be it should be like this <br /></p><div class="codebox"><pre><code>while ($row = db_fetch($result))
    {
        if ($row[&#039;type&#039;] == ST_SALESINVOICE)
        {
            $deliveries = get_sales_parent_numbers($row[&#039;type&#039;], $row[&#039;trans_no&#039;]);
            foreach ($deliveries as $delivery)
            {
                $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;debtor_trans_details WHERE debtor_trans_no = $delivery AND debtor_trans_type = &quot;.ST_CUSTDELIVERY;
                db_query($sql, &quot;Could not delete debtor trans details&quot;);
                $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;debtor_trans WHERE trans_no = $delivery AND type = &quot;.ST_CUSTDELIVERY;
                db_query($sql, &quot;Could not delete debtor trans&quot;);
                delete_attachments_and_comments(ST_CUSTDELIVERY, $delivery);
            }        
                      $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;cust_allocations WHERE trans_no_to = {$row[&#039;trans_no&#039;]} AND trans_type_to = {$row[&#039;type&#039;]}&quot;;  // newly added 
        db_query($sql, &quot;Could not delete cust allocations&quot;);  // newly added. 
        }    
        $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;cust_allocations WHERE trans_no_from = {$row[&#039;trans_no&#039;]} AND trans_type_from = {$row[&#039;type&#039;]}&quot;;
        db_query($sql, &quot;Could not delete cust allocations&quot;);
}</code></pre></div><p>I have added two more lines added newly to collect the respective invoice allocation entires delete. Like the same for supplier allocations.</p><p>If it helps feedback us to fix it in core.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Wed, 20 May 2020 15:32:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37557#p37557</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37556#p37556</link>
			<description><![CDATA[<p>After deletion year 2014 customer has records in debtor_trans table. For example;</p><p><strong>debtor_trans</strong><br />trans_no: <span class="bbu">15496</span><br />type: 12<br />tran_date: 2014-09-29<br />ov_amount: 785<br />alloc: 785</p><p><strong>cust_allocations</strong><br />amt: 335<br />date_alloc: 2014-09-29<br />trans_no_from: <span class="bbu">15496</span><br />trans_type_from: 12<br />trans_no_to: 14931<br />trans_type_to: 10&nbsp; &nbsp; </p><p>amt: 450<br />date_alloc: 2014-09-29<br />trans_no_from: <span class="bbu">15496</span><br />trans_type_from: 12<br />trans_no_to: 15472<br />trans_type_to: 10</p><p>But 15472, 14931 transactions do not exist in debtor_trans. Why this payment didn&#039;t deleted? whereas it payed in 2014 and allocated to invoices in 2014.</p><p>By the way invoices are still alive which are processed in 2014 and allocated in 2015. This part is working correct i think but payments part is not.</p>]]></description>
			<author><![CDATA[null@example.com (madosk)]]></author>
			<pubDate>Wed, 20 May 2020 14:47:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37556#p37556</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37555#p37555</link>
			<description><![CDATA[<p>I have compatibility problem. I &#039;m using 2.3.26 but commited file compatible with 2.4.x.<br />2.3.26 neither has add_journal method nor 0_journal table. <br />I removed this part of code and tried to delete year but unfortunately customer balance calculated wrong.<br />I&#039;m investigating why balance is wrong. I&#039;ll inform you more if i find something.</p>]]></description>
			<author><![CDATA[null@example.com (madosk)]]></author>
			<pubDate>Wed, 20 May 2020 13:56:04 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37555#p37555</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37539#p37539</link>
			<description><![CDATA[<p>Updated <a href="https://frontaccounting.com/fawiki/index.php?n=Help.FiscalYears">Wiki</a>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 17 May 2020 16:38:51 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37539#p37539</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37524#p37524</link>
			<description><![CDATA[<p>@joe, your solution is good. Instead of rewriting it as journal entry. We keep the invoices alive and it&#039;s allocations alive. So it will be removed if they remove next fiscal year.&nbsp; </p><p>@madosk, This is definitely a time saving way for you to implement it.&nbsp; Hope your problem fixed with this. And post an reply after using this updated program. It would be a solved solution for future referring users.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Fri, 15 May 2020 11:12:28 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37524#p37524</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37523#p37523</link>
			<description><![CDATA[<p>@joe: Thanks for solution. I have been working on it for a few days. Your solution is ver simple and i &#039;ll try asap. Will it work for payed before and invoiced next year transactions?</p>]]></description>
			<author><![CDATA[null@example.com (madosk)]]></author>
			<pubDate>Fri, 15 May 2020 10:06:11 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37523#p37523</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37522#p37522</link>
			<description><![CDATA[<p>The allocations has been revised and should now work. Committed to stable repo. The fixed file can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/admin/db/fiscalyears_db.inc">here</a>.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 15 May 2020 08:44:52 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37522#p37522</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37521#p37521</link>
			<description><![CDATA[<p>Oh yes, I see. The alloc field got stamped in the next year and when the invoice was not allocated by end of last year.<br />I will have to look at the allocation routines instead. Thanks.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 15 May 2020 07:36:22 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37521#p37521</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37520#p37520</link>
			<description><![CDATA[<p>How ever there is a problem with payment of next year for previous year invoice. </p><p>Let&#039;s take his example. He issued several invoices&nbsp; at the end of last year and collected the payment in next year.&nbsp; Which means the system needs to make one journal entry for a customer at least to record the invoice balances as opening balance and that should be allocated in the next year.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Fri, 15 May 2020 07:17:43 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37520#p37520</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37519#p37519</link>
			<description><![CDATA[<p>Hello again.</p><p>I have now went through the deleting fiscal year procedure. I have found no problems here.<br />Here is a list over what happens when processing deleting of a fiscal year:</p><div class="codebox"><pre><code>Delete Fiscalyear

1. Backup is done
2. All sales orders and details, up to last date, that are fully delivered are removed. Attachments are removed.
3. All purchase orders and details, up to last date, that are fully received are removed. Attachments are removed.
4. All GRN receivals, up to last date, are removed.
5. All debtor trans and details, up to last date, that are fully allocated are removed. Attachments are removed.
6. All cust allocations, up to last date, are removed.
7. All supp trans and details, up to last date, that are fully allocated are removed. Attachments are removed.
8. All supp allocations, up to last date, are removed.
9. All workorders, up to last date, and closed.
   a. All workorder issues are removed. Attachments are removed.
   b. All workorder manufacture are removed. 
   c. All workorder requirements are removed.
   d. Workorders removed. Attachments are removed.
10. All stock moves, up to last date, are removed and converted to a closing stock move.
11. All voided items, up to last date, are removed.
12. All trans tax details, up to last date, are removed.
13. All exchange rater, up to last date, are removed.
14. All cust and supp sub gl transactions are retrieved by account, removed and an end transaction are inserted. 
15. All bank trans, up to last date, are removed and converted to a closing balance trans.
16. All ausit trail, up to last date, are removed.
17. All comments, up to last date, are removed.
18. Finally the fiscalyear is removed.</code></pre></div><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 15 May 2020 06:40:49 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37519#p37519</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37507#p37507</link>
			<description><![CDATA[<p>This is a difficult task. I remember writing these routines years back and we really tried to get it all at that time.<br />I will try to look into it asap.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Thu, 14 May 2020 10:11:43 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37507#p37507</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37505#p37505</link>
			<description><![CDATA[<p>@joe: Need to refurbish the end of year routines to make sure that the client balances are automatically made along with unpaid and partially paid invoice data for allocation of payments in the subsequent year. This needs to be done for suppliers as well. The appropriate stock moves too need to be taken care of.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Thu, 14 May 2020 09:28:05 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37505#p37505</guid>
		</item>
		<item>
			<title><![CDATA[Re: Deleting a fiscal year problem]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=37492#p37492</link>
			<description><![CDATA[<p>Yes you&#039;re right. Thanks for the idea <img src="https://frontaccounting.com/punbb/img/smilies/smile.png" width="15" height="15" alt="smile" /><br />I&#039;ll inform you when finished.</p>]]></description>
			<author><![CDATA[null@example.com (madosk)]]></author>
			<pubDate>Wed, 13 May 2020 11:52:16 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=37492#p37492</guid>
		</item>
	</channel>
</rss>
