1<?php 2 3/*Get the Customer default details */ 4$sql = "SELECT name, 5 salestype, 6 currcode, 7 address1, 8 address2, 9 address3, 10 address4, 11 address5, 12 address6, 13 language_id, 14 taxref, 15 typeid, 16 creditlimit, 17 area, 18 salesman, 19 holdreason, 20 paymentterms, 21 defaultlocation, 22 taxprovinceid, 23 taxgroupid, 24 defaultshipvia, 25 decimalplaces as currdecimalplaces, 26 rate, 27 contactname, 28 braddress1, 29 braddress2, 30 braddress3, 31 braddress4, 32 braddress5, 33 braddress6, 34 phoneno, 35 daysbeforedue, 36 dayinfollowingmonth, 37 deladd5 as from_postal_code, 38 deladd6 as dispatch_country 39 FROM debtorsmaster INNER JOIN custbranch 40 ON debtorsmaster.debtorno=custbranch.debtorno 41 INNER JOIN locations ON custbranch.defaultlocation=locations.loccode 42 INNER JOIN currencies ON debtorsmaster.currcode=currencies.currabrev 43 INNER JOIN paymentterms ON debtorsmaster.paymentterms=paymentterms.termsindicator 44 WHERE debtorsmaster.debtorno='" . $_SESSION['ShopDebtorNo'] . "' 45 AND custbranch.branchcode='" . $_SESSION['ShopBranchCode'] . "'"; 46$ErrMsg = _('An error occurred accessing the default customer configuration'); 47$ReadCustomerDefaultsResult = DB_query($sql,$ErrMsg); 48 49if (DB_num_rows($ReadCustomerDefaultsResult)==0) { 50 print_r($_SESSION); 51 echo '<br /><b>'; 52 prnMsg( _('The customer defaults have not yet been set up') . '</b> 53 <br />' . _('From the webERP system setup tab select shop maintenance to enter the default customer and customer branch information and other shop set up preferences'),'error',_('CRITICAL PROBLEM')); 54 exit; 55} else { 56 $_SESSION['CustomerDetails'] = DB_fetch_array($ReadCustomerDefaultsResult); 57 if ($_SESSION['CustomerDetails']['dayinfollowingmonth'] >= 1 OR $_SESSION['CustomerDetails']['daysbeforedue'] > 1){ 58 $_SESSION['CustomerDetails']['creditcustomer'] = true; 59 $_SESSION['SelectedPaymentMethod'] = 'CreditAccount'; 60 } else { 61 $_SESSION['CustomerDetails']['creditcustomer'] = false; 62 } 63} 64$_SESSION['Language'] = $_SESSION['CustomerDetails']['language_id']; 65include($PathPrefix . 'includes/LanguageSetup.php'); 66 67/*Now get the tax details for sales to this customer */ 68 69$SQL = "SELECT taxgrouptaxes.calculationorder, 70 taxgrouptaxes.taxontax, 71 taxauthrates.taxcatid, 72 taxauthrates.taxrate 73 FROM taxauthrates INNER JOIN taxgrouptaxes ON 74 taxauthrates.taxauthority=taxgrouptaxes.taxauthid 75 WHERE taxgrouptaxes.taxgroupid='" . $_SESSION['CustomerDetails']['taxgroupid'] . "' 76 AND taxauthrates.dispatchtaxprovince='" . $_SESSION['CustomerDetails']['taxprovinceid'] . "' 77 ORDER BY taxauthrates.taxcatid, taxgrouptaxes.calculationorder"; 78 79/*Figure out effective total tax rate for each tax category */ 80$TaxesResult = DB_query($SQL); 81$_SESSION['TaxRates'] = array(); 82while ($TaxRow = DB_fetch_array($TaxesResult)){ 83 if (!isset($_SESSION['TaxRates'][$TaxRow['taxcatid']])){ 84 $_SESSION['TaxRates'][$TaxRow['taxcatid']] = 0; 85 } 86 if ($TaxRow['taxontax']==1) { //if tax on tax add taxrate x current total of taxes 87 $_SESSION['TaxRates'][$TaxRow['taxcatid']] += ($TaxRow['taxrate']*$_SESSION['TaxRates'][$TaxRow['taxcatid']]); 88 } 89 $_SESSION['TaxRates'][$TaxRow['taxcatid']] += $TaxRow['taxrate']; // add all taxes together for this taxgroup 90} 91//We should now have an array of $TaxRates that has the total effective tax rate with the index being the tax category id of the item 92?>