From: <ex...@us...> - 2013-12-22 14:21:06
|
Revision: 6509 http://sourceforge.net/p/web-erp/reponame/6509 Author: exsonqu Date: 2013-12-22 14:21:02 +0000 (Sun, 22 Dec 2013) Log Message: ----------- 22/12/2013 Exson: Add a fool-proof to Credit_Invoice.php to prevent an invoice was credit again and again. Modified Paths: -------------- trunk/Credit_Invoice.php Modified: trunk/Credit_Invoice.php =================================================================== --- trunk/Credit_Invoice.php 2013-12-22 11:28:30 UTC (rev 6508) +++ trunk/Credit_Invoice.php 2013-12-22 14:21:02 UTC (rev 6509) @@ -480,7 +480,27 @@ $DefaultDispatchDate = Date($_SESSION['DefaultDateFormat']); $OKToProcess = true; +//Here we just validate if there is no credit qty available since the credit items not retrieve from salesorders, so following method is not 100% correct. +if(isset($_POST['CreditType']) AND ($_POST['CreditType']=='WriteOff' OR $_POST['CreditType'] == 'Return' OR $_POST['CreditType']=='ReverseOverCharge')){ + foreach ($_SESSION['CreditItems' . $identifier]->LineItems as $CreditLine) { + $SQL = "SELECT count(*) FROM salesorderdetails WHERE orderno = '".$_SESSION['CreditItems'.$identifier]->OrderNo."' + AND stkcode = '".$CreditLine->StockID."' + AND quantity >=".$CreditLine->QtyDispatched." + AND qtyinvoiced >= ".$CreditLine->QtyDispatched; + $ErrMsg = _('Failed to retrieve salesoderdetails to compare if the credit is overkill'); + $DuplicateCreditResult = DB_query($SQL,$db,$ErrMsg); + $myrow1 = DB_fetch_array($DuplicateCreditResult); + if($myrow1[0] == 0){ + prnMsg(_('The credit quantity for ').$CreditLine->StockID.(' is over than quantity invoiced, must reduce the quantity to credit or you are duplicating the same invoice which is not allowed'),'error'); + $OKToProcess = false; + include('includes/footer.inc'); + exit; + } + } +} + + if ((isset($_POST['CreditType']) AND $_POST['CreditType']=='WriteOff') AND !isset($_POST['WriteOffGLCode'])){ prnMsg (_('The GL code to write off the credit value to must be specified. Please select the appropriate GL code for the selection box'),'info'); $OKToProcess = false; |