Skip to content

Commit

Permalink
cbSR and sonarqube recomendations
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed May 19, 2024
1 parent 42580d5 commit 5039bd7
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions modules/coreBOSTax/coreBOSTax.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,18 @@ public static function getTaxDetailsForProduct($pdosrvid, $acvid, $available = '
if (!empty($pdosrvid)) {
$sepdosrvid = getSalesEntityType($pdosrvid);
$psttype = 0;
switch ($sepdosrvid) {
case 'Products':
$ttrs = $adb->pquery('select taxtypeid from vtiger_products where productid=?', array($pdosrvid));
if ($ttrs) {
$psttype = $adb->query_result($ttrs, 0, 0);
}
$taxvalidationinfo[] = 'Related Products found';
break;
case 'Services':
$ttrs = $adb->pquery('select taxtypeid from vtiger_service where serviceid=?', array($pdosrvid));
if ($ttrs) {
$psttype = $adb->query_result($ttrs, 0, 0);
}
$taxvalidationinfo[] = 'Related Services found';
break;
if ($sepdosrvid=='Products') {
$ttrs = $adb->pquery('select taxtypeid from vtiger_products where productid=?', array($pdosrvid));
if ($ttrs) {
$psttype = $adb->query_result($ttrs, 0, 0);
}
$taxvalidationinfo[] = 'Related Products found';
} else { // Services
$ttrs = $adb->pquery('select taxtypeid from vtiger_service where serviceid=?', array($pdosrvid));
if ($ttrs) {
$psttype = $adb->query_result($ttrs, 0, 0);
}
$taxvalidationinfo[] = 'Related Services found';
}
if (empty($psttype)) {
$taxvalidationinfo[] = 'Product/Service tax type not found.';
Expand Down Expand Up @@ -244,40 +241,42 @@ public static function getTaxDetailsForProduct($pdosrvid, $acvid, $available = '
$where = "where ((acvtaxtype = '$acvttype') and (pdotaxtype = '$psttype')) ";
}
}
$activeTaxCondition = " and deleted=0 and corebostaxactive='1' ";
$shipCondition = " and shipping='".($shipping ? '1' : '0')."' ";
$lookForTax = 'looking for taxes ';
if ($available != 'all') {
$where .= " and deleted=0 and corebostaxactive='1' ";
$where .= $activeTaxCondition;
}
$where .= " and shipping='".($shipping ? '1' : '0')."' ";
$taxvalidationinfo[] = 'looking for taxes '.$where;
$where .= $shipCondition;
$taxvalidationinfo[] = $lookForTax.$where;
$taxrs = $adb->query($sql.$where);
if ($adb->num_rows($taxrs)==0) {
$taxvalidationinfo[] = 'no taxes found > we insist';
if (!empty($acvttype) && !empty($psttype)) {
$taxvalidationinfo[] = 'taxes of ACV(TxTy) and empty(PdoSrv(TxTy))';
$where = "where ((acvtaxtype = '$acvttype') and (pdotaxtype is null or pdotaxtype = 0)) ";
if ($available != 'all') {
$where .= " and deleted=0 and corebostaxactive='1' ";
$where .= $activeTaxCondition;
}
$where .= " and shipping='".($shipping ? '1' : '0')."' ";
$taxvalidationinfo[] = 'looking for taxes '.$where;
$where .= $shipCondition;
$taxvalidationinfo[] = $lookForTax.$where;
$taxrs = $adb->query($sql.$where);
if ($adb->num_rows($taxrs)==0) {
$taxvalidationinfo[] = 'taxes of empty(ACV(TxTy)) and PdoSrv(TxTy)';
$where = "where ((acvtaxtype is null or acvtaxtype = 0) and (pdotaxtype = '$psttype')) ";
if ($available != 'all') {
$where .= " and deleted=0 and corebostaxactive='1' ";
$where .= $activeTaxCondition;
}
$where .= " and shipping='".($shipping ? '1' : '0')."' ";
$taxvalidationinfo[] = 'looking for taxes '.$where;
$where .= $shipCondition;
$taxvalidationinfo[] = $lookForTax.$where;
$taxrs = $adb->query($sql.$where);
}
}
}
if ($adb->num_rows($taxrs)==0 && $available=='all') {
$taxvalidationinfo[] = 'all non-related taxes';
$where = "where ((acvtaxtype is null or acvtaxtype = 0) and (pdotaxtype is null or pdotaxtype = 0)) ";
$where .= " and deleted=0 and corebostaxactive='1' and shipping='".($shipping ? '1' : '0')."' ";
$taxvalidationinfo[] = 'looking for taxes '.$where;
$where = "where ((acvtaxtype is null or acvtaxtype = 0) and (pdotaxtype is null or pdotaxtype = 0)) ".$activeTaxCondition.$shipCondition;
$taxvalidationinfo[] = $lookForTax.$where;
$taxrs = $adb->query($sql.$where);
}
$taxes = array();
Expand Down Expand Up @@ -345,7 +344,6 @@ public static function getAllTaxes($available = 'all', $sh = '', $mode = '', $cr
$i = 0;
while ($tax=$adb->fetch_array($res)) {
$tax_details = array();
// $tax_details['productid'] = $tax['pdoid'];
$tax_details['taxid'] = $tax['cbtaxid'];
$tname = html_entity_decode($tax['taxname'], ENT_QUOTES);
$tax_details['taxname'] = $tname;
Expand Down

0 comments on commit 5039bd7

Please sign in to comment.