<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — items_cart class has a logical bug, should be fixed.]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7964&amp;type=atom" />
	<updated>2019-01-23T10:30:14Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=7964</id>
		<entry>
			<title type="html"><![CDATA[Re: items_cart class has a logical bug, should be fixed.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=34060#p34060" />
			<content type="html"><![CDATA[<p>This has been fixed and committed to repo. Thanks @kvvaradha for detecting this.</p><p>A new file for replacement can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/includes/ui/items_cart.inc">here</a>.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2019-01-23T10:30:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=34060#p34060</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[items_cart class has a logical bug, should be fixed.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=34059#p34059" />
			<content type="html"><![CDATA[<p>The items_cart.inc looks like this function</p><div class="codebox"><pre><code>function check_qoh($location, $date_, $reverse=false)
    {
        global $SysPrefs;

        $low_stock = array();

        if (!$SysPrefs-&gt;allow_negative_stock() || is_fixed_asset($line_items-&gt;mb_flag))
        {
            foreach ($this-&gt;line_items as $line_no =&gt; $line_item)
                if (has_stock_holding($line_item-&gt;mb_flag) || is_fixed_asset($line_item-&gt;mb_flag))
                {
                    $quantity = $line_item-&gt;quantity;
                    if ($reverse)
                        $quantity = -$line_item-&gt;quantity;

                    if ($quantity &gt;= 0)
                        continue;

                    if (check_negative_stock($line_item-&gt;stock_id, $quantity, $location, $date_))
                        $low_stock[] = $line_item-&gt;stock_id;
                }
        }
        return $low_stock;
    }</code></pre></div><p>But here&nbsp; is the bug,<br /></p><div class="codebox"><pre><code>if (!$SysPrefs-&gt;allow_negative_stock() || is_fixed_asset($line_items-&gt;mb_flag))</code></pre></div><p>Probably the <strong> is_fixed_asset($line_items-&gt;mb_flag)</strong> is invalid to put it here. we already checking that inside for loop.&nbsp; Also the object <strong> $line_items-&gt;mb_flag</strong> is not available.&nbsp; so change the function like this. </p><div class="codebox"><pre><code>function check_qoh($location, $date_, $reverse=false)
    {
        global $SysPrefs;

        $low_stock = array();
        if (!$SysPrefs-&gt;allow_negative_stock())
        {
            foreach ($this-&gt;line_items as $line_no =&gt; $line_item)
                if (has_stock_holding($line_item-&gt;mb_flag) || is_fixed_asset($line_item-&gt;mb_flag))
                {
                    $quantity = $line_item-&gt;quantity;
                    if ($reverse)
                        $quantity = -$line_item-&gt;quantity;

                    if ($quantity &gt;= 0)
                        continue;

                    if (check_negative_stock($line_item-&gt;stock_id, $quantity, $location, $date_))
                        $low_stock[] = $line_item-&gt;stock_id;
                }
        }
        return $low_stock;
    }</code></pre></div><p>Hope that fixes the undefined noin-object error</p>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2019-01-23T09:45:24Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=34059#p34059</id>
		</entry>
</feed>
