Sales Pack Bug products currency if used in quote items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • macistda
    Member
    • Jul 2022
    • 76

    Sales Pack Bug products currency if used in quote items

    We use an additional field (currency) within products. That value is calculated (15 % from listprice - annual maintenance) currency.
    But we have some products that have no maintenance. This field then is NULL.

    We use the same additional field (currency, field not linked from products) within quote items, where that value from products is written by formula to every position (calculated based on the maintenance data in products).

    If we use the products in quote items we get the error: Fehler 400: Bad request Ungültige Artikel.
    From Log:
    (WARNING: (400) Field validation failure; entityType: QuoteItem, field: listPrice, type: validCurrency.; PUT /Quote/65f1bf8565b669e90; line: 62, file: /var/www/crm/application/Espo/Core/Exceptions/BadRequest.php)


    Workaround we found:
    Insert a user-defined quote item first with no values (0) --> safe --> ok without getting this error. Then adding one ore more positions, the calculation is well, without any error, too.
    Must be the first position. If added on 2nd position, the error appears again.

    There must have been a change in sales pack within last releases, because in the past the function was very well and we haven't chanced anything within this logic.
    The behavior is the same, if we copy an old quote with quote items and want to change e.g. ammount of a quote item. (--> 400 Error). But if added a position (must be the first one)​

    I think this might be something for yuri to check :-)

    If you need further informations please don't hesitate to contact me again. Thanks.

    EspoCRM: 8.1.5 (But Error happened also in further versions)
    Sales Pack: 2.1.5 (But happened also in further versions)
    Last edited by macistda; 03-13-2024, 03:15 PM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Before v2, there was no validation for quote items.

    It could be not a bug. Too little information to say. I would need to reproduce it somehow to be able to fix if it's a bug.
    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

    • shalmaxb
      Senior Member
      • Mar 2015
      • 1602

      #3
      I once had a similar case, where the culprit was a default value in one of the position fields. Maybe worth a check.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #4
        I tried to replicate. Created a currency field in the Product. The same field in the Quote Item. Connected them. No error. Could save both a product with empty field and not empty.
        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

        • macistda
          Member
          • Jul 2022
          • 76

          #5
          The fields are not connected via relation. The fields are filled by formula (before safe) in quoteitem.

          product.wartungMonat
          wartungMonat (quoteitem)

          ifThen(product.wartungMonat!=null && quote.wartungIndividuellAngebot==false, wartungMonat=product.wartungMonat*quantity);
          ifThen(product.listPrice!=null, listPrice=product.listPrice);

          I can do a view screens and send you a link how to reproduce the ​error.

          ----------
          Maybe an other formula is responsible for the error. We haven't changed since a while and in the past it was working correctly.

          ifThen(description==null && entity\isNew() || entity\isAttributeChanged('name'), description=product.description);
          ifThenElse(quote.wartungIndividuellAngebot==true, wartungIndividuell=true, wartungIndividuell=false);
          ifThen(entity\isNew()==true && product.wartungMonat!=null, wartungMonat=product.wartungMonat*quantity);

          ifThen(product.wartungMonat!=null && quote.wartungIndividuellAngebot==false, wartungMonat=product.wartungMonat*quantity);

          ifThen(product.listPrice!=null, listPrice=product.listPrice);​

          Comment

          • yuri
            Member
            • Mar 2014
            • 8440

            #6
            I didn't not connect via relationship when tried to replicate.

            As I've mentioned, we did not have validation in v1. That was a problem. Now we have validation that might have exposed incorrect data being written by your formula.

            Maybe you needed to set listPriceCurrency.

            Currently I'm very busy. I can't look into it more detail.
            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

            • macistda
              Member
              • Jul 2022
              • 76

              #7
              Maybe you needed to set listPriceCurrency.

              --> That seemed to be the error. We have been quite a time at v1, the error came up with v2.

              I added to formula the update of currency and the error did not appear again. Thanks yuri.
              ifThen(product.listPrice!=null, listPrice=product.listPrice; listPriceCurrency=product.listPriceCurrency;
              I will write again if the error appears again.

              Comment

              Working...