<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Manufacturing Values Off By Small Amounts]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=8662</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=8662&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Manufacturing Values Off By Small Amounts.]]></description>
		<lastBuildDate>Thu, 30 Jan 2020 01:41:22 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36939#p36939</link>
			<description><![CDATA[<p>I suggest making a fork of the <a href="https://github.com/FrontAccountingERP/FA/tree/master">FA project</a> on github, and adding your changes in, perhaps with help from a 3-way diff tool.&nbsp; Then as new changes are made in FA, you can <a href="https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork">sync your fork with the upstream code</a>.&nbsp; Often the new changes are incorporated without any additional effort but sometimes there are conflicts, but then you run git mergetool to help determine how to proceed.</p>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Thu, 30 Jan 2020 01:41:22 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36939#p36939</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36938#p36938</link>
			<description><![CDATA[<p>I have made many changes to FrontAccounting the past 6 months. I have rough notes of these changes. Probably 99% of those changes have been offered from many of you via this forum. </p><p>&nbsp; What is the best way to backup and restore these changes when a new version becomes available? I imagine some of the changes I made to 2.4.7 may already be incorporated in the next version.</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Thu, 30 Jan 2020 01:24:25 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36938#p36938</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36937#p36937</link>
			<description><![CDATA[<p>Thanks Braathe. I blew right past the main section. After applying your modifications, it DOES address my problem with rounding. Thank you very much.</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Thu, 30 Jan 2020 01:17:04 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36937#p36937</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36936#p36936</link>
			<description><![CDATA[<p>Just for the record, round2() is mainly needed starting at line 55 to sum up the the boms.&nbsp; Line 65 is just the additional materials.</p>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Wed, 29 Jan 2020 21:45:15 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36936#p36936</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36935#p36935</link>
			<description><![CDATA[<p>The rounding modification didn&#039;t help my issue. I modified manufacturing/includes/db/work_order_produce_items_db.inc by replacing lines starting at line 65 with @Braathe&#039;s suggestion. I still see the differences.</p><p>&nbsp; I have no problem adding a journal entry to clean up. I was more concerned that I was doing something wrong or I setup something wrong and I wanted to correct that. Maybe most people just let this run wild and don&#039;t address it at all. I&#039;m not trying to make more work to do, just wanting to follow best practices with the tools available.</p><p>&nbsp; Thank you very much for the insight and suggestions.</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Wed, 29 Jan 2020 14:17:33 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36935#p36935</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36931#p36931</link>
			<description><![CDATA[<p>I don&#039;t know. We have tried to do our best by using the DELTA factor.<br />We can await @Braath Waate&#039;s approach by @paul testing it.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Mon, 27 Jan 2020 22:23:23 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36931#p36931</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36929#p36929</link>
			<description><![CDATA[<p>@joe: How do we handle such rounding errors in a standardised way to avoid adjustment journal entries?</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Mon, 27 Jan 2020 18:16:23 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36929#p36929</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36922#p36922</link>
			<description><![CDATA[<p>This is an FA bug, sort of, and it affects my site as well, but I haven&#039;t gotten around to fixing it yet.&nbsp; And yes, a journal entry is probably the only way to address it without fixing the code.</p><p>When FA closes a work order, it calls work_order_produce() which first creates the Finished Product Requirements.&nbsp; &nbsp;The g/l created by each requirement eventually calls add_gl_trans().&nbsp; Note the rounding in this function:</p><div class="codebox"><pre><code>function add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension2, $memo_,
    $amount, $currency=null, $person_type_id=null, $person_id=null, $err_msg=&quot;&quot;, $rate=0)
{
    global $SysPrefs;

    $date = date2sql($date_);
    if ($currency != null)
    {
        if ($rate == 0)
            $amount_in_home_currency = to_home_currency($amount, $currency, $date_);
        else
            $amount_in_home_currency = round2($amount * $rate,  user_price_dec());
    }
    else
        $amount_in_home_currency = round2($amount, user_price_dec());</code></pre></div><p>OK, so each requirement is rounded, and then added up.</p><p>But wait, there is more to do.&nbsp; work_order_produce() then sums up the Finished Product Recieval:</p><div class="codebox"><pre><code>        // 1. calculate sums of material/labour/overhead costs

        // sum collected BOM material &amp; labour costs (no way for separate overhead here for now - needs flag in bom or stock_master)
        $bom = get_wo_requirements($woid);
        $m_cost = $l_cost = 0;
        while ($component = db_fetch($bom))
        {
            if (!is_service($component[&quot;mb_flag&quot;]))
                $m_cost += $component[&#039;unit_cost&#039;]*$component[&#039;units_issued&#039;];
            else
                $l_cost += $component[&#039;unit_cost&#039;]*$component[&#039;units_issued&#039;];
        }

        // add additional material issues
        $issues = get_additional_issues($woid);
        while ($issue = db_fetch($issues))
        {
            if (!is_service($issue[&quot;mb_flag&quot;]))
                $m_cost += $issue[&#039;unit_cost&#039;]*$issue[&#039;qty_issued&#039;];
            else
                $l_cost += $issue[&#039;unit_cost&#039;]*$issue[&#039;qty_issued&#039;];
        }

        // and additional costs
        $o_cost = get_gl_wo_cost($woid, WO_OVERHEAD);
        $l_cost += get_gl_wo_cost($woid, WO_LABOUR);

        $total_cost = $o_cost + $m_cost + $l_cost;

        add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $product[&#039;wip_account&#039;],
            0, 0, $memo, -$total_cost);

        add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $product[&#039;inventory_account&#039;],
            0, 0, $memo, $total_cost);</code></pre></div><p>So if all units were able to be manufactured, the calculation should be the same.</p><p>Except for the lack of rounding in this code.</p><p>So if it disturbs you to see these rounding errors, what can you do?&nbsp; Well, you could try rounding m_cost and l_cost like in add_gl_trans.&nbsp; Maybe try:</p><div class="codebox"><pre><code>          if (!is_service($issue[&quot;mb_flag&quot;]))
                $m_cost += round2($issue[&#039;unit_cost&#039;]*$issue[&#039;qty_issued&#039;], user_price_dec());
            else
                $l_cost += round2($issue[&#039;unit_cost&#039;]*$issue[&#039;qty_issued&#039;], user_price_dec());</code></pre></div><p>I haven&#039;t tried this, so it might not work.&nbsp; But this is first thing I would try.</p>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Sun, 26 Jan 2020 23:35:06 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36922#p36922</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36920#p36920</link>
			<description><![CDATA[<p>I just entered four work orders from yesterday. Only one was accurate from inventory through work in progress back into inventory. Two others were off by one penny. One other one was off by 2 pennies. Each one is not much, but with up to 400 work orders a month, it starts to add up.</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Sun, 26 Jan 2020 17:43:10 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36920#p36920</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36919#p36919</link>
			<description><![CDATA[<p>With the test php file, I get:</p><div class="codebox"><pre><code>1.7 is NOT greater than or equal to 1.7000000000000002
0.30000000000000004</code></pre></div><p>&nbsp; I don&#039;t need super fine precision. I would like consistency. If I&#039;m taking $33.01 out of inventory for manufacturing, I need $33.01 taken from manufacturing back into inventory. Maybe part of my problem is the difference from my vendors unit of 1 equals 1152 units in my inventory. Standard costs are shown at 4 decimal places.</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Sun, 26 Jan 2020 17:03:44 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36919#p36919</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36918#p36918</link>
			<description><![CDATA[<p>Try this piece of code in a test php file:<br /></p><div class="codebox"><pre><code>&lt;?php
if (1.7 &gt;= 17 * 0.1) {
  echo &#039;1.7 is greater than or equal to &#039; . 17 * 0.1;
} else {
  echo &#039;1.7 is NOT greater than or equal to &#039; . 17 * 0.1;
}

echo &quot;&lt;br&gt;\n&quot; . (0.1 + 0.2);

?&gt;</code></pre></div><p>In XAMPP 1.7.3 (PHP 5.3.1) we get:<br /></p><div class="codebox"><pre><code>1.7 is NOT greater than or equal to 1.7000000000000002
0.30000000000000004</code></pre></div><p>This is because native operator are indeed interpreted in base 2, and most base 10 decimal converts badly in base 2.</p><p>If you need precision, you need to either only manipulate integers (converts perfectly to base 2) or use a dedicated lib such as <a href="https://www.php.net/manual/en/book.bc.php">bcmath</a> (checkout the wrapper to ease bcmath usage <a href="https://github.com/fab2s/Math">Math</a>).</p><p>Ref as of 2 months ago:<br />https://stackoverflow.com/questions/58744298/php-floating-point-multiplication-and-comparison-issue</p><p>Ref as of nearly 11 years ago:<br />https://stackoverflow.com/questions/588004/is-floating-point-math-broken</p><p>Ref in PHP.net:<br />https://bugs.php.net/bug.php?id=74534</p><p><a href="https://floating-point-gui.de/">Floating point arithmetic for programmers</a></p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 26 Jan 2020 16:33:48 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36918#p36918</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36913#p36913</link>
			<description><![CDATA[<p>I saw this option, but thought it was for discrepancies while receiving a purchase order if pricing was too far off of the entered amount. But, I did change the value (not knowing it&#039;s potential) with no change to my manufacturing issue. The values I tested with other than the 0.005 were 0.505 and 5.505 - Manufacturing amount inaccuracies are still produced.</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Sat, 25 Jan 2020 14:36:58 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36913#p36913</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36909#p36909</link>
			<description><![CDATA[<p><strong><em>$config_allocation_settled_allowance</em></strong> value in <strong>config.php</strong>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sat, 25 Jan 2020 06:31:28 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36909#p36909</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36907#p36907</link>
			<description><![CDATA[<p>Assuming you are referring to a literal term, I do not find a &quot;delta&quot; value in my FrontAccounting&#039;s config.php</p>]]></description>
			<author><![CDATA[null@example.com (paul)]]></author>
			<pubDate>Sat, 25 Jan 2020 03:40:19 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36907#p36907</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manufacturing Values Off By Small Amounts]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=36905#p36905</link>
			<description><![CDATA[<p>Then play with the delta value in config.php</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sat, 25 Jan 2020 03:01:51 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=36905#p36905</guid>
		</item>
	</channel>
</rss>
