[Weberp-svn] SF.net SVN: weberp:[4351] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-01-20 16:24:29
|
Revision: 4351 http://weberp.svn.sourceforge.net/weberp/?rev=4351&view=rev Author: tim_schofield Date: 2011-01-20 16:24:22 +0000 (Thu, 20 Jan 2011) Log Message: ----------- Fix up many silly errors in Phils CounterSales.php Modified Paths: -------------- trunk/CounterSales.php trunk/includes/DefineCartClass.php Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2011-01-20 13:19:22 UTC (rev 4350) +++ trunk/CounterSales.php 2011-01-20 16:24:22 UTC (rev 4351) @@ -458,7 +458,6 @@ unset($NewItem); } /* end of if quick entry */ - /*Now do non-quick entry delete/edits/adds */ if ((isset($_SESSION['Items'.$identifier])) OR isset($NewItem)) { @@ -516,7 +515,47 @@ } } +if (isset($_POST['Recalculate'])) { + foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { + $NewItem=$OrderLine->StockID; + $sql = "SELECT stockmaster.mbflag, stockmaster.controlled + FROM stockmaster + WHERE stockmaster.stockid='". $OrderLine->StockID."'"; + $ErrMsg = _('Could not determine if the part being ordered was a kitset or not because'); + $DbgMsg = _('The sql that was used to determine if the part being ordered was a kitset or not was '); + $KitResult = DB_query($sql, $db,$ErrMsg,$DbgMsg); + if ($myrow=DB_fetch_array($KitResult)){ + if ($myrow['mbflag']=='K'){ /*It is a kit set item */ + $sql = "SELECT bom.component, + bom.quantity + FROM bom + WHERE bom.parent='" . $OrderLine->StockID. "' + AND bom.effectiveto > '" . Date('Y-m-d') . "' + AND bom.effectiveafter < '" . Date('Y-m-d') . "'"; + + $ErrMsg = _('Could not retrieve kitset components from the database because'); + $KitResult = DB_query($sql,$db,$ErrMsg); + + $ParentQty = $NewItemQty; + while ($KitParts = DB_fetch_array($KitResult,$db)){ + $NewItem = $KitParts['component']; + $NewItemQty = $KitParts['quantity'] * $ParentQty; + $NewPOLine = 0; + $NewItemDue = date($_SESSION['DefaultDateFormat']); + $_SESSION['Items'.$identifier]->GetTaxes($OrderLine->LineNumber); + } + + } else { /*Its not a kit set item*/ + $NewItemDue = date($_SESSION['DefaultDateFormat']); + $NewPOLine = 0; + $_SESSION['Items'.$identifier]->GetTaxes($OrderLine->LineNumber); + } + } + unset($NewItem); + } /* end of if its a new item */ +} + if (isset($NewItem)){ /* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart Now figure out if the item is a kit set - the field MBFlag='K' @@ -738,7 +777,8 @@ } $TaxTotal += $TaxLineTotal; - + $_SESSION['Items'.$identifier]->TaxTotals=$TaxTotals; + $_SESSION['Items'.$identifier]->TaxGLCodes=$TaxGLCodes; echo '<td class="number">' . number_format($TaxLineTotal ,2) . '</td>'; echo '<td class="number">' . number_format($SubTotal + $TaxLineTotal ,2) . '</td>'; echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID .'&identifier='.$identifier . '&Delete=' . $OrderLine->LineNumber . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">' . _('Delete') . '</a></td></tr>'; @@ -762,6 +802,7 @@ <td class="number">' . number_format(($_SESSION['Items'.$identifier]->total+$TaxTotal),2) . '</td> </tr> </table>'; + echo '<input type="hidden" name="TaxTotal" value="'.$TaxTotal.'" />'; echo '<table><tr><td>'; //nested table echo '<table><tr> @@ -820,6 +861,7 @@ echo '</th></tr></table>'; //end of column/row/master table echo '<br /><div class="centre"><input type="submit" name="Recalculate" value="' . _('Re-Calculate') . '" /> <input type="submit" name="ProcessSale" value="' . _('Process The Sale') . '" /></div><hr />'; + } # end of if lines /* ********************************** @@ -834,7 +876,7 @@ prnMsg(_('There are no lines on this sale. Please enter lines to invoice first'),'error'); $InputError = true; } - if (abs($_POST['AmountPaid'] -($_SESSION['Items'.$identifier]->total+$TaxTotal))>=0.01) { + if (abs($_POST['AmountPaid'] -($_SESSION['Items'.$identifier]->total+$_POST['TaxTotal']))>=0.01) { prnMsg(_('The amount entered as payment does not equal the amount of the invoice. Please ensure the customer has paid the correct amount and re-enter'),'error'); $InputError = true; } @@ -1106,7 +1148,7 @@ WoRealRequirements($db, $WONo, $_SESSION['DefaultFactoryLocation'], $StockItem->StockID); $FactoryManagerEmail = _('A new work order has been created for') . - ":\n" . $StockItem->StockID . ' - ' . $StockItem->Descr . ' x ' . $WOQuantity . ' ' . $StockItem->UOM . + ":\n" . $StockItem->StockID . ' - ' . $StockItem->ItemDescription . ' x ' . $WOQuantity . ' ' . $StockItem->Units . "\n" . _('These are for') . ' ' . $_SESSION['Items'.$identifier]->CustomerName . ' ' . _('there order ref') . ': ' . $_SESSION['Items'.$identifier]->CustRef . ' ' ._('our order number') . ': ' . $OrderNo; if ($StockItem->Serialised AND $StockItem->NextSerialNo>0){ @@ -1202,11 +1244,11 @@ '" . $_SESSION['Items'.$identifier]->DefaultSalesType . "', '" . $OrderNo . "', '" . $_SESSION['Items'.$identifier]->total . "', - '" . $TaxTotal . "', + '" . $_POST['TaxTotal'] . "', '" . $ExRate . "', '" . $_SESSION['Items'.$identifier]->Comments . "', '" . $_SESSION['Items'.$identifier]->ShipVia . "', - '" . ($_SESSION['Items'.$identifier]->total + $TaxTotal) . "')"; + '" . ($_SESSION['Items'.$identifier]->total + $_POST['TaxTotal']) . "')"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction record was used'); @@ -1215,7 +1257,7 @@ $DebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id'); /* Insert the tax totals for each tax authority where tax was charged on the invoice */ - foreach ($TaxTotals AS $TaxAuthID => $TaxAmount) { + foreach ($_SESSION['Items'.$identifier]->TaxTotals AS $TaxAuthID => $TaxAmount) { $SQL = "INSERT INTO debtortranstaxes (debtortransid, taxauthid, @@ -1694,7 +1736,7 @@ if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */ - if (($_SESSION['Items'.$identifier]->total + $TaxTotal) !=0) { + if (($_SESSION['Items'.$identifier]->total + $_POST['TaxTotal']) !=0) { $SQL = "INSERT INTO gltrans ( type, typeno, trandate, @@ -1708,7 +1750,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['debtorsact'] . "', '" . $_SESSION['Items'.$identifier]->DebtorNo . "', - '" . (($_SESSION['Items'.$identifier]->total + $TaxTotal)/$ExRate) . "')"; + '" . (($_SESSION['Items'.$identifier]->total + $_POST['TaxTotal'])/$ExRate) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The total debtor GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the total debtors control GLTrans record was used'); @@ -1716,7 +1758,7 @@ } - foreach ( $TaxTotals as $TaxAuthID => $TaxAmount){ + foreach ( $_SESSION['Items'.$identifier]->TaxTotals as $TaxAuthID => $TaxAmount){ if ($TaxAmount !=0 ){ $SQL = "INSERT INTO gltrans ( type, typeno, @@ -1729,7 +1771,7 @@ '" . $InvoiceNo . "', '" . $DefaultDispatchDate . "', '" . $PeriodNo . "', - '" . $TaxGLCodes[$TaxAuthID] . "', + '" . $_SESSION['Items'.$identifier]->TaxGLCodes[$TaxAuthID] . "', '" . $_SESSION['Items'.$identifier]->DebtorNo . "', '" . (-$TaxAmount/$ExRate) . "')"; @@ -1996,7 +2038,7 @@ AND purchorders.status<>'Cancelled' AND purchorders.status<>'Rejected' AND purchorderdetails.itemcode='" . $myrow['stockid'] . "'"; - + $ErrMsg = _('The order details for this product cannot be retrieved because'); $PurchResult = db_query($sql,$db,$ErrMsg); @@ -2143,7 +2185,7 @@ $QOHSql = "SELECT sum(quantity) AS QOH, stockmaster.decimalplaces FROM locstock INNER JOIN stockmaster - WHERE locstock.stockid='" .$myrow['stockid'] . "' + WHERE locstock.stockid='" .$myrow['stockid'] . "' AND loccode = '" . $_SESSION['Items'.$identifier]->Location . "'"; $QOHResult = DB_query($QOHSql,$db); $QOHRow = DB_fetch_array($QOHResult); @@ -2152,10 +2194,10 @@ // Find the quantity on outstanding sales orders $sql = "SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem FROM salesorderdetails INNER JOIN salesorders - ON salesorders.orderno = salesorderdetails.orderno - WHERE salesorders.fromstkloc='" . $_SESSION['Items'.$identifier]->Location . "' - AND salesorderdetails.completed=0 - AND salesorders.quotation=0 + ON salesorders.orderno = salesorderdetails.orderno + WHERE salesorders.fromstkloc='" . $_SESSION['Items'.$identifier]->Location . "' + AND salesorderdetails.completed=0 + AND salesorders.quotation=0 AND salesorderdetails.stkcode='" . $myrow['stockid'] . "'"; $ErrMsg = _('The demand for this product from') . ' ' . $_SESSION['Items'.$identifier]->Location . ' ' . _('cannot be retrieved because'); @@ -2171,7 +2213,7 @@ // Find the quantity on purchase orders $sql = "SELECT SUM(purchorderdetails.quantityord-purchorderdetails.quantityrecd) AS QOO FROM purchorderdetails INNER JOIN purchorders - WHERE purchorderdetails.completed=0 + WHERE purchorderdetails.completed=0 AND purchorders.status <>'Cancelled' AND purchorders.status <>'Rejected' AND purchorderdetails.itemcode='" . $myrow['stockid'] . "'"; Modified: trunk/includes/DefineCartClass.php =================================================================== --- trunk/includes/DefineCartClass.php 2011-01-20 13:19:22 UTC (rev 4350) +++ trunk/includes/DefineCartClass.php 2011-01-20 16:24:22 UTC (rev 4351) @@ -56,6 +56,8 @@ VAR $vtigerProductID; Var $DefaultPOLine; Var $DeliveryDays; + var $TaxTotals; + var $TaxGLCodes; function Cart(){ /*Constructor function initialises a new shopping cart */ @@ -338,7 +340,7 @@ $ErrMsg = _('The taxes and rates for this item could not be retrieved because'); $GetTaxRatesResult = DB_query($SQL,$db,$ErrMsg); - + unset($this->LineItems[$LineNumber]->Taxes); while ($myrow = DB_fetch_array($GetTaxRatesResult)){ $this->LineItems[$LineNumber]->Taxes[$myrow['calculationorder']] = new Tax($myrow['calculationorder'], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |