Additional Quantity field for Quoted Line Items

Dear Sugar Community,

I have a question relating to quoted line items. We have the need to add an additional field to the quoted line item, this field will be known as a “term”, i.e. a term of 1 year 1.5 years 2 years etc.

I need the “term” value to also be used within the calculations of the quoted line item totals.

I can see that there are several calculated value fields within the QLIs. i.e.

  • Discount Total
  • Subtotal
  • Line Item Total

These calculated values all use the Quantity field within their calculation.

My first thought was to change each calculation formula to include the term within the calculation, i.e. the $term_c would become a new factor in the formula.

Another option would be to create a new calculated field being a new quantity field, i.e.

multiply($quantity, $term_c)

Then use this in the calculations listed above.

I’m attempting both approaches, however when I edit the formula, I can not save it as I receive this error.

Unknown field: discount_amount

However, this field exists in my QLIs, as you can see.

  • Has anyone experienced this issue?
  • Is there a work around, for example, can I edit the vardef.php for Products, to change the “Formula” to include my new “quantity” field in the calculation?
  • Or does anyone have an alternate suggestion?

Many thanks for any assistance.  

Sugar version details:

  • SugarCRM Version 11.0.0 (Build 238 P) (Q2 2021)
  • Professional
  • On-Premise

 

Parents Reply Children
  • Hi Francesca, 

    Thanks again for your help with this issue, and all the issues over the years. You are a true wealth of knowledge. 

    There were two VarDef files I need to modify, 

    custom/Extension/modules/Products/Ext/Vardefs/sugarfield_subtotal.php

    and 

    custom/Extension/modules/Products/Ext/Vardefs/sugarfield_total_amount.php

    I basically added my new "term" field to the multiplication function of the $discount_price and $quantity i.e. 

    multiply($discount_price, $quantity, $term_c),
    Plus some isNumeric() tests where relevant. 

    The formula for both fields needed to be overridden as the "total_amount" references the "subtotal" in its formula.

    The strange thing is, I could not edit the formula via studio as  I would receive this error when trying to save the formula.

    Unknown field: discount_amount

    As mentioned above, the discount_amount is a valid field. As you can see in Studio.

    However I can not use it in the Formula Builder, 

    It is some how hidden from the Formula Builder. However I can add it via the Vardef file. 

    Any clues?