|
From: <dai...@us...> - 2011-08-14 04:28:49
|
Revision: 4658
http://web-erp.svn.sourceforge.net/web-erp/?rev=4658&view=rev
Author: daintree
Date: 2011-08-14 04:28:42 +0000 (Sun, 14 Aug 2011)
Log Message:
-----------
14/8/11 Phil: Stocks.php now does a journal for any work in progress on a change of category where the new category has a different GL account for WIP - and bug fixes as per Ricard
Modified Paths:
--------------
trunk/Stocks.php
trunk/WorkOrderCosting.php
trunk/doc/Change.log
trunk/includes/session.inc
trunk/install/save.php
Modified: trunk/Stocks.php
===================================================================
--- trunk/Stocks.php 2011-08-12 11:01:35 UTC (rev 4657)
+++ trunk/Stocks.php 2011-08-14 04:28:42 UTC (rev 4658)
@@ -5,6 +5,7 @@
include('includes/session.inc');
$title = _('Item Maintenance');
include('includes/header.inc');
+include('includes/SQL_CommonFunctions.inc');
/*If this form is called with the StockID then it is assumed that the stock item is to be modified */
@@ -213,7 +214,8 @@
controlled,
serialised,
materialcost+labourcost+overheadcost AS itemcost,
- stockcategory.stockact
+ stockcategory.stockact,
+ stockcategory.wipact
FROM stockmaster
INNER JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid
@@ -225,6 +227,8 @@
$OldSerialised = $myrow[2];
$UnitCost = $myrow[3];
$OldStockAccount = $myrow[4];
+ $OldWIPAccount = $myrow[5];
+
$sql = "SELECT SUM(locstock.quantity)
FROM locstock
@@ -235,12 +239,14 @@
/*Now check the GL account of the new category to see if it is different to the old stock gl account */
- $result = DB_query("SELECT stockact
+ $result = DB_query("SELECT stockact,
+ wipact
FROM stockcategory
WHERE categoryid='" . $_POST['CategoryID'] . "'",
$db);
$NewStockActRow = DB_fetch_array($result);
$NewStockAct = $NewStockActRow['stockact'];
+ $NewWIPAct = $NewStockActRow['wipact'];
if ($OldMBFlag != $_POST['MBFlag']){
if (($OldMBFlag == 'M' OR $OldMBFlag=='B') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K' OR $_POST['MBFlag']=='D' OR $_POST['MBFlag']=='G')){ /*then need to check that there is no stock holding first */
@@ -378,7 +384,7 @@
$db,$ErrMsg,$DbgMsg,true);
} //end of loop around properties defined for the category
- if ($OldStockAccount != $NewStockAct AND $_SESSION['CompanyRecord']['gllinkstock']==1) {
+ if ($OldStockAccount != $NewStockAct AND $_SESSION['CompanyRecord']['gllink_stock']==1) {
/*Then we need to make a journal to transfer the cost to the new stock account */
$JournalNo = GetNextTransNo(0,$db); //enter as a journal
$SQL = "INSERT INTO gltrans (type,
@@ -391,13 +397,13 @@
VALUES ( 0,
'" . $JournalNo . "',
'" . Date('Y-m-d') . "',
- '" . GetPeriodNo(Date('Y-m-d'),true) . "',
+ '" . GetPeriod(Date('Y-m-d'),$db,true) . "',
'" . $NewStockAccount . "',
'" . $StockID . ' ' . _('Change stock category') . "',
'" . ($UnitCost* $StockQtyRow[0]) . "'";
$ErrMsg = _('The stock cost journal could not be inserted because');
$DbgMsg = _('The SQL that was used to create the stock cost journal and failed was');
- $result = DB_query($sql,$db, $ErrMsg, $DbgMsg,true);
+ $result = DB_query($SQL,$db, $ErrMsg, $DbgMsg,true);
$SQL = "INSERT INTO gltrans (type,
typeno,
trandate,
@@ -408,13 +414,68 @@
VALUES ( 0,
'" . $JournalNo . "',
'" . Date('Y-m-d') . "',
- '" . GetPeriodNo(Date('Y-m-d'),true) . "',
+ '" . GetPeriod(Date('Y-m-d'),$db,true) . "',
'" . $OldStockAccount . "',
'" . $StockID . ' ' . _('Change stock category') . "',
'" . (-$UnitCost* $StockQtyRow[0]) . "'";
- $result = DB_query($sql,$db, $ErrMsg, $DbgMsg,true);
+ $result = DB_query($SQL,$db, $ErrMsg, $DbgMsg,true);
} /* end if the stock category changed and forced a change in stock cost account */
+ if ($OldWIPAccount != $NewWIPAct AND $_SESSION['CompanyRecord']['gllink_stock']==1) {
+ /*Then we need to make a journal to transfer the cost of WIP to the new WIP account */
+ /*First get the total cost of WIP for this category */
+
+ $WOCostsResult = DB_query("SELECT workorders.costissued,
+ SUM(woitems.qtyreqd * woitems.stdcost) AS costrecd
+ FROM woitems INNER JOIN workorders
+ ON woitems.wo = workorders.wo
+ INNER JOIN stockmaster
+ ON woitems.stockid=stockmaster.stockid
+ WHERE stockmaster.stockid='". $StockID . "'
+ AND workorders.closed=0
+ GROUP BY workorders.costissued",
+ $db,
+ _('Error retrieving value of finished goods received and cost issued against work orders for this item'));
+ $WIPValue = 0;
+ while ($WIPRow=DB_fetch_array($WOCostsResult)){
+ $WIPValue += ($WIPRow['costissued']-$WIPRow['costrecd']);
+ }
+ if ($WIPValue !=0){
+ $JournalNo = GetNextTransNo(0,$db); //enter as a journal
+ $SQL = "INSERT INTO gltrans (type,
+ typeno,
+ trandate,
+ periodno,
+ account,
+ narrative,
+ amount)
+ VALUES ( 0,
+ '" . $JournalNo . "',
+ '" . Date('Y-m-d') . "',
+ '" . GetPeriod(Date('Y-m-d'),$db,true) . "',
+ '" . $NewWIPAct . "',
+ '" . $StockID . ' ' . _('Change stock category') . "',
+ '" . $WIPValue . "'";
+ $ErrMsg = _('The WIP cost journal could not be inserted because');
+ $DbgMsg = _('The SQL that was used to create the WIP cost journal and failed was');
+ $result = DB_query($SQL,$db, $ErrMsg, $DbgMsg,true);
+ $SQL = "INSERT INTO gltrans (type,
+ typeno,
+ trandate,
+ periodno,
+ account,
+ narrative,
+ amount)
+ VALUES ( 0,
+ '" . $JournalNo . "',
+ '" . Date('Y-m-d') . "',
+ '" . GetPeriod(Date('Y-m-d'),true) . "',
+ '" . $OldWIPAccount . "',
+ '" . $StockID . ' ' . _('Change stock category') . "',
+ '" . (-$WIPValue) . "'";
+ $result = DB_query($SQL,$db, $ErrMsg, $DbgMsg,true);
+ }
+ } /* end if the stock category changed and forced a change in WIP account */
DB_Txn_Commit($db);
prnMsg( _('Stock Item') . ' ' . $StockID . ' ' . _('has been updated'), 'success');
echo '<br />';
@@ -512,11 +573,12 @@
unset($_POST['ShrinkFactor']);
unset($_POST['Pansize']);
unset($StockID);
+ $New=1;
}//ALL WORKED SO RESET THE FORM VARIABLES
}//THE INSERT OF THE NEW CODE WORKED SO BANG IN THE STOCK LOCATION RECORDS TOO
}//END CHECK FOR ALREADY EXISTING ITEM OF THE SAME CODE
}
- $New=1;
+
} else {
echo '<br />'. "\n";
Modified: trunk/WorkOrderCosting.php
===================================================================
--- trunk/WorkOrderCosting.php 2011-08-12 11:01:35 UTC (rev 4657)
+++ trunk/WorkOrderCosting.php 2011-08-14 04:28:42 UTC (rev 4658)
@@ -77,7 +77,7 @@
$db,
$ErrMsg);
-echo '<table class=selection><tr><th>' . _('Item') . '</th>
+echo '<table class="selection"><tr><th>' . _('Item') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Quantity Required') . '</th>
<th>' . _('Units') . '</th>
@@ -91,12 +91,12 @@
echo '<tr><td>' . $WORow['stockid'] . '</td>
<td>' . $WORow['description'] . '</td>
- <td class=number>' . number_format($WORow['qtyreqd'],$WORow['decimalplaces']) . '</td>
+ <td class="number">' . number_format($WORow['qtyreqd'],$WORow['decimalplaces']) . '</td>
<td>' . $WORow['units'] . '</td>
- <td class=number>' . number_format($WORow['qtyrecd'],$WORow['decimalplaces']) . '</td>
- <td class=number><a href="'. $rootpath . '/WorkOrderStatus.php?WO=' . $_POST['WO'] . '&StockID=' . $WORow['stockid'] . '">' . _('Status') . '</a></td>
- <td class=number><a href="'. $rootpath . '/WorkOrderReceive.php?WO=' . $_POST['WO'] . '&StockID=' . $WORow['stockid'] . '">' . _('Receive') . '</a></td>
- <td class=number><a href="'. $rootpath . '/WorkOrderIssue.php?WO=' . $_POST['WO'] . '&StockID=' . $WORow['stockid'] . '">' . _('Issue') . '</a></td>
+ <td class="number">' . number_format($WORow['qtyrecd'],$WORow['decimalplaces']) . '</td>
+ <td class="number"><a href="'. $rootpath . '/WorkOrderStatus.php?WO=' . $_POST['WO'] . '&StockID=' . $WORow['stockid'] . '">' . _('Status') . '</a></td>
+ <td class="number"><a href="'. $rootpath . '/WorkOrderReceive.php?WO=' . $_POST['WO'] . '&StockID=' . $WORow['stockid'] . '">' . _('Receive') . '</a></td>
+ <td class="number"><a href="'. $rootpath . '/WorkOrderIssue.php?WO=' . $_POST['WO'] . '&StockID=' . $WORow['stockid'] . '">' . _('Issue') . '</a></td>
</tr>';
$TotalStdValueRecd +=($WORow['stdcost']*$WORow['qtyrecd']);
@@ -174,8 +174,8 @@
echo '<tr class="OddTableRows">';
}
echo '<td colspan=4></td><td>' . ConvertSQLDate($IssuesRow['trandate']) . '</td>
- <td class=number>' . number_format(-$IssuesRow['qty'],$RequirementsRow['decimalplaces']) . '</td>
- <td class=number>' . number_format(-($IssuesRow['qty']*$IssuesRow['standardcost']),$IssuesRow['decimalplaces']) . '</td></tr>';
+ <td class="number">' . number_format(-$IssuesRow['qty'],$RequirementsRow['decimalplaces']) . '</td>
+ <td class="number">' . number_format(-($IssuesRow['qty']*$IssuesRow['standardcost']),$IssuesRow['decimalplaces']) . '</td></tr>';
$IssueQty -= $IssuesRow['qty'];// because qty for the stock movement will be negative
$IssueCost -= ($IssuesRow['qty']*$IssuesRow['standardcost']);
@@ -201,13 +201,13 @@
/*Required quantity is the quantity required of the component based on the quantity of the finished item received */
$UsageVar =($RequirementsRow['requiredqty']-$IssueQty)*($RequirementsRow['stdcost']);
- echo '<td colspan="2"></td><td class=number>' . number_format($RequirementsRow['requiredqty'],$RequirementsRow['decimalplaces']) . '</td>
- <td class=number>' . number_format($RequirementsRow['expectedcost'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ echo '<td colspan="2"></td><td class="number">' . number_format($RequirementsRow['requiredqty'],$RequirementsRow['decimalplaces']) . '</td>
+ <td class="number">' . number_format($RequirementsRow['expectedcost'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
<td></td>
- <td class=number>' . number_format($IssueQty,$RequirementsRow['decimalplaces']) . '</td>
- <td class=number>' . number_format($IssueCost,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
- <td class=number>' . number_format($UsageVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
- <td class=number>' . number_format($CostVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>';
+ <td class="number">' . number_format($IssueQty,$RequirementsRow['decimalplaces']) . '</td>
+ <td class="number">' . number_format($IssueCost,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ <td class="number">' . number_format($UsageVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ <td class="number">' . number_format($CostVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>';
$TotalReqdCost += $RequirementsRow['expectedcost'];
$TotalIssuedCost += $IssueCost;
$TotalCostVar += $CostVar;
@@ -252,13 +252,13 @@
echo '<td>' . $WOIssuesRow['stockid'] . '</td>
<td>' . $WOIssuesRow['description'] . '</td>
- <td class=number>0</td>
- <td class=number>0</td>
+ <td class="number">0</td>
+ <td class="number">0</td>
<td>' . ConvertSQLDate($WOIssuesRow['trandate']) . '</td>
- <td class=number>' . number_format(-$WOIssuesRow['qty'],$WOIssuesRow['decimalplaces']) .'</td>
- <td class=number>' . number_format(-$WOIssuesRow['qty']*$WOIssuesRow['standardcost'],$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
- <td class=number>' . number_format($WOIssuesRow['qty']*$WOIssuesRow['standardcost'],$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
- <td class=number>0</td></tr>';
+ <td class="number">' . number_format(-$WOIssuesRow['qty'],$WOIssuesRow['decimalplaces']) .'</td>
+ <td class="number">' . number_format(-$WOIssuesRow['qty']*$WOIssuesRow['standardcost'],$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
+ <td class="number">' . number_format($WOIssuesRow['qty']*$WOIssuesRow['standardcost'],$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
+ <td class="number">0</td></tr>';
$TotalUsageVar += ($WOIssuesRow['qty']*$WOIssuesRow['standardcost']);
}
@@ -269,13 +269,13 @@
<td colspan="2"></td>
<td colspan="3"><hr></td>
</tr>';
-echo '<tr><td colspan="2" class=number>' . _('Totals') . '</td>
+echo '<tr><td colspan="2" class="number">' . _('Totals') . '</td>
<td></td>
- <td class=number>' . number_format($TotalReqdCost,$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
+ <td class="number">' . number_format($TotalReqdCost,$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
<td></td><td></td>
- <td class=number>' . number_format($TotalIssuedCost,$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
- <td class=number>' . number_format($TotalUsageVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
- <td class=number>' . number_format($TotalCostVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>';
+ <td class="number">' . number_format($TotalIssuedCost,$_SESSION['CompanyRecord']['decimalplaces']) .'</td>
+ <td class="number">' . number_format($TotalUsageVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ <td class="number">' . number_format($TotalCostVar,$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>';
echo '<tr><td colspan="3"></td>
<td><hr/></td>
Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log 2011-08-12 11:01:35 UTC (rev 4657)
+++ trunk/doc/Change.log 2011-08-14 04:28:42 UTC (rev 4658)
@@ -1,5 +1,6 @@
webERP Change Log
+14/8/11 Phil: Stocks.php now does a journal for any work in progress on a change of category where the new category has a different GL account for WIP - and bug fixes as per Ricard
12/8/11 Phil: Backed out changes on 7/8 that prevented SelectProduct.php transaction links - now only purchase order links blocked if an item is obsolete
12/8/11 Phil: CounterSales.php apply discountmatrix fixes
11/8/11 Phil: GoodsReceived.php now has checkbox to flag the order line as complete - even though the quantity delivered might be short of the order quantity.
Modified: trunk/includes/session.inc
===================================================================
--- trunk/includes/session.inc 2011-08-12 11:01:35 UTC (rev 4657)
+++ trunk/includes/session.inc 2011-08-14 04:28:42 UTC (rev 4658)
@@ -19,8 +19,12 @@
}
ini_set('session.gc_Maxlifetime',$SessionLifeTime);
-ini_set('max_execution_time',$MaximumExecutionTime);
+if( !ini_get('safe_mode') ){
+ set_time_limit($MaximumExecutionTime);
+ ini_set('max_execution_time',$MaximumExecutionTime);
+}
+
session_start();
include($PathPrefix . 'includes/ConnectDB.inc');
Modified: trunk/install/save.php
===================================================================
--- trunk/install/save.php 2011-08-12 11:01:35 UTC (rev 4657)
+++ trunk/install/save.php 2011-08-14 04:28:42 UTC (rev 4658)
@@ -3,6 +3,8 @@
error_reporting(E_ALL && ~E_NOTICE);
ini_set('display_errors', 'On');
ini_set('max_execution_time', '180');
+/*Klaus Opto advised that timeout issues made it difficult to install even though max_execution_time has been set - Tim though set_time_limit should also be set - it might be a windows thing - Klaus was using WAMP */
+set_time_limit(180);
require_once('../includes/MiscFunctions.php');
// Start a session
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|