[Weberp-svn] SF.net SVN: weberp:[4252] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-01-11 12:42:15
|
Revision: 4252 http://weberp.svn.sourceforge.net/weberp/?rev=4252&view=rev Author: tim_schofield Date: 2011-01-11 12:42:08 +0000 (Tue, 11 Jan 2011) Log Message: ----------- Phil: Improvements to Supplier Invoice and Credit notes Modified Paths: -------------- trunk/SupplierCredit.php trunk/SupplierInvoice.php Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2011-01-11 12:28:10 UTC (rev 4251) +++ trunk/SupplierCredit.php 2011-01-11 12:42:08 UTC (rev 4252) @@ -661,22 +661,21 @@ the debit is to creditors control act done later for the total credit note value + tax*/ $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount, - jobref) - VALUES (21, - '" . $CreditNoteNo . "', - '" . $SQLCreditNoteDate . "', - '" . $PeriodNo . "', - '" . $EnteredGLCode->GLCode . "', - '" . $_SESSION['SuppTrans']->SupplierID . " " . $EnteredGLCode->Narrative . "', - '" . round(-$EnteredGLCode->Amount/$_SESSION['SuppTrans']->ExRate,2) ."', - '' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount, + jobref) + VALUES (21, + '" . $CreditNoteNo . "', + '" . $SQLCreditNoteDate . "', + '" . $PeriodNo . "', + '" . $EnteredGLCode->GLCode . "', + '" . $_SESSION['SuppTrans']->SupplierID . " " . $EnteredGLCode->Narrative . "', + '" . round(-$EnteredGLCode->Amount/$_SESSION['SuppTrans']->ExRate,2) ."', + '' )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction could not be added because'); @@ -694,20 +693,19 @@ these entries are reversed from the GRN suspense when the shipment is closed - entries only to open shipts*/ $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (21, - '" . $CreditNoteNo . "', - '" . $SQLCreditNoteDate . "', - '" . $PeriodNo . "', - '" . $_SESSION['SuppTrans']->GRNAct . "', - '" . $_SESSION['SuppTrans']->SupplierID . ' ' . _('Shipment credit against') . ' ' . $ShiptChg->ShiptRef . "', - '" . round(-$ShiptChg->Amount/$_SESSION['SuppTrans']->ExRate,2) . "' - )"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (21, + '" . $CreditNoteNo . "', + '" . $SQLCreditNoteDate . "', + '" . $PeriodNo . "', + '" . $_SESSION['SuppTrans']->GRNAct . "', + '" . $_SESSION['SuppTrans']->SupplierID . ' ' . _('Shipment credit against') . ' ' . $ShiptChg->ShiptRef . "', + '" . round(-$ShiptChg->Amount/$_SESSION['SuppTrans']->ExRate,2) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction for the shipment') . ' ' . $ShiptChg->ShiptRef . ' ' . _('could not be added because'); $DbgMsg = _('The following SQL to insert the GL transaction was used'); @@ -810,7 +808,7 @@ } - $PurchPriceVar = round($EnteredGRN->This_QuantityInv * (($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) - $EnteredGRN->StdCostUnit),2); + $PurchPriceVar = $EnteredGRN->This_QuantityInv * (($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) - $EnteredGRN->StdCostUnit); /*Yes but where to post this difference to - if its a stock item the variance account must be retrieved from the stock category record if its a nominal purchase order item with no stock item then post it to the account specified in the purchase order detail record */ @@ -1125,7 +1123,8 @@ $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } - /* Now update the GRN and PurchOrderDetails records for amounts invoiced */ + /* Now update the GRN and PurchOrderDetails records for amounts invoiced + * can't use the previous loop around GRNs as this was only for where the creditors->GL link was active*/ foreach ($_SESSION['SuppTrans']->GRNs as $EnteredGRN){ @@ -1169,34 +1168,37 @@ $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True); } if ($EnteredGRN->AssetID!=0) { //then it is an asset - /*Add the fixed asset trans for the difference in the cost */ - $SQL = "INSERT INTO fixedassettrans (assetid, - transtype, - transno, - transdate, - periodno, - inputdate, - fixedassettranstype, - amount) - VALUES ('" . $EnteredGRN->AssetID . "', - 21, - '" . $CreditNoteNo . "', - '" . $SQLCreditNoteDate . "', - '" . $PeriodNo . "', - '" . Date('Y-m-d') . "', - 'cost', - '" . -($PurchPriceVar) . "')"; - $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); + $PurchPriceVar = $EnteredGRN->This_QuantityInv * (($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) - $EnteredGRN->StdCostUnit); + if ($PurchPriceVar !=0){ + /*Add the fixed asset trans for the difference in the cost */ + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + transno, + transdate, + periodno, + inputdate, + fixedassettranstype, + amount) + VALUES ('" . $EnteredGRN->AssetID . "', + 21, + '" . $CreditNoteNo . "', + '" . $SQLCreditNoteDate . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + 'cost', + '" . -($PurchPriceVar) . "')"; + $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 update the asset cost in fixedassets table */ - $SQL = "UPDATE fixedassets SET cost = cost - " . $PurchPriceVar . " - WHERE assetid = '" . $EnteredGRN->AssetID . "'"; - $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset cost was not able to be updated because:'); - $DbgMsg = _('The following SQL was used to attempt the update of the fixed asset cost:'); - $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); - } + /*Now update the asset cost in fixedassets table */ + $SQL = "UPDATE fixedassets SET cost = cost - " . $PurchPriceVar . " + WHERE assetid = '" . $EnteredGRN->AssetID . "'"; + $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset cost was not able to be updated because:'); + $DbgMsg = _('The following SQL was used to attempt the update of the fixed asset cost:'); + $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); + } //end if there is a cost difference on invoice compared to purchase order for the fixed asset + }//the line is a fixed asset } /* end of the loop to do the updates for the quantity of order items the supplier has credited */ /*Add shipment charges records as necessary */ Modified: trunk/SupplierInvoice.php =================================================================== --- trunk/SupplierInvoice.php 2011-01-11 12:28:10 UTC (rev 4251) +++ trunk/SupplierInvoice.php 2011-01-11 12:42:08 UTC (rev 4252) @@ -7,7 +7,7 @@ Also an array of GLCodes objects - only used if the AP - GL link is effective Also an array of shipment charges for charges to shipments to be apportioned accross the cost of stock items */ -//$PageSecurity = 5; +//$PageSecurity = 5; now retrieved from database include('includes/DefineSuppTransClass.php'); /* Session started in header.inc for password checking and authorisation level check */ @@ -1122,10 +1122,11 @@ $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } - /* Now update the GRN and PurchOrderDetails records for amounts invoiced */ + /* Now update the GRN and PurchOrderDetails records for amounts invoiced - can't use the other loop through the GRNs as this was only where the GL link to credtors is active */ foreach ($_SESSION['SuppTrans']->GRNs as $EnteredGRN){ + $SQL = "UPDATE purchorderdetails SET qtyinvoiced = qtyinvoiced + " . $EnteredGRN->This_QuantityInv .", actprice = '" . $EnteredGRN->ChgPrice . "' WHERE podetailitem = '" . $EnteredGRN->PODetailItem . "'"; @@ -1166,32 +1167,35 @@ if ($EnteredGRN->AssetID!=0) { //then it is an asset - /*Add the fixed asset trans for the difference in the cost */ - $SQL = "INSERT INTO fixedassettrans (assetid, - transtype, - transno, - transdate, - periodno, - inputdate, - fixedassettranstype, - amount) - VALUES ('" . $EnteredGRN->AssetID . "', - 20, - '" . $InvoiceNo . "', - '" . $SQLInvoiceDate . "', - '" . $PeriodNo . "', - '" . Date('Y-m-d') . "', - 'cost', - '" . ($PurchPriceVar) . "')"; - $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); + $PurchPriceVar = $EnteredGRN->This_QuantityInv * (($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) - $EnteredGRN->StdCostUnit); + if ($PurchPriceVar !=0) { + /*Add the fixed asset trans for the difference in the cost */ + $SQL = "INSERT INTO fixedassettrans (assetid, + transtype, + transno, + transdate, + periodno, + inputdate, + fixedassettranstype, + amount) + VALUES ('" . $EnteredGRN->AssetID . "', + 20, + '" . $InvoiceNo . "', + '" . $SQLInvoiceDate . "', + '" . $PeriodNo . "', + '" . Date('Y-m-d') . "', + 'cost', + '" . ($PurchPriceVar) . "')"; + $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 update the asset cost in fixedassets table */ - $SQL = "UPDATE fixedassets SET cost = cost - " . ($PurchPriceVar) . " WHERE assetid = '" . $EnteredGRN->AssetID . "'"; - $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset cost could not be updated because:'); - $DbgMsg = _('The following SQL was used to attempt the update of the asset cost:'); - $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); + /*Now update the asset cost in fixedassets table */ + $SQL = "UPDATE fixedassets SET cost = cost + " . ($PurchPriceVar) . " WHERE assetid = '" . $EnteredGRN->AssetID . "'"; + $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset cost could not be updated because:'); + $DbgMsg = _('The following SQL was used to attempt the update of the asset cost:'); + $Result = DB_query($SQL,$db,$ErrMsg, $DbgMsg, true); + } //end if there was a difference in the cost } //the item was an asset received on a purchase order } /* end of the GRN loop to do the updates for the quantity of order items the supplier has invoiced */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |