Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel1
maxLevel1

Calculation Logic Architecture

...

Prerequisites

Review execution flows diagrams of how and when the quote logics are executed from the Quote perspective:

...

:

Syntax Check

This dry run is used to discover inputs in the line item. Most of other API calls are mocked. Be aware that the syntax check dry run is executed only once when a new line item is added.

...

  • Configurator Logic

    • The logic is executed after clicking the Open button of Configurator.

      Image RemovedImage Added

      After clicking the Save button of a popup Configurator, a new configurator value is saved to the Quote object. (Quote object is what you get by calling quoteProcessor.getQuoteView().) But you cannot work with the values until the quote is recalculated. Why? All the logic knows is the old quote object since all other calculation logics finished before the configurator logic was executed. You must click the Recalculate button or set automatic recalculation; to learn more see how to recalculate a quote automatically.

  • Template Logic

    • The logic is executed after clicking the download PDF button.

    • From the template logic the whole quote object is accessible through api.getCurrentItem().

...

To do this, you need to combine the following use cases:

Use Case 1: Quote Header Logic Configurator → Quote Header Logic.

and then

Use Case 3: Quote Header Logic → Line Item logic

If priceEntityAfterSave is not set to true, the Recalculate button has to be used after saving values in the configurator.

...

To read values from a line item logic, use the steps from Use Case 4: Quote Line Item Logic → Quote Header Logic.

Then in the post-phase in the header logic, pass those values through the value property in the configurator. For details see Use Case 2: Quote Header Logic → Quote Header Logic Configurator.

Thanks to the post-phase you can pass these values within one recalculation transaction.

...

But this is does not work because:

  1. Line item configurator “test” is created during the syntax check.

  2. During the syntax check, api.input returns only mock data, not real data.

  3. During the syntax check (and only during the syntax check), api.getParameter("test") returns a context parameter of the "test" configurator. During recalculation (when the syntax check is not running), api.getParameter("test") returns null.

  4. ConfA?.setValue in the syntax check:

    1. Has a context parameter of the configurator.

    2. Does not have a value loaded from api.input.

  5. ConfA?.setValue when the quote is recalculated:

    1. Does not have a context parameter of the configurator.

    2. Has a value loaded from api.input but it cannot be set, as confA is null.

As a result:

  • You can set a static value via confA.setValue() as the value is known during the syntax check.

  • You cannot dynamically set loaded data from the header configurator because in the syntax check api.input does not return an expected value and during recalculation, api.getParameters("test") does not return the context parameter of the configurator.

...

The principles are same as in Use Case 7: Line Item Logic → Quote Header Configurator Logic.

The only change is when you iterate over lineItems you need to look inside the configurator value field and collect all needed values.

...