Product distributor price – how to update unitPriceDist live in UI like unitPrice?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muulox
    Member
    • Jan 2022
    • 65

    #1

    Product distributor price – how to update unitPriceDist live in UI like unitPrice?

    Hello,

    I’m working with EspoCRM 9.x (Cloud / self-hosted) and I’ve extended the product pricing logic to also handle distributor prices.

    What I did:

    I’m using the standard ProductPricingTypeHandler as a base and added a second set of fields for distributor price:
    • listPriceDist (Currency)
    • pricingFactorDist (Float)
    • pricingTypeDist (Enum – same options as pricingType)
    • unitPriceDist (Currency, result)
    • I reuse the existing costPrice field.
    This works correctly on save:
    unitPriceDist is calculated and stored as expected when I save the product. The problem / question


    For the standard client price, when I change e.g. pricingFactor or pricingType on the Product form:
    • unitPrice is updated live in the UI (without saving),
    • so there is some front-end (JavaScript) logic that recalculates it on the fly.

    For my distributor price:
    • the value of unitPriceDist is only updated after save (because only PHP handler runs),
    • it does not update live when I change pricingFactorDist, pricingTypeDist, etc.

    I’d like to have the same UX for distributor price – update unitPriceDist instantly in the Product edit view when one of the related fields changes.

    My questions
    1. In which JS file / view does Espo implement the live calculation for unitPrice on Product (when pricingType, listPrice, costPrice, pricingFactor change)?
    2. What is the recommended way to extend this to also handle:
      • pricingTypeDist
      • listPriceDist
      • pricingFactorDist
      • unitPriceDist

    Any hints (file paths, example code, best practice) would be greatly appreciated.

    Thank you!
Working...