Example #1
0
    $tax_details = getAllTaxes('available');
}
for ($i = 0; $i < count($tax_details); $i++) {
    $tax_details[$i]['check_name'] = $tax_details[$i]['taxname'] . '_check';
    $tax_details[$i]['check_value'] = 0;
}
//For Edit and Duplicate we have to retrieve the product associated taxes and show them
if ($retrieve_taxes) {
    for ($i = 0; $i < count($tax_details); $i++) {
        $tax_value = getProductTaxPercentage($tax_details[$i]['taxname'], $productid);
        $tax_details[$i]['percentage'] = $tax_value;
        $tax_details[$i]['check_value'] = 1;
        //if the tax is not associated with the product then we should get the default value and unchecked
        if ($tax_value == '') {
            $tax_details[$i]['check_value'] = 0;
            $tax_details[$i]['percentage'] = getTaxPercentage($tax_details[$i]['taxname']);
        }
    }
}
$smarty->assign("TAX_DETAILS", $tax_details);
//Tax handling - ends
$unit_price = $focus->column_fields['unit_price'];
$price_details = getPriceDetailsForProduct($productid, $unit_price, 'available', $currentModule);
$smarty->assign("PRICE_DETAILS", $price_details);
$base_currency = 'curname' . $product_base_currency;
$smarty->assign("BASE_CURRENCY", $base_currency);
if (isset($focus->id) && $_REQUEST['isDuplicate'] != 'true') {
    $is_parent = $focus->isparent_check();
} else {
    $is_parent = 0;
}
Example #2
0
/**	function to get the product's taxpercentage
 *	@param string $type       - tax type (VAT or Sales or Service)
 *	@param id  $productid     - productid to which we want the tax percentage
 *	@param id  $default       - if 'default' then first look for product's tax percentage and product's tax is empty then it will return the default configured tax percentage, else it will return the product's tax (not look for default value)
 *	return int $taxpercentage - taxpercentage corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
 */
function getProductTaxPercentage($type, $productid, $default = '')
{
    global $adb, $log;
    $log->debug("Entering into getProductTaxPercentage({$type},{$productid}) function.");
    list($void1, $void2, $taxpercentage) = cbEventHandler::do_filter('corebos.filter.TaxCalculation.getProductTaxPercentage', array($type, $productid, ''));
    if ($taxpercentage == '') {
        $res = $adb->pquery("SELECT taxpercentage\n\t\t\tFROM vtiger_inventorytaxinfo\n\t\t\tINNER JOIN vtiger_producttaxrel\n\t\t\t\tON vtiger_inventorytaxinfo.taxid = vtiger_producttaxrel.taxid\n\t\t\tWHERE vtiger_producttaxrel.productid = ?\n\t\t\tAND vtiger_inventorytaxinfo.taxname = ?", array($productid, $type));
        if ($res and $adb->num_rows($res) > 0) {
            $taxpercentage = $adb->query_result($res, 0, 'taxpercentage');
        }
    }
    //This is to retrieve the default configured value if the taxpercentage related to product is empty
    if ($taxpercentage == '' && $default == 'default') {
        $taxpercentage = getTaxPercentage($type);
    }
    $log->debug("Exiting from getProductTaxPercentage({$productid},{$type}) function. return value={$taxpercentage}");
    return $taxpercentage;
}
Example #3
0
 /**	function to save the service tax information in vtiger_servicetaxrel table
  *	@param string $tablename - vtiger_tablename to save the service tax relationship (servicetaxrel)
  *	@param string $module	 - current module name
  *	$return void
  */
 function insertTaxInformation($tablename, $module)
 {
     global $adb, $log;
     $log->debug("Entering into insertTaxInformation({$tablename}, {$module}) method ...");
     $tax_details = getAllTaxes();
     $tax_per = '';
     //Save the Product - tax relationship if corresponding tax check box is enabled
     //Delete the existing tax if any
     if ($this->mode == 'edit') {
         for ($i = 0; $i < count($tax_details); $i++) {
             $taxid = getTaxId($tax_details[$i]['taxname']);
             $sql = "delete from vtiger_producttaxrel where productid=? and taxid=?";
             $adb->pquery($sql, array($this->id, $taxid));
         }
     }
     for ($i = 0; $i < count($tax_details); $i++) {
         $tax_name = $tax_details[$i]['taxname'];
         $tax_checkname = $tax_details[$i]['taxname'] . "_check";
         if ($_REQUEST[$tax_checkname] == 'on' || $_REQUEST[$tax_checkname] == 1) {
             $taxid = getTaxId($tax_name);
             $tax_per = $_REQUEST[$tax_name];
             if ($tax_per == '') {
                 $log->debug("Tax selected but value not given so default value will be saved.");
                 $tax_per = getTaxPercentage($tax_name);
             }
             $log->debug("Going to save the Product - {$tax_name} tax relationship");
             $query = "insert into vtiger_producttaxrel values(?,?,?)";
             $adb->pquery($query, array($this->id, $taxid, $tax_per));
         }
     }
     $log->debug("Exiting from insertTaxInformation({$tablename}, {$module}) method ...");
 }
/** 	function to get the product's taxpercentage
 * 	@param string $type       - tax type (VAT or Sales or Service)
 * 	@param id  $productid     - productid to which we want the tax percentage
 * 	@param id  $default       - if 'default' then first look for product's tax percentage and product's tax is empty then it will return the default configured tax percentage, else it will return the product's tax (not look for default value)
 * 	return int $taxpercentage - taxpercentage corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
 */
function getProductTaxPercentage($type, $productid, $default = '')
{
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    $current_user = vglobal('current_user');
    $log->debug("Entering into getProductTaxPercentage({$type},{$productid}) function.");
    $taxpercentage = '';
    $res = $adb->pquery("SELECT taxpercentage\n\t\t\tFROM vtiger_inventorytaxinfo\n\t\t\tINNER JOIN vtiger_producttaxrel\n\t\t\t\tON vtiger_inventorytaxinfo.taxid = vtiger_producttaxrel.taxid\n\t\t\tWHERE vtiger_producttaxrel.productid = ?\n\t\t\tAND vtiger_inventorytaxinfo.taxname = ?", array($productid, $type));
    $taxpercentage = $adb->query_result($res, 0, 'taxpercentage');
    //This is to retrive the default configured value if the taxpercentage related to product is empty
    if ($taxpercentage == '' && $default == 'default') {
        $taxpercentage = getTaxPercentage($type);
    }
    $log->debug("Exiting from getProductTaxPercentage({$productid},{$type}) function. return value={$taxpercentage}");
    if ($current_user->truncate_trailing_zeros == true) {
        return decimalFormat($taxpercentage);
    } else {
        return $taxpercentage;
    }
}
Example #5
0
/**	function to get the product's taxpercentage
 *	@param string $type       - tax type (VAT or Sales or Service)
 *	@param id  $productid     - productid to which we want the tax percentage
 *	@param id  $default       - if 'default' then first look for product's tax percentage and product's tax is empty then it will return the default configured tax percentage, else it will return the product's tax (not look for default value)
 *	return int $taxpercentage - taxpercentage corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
 */
function getProductTaxPercentage($type, $productid, $default = '')
{
    global $adb, $log;
    $log->debug("Entering into getProductTaxPercentage({$type},{$productid}) function.");
    $taxpercentage = '';
    $res = $adb->pquery("SELECT taxpercentage\n\t\t\tFROM vtiger_inventorytaxinfo\n\t\t\tINNER JOIN vtiger_producttaxrel\n\t\t\t\tON vtiger_inventorytaxinfo.taxid = vtiger_producttaxrel.taxid\n\t\t\tWHERE vtiger_producttaxrel.productid = ?\n\t\t\tAND vtiger_inventorytaxinfo.taxname = ?", array($productid, $type));
    $taxpercentage = $adb->query_result($res, 0, 'taxpercentage');
    //This is to retrive the default configured value if the taxpercentage related to product is empty
    if ($taxpercentage == '' && $default == 'default') {
        $taxpercentage = getTaxPercentage($type);
    }
    $log->debug("Exiting from getProductTaxPercentage({$productid},{$type}) function. return value={$taxpercentage}");
    return $taxpercentage;
}
Example #6
0
 /**
  * Function to get Tax Class Details for this record(Product)
  * @return <Array> List of Taxes
  */
 public function getTaxClassDetails()
 {
     $taxClassDetails = $this->get('taxClassDetails');
     if (!empty($taxClassDetails)) {
         return $taxClassDetails;
     }
     $record = $this->getId();
     if (empty($record)) {
         return $this->getAllTaxes();
     }
     $taxClassDetails = getTaxDetailsForProduct($record, 'available_associated');
     $noOfTaxes = count($taxClassDetails);
     for ($i = 0; $i < $noOfTaxes; $i++) {
         $taxValue = getProductTaxPercentage($taxClassDetails[$i]['taxname'], $this->getId());
         $taxClassDetails[$i]['percentage'] = $taxValue;
         $taxClassDetails[$i]['check_name'] = $taxClassDetails[$i]['taxname'] . '_check';
         $taxClassDetails[$i]['check_value'] = 1;
         //if the tax is not associated with the product then we should get the default value and unchecked
         if ($taxValue == '') {
             $taxClassDetails[$i]['check_value'] = 0;
             $taxClassDetails[$i]['percentage'] = getTaxPercentage($taxClassDetails[$i]['taxname']);
         }
     }
     $this->set('taxClassDetails', $taxClassDetails);
     return $taxClassDetails;
 }