|
From: <dai...@us...> - 2012-02-22 09:05:35
|
Revision: 4951
http://web-erp.svn.sourceforge.net/web-erp/?rev=4951&view=rev
Author: daintree
Date: 2012-02-22 09:05:28 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
cost of negative stock changes
Modified Paths:
--------------
trunk/DailySalesInquiry.php
trunk/SupplierInvoice.php
trunk/doc/Change.log
Modified: trunk/DailySalesInquiry.php
===================================================================
--- trunk/DailySalesInquiry.php 2012-02-22 06:26:38 UTC (rev 4950)
+++ trunk/DailySalesInquiry.php 2012-02-22 09:05:28 UTC (rev 4951)
@@ -81,12 +81,14 @@
$sql = "SELECT trandate,
SUM(price*(1-discountpercent)* (-qty)) as salesvalue,
- SUM((standardcost * -qty)) as cost
+ SUM(CASE WHEN mbflag='A' THEN 0 ELSE (standardcost * -qty) END) as cost
FROM stockmoves
- INNER JOIN custbranch ON stockmoves.debtorno=custbranch.debtorno
- AND stockmoves.branchcode=custbranch.branchcode
+ INNER JOIN stockmaster
+ ON stockmoves.stockid=stockmaster.stockid
+ INNER JOIN custbranch
+ ON stockmoves.debtorno=custbranch.debtorno
+ AND stockmoves.branchcode=custbranch.branchcode
WHERE (stockmoves.type=10 or stockmoves.type=11)
- AND show_on_inv_crds =1
AND trandate>='" . $StartDateSQL . "'
AND trandate<='" . $EndDateSQL . "'";
Modified: trunk/SupplierInvoice.php
===================================================================
--- trunk/SupplierInvoice.php 2012-02-22 06:26:38 UTC (rev 4950)
+++ trunk/SupplierInvoice.php 2012-02-22 09:05:28 UTC (rev 4951)
@@ -1325,7 +1325,17 @@
WHERE stkmoveno = '" . $StkMoveRow['stkmoveno'] . "'",
$db,$ErrMsg,$DbgMsg,True);
}
- } //end if the invoice qty is more than is left to allocate
+ } else { //Only $QuantityVarianceAllocated left to allocate so need need to apportion cost using weighted average
+ if ($StkMoveRow['type']==10) { //its a sales invoice
+
+ $WACost = (((-$StkMoveRow['qty']- $QuantityVarianceAllocated)*$StkMoveRow['standardcost'])+($QuantityVarianceAllocated*$ActualCost))/-$StkMoveRow['qty'];
+
+ $UpdStkMovesResult = DB_query("UPDATE stockmoves
+ SET standardcost = '" . $WACost . "'
+ WHERE stkmoveno = '" . $StkMoveRow['stkmoveno'] . "'",
+ $db,$ErrMsg,$DbgMsg,True);
+ }
+ }
$QuantityVarianceAllocated+=$StkMoveRow['qty'];
}
} // end if the quantity being invoiced here is greater than the current stock on hand
@@ -1353,7 +1363,7 @@
/* if stock is negative then update the cost to this cost */
$sql = "UPDATE stockmaster
SET lastcost=materialcost+overheadcost+labourcost,
- materialcost='" . ($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) . "'
+ materialcost='" . $ActualCost . "'
WHERE stockid='" . $EnteredGRN->ItemCode . "'";
$Result = DB_query($sql, $db, $ErrMsg, $DbgMsg, True);
}
Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log 2012-02-22 06:26:38 UTC (rev 4950)
+++ trunk/doc/Change.log 2012-02-22 09:05:28 UTC (rev 4951)
@@ -1,5 +1,6 @@
webERP Change Log
+22/2/12 Phil: Make daily sales inquiry work correctly with assembly items where costs are recalculated in the case of negatives stock when supplier invoices entered
22/2/12 James Dupin: Update to French translation
22/2/12 Phil: Add ENT_QUOTES, 'UTF-8' to all htmlspecialchars calls
17/2/12 Phil: SuppCreditGRNs.php SuppInvGRNs.php DefineSuppTransClass.php SupplierInvoice.php stock movement was not being updated correctly with cost on purchase invoice entry as was using GRNNo not GRNBatchNo - which is used as the GRN transaction number in stock movements.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|