Tax calculation on line item - Quote Sugar 7.9

Hello,

I have noticed currently quote calculation on Quote level. I can apply to calculation tax on quote line item level. Because I have different type categories and product, so each product apply different type of VAT.

I have attached below screen shot. 

1) First product line item apply "20% (Vat on Income)"

2) Second product line item apply "5% (Vat on Income)"

3) Third product line item apply "0% (No Vat)"

Thanks

Asif

Offshore Evolution

Francesca Shiekh André Lopes Ramana Raju Santhana Alex Nassi 

Parents
  • I needed line item tax as well, I called the field line_tax_amount_c. In my case this is not a percentage but an amount, I have an API which retrieves the correct amount based on tax tables on our ERP system and returns it to the Quote. 

    I add up the line item tax at ProductBundle level:

    custom/Extension/modules/ProductBundles/Ext/Vardefs/vardef.ext.php

    <?php
    $dictionary['ProductBundle']['fields']['tax_amount_c']['labelValue']='Tax Amount';
    $dictionary['ProductBundle']['fields']['tax_amount_c']['calculated']='true';
    $dictionary['ProductBundle']['fields']['tax_amount_c']['formula']='rollupCurrencySum($products, "line_tax_amount_c")';
    $dictionary['ProductBundle']['fields']['tax_amount_c']['enforced']='true';
    $dictionary['ProductBundle']['fields']['tax_amount_c']['dependency']='';
    $dictionary['ProductBundle']['fields']['tax_amount_c']['related_fields']=array (
      0 => 'currency_id',
      1 => 'base_rate',
    );

    Then I add the Tax to the Bundle Total:

    custom/Extension/modules/ProductBundles/Ext/Vardefs/sugarfield_total.php

    <?php
    $dictionary['ProductBundle']['fields']['total']['formula']='currencyAdd($new_sub, $tax_amount_c)';
    $dictionary['ProductBundle']['fields']['total']['related_fields']=array (
      0 => 'currency_id',
      1 => 'base_rate',
      2 => 'new_sub',
      3 => 'tax_amount_c',
    );
    $dictionary['ProductBundle']['fields']['total']['calculated']='true';
    $dictionary['ProductBundle']['fields']['total']['enforced']='true';

    I then add the bundle tax for the total Tax at Quote level:

    custom/Extension/modules/Quotes/Ext/Vardefs/sugarfield_tax_amount_c.php

    <?php
    // created: 2017-06-13 11:14:46
    $dictionary['Quote']['fields']['tax_amount_c']['duplicate_merge_dom_value']=0;
    $dictionary['Quote']['fields']['tax_amount_c']['labelValue']='Tax';
    $dictionary['Quote']['fields']['tax_amount_c']['calculated']='true';
    $dictionary['Quote']['fields']['tax_amount_c']['formula']='rollupCurrencySum($product_bundles,"tax_amount_c")';
    $dictionary['Quote']['fields']['tax_amount_c']['enforced']='true';
    $dictionary['Quote']['fields']['tax_amount_c']['dependency']='';
    $dictionary['Quote']['fields']['tax_amount_c']['related_fields']=array (
      0 => 'currency_id',
      1 => 'base_rate',
    );

    The Quote total includes all the tax as it is because it's just a rollup total of the individual bundle totals, which include the line item tax per the customization above.

    HTH

    FrancescaS

  • Offshore Evolution, could you please share the code you used for creating the dropdown on the line?

    Is it an enum? Or a relate field to the TaxRates class? I've been trying relate fields, enums, as well as attempting to mimic the product template lookup, but I'm struggling to get this to work as you've done, and I have the exact same requirement. If you had the code to hand, I'd really appreciate a point in the right direction.

  • He Richard Coleman,

    I have not checked and I have not get resolved my issue. If you will find, then you will inform me.

    Thanks

    Asif

Reply Children
No Data