How do I access tax rates in the bean or the database?

I'm using  SugarCRM Professional, Version 7.2.2.1. I can see tax rates on the front end, I'd like to write a logic hook that makes use of them, but I can't find any documentation for how to access it in the bean or where it is linked to products or quotes in the database.
Parents Reply Children
  • If your quote bean is loaded in $quote then you can access the taxrates using the code below:
       $taxRate = BeanFactory::getBean('TaxRates', $quote->taxrate_id);
       if ($product->tax_class == 'Taxable') {
               $taxAmount = $product->total_amount * $taxRate->value / 100;
       } else {
                 $taxAmount = 0;
      }
  • It is possible although it's undocumented. I've answered it in my answer below. Generally doing a print_r() on the bean will give you a list of potential relationships.
  • Hi,

    Actually Taxes get saved in a separate table name 'taxrates'.
    As Tax is applied at Quote level so you will find taxrate_id in Quote bean and with the help of this Id you can retrieve Tax Rate.

    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech