From: <dai...@us...> - 2011-11-12 09:42:42
|
Revision: 4744 http://web-erp.svn.sourceforge.net/web-erp/?rev=4744&view=rev Author: daintree Date: 2011-11-12 09:42:34 +0000 (Sat, 12 Nov 2011) Log Message: ----------- bug fixes and tidy Modified Paths: -------------- trunk/CounterSales.php trunk/Credit_Invoice.php trunk/CustomerReceipt.php trunk/GoodsReceived.php trunk/PDFCustTransListing.php trunk/Payments.php trunk/PrintCheque.php trunk/SelectCreditItems.php trunk/SuppPaymentRun.php trunk/doc/Change.log trunk/includes/DefinePOClass.php trunk/includes/DefinePaymentClass.php trunk/includes/MiscFunctions.php trunk/includes/PDFPaymentRun_PymtFooter.php Removed Paths: ------------- trunk/Numbers/ Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/CounterSales.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -1432,37 +1432,36 @@ $OrderLine->StandardCost=0; } if ($MBFlag=='B' OR $MBFlag=='M'){ - $SQL = "INSERT INTO stockmoves ( - stockid, - type, - transno, - loccode, - trandate, - debtorno, - branchcode, - price, - prd, - reference, - qty, - discountpercent, - standardcost, - newqoh, - narrative ) - VALUES ('" . $OrderLine->StockID . "', - 10, - '" . $InvoiceNo . "', - '" . $_SESSION['Items'.$identifier]->Location . "', - '" . $DefaultDispatchDate . "', - '" . $_SESSION['Items'.$identifier]->DebtorNo . "', - '" . $_SESSION['Items'.$identifier]->Branch . "', - '" . $LocalCurrencyPrice . "', - '" . $PeriodNo . "', - '" . $OrderNo . "', - '" . -$OrderLine->Quantity . "', - '" . $OrderLine->DiscountPercent . "', - '" . $OrderLine->StandardCost . "', - '" . ($QtyOnHandPrior - $OrderLine->Quantity) . "', - '" . DB_escape_string($OrderLine->Narrative) . "' )"; + $SQL = "INSERT INTO stockmoves (stockid, + type, + transno, + loccode, + trandate, + debtorno, + branchcode, + price, + prd, + reference, + qty, + discountpercent, + standardcost, + newqoh, + narrative ) + VALUES ('" . $OrderLine->StockID . "', + 10, + '" . $InvoiceNo . "', + '" . $_SESSION['Items'.$identifier]->Location . "', + '" . $DefaultDispatchDate . "', + '" . $_SESSION['Items'.$identifier]->DebtorNo . "', + '" . $_SESSION['Items'.$identifier]->Branch . "', + '" . $LocalCurrencyPrice . "', + '" . $PeriodNo . "', + '" . $OrderNo . "', + '" . -$OrderLine->Quantity . "', + '" . $OrderLine->DiscountPercent . "', + '" . $OrderLine->StandardCost . "', + '" . ($QtyOnHandPrior - $OrderLine->Quantity) . "', + '" . DB_escape_string($OrderLine->Narrative) . "' )"; } else { // its an assembly or dummy and assemblies/dummies always have nil stock (by definition they are made up at the time of dispatch so new qty on hand will be nil if (empty($OrderLine->StandardCost)) { @@ -1688,13 +1687,13 @@ /*now the stock entry*/ $StockGLCode = GetStockGLCode($OrderLine->StockID,$db); - $SQL = "INSERT INTO gltrans ( type, - typeno, - trandate, - periodno, - account, - narrative, - amount ) + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount ) VALUES ( 10, '" . $InvoiceNo . "', '" . $DefaultDispatchDate . "', @@ -1713,14 +1712,13 @@ //Post sales transaction to GL credit sales $SalesGLAccounts = GetSalesGLAccount($Area, $OrderLine->StockID, $_SESSION['Items'.$identifier]->DefaultSalesType, $db); - $SQL = "INSERT INTO gltrans ( type, - typeno, - trandate, - periodno, - account, - narrative, - amount - ) + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount ) VALUES ( 10, '" . $InvoiceNo . "', '" . $DefaultDispatchDate . "', @@ -1735,14 +1733,13 @@ if ($OrderLine->DiscountPercent !=0){ - $SQL = "INSERT INTO gltrans ( type, - typeno, - trandate, - periodno, - account, - narrative, - amount - ) + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount ) VALUES ( 10, '" . $InvoiceNo . "', '" . $DefaultDispatchDate . "', @@ -1805,6 +1802,9 @@ $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } } + + EnsureGLEntriesBalance(10,$InvoiceNo,$db); + /*Also if GL is linked to debtors need to process the debit to bank and credit to debtors for the payment */ /*Need to figure out the cross rate between customer currency and bank account currency */ @@ -1847,6 +1847,9 @@ $ErrMsg = _('Cannot insert a GL transaction for the debtors account credit'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); }//amount paid we not zero + + EnsureGLEntriesBalance(12,$ReceiptNumber,$db); + } /*end of if Sales and GL integrated */ if ($_POST['AmountPaid']!=0){ if (!isset($ReceiptNumber)){ Modified: trunk/Credit_Invoice.php =================================================================== --- trunk/Credit_Invoice.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/Credit_Invoice.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -20,11 +20,11 @@ exit; } elseif (isset($_GET['InvoiceNumber'])) { - $_GET['InvoiceNumber']=(int)$_GET['InvoiceNumber']; + $_GET['InvoiceNumber']=intval($_GET['InvoiceNumber']); unset($_SESSION['CreditItems']->LineItems); unset($_SESSION['CreditItems']); - $_SESSION['ProcessingCredit'] = $_GET['InvoiceNumber']; + $_SESSION['ProcessingCredit'] = intval($_GET['InvoiceNumber']); $_SESSION['CreditItems'] = new cart; /*read in all the guff from the selected invoice into the Items cart */ @@ -61,7 +61,7 @@ AND stockmoves.type=debtortrans.type INNER JOIN locations ON stockmoves.loccode = locations.loccode - WHERE debtortrans.transno = '" . $_GET['InvoiceNumber'] . "' + WHERE debtortrans.transno = '" . intval($_GET['InvoiceNumber']) . "' AND stockmoves.type=10"; $ErrMsg = _('A credit cannot be produced for the selected invoice') . '. ' . _('The invoice details cannot be retrieved because'); @@ -1414,6 +1414,9 @@ $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } } + + EnsureGLEntriesBalance(11,$CreditNo,$db); + } /*end of if Sales and GL integrated */ $Result = DB_Txn_Commit($db); Modified: trunk/CustomerReceipt.php =================================================================== --- trunk/CustomerReceipt.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/CustomerReceipt.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -534,6 +534,7 @@ $ErrMsg = _('Cannot insert a GL transaction for the payment discount debit'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } //end if there is some discount + EnsureGLEntriesBalance(12,$_SESSION['ReceiptBatch']->BatchNo,$db); } //end if there is GL work to be done - ie config is to link to GL Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/GoodsReceived.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -38,7 +38,7 @@ AND !isset($_POST['Update'])) { /*Update only occurs if the user hits the button to refresh the data and recalc the value of goods recd*/ - $_GET['ModifyOrderNumber'] = (int)$_GET['PONumber']; + $_GET['ModifyOrderNumber'] = intval($_GET['PONumber']); include('includes/PO_ReadInOrder.inc'); } elseif (isset($_POST['Update']) OR isset($_POST['ProcessGoodsReceived'])) { @@ -47,7 +47,7 @@ set from the post to the quantity to be received */ foreach ($_SESSION['PO'.$identifier]->LineItems as $Line) { - $RecvQty = filter_number_format($_POST['RecvQty_' . $Line->LineNo]); + $RecvQty = round(filter_number_format($_POST['RecvQty_' . $Line->LineNo]),$Line->DecimalPlaces); if (!is_numeric($RecvQty)){ $RecvQty = 0; } @@ -612,7 +612,7 @@ '" . $_POST['DefaultReceivedDate'] . "', '" . $PeriodNo . "', '" . Date('Y-m-d') . "', - 'cost', + '" . _('cost') . "', '" . $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'); @@ -662,7 +662,7 @@ '" . $OrderLine->GLCode . "', 'PO: " . $_SESSION['PO'.$identifier]->OrderNo . " " . $_SESSION['PO'.$identifier]->SupplierID . " - " . $OrderLine->StockID . " - " . $OrderLine->ItemDescription . " x " . $OrderLine->ReceiveQty . " @ " . - locale_number_format($CurrentStandardCost,2) . "', + locale_number_format($CurrentStandardCost,$_SESSION['CompanyRecord']['decimalplaces']) . "', '" . $CurrentStandardCost * $OrderLine->ReceiveQty . "' )"; @@ -685,7 +685,7 @@ '" . $_POST['DefaultReceivedDate'] . "', '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['grnact'] . "', - '" . _('PO'.$identifier) . ': ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . $_SESSION['PO'.$identifier]->SupplierID . ' - ' . $OrderLine->StockID . ' - ' . $OrderLine->ItemDescription . ' x ' . $OrderLine->ReceiveQty . ' @ ' . locale_number_format($UnitCost,2) . "', + '" . _('PO'.$identifier) . ': ' . $_SESSION['PO'.$identifier]->OrderNo . ' ' . $_SESSION['PO'.$identifier]->SupplierID . ' - ' . $OrderLine->StockID . ' - ' . $OrderLine->ItemDescription . ' x ' . $OrderLine->ReceiveQty . ' @ ' . locale_number_format($UnitCost,$_SESSION['CompanyRecord']['decimalplaces']) . "', '" . -$UnitCost * $OrderLine->ReceiveQty . "' )"; @@ -705,8 +705,11 @@ WHERE orderno='" . $_SESSION['PO'.$identifier]->OrderNo . "'"; $result=DB_query($sql,$db); } + + if ($_SESSION['PO'.$identifier]->GLLink==1) { + EnsureGLEntriesBalance(25, $GRN,$db); + } - $Result = DB_Txn_Commit($db); $PONo = $_SESSION['PO'.$identifier]->OrderNo; unset($_SESSION['PO'.$identifier]->LineItems); @@ -714,7 +717,7 @@ unset($_POST['ProcessGoodsReceived']); echo '<br /> - <div class=centre> + <div class="centre"> '. prnMsg(_('GRN number'). ' '. $GRN .' '. _('has been processed'),'success') . ' <br /> <br /> Modified: trunk/PDFCustTransListing.php =================================================================== --- trunk/PDFCustTransListing.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/PDFCustTransListing.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -130,7 +130,7 @@ $YPos-=$line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin+452,$YPos,70,$FontSize,locale_number_format($TotalAmount,$_SESSION['CompanyRecord']['decimalplaces']), 'right'); -$LeftOvers = $pdf->addTextWrap($Left_Margin+265,$YPos,300,$FontSize,_('Total') . ' ' . _('Transactions') . ' ' . $_SESSION['CompanyRecord']['CurrencyDefault'], 'left'); +$LeftOvers = $pdf->addTextWrap($Left_Margin+265,$YPos,300,$FontSize,_('Total') . ' ' . _('Transactions') . ' ' . $_SESSION['CompanyRecord']['currencydefault'], 'left'); $ReportFileName = $_SESSION['DatabaseName'] . '_CustTransListing_' . date('Y-m-d').'.pdf'; $pdf->OutputD($ReportFileName); Modified: trunk/Payments.php =================================================================== --- trunk/Payments.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/Payments.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -30,10 +30,12 @@ if ((isset($_POST['UpdateHeader']) AND $_POST['BankAccount']=='') OR (isset($_POST['Process']) AND $_POST['BankAccount']=='')) { + prnMsg(_('A bank account must be selected to make this payment from'), 'warn'); - $BankAccountEmpty=TRUE; + $BankAccountEmpty=true; } else { - $BankAccountEmpty=FALSE; + + $BankAccountEmpty=false; } echo '<p class="page_title_text"> @@ -72,7 +74,7 @@ exit; } else { $myrow = DB_fetch_array($Result); - if ($myrow['factorcompanyid'] == 1) { + if ($myrow['factorcompanyid'] == 0) { $_SESSION['PaymentDetail']->SuppName = $myrow['suppname']; $_SESSION['PaymentDetail']->Address1 = $myrow['address1']; $_SESSION['PaymentDetail']->Address2 = $myrow['address2']; @@ -82,6 +84,7 @@ $_SESSION['PaymentDetail']->Address6 = $myrow['address6']; $_SESSION['PaymentDetail']->SupplierID = $_GET['SupplierID']; $_SESSION['PaymentDetail']->Currency = $myrow['currcode']; + $_POST['Currency'] = $_SESSION['PaymentDetail']->Currency; } else { $factorsql= "SELECT coyname, @@ -111,6 +114,7 @@ } if (isset($_POST['BankAccount']) AND $_POST['BankAccount']!=''){ + $_SESSION['PaymentDetail']->Account=$_POST['BankAccount']; /*Get the bank account currency and set that too */ $ErrMsg = _('Could not get the currency of the bank account'); @@ -134,10 +138,10 @@ $_SESSION['PaymentDetail']->DatePaid=$_POST['DatePaid']; } if (isset($_POST['ExRate']) AND $_POST['ExRate']!=''){ - $_SESSION['PaymentDetail']->ExRate=$_POST['ExRate']; //ex rate between payment currency and account currency + $_SESSION['PaymentDetail']->ExRate=filter_number_format($_POST['ExRate']); //ex rate between payment currency and account currency } if (isset($_POST['FunctionalExRate']) AND $_POST['FunctionalExRate']!=''){ - $_SESSION['PaymentDetail']->FunctionalExRate=$_POST['FunctionalExRate']; //ex rate between payment currency and account currency + $_SESSION['PaymentDetail']->FunctionalExRate=filter_number_format($_POST['FunctionalExRate']); //ex rate between payment currency and account currency } if (isset($_POST['Paymenttype']) AND $_POST['Paymenttype']!=''){ $_SESSION['PaymentDetail']->Paymenttype = $_POST['Paymenttype']; @@ -158,8 +162,8 @@ if ($_SESSION['PaymentDetail']->AccountCurrency==$_SESSION['CompanyRecord']['currencydefault']){ $_POST['FunctionalExRate']=1; $_SESSION['PaymentDetail']->FunctionalExRate=filter_number_format($_POST['FunctionalExRate']); + $SuggestedExRate = $tableExRate; $SuggestedFunctionalExRate =1; - $SuggestedExRate = $tableExRate; } else { /*To illustrate the rates required @@ -190,8 +194,8 @@ if (isset($_POST['Narrative']) AND $_POST['Narrative']!=''){ $_SESSION['PaymentDetail']->Narrative=$_POST['Narrative']; } -if (isset($_POST['Amount']) AND $_POST['Amount']!=""){ - $_SESSION['PaymentDetail']->Amount=$_POST['Amount']; +if (isset($_POST['Amount']) AND $_POST['Amount']!=''){ + $_SESSION['PaymentDetail']->Amount=filter_number_format($_POST['Amount']); } else { if (!isset($_SESSION['PaymentDetail']->Amount)) { $_SESSION['PaymentDetail']->Amount=0; @@ -275,11 +279,16 @@ echo '<form method=post action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo _('Has the cheque been printed') . '?<br /><br />'; - echo '<input type="hidden" name="CommitBatch" value="' . $_POST['CommitBatch'] . '" />'; - echo '<input type="hidden" name="BankAccount" value="' . $_POST['BankAccount'] . '" />'; - echo '<input type="submit" name="ChequePrinted" value="' . _('Yes / Continue') . '" /> '; - echo '<input type="submit" name="PaymentCancelled" value="' . _('No / Cancel Payment') . '" />'; + echo _('Has the cheque been printed') . '? + <br /> + <br /> + <input type="hidden" name="CommitBatch" value="' . $_POST['CommitBatch'] . '" /> + <input type="hidden" name="BankAccount" value="' . $_POST['BankAccount'] . '" /> + <input type="submit" name="ChequePrinted" value="' . _('Yes / Continue') . '" /> + <input type="submit" name="PaymentCancelled" value="' . _('No / Cancel Payment') . '" />'; + + echo '<br />Payment amount = ' . $_SESSION['PaymentDetail']->Amount; + } else { //Start a transaction to do the whole lot inside @@ -292,7 +301,7 @@ //its a nominal bank transaction type 1 $TransNo = GetNextTransNo( 1, $db); - $Transtype = 1; + $TransType = 1; if ($_SESSION['CompanyRecord']['gllink_creditors']==1){ /* then enter GLTrans */ $TotalAmount=0; @@ -301,7 +310,7 @@ /*The functional currency amount will be the payment currenct amount / the bank account currency exchange rate - to get to the bank account currency then / the functional currency exchange rate to get to the functional currency */ - if ($PaymentItem->cheque=='') $PaymentItem->cheque=0; + if ($PaymentItem->Cheque=='') $PaymentItem->Cheque=0; $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -318,8 +327,8 @@ '" . $PaymentItem->GLCode . "', '" . $PaymentItem->Narrative . "', '" . ($PaymentItem->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "', - '". $PaymentItem->cheque ."', - '" . $PaymentItem->tag . "' + '". $PaymentItem->Cheque ."', + '" . $PaymentItem->Tag . "' )"; $ErrMsg = _('Cannot insert a GL entry for the payment using the SQL'); $result = DB_query($SQL,$db,$ErrMsg,_('The SQL that failed was'),true); @@ -413,7 +422,7 @@ $CreditorTotal = (($_SESSION['PaymentDetail']->Discount + $_SESSION['PaymentDetail']->Amount)/$_SESSION['PaymentDetail']->ExRate)/$_SESSION['PaymentDetail']->FunctionalExRate; $TransNo = GetNextTransNo(22, $db); - $Transtype = 22; + $TransType = 22; /* Create a SuppTrans entry for the supplier payment */ $SQL = "INSERT INTO supptrans (transno, @@ -483,8 +492,8 @@ periodno, account, narrative, - amount) "; - $SQL=$SQL . "VALUES (22, + amount) + VALUES (22, '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', '" . $PeriodNo . "', @@ -496,6 +505,7 @@ $DbgMsg = _('Cannot insert a GL transaction for the payment discount credit using the SQL'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } // end if discount + } // end if gl creditors } // end if supplier @@ -510,7 +520,7 @@ account, narrative, amount) - VALUES ('" . $Transtype . "', + VALUES ('" . $TransType . "', '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', '" . $PeriodNo . "', @@ -522,11 +532,12 @@ $DbgMsg = _('Cannot insert a GL transaction for the bank account credit using the SQL'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + EnsureGLEntriesBalance($TransType,$TransNo,$db); } } /*now enter the BankTrans entry */ - if ($Transtype==22) { + if ($TransType==22) { $SQL="INSERT INTO banktrans (transno, type, bankact, @@ -538,7 +549,7 @@ amount, currcode) VALUES ('" . $TransNo . "', - '" . $Transtype . "', + '" . $TransType . "', '" . $_SESSION['PaymentDetail']->Account . "', '" . $_SESSION['PaymentDetail']->Narrative . "', '" . $_SESSION['PaymentDetail']->ExRate . "', @@ -565,7 +576,7 @@ amount, currcode) VALUES ('" . $TransNo . "', - '" . $Transtype . "', + '" . $TransType . "', '" . $_SESSION['PaymentDetail']->Account . "', '" . $_SESSION['PaymentDetail']->Narrative . "', '" . $_SESSION['PaymentDetail']->ExRate . "', @@ -616,9 +627,10 @@ } elseif (isset($_GET['Delete'])){ /* User hit delete the receipt entry from the batch */ $_SESSION['PaymentDetail']->Remove_GLItem($_GET['Delete']); + } elseif (isset($_POST['Process']) AND !$BankAccountEmpty){ //user hit submit a new GL Analysis line into the payment - $ChequeNoSQL="SELECT account FROM gltrans WHERE chequeno='" . $_POST['cheque'] ."'"; + $ChequeNoSQL="SELECT account FROM gltrans WHERE chequeno='" . $_POST['Cheque'] ."'"; $ChequeNoResult=DB_query($ChequeNoSQL, $db); if (is_numeric($_POST['GLManualCode'])){ @@ -632,7 +644,7 @@ if (DB_num_rows($Result)==0){ prnMsg( _('The manual GL code entered does not exist in the database') . ' - ' . _('so this GL analysis item could not be added'),'warn'); unset($_POST['GLManualCode']); - } else if (DB_num_rows($ChequeNoResult)!=0 AND $_POST['cheque']!=''){ + } else if (DB_num_rows($ChequeNoResult)!=0 AND $_POST['Cheque']!=''){ prnMsg( _('The Cheque/Voucher number has already been used') . ' - ' . _('This GL analysis item could not be added'),'error'); } else { $myrow = DB_fetch_array($Result); @@ -640,11 +652,11 @@ $_POST['GLNarrative'], $_POST['GLManualCode'], $myrow['accountname'], - $_POST['tag'], - $_POST['cheque']); + $_POST['Tag'], + $_POST['Cheque']); unset($_POST['GLManualCode']); } - } else if (DB_num_rows($ChequeNoResult)!=0 AND $_POST['cheque']!=''){ + } else if (DB_num_rows($ChequeNoResult)!=0 AND $_POST['Cheque']!=''){ prnMsg( _('The cheque number has already been used') . ' - ' . _('This GL analysis item could not be added'),'error'); } else if ($_POST['GLCode'] == '') { prnMsg( _('No General Ledger code has been chosen') . ' - ' . _('so this GL analysis item could not be added'),'warn'); @@ -656,8 +668,8 @@ $_POST['GLNarrative'], $_POST['GLCode'], $myrow['accountname'], - $_POST['tag'], - $_POST['cheque']); + $_POST['Tag'], + $_POST['Cheque']); } /*Make sure the same receipt is not double processed by a page refresh */ @@ -821,7 +833,7 @@ $SuggestedExRateText =''; } if ($_POST['ExRate']==1 AND isset($SuggestedExRate)){ - $_POST['ExRate'] = $SuggestedExRate; + $_POST['ExRate'] = locale_number_format($SuggestedExRate,6); } echo '<tr> <td>' . _('Payment Exchange Rate') . ':</td> @@ -896,10 +908,10 @@ echo '<br /><table class="selection">'; echo '<tr><th colspan="2"><font size="3" color="blue">' . _('General Ledger Payment Analysis Entry') . '</font></th></tr>'; - //Select the tag + //Select the Tag echo '<tr> <td>' . _('Select Tag') . ':</td> - <td><select name="tag">'; + <td><select name="Tag">'; $SQL = "SELECT tagref, tagdescription @@ -909,7 +921,7 @@ $result=DB_query($SQL,$db); echo '<option value=0></option>'; while ($myrow=DB_fetch_array($result)){ - if (isset($_POST['tag']) AND $_POST['tag']==$myrow['tagref']){ + if (isset($_POST['Tag']) AND $_POST['Tag']==$myrow['tagref']){ echo '<option selected value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription'] . '</option>'; } else { echo '<option value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription'] . '</option>'; @@ -917,7 +929,7 @@ } echo '</select></td> </tr>'; -// End select tag +// End select Tag /*now set up a GLCode field to select from avaialble GL accounts */ if (isset($_POST['GLManualCode'])) { @@ -994,7 +1006,7 @@ echo '<tr> <td>'. _('Cheque/Voucher Number') .'</td> - <td><input type="text" name="cheque" maxlength="12" size="12" /></td> + <td><input type="text" name="Cheque" maxlength="12" size="12" /></td> </tr>'; if (isset($_POST['GLNarrative'])) { @@ -1039,21 +1051,21 @@ $PaymentTotal = 0; foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { - $tagsql="SELECT tagdescription from tags where tagref='" . $PaymentItem->tag . "'"; - $TagResult=DB_query($tagsql, $db); + $Tagsql="SELECT tagdescription from tags where tagref='" . $PaymentItem->Tag . "'"; + $TagResult=DB_query($Tagsql, $db); $TagMyrow=DB_fetch_row($TagResult); - if ($PaymentItem->tag==0) { + if ($PaymentItem->Tag==0) { $TagName='None'; } else { $TagName=$TagMyrow[0]; } echo '<tr> - <td align=left>' . $PaymentItem->cheque . '</td> + <td>' . $PaymentItem->Cheque . '</td> <td class="number">' . locale_number_format($PaymentItem->Amount,$_SESSION['PaymentDetail']->CurrDecimalPlaces) . '</td> <td>' . $PaymentItem->GLCode . ' - ' . $PaymentItem->GLActName . '</td> <td>' . stripslashes($PaymentItem->Narrative) . '</td> - <td>' . $PaymentItem->tag . ' - ' . $TagName . '</td> + <td>' . $PaymentItem->Tag . ' - ' . $TagName . '</td> <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?Delete=' . $PaymentItem->ID . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this payment analysis item?') . '\');">' . _('Delete') . '</a></td> </tr>'; $PaymentTotal += $PaymentItem->Amount; @@ -1077,7 +1089,7 @@ echo '<table class="selection"> <tr> <td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail']->Currency . ':</td> - <td><input class="number" type="text" name="Amount" maxlength=12 size=13 value=' . $_SESSION['PaymentDetail']->Amount . '></td> + <td><input class="number" type="text" name="Amount" maxlength="12" size="13" value=' . $_SESSION['PaymentDetail']->Amount . '></td> </tr>'; if (isset($_SESSION['PaymentDetail']->SupplierID)){ /*So it is a supplier payment so show the discount entry item */ @@ -1087,7 +1099,7 @@ </tr>'; echo '<input type="hidden" name="SuppName" value="' . $_SESSION['PaymentDetail']->SuppName . '" />'; } else { - echo '<input type="hidden" name="discount" Value="0" />'; + echo '<input type="hidden" name="Discount" Value="0" />'; } echo '</table><br />'; echo '<input type=submit name="CommitBatch" value="' . _('Accept and Process Payment') . '" />'; Modified: trunk/PrintCheque.php =================================================================== --- trunk/PrintCheque.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/PrintCheque.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -2,10 +2,12 @@ /* $Id$*/ +/*Hard coded for currencies with 2 decimal places */ + include('includes/DefinePaymentClass.php'); include('includes/session.inc'); -include('Numbers/Words.php'); + include('includes/PDFStarter.php'); $pdf->addInfo('Title', _('Print Cheque')); $pdf->addInfo('Subject', _('Print Cheque')); @@ -14,7 +16,8 @@ $line_height=12; $result = db_query("SELECT hundredsname, - decimalplaces + decimalplaces, + currency FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->Currency . "'",$db); @@ -25,15 +28,23 @@ exit; } -$CurrencyRow = db_fetch_row($result); -$HundredsName = $CurrencyRow[0]; -$CurrDecimalPlaces = $CurrencyRow[1]; +$CurrencyRow = db_fetch_array($result); +$HundredsName = $CurrencyRow['hundredsname']; +$CurrDecimalPlaces = $CurrencyRow['decimalplaces']; +$CurrencyName = mb_strtolower($CurrencyRow['currency']); // cheque $YPos= $Page_Height-5*$line_height; $LeftOvers = $pdf->addTextWrap($Page_Width-75,$YPos,100,$FontSize,$_GET['ChequeNum'], 'left'); $YPos -= 3*$line_height; +$AmountWords = number_to_words($_SESSION['PaymentDetail']->Amount) . ' ' . $CurrencyName; +$Cents = intval(round(($_SESSION['PaymentDetail']->Amount - intval($_SESSION['PaymentDetail']->Amount))*100,0)); +if ($Cents > 0){ + $AmountWords .= ' ' . _('and') . ' ' . strval($Cents) . ' ' . $HundredsName; +} else { + $AmountWords .= ' ' . _('only'); +} $LeftOvers = $pdf->addTextWrap(75,$YPos,475,$FontSize,$AmountWords, 'left'); $YPos -= 1*$line_height; @@ -50,8 +61,6 @@ $Address3 = $_SESSION['PaymentDetail']->Address3 . ' ' . $_SESSION['PaymentDetail']->Address4 . ' ' . $_SESSION['PaymentDetail']->Address5 . ' ' . $_SESSION['PaymentDetail']->Address6; $LeftOvers = $pdf->addTextWrap(75,$YPos,300,$FontSize, $Address3, 'left'); -$AmountWords = Numbers_Words::toWords(intval($_SESSION['PaymentDetail']->Amount),$Locale); -$AmountWords .= ' ' . _('and') . ' ' . Numbers_Words::toWords(intval(($_SESSION['PaymentDetail']->Amount - intval($_SESSION['PaymentDetail']->Amount))*100),$Locale) . ' ' . $HundredsName; $YPos -= 2*$line_height; $LeftOvers = $pdf->addTextWrap(75,$YPos,300,$FontSize, $AmountWords, 'left'); @@ -88,4 +97,94 @@ $pdf->OutputD($_SESSION['DatabaseName'] . '_Cheque_' . date('Y-m-d') . '_ChequeNum_' . $_GET['ChequeNum'] . '.pdf'); $pdf->__destruct(); + +exit; +/* ****************************************************************************************** */ + +function number_to_words($Number) { + + if (($Number < 0) OR ($Number > 999999999)) { + prnMsg(_('Number is out of the range of numbers that can be expressed in words'),'error'); + return _('error'); + } + + $Millions = floor($Number / 1000000); + $Number -= $Millions * 1000000; + $Thousands = floor($Number / 1000); + $Number -= $Thousands * 1000; + $Hundreds = floor($Number / 100); + $Number -= $Hundreds * 100; + $NoOfTens = floor($Number / 10); + $NoOfOnes = $Number % 10; + + $NumberInWords = ''; + + if ($Millions) { + $NumberInWords .= number_to_words($Millions) . ' ' . _('million'); + } + + if ($Thousands) { + $NumberInWords .= (empty($NumberInWords) ? '' : ' ') . number_to_words($Thousands) . ' ' . _('thousand'); + } + + if ($Hundreds) { + $NumberInWords .= (empty($NumberInWords) ? '' : ' ') . number_to_words($Hundreds) . ' ' . _('hundred'); + } + + $Ones = array( 0 => '', + 1 => _('one'), + 2 => _('two'), + 3 => _('three'), + 4 => _('four'), + 5 => _('five'), + 6 => _('six'), + 7 => _('seven'), + 8 => _('eight'), + 9 => _('nine'), + 10 => _('ten'), + 11 => _('eleven'), + 12 => _('twelve'), + 13 => _('thirteen'), + 14 => _('fourteen'), + 15 => _('fifteen'), + 16 => _('sixteen'), + 17 => _('seventeen'), + 18 => _('eighteen'), + 19 => _('nineteen') ); + + $Tens = array( 0 => '', + 1 => '', + 2 => _('twenty'), + 3 => _('thirty'), + 4 => _('forty'), + 5 => _('fifty'), + 6 => _('sixty'), + 7 => _('seventy'), + 8 => _('eighty'), + 9 => _('ninety') ); + + + if ($NoOfTens OR $NoOfOnes) { + if (!empty($NumberInWords)) { + $NumberInWords .= ' ' . _('and') . ' '; + } + + if ($NoOfTens < 2){ + $NumberInWords .= $Ones[$NoOfTens * 10 + $NoOfOnes]; + } + else { + $NumberInWords .= $Tens[$NoOfTens]; + if ($NoOfOnes) { + $NumberInWords .= '-' . $Ones[$NoOfOnes]; + } + } + } + + if (empty($NumberInWords)){ + $NumberInWords = _('zero'); + } + + return $NumberInWords; +} + ?> \ No newline at end of file Modified: trunk/SelectCreditItems.php =================================================================== --- trunk/SelectCreditItems.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/SelectCreditItems.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -1553,7 +1553,7 @@ } - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement record to write the stock off could not be inserted because'); + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement record to write the stock off could not be inserted because'); $DbgMsg = _('The following SQL to insert the stock movement to write off the stock was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -1823,9 +1823,9 @@ $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); } - } /* end of if GL and stock integrated and standard cost !=0 */ + } /* end of if GL and stock integrated and standard cost !=0 */ - if ($_SESSION['CompanyRecord']['gllink_debtors']==1 AND $CreditLine->Price !=0){ + if ($_SESSION['CompanyRecord']['gllink_debtors']==1 AND $CreditLine->Price !=0){ //Post sales transaction to GL credit sales $SalesGLAccounts = GetSalesGLAccount($Area, @@ -1849,49 +1849,49 @@ '" . (($CreditLine->Price * $CreditLine->Quantity)/$_SESSION['CurrencyRate']) . "' )"; - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit note GL posting could not be inserted because'); - $DbgMsg = _('The following SQL to insert the GLTrans record was used'); - $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - - if ($CreditLine->DiscountPercent !=0){ - - $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (11, - '" . $CreditNo . "', - '" . $SQLCreditDate . "', - '" . $PeriodNo . "', - '" . $SalesGLAccounts['discountglcode'] . "', - '" . $_SESSION['CreditItems'.$identifier]->DebtorNo . " - " . $CreditLine->StockID . " @ " . ($CreditLine->DiscountPercent * 100) . "%', - '" . -(($CreditLine->Price * $CreditLine->Quantity * $CreditLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "' - )"; - - - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit note discount GL posting could not be inserted because'); + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit note GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - }/* end of if discount not equal to 0 */ - } /*end of if sales integrated with debtors */ + + if ($CreditLine->DiscountPercent !=0){ + + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (11, + '" . $CreditNo . "', + '" . $SQLCreditDate . "', + '" . $PeriodNo . "', + '" . $SalesGLAccounts['discountglcode'] . "', + '" . $_SESSION['CreditItems'.$identifier]->DebtorNo . " - " . $CreditLine->StockID . " @ " . ($CreditLine->DiscountPercent * 100) . "%', + '" . -(($CreditLine->Price * $CreditLine->Quantity * $CreditLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "' + )"; + + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit note discount GL posting could not be inserted because'); + $DbgMsg = _('The following SQL to insert the GLTrans record was used'); + $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); + }/* end of if discount not equal to 0 */ + } /*end of if sales integrated with debtors */ } /*Quantity credited is more than 0 */ - } /*end of CreditLine loop */ + } /*end of CreditLine loop */ - if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ + if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ /*Post credit note transaction to GL credit debtors, debit freight re-charged and debit sales */ - if (($_SESSION['CreditItems'.$identifier]->total + $_SESSION['CreditItems'.$identifier]->FreightCost + $TaxTotal) !=0) { - $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) + if (($_SESSION['CreditItems'.$identifier]->total + $_SESSION['CreditItems'.$identifier]->FreightCost + $TaxTotal) !=0) { + $SQL = "INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) VALUES (11, '" . $CreditNo . "', '" . $SQLCreditDate . "', @@ -1903,8 +1903,8 @@ $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The total debtor GL posting for the credit note could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); - } - if ($_SESSION['CreditItems'.$identifier]->FreightCost !=0) { + } + if ($_SESSION['CreditItems'.$identifier]->FreightCost !=0) { $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -1946,7 +1946,10 @@ $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } } - } /*end of if Sales and GL integrated */ + + EnsureGLEntriesBalance(11,$CreditNo,$db); + + } /*end of if Sales and GL integrated */ DB_Txn_Commit($db); Modified: trunk/SuppPaymentRun.php =================================================================== --- trunk/SuppPaymentRun.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/SuppPaymentRun.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -205,10 +205,11 @@ } /* end while there are suppliers to retrieve transactions for */ if ($SupplierID!=''){ - + /*All the payment processing is in the below file */ include('includes/PDFPaymentRun_PymtFooter.php'); - $ProcessResult = DB_Txn_Commit($db); + $ProcessResult = DB_Txn_Commit($db); + if (DB_error_no($db) !=0) { $title = _('Payment Processing - Problem Report') . '.... '; include('includes/header.inc'); @@ -228,7 +229,7 @@ } - $pdf->OutputD($_SESSION['DatabaseName'] . '_Payment_Run_' . Date('Y-m-d') . '.pdf'); + $pdf->OutputD($_SESSION['DatabaseName'] . '_Payment_Run_' . Date('Y-m-d_Hms') . '.pdf'); $pdf->__destruct(); } else { /*The option to print PDF was not hit */ Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/doc/Change.log 2011-11-12 09:42:34 UTC (rev 4744) @@ -1,9 +1,13 @@ webERP Change Log +12/11/11 Phil: Purchase order Order_Value in includes/DefinePOClass.php now only looks at the value of lines left on the order after deleted lines +12/11/11 Phil: Removed old Numbers to words class code - this code was not in keeping with the rest of the system and not PHP 5 compatible anyway. Replaced with a much simpler function. This code is only used for pre-printed cheques - so it is in that script only. The new function may not effective for other languages but will be easily adapted as needed. The PrintCheque.php script needs to be modified specifically for the business stationery. +10/11/11 Phil: added a function in includes/SQL_CommonFunctions.inc EnsureGLTransBalance that looks at the gltrans entries for a given transaction type and type number and if the total is not zero and less than 0.05 it fudges the largest gltrans record to make the gltrans balance in total - added to ConfirmDispatch_Invoice.php Credit_Invoice.php SelectCreditItems.php CounterSales.php Payments.php CustomerReceipt.php 10/11/11 Phil: includes/DateFunctions.inc fixed GetPeriod function to create new period when just one month ahead of last period - worried about this can't see how it could have been like this so long without a bug report? 10/11/11 Phil: includes/LanguageSetup.php now sets LC_NUMERIC locale category after LC_ALL to ensure SQL compliant calculations 8/11/11 Phil: includes/GetConfig.php no longer casts the VersionNumber to a double - issue highlighted by Tim 8/11/11 Felix Lim: includes/InputSerialItems.php and InputSerialItemsKeyed.php now sends $identifier +8/11/11 Phil: CustomerReceipt.php now shows entries made with decimal places of the currency being entered 8/11/11 Phil: fixed bugs reported by Ron Wong and Don SelectSupplier.php sql error missed "s" off suppliers and CustomerReceipt.php - had not populated new class variable (property) of CurrDecimalPlaces 6/11/11 Release 4.06RC1 Modified: trunk/includes/DefinePOClass.php =================================================================== --- trunk/includes/DefinePOClass.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/includes/DefinePOClass.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -146,7 +146,7 @@ /* Checks if there have been deliveries or invoiced entered against any of the line items */ if (count($this->LineItems)>0){ foreach ($this->LineItems as $OrderedItems) { - if ($OrderedItems->QtyReceived !=0 OR $OrderedItems->QtyInvoiced !=0){ + if ($OrderedItems->QtyReceived !=0 OR $OrderedItems->QtyInv !=0){ return 1; } } @@ -167,7 +167,9 @@ function Order_Value() { $TotalValue=0; foreach ($this->LineItems as $OrderedItems) { - $TotalValue += ($OrderedItems->Price)*($OrderedItems->Quantity); + if ($OrderedItems->Deleted = False){ + $TotalValue += ($OrderedItems->Price)*($OrderedItems->Quantity); + } } return $TotalValue; } Modified: trunk/includes/DefinePaymentClass.php =================================================================== --- trunk/includes/DefinePaymentClass.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/includes/DefinePaymentClass.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -41,10 +41,23 @@ } - function Add_To_GLAnalysis($Amount, $Narrative, $GLCode, $GLActName, $tag, $cheque){ + function Add_To_GLAnalysis($Amount, + $Narrative, + $GLCode, + $GLActName, + $Tag, + $Cheque){ + if (isset($GLCode) AND $Amount!=0){ - $this->GLItems[$this->GLItemCounter] = new PaymentGLAnalysis($Amount, $Narrative, $this->GLItemCounter, $GLCode, $GLActName, $tag, $cheque); + $this->GLItems[$this->GLItemCounter] = new PaymentGLAnalysis($Amount, + $Narrative, + $this->GLItemCounter, + $GLCode, + $GLActName, + $Tag, + $Cheque); $this->GLItemCounter++; + $this->Amount += $Amount; Return 1; } Return 0; @@ -63,10 +76,16 @@ var $GLCode; var $GLActName; var $ID; - var $tag; - var $cheque; + var $Tag; + var $Cheque; - function PaymentGLAnalysis ($Amt, $Narr, $id, $GLCode, $GLActName, $tag, $cheque){ + function PaymentGLAnalysis ($Amt, + $Narr, + $id, + $GLCode, + $GLActName, + $Tag, + $Cheque){ /* Constructor function to add a new PaymentGLAnalysis object with passed params */ $this->Amount =$Amt; @@ -74,8 +93,8 @@ $this->GLCode = $GLCode; $this->GLActName = $GLActName; $this->ID = $id; - $this->tag = $tag; - $this->cheque = $cheque; + $this->Tag = $Tag; + $this->Cheque = $Cheque; } } Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/includes/MiscFunctions.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -238,7 +238,6 @@ }//wikiLink - // Lindsay debug stuff function LogBackTrace( $dest = 0 ) { error_log( "***BEGIN STACK BACKTRACE***", $dest ); @@ -334,4 +333,6 @@ global $ThousandsSeparator; return str_replace($DecimalPoint,'.',str_replace($ThousandsSeparator,'',trim($Number))); } -?> + + +?> \ No newline at end of file Modified: trunk/includes/PDFPaymentRun_PymtFooter.php =================================================================== --- trunk/includes/PDFPaymentRun_PymtFooter.php 2011-11-10 09:30:52 UTC (rev 4743) +++ trunk/includes/PDFPaymentRun_PymtFooter.php 2011-11-12 09:42:34 UTC (rev 4744) @@ -10,14 +10,14 @@ $TotalPayments += $AccumBalance; $TotalAccumDiffOnExch += $AccumDiffOnExch; -$LeftOvers = $pdf->addTextWrap(340,$YPos,60,$FontSize,locale_number_format($AccumBalance,2), 'right'); -$LeftOvers = $pdf->addTextWrap(405,$YPos,60,$FontSize,locale_number_format($AccumDiffOnExch,2), 'right'); +$LeftOvers = $pdf->addTextWrap(340,$YPos,60,$FontSize,locale_number_format($AccumBalance,$CurrDecimalPlaces), 'right'); +$LeftOvers = $pdf->addTextWrap(405,$YPos,60,$FontSize,locale_number_format($AccumDiffOnExch,$CurrDecimalPlaces), 'right'); if (isset($_POST['PrintPDFAndProcess'])){ - if (is_numeric($_POST['Ref'])) { - $PaytReference = $_POST['Ref'] + $RefCounter; + if (is_numeric(filter_number_format($_POST['Ref']))) { + $PaytReference = filter_number_format($_POST['Ref']) + $RefCounter; } else { $PaytReference = $_POST['Ref'] . ($RefCounter + 1); } @@ -36,8 +36,8 @@ rate, ovamount, diffonexch, - alloc) "; - $SQL = $SQL . "VALUES (22, + alloc) + VALUES (22, '" . $SuppPaymentNo . "', '" . $PaytReference . "', '" . $SupplierID . "', @@ -45,18 +45,20 @@ '" . FormatDateForSQL($_POST['AmountsDueBy']) . "', '" . date('Y-m-d H-i-s') . "', 1, - '" . $_POST['ExRate'] . "', + '" . filter_number_format($_POST['ExRate']) . "', '" . -$AccumBalance . "', '" . -$AccumDiffOnExch . "', '" . -$AccumBalance . "')"; + $ProcessResult = DB_query($SQL,$db,'','',false,false); if (DB_error_no($db) !=0) { $title = _('Payment Processing - Problem Report'); include('header.inc'); prnMsg(_('None of the payments will be processed because the payment record for') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db),'error'); - echo "<BR><A HREF='$rootpath/index.php'>" . _("Back to the menu") . "</A>"; + echo '<br> + <a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ - prnMsg(_("The SQL that failed was") . ' ' . $SQL,'error'); + prnMsg(_('The SQL that failed was') . ' ' . $SQL,'error'); } $ProcessResult = DB_Txn_Rollback($db); include('footer.inc'); @@ -84,7 +86,7 @@ $title = _('Payment Processing - Problem Report') . '.... '; include('header.inc'); prnMsg(_('None of the payments will be processed since an allocation record for') . $SupplierName . _('could not be inserted because') . ' - ' . DB_error_msg($db),'error'); - echo '<BR><A HREF="' . $rootpath . '/index.php">' . _('Back to the menu') . '</A>'; + echo '<br><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ prnMsg(_('The SQL that failed was') . $SQL,'error'); } @@ -104,7 +106,7 @@ amount) "; $SQL = $SQL . "VALUES ( " . $_POST['BankAccount'] . ", '" . $PaytReference . " " . $SupplierID . "', - " . $_POST['ExRate'] . ", + " . filter_number_format($_POST['ExRate']) . ", '" . FormatDateForSQL($_POST['AmountsDueBy']) . "', '" . $_POST['PaytType'] . "', " . -$AccumBalance . ")"; @@ -113,7 +115,8 @@ $title = _('Payment Processing - Problem Report'); include('header.inc'); prnMsg(_('None of the payments will be processed because the bank account payment record for') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db),'error'); - echo "<BR><A HREF='$rootpath/index.php'>" . _("Back to the menu") . "</A>"; + echo '<br /> + <a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ prnMsg(_('The SQL that failed was') . ' ' . $SQL,'error'); } @@ -142,16 +145,17 @@ '" . $PeriodNo . "', '" . $_POST['BankAccount'] . "', '" . $SupplierID . " - " . $SupplierName . ' ' . _('payment run on') . ' ' . Date($_SESSION['DefaultDateFormat']) . ' - ' . $PaytReference . "', - '" . (-$AccumBalance/ $_POST['ExRate']) . "')"; + '" . (-$AccumBalance/ filter_number_format($_POST['ExRate'])) . "')"; $ProcessResult = DB_query($SQL,$db,'','',false,false); if (DB_error_no($db) !=0) { $title = _('Payment Processing') . ' - ' . _('Problem Report') . '.... '; include('header.inc'); prnMsg(_('None of the payments will be processed since the general ledger posting for the payment to') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db),'error'); - echo "<BR><A HREF='$rootpath/index.php'>" . _('Back to the menu') . '</A>'; + echo '<br /> + <a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ - prnMsg(_('The SQL that failed was') . ':<BR>' . $SQL, 'error'); + prnMsg(_('The SQL that failed was') . ':<br />' . $SQL, 'error'); } $ProcessResult = DB_Txn_Rollback($db); include('footer.inc'); @@ -173,19 +177,18 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['creditorsact'] . "', '" . $SupplierID . ' - ' . $SupplierName . ' ' . _('payment run on') . ' ' . Date($_SESSION['DefaultDateFormat']) . ' - ' . $PaytReference . "', - '" . ($AccumBalance/ $_POST['ExRate'] + $AccumDiffOnExch) . "')"; + '" . ($AccumBalance/ filter_number_format($_POST['ExRate']) + $AccumDiffOnExch) . "')"; $ProcessResult = DB_query($SQL,$db,'','',false,false); if (DB_error_no($db) !=0) { $title = _('Payment Processing - Problem Report'); include('header.inc'); - echo '<BR>' . _('None of the payments will be processed since the general ledger posting for the payment to') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db); - echo "<BR><A HREF='$rootpath/index.php'>" . _('Back to the menu') . '</A>'; + prnMsg(_('None of the payments will be processed since the general ledger posting for the payment to') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db),'error'); + echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ prnMsg(_('The SQL that failed was') . ':<BR>' . $SQL,'error'); } $ProcessResult = DB_Txn_Rollback($db); - include('footer.inc'); exit; } @@ -193,12 +196,12 @@ /*Do the GL trans for the exch diff */ if ($AccumDiffOnExch != 0){ $SQL = "INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount ) + typeno, + trandate, + periodno, + account, + narrative, + amount ) VALUES (22, '" . $SuppPaymentNo . "', '" . FormatDateForSQL($_POST['AmountsDueBy']) . "', @@ -212,7 +215,7 @@ $title = _('Payment Processing - Problem Report'); include('header.inc'); prnMsg(_('None of the payments will be processed since the general ledger posting for the exchange difference on') . ' ' . $SupplierName . ' ' . _('could not be inserted because') .' - ' . DB_error_msg($db),'error'); - echo "<br /><a href='$rootpath/index.php'>" . _('Back to the menu') . '</a>'; + echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>'; if ($debug==1){ prnMsg(_('The SQL that failed was: ') . '<br />' . $SQL,'error'); } @@ -221,6 +224,7 @@ exit; } } + EnsureGLEntriesBalance(22,$SuppPaymentNo,$db); } /*end if GL linked to creditors */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |