<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Items Cost in negative in inventory sales report]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=8157&amp;type=atom" />
	<updated>2019-06-01T08:14:46Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=8157</id>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35077#p35077" />
			<content type="html"><![CDATA[<p>The Code I have suggested in post#34 will affect many reports. So doing this may need to change reports. And also the previous data may need to be adjusted in stock_moves table.</p><p>Hence therefore a separate log idea is better i think.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-06-01T08:14:46Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35077#p35077</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35070#p35070" />
			<content type="html"><![CDATA[<p>Further investigating this topic I found that the function defined at Line # 425 of /includes/db/inventory_db.inc&nbsp; <strong>function update_stock_move</strong> is not used anywhere in the system.</p><p>I have tried to help @zia why the cost is -ve. This might be helpful for others in this forum so I am attaching <a href="https://prnt.sc/nvkezx">here</a>.</p><p>This Image explains the affect of using <strong>Cost Update on the Average Cost of the Product</strong></p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-30T19:10:48Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35070#p35070</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35062#p35062" />
			<content type="html"><![CDATA[<p>Hello @joe, I found that there is already a Log System for Average Cost in FA in stock_moves table but that is not properly used with Stock Adjustments.</p><p>In the file <strong>/inventory/includes/db/items_adjust_db.inc</strong> if we modify code at Line # 103 as below then Stock_Moves Table will have complete log of Transaction Affecting the Average Cost.</p><div class="codebox"><pre><code>$calculated_avg_cost = get_unit_cost($stock_id); //added by faisal
    add_stock_move(ST_INVADJUST, $stock_id, $adj_id, $location, //modified by faisal
        $date_, $reference, $quantity,$calculated_avg_cost, $standard_cost);</code></pre></div><p>After Doing this <strong>/inventory/inquiry/stock_movements.php</strong> can be modified to show the columns as below</p><div class="codebox"><pre><code>array_push($th, _(&quot;Date&quot;), _(&quot;Detail&quot;), _(&quot;Quantity In&quot;), _(&quot;Quantity Out&quot;), _(&quot;Quantity On Hand&quot;),_(&quot;Price&quot;), _(&quot;Avg Cost&quot;));//Modified by faisal</code></pre></div><p>and </p><div class="codebox"><pre><code>qty_cell($after_qty, false, $dec);
    amount_cell($myrow[&quot;price&quot;]); //added by faisal
    amount_cell($myrow[&quot;standard_cost&quot;]); //added by faisal</code></pre></div>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-29T21:40:31Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35062#p35062</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35049#p35049" />
			<content type="html"><![CDATA[<p>Fine, In the log some more fields are necessary but for that we may need to increase arguments in function. Like TransactionDate, TransactionType and TransactionRef or ID, User</p><p>Similarly the direct CostUpdate of any items shall also reflect in this Log.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-27T07:54:20Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35049#p35049</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35046#p35046" />
			<content type="html"><![CDATA[<p>I have a meeting with Janusz medio June.&nbsp; We will, among other thngs, discuss this topic too.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2019-05-27T04:35:48Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35046#p35046</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35044#p35044" />
			<content type="html"><![CDATA[<p>@joe, we can add this function to <strong>purchasing/includes/db/grn_db.inc</strong>. to create a log file in the company&#039;s folder for each item whenever the average cost is updated in the system for any reason.</p><p>This function (in my instance) also sends an Email Alert to BCC Email of the company.</p><div class="codebox"><pre><code>function update_cost_log($new_material_cost, $curr_material_cost, $qty, $price, $stock_id, $qoh )
{
  global $path_to_root, $db_connections;
    $company = $db_connections[$_SESSION[&quot;wa_current_user&quot;]-&gt;company][&quot;name&quot;]; //added by faisal
    $date = Today().&quot; &quot;.Now();// date(&quot;Y-m-d h:i:sa&quot;, $d);

  $tran_type = $qty &gt; 0 ? &quot;Stock IN&quot; : &quot;Stock Out&quot;;

  $log = &quot;date=$date,  company=$company,  stock_id=&quot;.get_item($stock_id)[&#039;description&#039;].&quot;,&quot;;
  $log .=&quot;Quntity On Hand=$qoh,&quot;;
  $log .= &quot;Current Material Cost=$curr_material_cost,&quot;;
  $log .= &quot;$tran_type=$qty,&quot;;
  $log .= &quot;Price to Receive Stock=$price,&quot;;
  $log .= &quot;Calculated Material Cost = $new_material_cost&quot;;

  file_put_contents(company_path().&quot;/&quot;.$stock_id.&#039;.log&#039;,$log.PHP_EOL,FILE_APPEND);

if (!get_company_pref(&#039;avg_cost_alert&#039;)) return;

      require_once($path_to_root . &quot;/reporting/includes/class.mail.inc&quot;);

      $mail = new email(&quot;ABC&quot;, &quot;smtp@abc.net&quot;);

          $mail-&gt;phpmailer-&gt;addAddress(get_company_pref(&#039;bcc_email&#039;));

          $mail-&gt;subject(&quot;Average Cost Alert&quot;);
          $mail-&gt;text($log);
          $mail-&gt;send();
    }</code></pre></div><p>This function can be called at Line # 74 in the above file as below</p><div class="codebox"><pre><code>if ($curr_material_cost &lt;&gt; $material_cost)
        update_cost_log($material_cost, $curr_material_cost, $qty, $price_in_home_currency, $stock_id, $qoh); //by faisal</code></pre></div><p>The same process can be repeated for manufacturing/includes/db/work_order_costing_db.inc</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-27T02:57:09Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35044#p35044</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35043#p35043" />
			<content type="html"><![CDATA[<p>@zia, first of all you are using very older version. At FA on daily basis bugs are identified and rectified. It may be very cumbersome for any senior member here to support you on an older version. I would recommend that to avoid any future problems you keep your FA instance updated to the latest repo.</p><p>Secondly you can send me your ERPs credentials via Forum Email. I will try to locate the problem.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-26T15:36:36Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35043#p35043</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35042#p35042" />
			<content type="html"><![CDATA[<p>any update for my issue. @boxygen or any other expert.</p>]]></content>
			<author>
				<name><![CDATA[zia]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42577</uri>
			</author>
			<updated>2019-05-26T11:26:05Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35042#p35042</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35041#p35041" />
			<content type="html"><![CDATA[<p>May be we can maintain a log file in the company&#039;s folder for each item. That Log file can be called in Item Setup to view history with Date and Time, User and Transaction affecting the Average Cost. The user shall be able to refresh that log file.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-26T10:51:43Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35041#p35041</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35040#p35040" />
			<content type="html"><![CDATA[<p>Of course, but please help me finding where to fix this.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2019-05-26T09:31:58Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35040#p35040</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35039#p35039" />
			<content type="html"><![CDATA[<p>@joe, this area of FA that average cost of the item get changes but there is no LOG maintained for such change shall be addressed in 2.5.</p><p>This has placed me at very critical situation sometimes when a client asks why this Average Cost arrives?</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2019-05-26T07:00:51Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35039#p35039</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35015#p35015" />
			<content type="html"><![CDATA[<p>any help guys.</p>]]></content>
			<author>
				<name><![CDATA[zia]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42577</uri>
			</author>
			<updated>2019-05-23T05:49:00Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35015#p35015</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=35000#p35000" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kvvaradha wrote:</cite><blockquote><p>@barbarian - he also don&#039;t know when the entries are created. Because all of them are auto created. This&nbsp; entries created by the update average cost method. This issue was fixed from 2.4 onwards. So you can compare code between the two version and get it</p></blockquote></div><p>Oh, so it is auto created means direct supplier invoice feature?</p>]]></content>
			<author>
				<name><![CDATA[barbarian]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18954</uri>
			</author>
			<updated>2019-05-22T08:23:52Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=35000#p35000</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=34998#p34998" />
			<content type="html"><![CDATA[<p>@kvvaradha,</p><p>if you allow me then i can share with you erp credentials then you can check, because i am stuck here and did every possible thing,</p>]]></content>
			<author>
				<name><![CDATA[zia]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42577</uri>
			</author>
			<updated>2019-05-22T07:30:18Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=34998#p34998</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Items Cost in negative in inventory sales report]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=34996#p34996" />
			<content type="html"><![CDATA[<p>There are two possibilities, either you have any entries left to void or the standard cost was not updated. Check once again from beginning to end and get solution for it</p>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2019-05-22T07:24:29Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=34996#p34996</id>
		</entry>
</feed>
