From: <dai...@us...> - 2010-12-11 00:03:25
|
Revision: 4182 http://web-erp.svn.sourceforge.net/web-erp/?rev=4182&view=rev Author: daintree Date: 2010-12-11 00:03:18 +0000 (Sat, 11 Dec 2010) Log Message: ----------- Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made Modified Paths: -------------- trunk/GoodsReceived.php trunk/PDFStockCheckComparison.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/GoodsReceived.php 2010-12-11 00:03:18 UTC (rev 4182) @@ -582,7 +582,7 @@ transdate, periodno, inputdate, - fixedassettranstype + fixedassettranstype, amount) VALUES ('" . $OrderLine->AssetID . "', 25, Modified: trunk/PDFStockCheckComparison.php =================================================================== --- trunk/PDFStockCheckComparison.php 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/PDFStockCheckComparison.php 2010-12-11 00:03:18 UTC (rev 4182) @@ -23,12 +23,13 @@ if ($_POST['ReportOrClose']=='ReportAndClose'){ $sql = "SELECT stockcheckfreeze.stockid, - stockcheckfreeze.loccode, - qoh, - materialcost+labourcost+overheadcost AS standardcost - FROM stockmaster INNER JOIN stockcheckfreeze - ON stockcheckfreeze.stockid=stockmaster.stockid - ORDER BY stockcheckfreeze.loccode, stockcheckfreeze.stockid"; + stockcheckfreeze.loccode, + qoh, + materialcost+labourcost+overheadcost AS standardcost, + stockcheckfreeze.stockcheckdate + FROM stockmaster INNER JOIN stockcheckfreeze + ON stockcheckfreeze.stockid=stockmaster.stockid + ORDER BY stockcheckfreeze.loccode, stockcheckfreeze.stockid"; $StockChecks = DB_query($sql, $db,'','',false,false); if (DB_error_no($db) !=0) { @@ -44,18 +45,16 @@ exit; } - $PeriodNo = GetPeriod (Date($_SESSION['DefaultDateFormat']), $db); - $SQLAdjustmentDate = FormatDateForSQL(Date($_SESSION['DefaultDateFormat'])); $AdjustmentNumber = GetNextTransNo(17,$db); while ($myrow = DB_fetch_array($StockChecks)){ $sql = "SELECT SUM(stockcounts.qtycounted) AS totcounted, - COUNT(stockcounts.stockid) AS noofcounts - FROM stockcounts - WHERE stockcounts.stockid='" . $myrow['stockid'] . "' - AND stockcounts.loccode='" . $myrow['loccode'] . "'"; - + COUNT(stockcounts.stockid) AS noofcounts + FROM stockcounts + WHERE stockcounts.stockid='" . $myrow['stockid'] . "' + AND stockcounts.loccode='" . $myrow['loccode'] . "'"; + $StockCounts = DB_query($sql, $db); if (DB_error_no($db) !=0) { $title = _('Stock Count Comparison') . ' - ' . _('Problem Report') . '....'; @@ -81,14 +80,12 @@ if ($StockQtyDifference !=0){ // only adjust stock if there is an adjustment to make!! - $SQL = 'BEGIN'; - $Result = DB_query($SQL,$db); - + DB_Txn_Begin($db); // Need to get the current location quantity will need it later for the stock movement $SQL="SELECT locstock.quantity - FROM locstock - WHERE locstock.stockid='" . $myrow['stockid'] . "' - AND loccode= '" . $myrow['loccode'] . "'"; + FROM locstock + WHERE locstock.stockid='" . $myrow['stockid'] . "' + AND loccode= '" . $myrow['loccode'] . "'"; $Result = DB_query($SQL, $db); if (DB_num_rows($Result)==1){ @@ -98,7 +95,9 @@ // There must actually be some error this should never happen $QtyOnHandPrior = 0; } - + + $PeriodNo = GetPeriod (ConvertSQLDate($myrow['stockcheckdate']), $db); + $SQL = "INSERT INTO stockmoves (stockid, type, transno, @@ -112,9 +111,9 @@ 17, '" . $AdjustmentNumber . "', '" . $myrow['loccode'] . "', - '" . $SQLAdjustmentDate . "', + '" . Date('Y-m-d') . "', '" . $PeriodNo . "', - '" . _('Inventory Check') . "', + '" . _('Inventory Check') . ' - ' . ConvertSQLDate($myrow['stockcheckdate']) . "', '" . $StockQtyDifference . "', '" . ($QtyOnHandPrior + $StockQtyDifference) . "' )"; @@ -124,9 +123,9 @@ $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); $SQL = "UPDATE locstock - SET quantity = quantity + '" . $StockQtyDifference . "' - WHERE stockid='" . $myrow['stockid'] . "' - AND loccode='" . $myrow['loccode'] . "'"; + SET quantity = quantity + '" . $StockQtyDifference . "' + WHERE stockid='" . $myrow['stockid'] . "' + AND loccode='" . $myrow['loccode'] . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The location stock record could not be updated because'); $DbgMsg = _('The following SQL to update the stock record was used'); $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); @@ -146,7 +145,7 @@ narrative) VALUES (17, '" .$AdjustmentNumber . "', - '" . $SQLAdjustmentDate . "', + '" . $myrow['stockcheckdate'] . "', '" . $PeriodNo . "', '" . $StockGLCodes['adjglact'] . "', '" . $myrow['standardcost'] * -($StockQtyDifference) . "', @@ -165,16 +164,15 @@ narrative) VALUES (17, '" .$AdjustmentNumber . "', - '" . $SQLAdjustmentDate . "', + '" . $myrow['stockcheckdate'] . "', '" . $PeriodNo . "', '" . $StockGLCodes['stockact'] . "', - '" . $myrow['standardcost'] * $StockQtyDifference . ", '" . $myrow['stockid'] . " x " . $StockQtyDifference . " @ " . $myrow['standardcost'] . " - " . _('Inventory Check') . "')"; + '" . $myrow['standardcost'] * $StockQtyDifference . "', + '" . $myrow['stockid'] . " x " . $StockQtyDifference . " @ " . $myrow['standardcost'] . " - " . _('Inventory Check') . "')"; $Result = DB_query($SQL,$db, $ErrMsg, $DbgMsg, true); } //END INSERT GL TRANS - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Unable to COMMIT transaction while adjusting stock in StockCheckAdjustmet report'); - $SQL = "COMMIT"; - $Result = DB_query($SQL,$db, $ErrMsg,'',true); + DB_Txn_Commit($db); } // end if $StockQtyDifference !=0 Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/doc/Change.log.html 2010-12-11 00:03:18 UTC (rev 4182) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p>/</p> +<p>11/12/10 Phil: Have populated the new field stockcheckdate in stockcheckfreeze and modified PDFStockCheckComparison to use this field when posting the GL - stockmoves need to be on the current day otherwise historical balances will all need to be updated. But narrative shows the date of the stock check for which the adjustment is being made</p> <p>9/12/10 James Murray: highlighted a bug in SupplierInvoice.php (and also in SupplierCredit.php) where the due date of the invoice/credit was not calculated correctly based on the terms - it was picking up the current date rather than the invoice/credit date. Now fixed</p> <p>8/12/10 James Murray: fixed bug in SuppPaymentRun.php - was not showing anything as the test to see if there was anything to see was using a non-existant result set!</p> <p>5/12/10 Phil: Fixed bug in purchase orders that did not actually delete purchase orders that were cancelled. I think the reason was a fraud prevention issue so instead I have made new tables for purchorders_deleted and purchorderdetails_deleted to copy the details of the deleted orders to - should investigation be required.</p> Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-09 06:59:34 UTC (rev 4181) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-12-11 00:03:18 UTC (rev 4182) @@ -432,7 +432,7 @@ ALTER TABLE `reports` ADD `col20width` INT( 3 ) NOT NULL DEFAULT '25' AFTER `col19width` ; -ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT ''; +ALTER TABLE `reportfields` CHANGE `fieldname` `fieldname` VARCHAR( 80) NOT NULL DEFAULT ''; ALTER TABLE `stockcatproperties` ADD `maximumvalue` DOUBLE NOT NULL DEFAULT 999999999 AFTER `defaultvalue` , ADD `minimumvalue` DOUBLE NOT NULL DEFAULT -999999999, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |