Opportunity » Amount Value Update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AGil
    Junior Member
    • Apr 2020
    • 15

    Opportunity » Amount Value Update

    Good afternoon,

    We have implemented the EspoCRM and we have made some customizations at "Opportinity Items" in base to our needs.

    This customizations are all about new fields and formulas which already works perfectly.
    In attach there are some images about them.

    The problem happens when the opportunity is saved.
    The field amount at "Opportinuty" doesnt update properly with the amount value (SubTotal) at "Opportunity Item".

    As you can see in the images attached, the amount at Opportunity gets the previous value any time that we save/edit the opportunity.

    Could someone help us?

    Best Regards!
  • AGil
    Junior Member
    • Apr 2020
    • 15

    #2
    Afternoon,

    we have solved this problem making some changes at opportunity-calculation-handler.js file

    But we make some different formulas per opportunity item since the brand of them where equals to a value.
    The problem is that we cant get the brand at opportunity item because it is a value from a related entity.

    How could we solve this problem?

    We have tried create a foreign field at opportunity item but it only show us the name of the product.

    Thank you.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8442

      #3
      Hi,

      In calculation handler you can extend selectProduct method. Copy product brand field to OpportunityItem brand (not existing by default) field. You need to create a custom field for OpportunityItem that will store brand name (or ID).
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • AGil
        Junior Member
        • Apr 2020
        • 15

        #4
        Morning Yuri,

        I have already made a relationship between "Opportunity Item" and "Product Brand", but it's still not working and I don't really know why.

        All product added at the EspoCRM have a brand associated but when I chose them at Oppotunity Items, the brand doesnt appear.

        Do you know what am I doing wrong?

        Thank you,
        Best Regards!

        Comment

        • AGil
          Junior Member
          • Apr 2020
          • 15

          #5
          I have already got the brand at opportunity item but now its happening something different.

          The formulas now work properly but the problem starts when try to plus the values from each opportunity item it give a value quite diferently.

          Why is this happening? Could someone help?

          Comment

          • yuri
            Member
            • Mar 2014
            • 8442

            #6
            Might be calculation on the server side differs? On server side calculation should be also customized.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment


            • AGil
              AGil commented
              Editing a comment
              The formulas that I have shared were made at the files .js available at server.
          • AGil
            Junior Member
            • Apr 2020
            • 15

            #7
            There are two ways to make formulas for us:

            a) (unitPricequantity)-(partnerDiscount/100)(unitPricequantity); when the product its diferent from "Ubiquiti or Perle" Brand
            b) (unitPrice
            quantity)+(partnerDiscount/100)(unitPricequantity); when the product its "Ubiquiti or Perle" Brand

            so in the last img that I have shared, we have two item opportunities where the first one is a product diferent than ubiquiti or perle and the second one its ubiquiti one.

            The value per line its ok, but when the systems try to plus both and update the amout at opportinity entity, the system plus both lines as they were both products different from Ubiquiti.

            As you can see with my explanation at in the img, thats not right!

            So, where should be the problem this time? What should we do?

            If someone could help, we are lost with this problem :s

            Comment

            • jaltz09
              Junior Member
              • Jun 2018
              • 11

              #8
              HI AGil,

              Can you please share how you add the additional fields from 'Items'?

              Comment

              Working...