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.
Tax Rates are stored in the 'taxrates' table and their functionality is hard-coded in the Quotes module, used only with Products / Product Catalog records, where the 'Tax Class' is set to 'Taxable'. The calculation takes place in real-time.
Reviewing the TaxRates module, I don't see any relationships with other modules, so I'm unsure if that value is accessible by the $bean.
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; }
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; }