Optional QuoteItems in Quotes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nina
    Junior Member
    • Apr 2021
    • 22

    Optional QuoteItems in Quotes

    Hey!


    Is there a way to display optional quote items in offers?

    We often have quote item that are offered as options.
    I have not yet understood how I can display these items in the Quote.


    These items should not be included in the total but should be displayed like this ():

    In example:

    Pos 1 fruit 1 (50 € )
    Pos 2 Banana 1 150 €

    total Amount: 150 €


    I hope you know what I mean

    thx a lot

  • lazovic
    Super Moderator
    • Jan 2022
    • 809

    #2
    Hi Nina,

    After a long search for a solution to your issue and careful testing, I can offer you an option to create a Workflow (you need an extension Advanced Pack). Using the standard formula in the Entity Manager, we will not achieve the desired result.

    To get started, go to Administration > Entity Manager > Quote Item > Fields and create a new Boolean field, name it Don't Include. This field will be a checkbox which the future Workflow will react to.
    After that, go to Layout Manager > Quote Items > List (Item) and from the right panel of Disabled, transfer the previously created Don't Include field to the Enabled panel.

    Next, it's time to create a Workflow with the following parameters:
    • Target Entity: Quote Item
    • Trigger Type: After record saved (created or updated)
    • Conditions: All > Don't Include > true
    • Actions: Update Related Record » Quote

      Insert this formula:
    Code:
    $quoteItemAmount = targetEntity\attribute('amount');
    $quoteItemListPrice = targetEntity\attribute('listPrice');
    $quoteItemUnitPrice = targetEntity\attribute('unitPrice');
    $quoteItemDiscount = targetEntity\attribute('listPrice') - targetEntity\attribute('unitPrice');
    $quoteItemQuantity = targetEntity\attribute('quantity');
    
    preDiscountedAmount = preDiscountedAmount - ($quoteItemListPrice * $quoteItemQuantity);
    discountAmount = discountAmount - ($quoteItemDiscount * $quoteItemQuantity);
    amount = amount - $quoteItemAmount;
    grandTotalAmount = grandTotalAmount - $quoteItemAmount;
    Now, you will need to mark the checkbox Don't include in front of those Quote Items in the Quote, the price of which should not be included in the Total Amount.

    Comment

    • Nina
      Junior Member
      • Apr 2021
      • 22

      #3
      Hey @Iazovic,

      thanks a lot! <3
      That works out wonderfully! It's very kind of you to help me!

      But there is still a small calculation problem with the tax.
      It now calculates the following:
      Amount (with optional position) - Tax


      In example:
      Pos 1: 240 €
      Pos 2. (opt.): 80 €
      Amount with opt.. : 320 €
      Amount without opt. : 240 €


      Amount (+optional) = 320 €
      TAX (19%): 60,80 €
      Total = 380,80 €
      and only now your formula subtracts the - optional position = 300,80 €

      But this is wrong... :/

      Actually, you have to settle the tax without the optional items..
      240 € + 19% = 259,20€

      Unfortunately, I do not know so well with the workflows or calculations that I would know where exactly you can include something like that.

      Can you help mit please <3 that would be great <3

      Comment

      • lazovic
        Super Moderator
        • Jan 2022
        • 809

        #4
        Hi Nina!

        You are welcome.

        Please replace all the formulas in this Workflow with these (just added two lines, but you need to follow their specific order) and try testing the functionality you need again:
        Code:
        $quoteItemAmount = targetEntity\attribute('amount');
        $quoteItemListPrice = targetEntity\attribute('listPrice');
        $quoteItemUnitPrice = targetEntity\attribute('unitPrice');
        $quoteItemDiscount = targetEntity\attribute('listPrice') - targetEntity\attribute('unitPrice');
        $quoteItemQuantity = targetEntity\attribute('quantity');
        $quoteItemTaxAmount = ($quoteItemAmount * targetEntity\attribute('taxRate')) / 100;
        
        preDiscountedAmount = preDiscountedAmount - ($quoteItemListPrice * $quoteItemQuantity);
        discountAmount = discountAmount - ($quoteItemDiscount * $quoteItemQuantity);
        amount = amount - $quoteItemAmount;
        taxAmount = taxAmount - $quoteItemTaxAmount;
        grandTotalAmount = grandTotalAmount - $quoteItemAmount;

        Comment

        • Nina
          Junior Member
          • Apr 2021
          • 22

          #5
          Hey lazovic

          First: Now he calculates the tax correctly - thx <3

          But there's something other fishy :/

          If you have a second,optional position, he still counts it
          Attached you will find an example image

          In expl:

          Pos 1: 240
          Pos 2 opt: 80
          Pos 3 opt: 80
          -----
          Correct: Total 240
          But: it calculates: 320 ...


          Sorry for being so annoying
          Attached Files

          Comment


          • lazovic
            lazovic commented
            Editing a comment
            Nina,

            Most likely, you checked the Quote Item already after creating this Quote.

            My solution is quite banal and works correctly only when creating a Quote. That is, you need to immediately determine which Quote Item will be additional, without subsequent changes.

            This can be improved a little, but this process will need to be thought through more deeply.
        • Nina
          Junior Member
          • Apr 2021
          • 22

          #6
          HEy,!

          I was now looking for a solution using a PDF template and an additional field.

          That works so far!
          It's not perfect yet, but it's a workaround

          Thank you for your help!

          Code:
              <!-- {{#each itemList}} -->
              <tr style="border-bottom:1pt solid #000; font-size: 9px">
                <td style="border-bottom:1pt solid #000">{{order}} {{#if optionalePosition}}
              opt. {{else}}
          {{/if}}</td>
                <td style="border-left: 1pt solid #000; border-bottom:1pt solid #000">{{quantity}}<br></td>
                <td style="border-left: 1pt solid #000; border-bottom:1pt solid #000"><b>{{name}}</b><br><span style="font-size: 9px;">{{{description}}}</span></td>
                <td align="right" style="border-left: 1pt solid #000; border-bottom:1pt solid #000">{{#if optionalePosition}}
              ({{optPrice}})
          {{else}}{{amount}}
          {{/if}}</td>
              </tr>​

          Comment

          Working...