From: <dai...@us...> - 2010-11-24 09:05:50
|
Revision: 4165 http://web-erp.svn.sourceforge.net/web-erp/?rev=4165&view=rev Author: daintree Date: 2010-11-24 09:05:42 +0000 (Wed, 24 Nov 2010) Log Message: ----------- receiving fixed asset nominal order lines postings to fixedassettrans and GL Modified Paths: -------------- trunk/GoodsReceived.php trunk/doc/Change.log.html trunk/includes/PO_ReadInOrder.inc trunk/sql/mysql/upgrade3.11.1-4.00.sql Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/GoodsReceived.php 2010-11-24 09:05:42 UTC (rev 4165) @@ -78,12 +78,12 @@ '"></td></tr></table><br>'; echo '<table cellpadding=2 class=selection> - <tr><th>' . _('Item Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> - <th>' . _('Units') . '</th> - <th>' . _('Already Received') . '</th> - <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; + <tr><th>' . _('Item Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Already Received') . '</th> + <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; if ($_SESSION['ShowValueOnGRN']==1) { echo '<th>' . _('Price') . '</th><th>' . _('Total Value') . '<br>' . _('Received') . '</th>'; @@ -362,8 +362,8 @@ if ($OrderLine->StockID!='') { /*Its a stock item line */ /*Need to get the current standard cost as it is now so we can process GL jorunals later*/ $SQL = "SELECT materialcost + labourcost + overheadcost as stdcost - FROM stockmaster - WHERE stockid='" . $OrderLine->StockID . "'"; + FROM stockmaster + WHERE stockid='" . $OrderLine->StockID . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The standard cost of the item being received cannot be retrieved because'); $DbgMsg = _('The following SQL to retrieve the standard cost was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -482,7 +482,7 @@ $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - /* If its a stock item still .... Insert stock movements - with unit cost */ + /* ... Insert stock movements - with unit cost */ $SQL = "INSERT INTO stockmoves (stockid, type, @@ -579,6 +579,40 @@ } } /*end of its a stock item - updates to locations and insert movements*/ + /* Check to see if the line item was flagged as the purchase of an asset */ + if ($OrderLine->AssetID !=''){ //then it is an asset + + /*first validate the AssetID and if it doesn't exist treat it like a normal nominal item */ + $CheckAssetExistsResult = DB_query("SELECT assetid, costact + FROM fixedassets INNER JOIN fixedassetcategories + ON fixedassets.assetcategoryid=fixedassetcategories.categoryid + WHERE assetid='" . $OrderLine->AssetID . "'",$db); + if (DB_num_rows($CheckAssetExistsResult)==1){ //then work with the assetid provided + + /*Need to add a fixedassettrans for the cost of the asset being received */ + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + typeno, + transdate, + periodno, + inputdate, + cost) + VALUES (25, + '" . $GRN . "', + '" . $_POST['DefaultReceivedDate'] . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + '" . $CurrentStandardCost * $OrderLine->ReceiveQty . "')"; + $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because'); + $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used'); + $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); + + /*Now get the correct cost GL account from the asset category */ + $AssetRow = DB_fetch_array($CheckAssetExistsResult); + /*Over-ride any GL account specified in the order with the asset category cost account */ + $_SESSION['PO']->LineItems[$OrderLine->LineNo]->GLCode = $AssetRow['costact']; + } //assetid provided doesn't exist so ignore it and treat as a normal nominal item + } //assetid is set so the nominal item is an asset /* If GLLink_Stock then insert GLTrans to debit the GL Code and credit GRN Suspense account at standard cost*/ if ($_SESSION['PO']->GLLink==1 AND $OrderLine->GLCode !=0){ /*GLCode is set to 0 when the GLLink is not activated this covers a situation where the GLLink is now active but it wasn't when this PO was entered */ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/doc/Change.log.html 2010-11-24 09:05:42 UTC (rev 4165) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>24/11/10 Phil: GoodsReceived.php - modified to insert fixedassettrans and to post nominal POs to fixed asset cost account from fixedassetcategories.costact <p>23/11/10 Pak Ricard: MRP.php and MRPShortages.php fixed temporary tables to use utf-8 - code failed without probably depends on mysql server settings</p> <p>21/11/10 Phil:Rewritten FixedAssetJournal.php - renamed FixedAssetDepreciation.php</p> <p>20/11/10 Phil: Rewritten FixedAssetItems.php FixedAssetCategories.php and modified FixedAssetLocations.php to use the new structure</p> Modified: trunk/includes/PO_ReadInOrder.inc =================================================================== --- trunk/includes/PO_ReadInOrder.inc 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/includes/PO_ReadInOrder.inc 2010-11-24 09:05:42 UTC (rev 4165) @@ -16,45 +16,45 @@ /*read in all the guff from the selected order into the PO PurchOrder Class variable */ $OrderHeaderSQL = 'SELECT purchorders.supplierno, - suppliers.suppname, - purchorders.comments, - purchorders.orddate, - purchorders.rate, - purchorders.dateprinted, - purchorders.deladd1, - purchorders.deladd2, - purchorders.deladd3, - purchorders.deladd4, - purchorders.deladd5, - purchorders.deladd6, - purchorders.tel, - purchorders.suppdeladdress1, - purchorders.suppdeladdress2, - purchorders.suppdeladdress3, - purchorders.suppdeladdress4, - purchorders.suppdeladdress5, - purchorders.suppdeladdress6, - purchorders.suppliercontact, - purchorders.supptel, - purchorders.contact, - purchorders.allowprint, - purchorders.requisitionno, - purchorders.intostocklocation, - purchorders.initiator, - purchorders.version, - purchorders.status, - purchorders.stat_comment, - purchorders.deliverydate, - purchorders.port, - suppliers.currcode, - locations.managed , - purchorders.paymentterms - FROM purchorders - LEFT JOIN locations ON purchorders.intostocklocation=locations.loccode, - suppliers - WHERE purchorders.supplierno = suppliers.supplierid - AND purchorders.orderno = ' . $_GET['ModifyOrderNumber']; - + suppliers.suppname, + purchorders.comments, + purchorders.orddate, + purchorders.rate, + purchorders.dateprinted, + purchorders.deladd1, + purchorders.deladd2, + purchorders.deladd3, + purchorders.deladd4, + purchorders.deladd5, + purchorders.deladd6, + purchorders.tel, + purchorders.suppdeladdress1, + purchorders.suppdeladdress2, + purchorders.suppdeladdress3, + purchorders.suppdeladdress4, + purchorders.suppdeladdress5, + purchorders.suppdeladdress6, + purchorders.suppliercontact, + purchorders.supptel, + purchorders.contact, + purchorders.allowprint, + purchorders.requisitionno, + purchorders.intostocklocation, + purchorders.initiator, + purchorders.version, + purchorders.status, + purchorders.stat_comment, + purchorders.deliverydate, + purchorders.port, + suppliers.currcode, + locations.managed , + purchorders.paymentterms + FROM purchorders + LEFT JOIN locations ON purchorders.intostocklocation=locations.loccode, + suppliers + WHERE purchorders.supplierno = suppliers.supplierid + AND purchorders.orderno = ' . $_GET['ModifyOrderNumber']; + $ErrMsg = _('The order cannot be retrieved because'); $DbgMsg = _('The SQL statement that was used and failed was'); $GetOrdHdrResult = DB_query($OrderHeaderSQL,$db,$ErrMsg,$DbgMsg); @@ -243,7 +243,8 @@ $myrow['gw'], $myrow['cuft'], $myrow['total_quantity'], - $myrow['total_amount']); + $myrow['total_amount'], + $myrow['assetid'] ); $_SESSION['PO'.$identifier]->LineItems[$_SESSION['PO'.$identifier]->LinesOnOrder]->PODetailRec = $myrow['podetailitem']; $_SESSION['PO'.$identifier]->LineItems[$_SESSION['PO'.$identifier]->LinesOnOrder]->StandardCost = $myrow['stdcostunit']; /*Needed for receiving goods and GL interface */ Modified: trunk/sql/mysql/upgrade3.11.1-4.00.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-23 07:05:34 UTC (rev 4164) +++ trunk/sql/mysql/upgrade3.11.1-4.00.sql 2010-11-24 09:05:42 UTC (rev 4165) @@ -479,17 +479,18 @@ INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('43', 'Delete w/down asset', '1'); INSERT INTO `systypes` (`typeid`, `typename`, `typeno`) VALUES ('44', 'Depreciation', '1'); -CREATE TABLE `fixedassettrans` ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`assetid` INT NOT NULL , -`transtype` TINYINT NOT NULL , -`transno` INT NOT NULL , -`periodno` SMALLINT( 4 ) NOT NULL, -`inputdate` DATE NOT, -`cost` DOUBLE NOT NULL , -`depn` DOUBLE NOT NULL , -INDEX ( `assetid` , `transtype` , `transno` ), +CREATE TABLE fixedassettrans( +id INT( 11 ) NOT NULL AUTO_INCREMENT , +assetid INT( 11 ) NOT NULL , +transtype TINYINT( 4 ) NOT NULL , +transno INT NOT NULL , +periodno SMALLINT( 6 ) NOT NULL , +inputdate DATE NOT NULL , +cost DOUBLE NOT NULL , +depn DOUBLE NOT NULL , +PRIMARY KEY ( id ) , +INDEX ( assetid, transtype, transno ) , INDEX ( inputdate ) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; UPDATE config SET confvalue='4.0-RC2' WHERE confname='VersionName'; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |