Interface RATBuilder.RABuilder

All Superinterfaces:
CalculableLineItemCollectionBuilder<RATBuilder.RABuilder>
Enclosing interface:
RATBuilder

public static interface RATBuilder.RABuilder extends CalculableLineItemCollectionBuilder<RATBuilder.RABuilder>
Builder for a Rebate Agreement created from a Rebate Agreement Template (RAT). Obtained via RATBuilder.fromExisting(String) or RATBuilder.fromParams(java.util.Map).

Besides the methods declared here, the builder supports updateField, addLineItem, addOrUpdateInput and addOrUpdateOutput of CalculableLineItemCollectionBuilder. The key of addLineItem is the Rebate Type unique name. Other CalculableLineItemCollectionBuilder methods are ignored without an error. The contextParameter list of addLineItem(String, String, List) is ignored. To set inputs on a new line item, add it with addLineItemWithId(String, String) and then call addOrUpdateInput with the same line ID. Finish each chain with build(), which saves the Rebate Agreement when the recorded operations run.

See Also:
  • Method Details

    • getIstanceId

      String getIstanceId()
      Returns the instance ID of this builder. Every builder created in one logic run gets its own ID, so the ID tells apart several Rebate Agreements built by the same logic.

      This method only reads a value and does not record any operation. The ID identifies the builder, not the Rebate Agreement: it is not the ID or the unique name of the saved agreement.

      Example:

      
       def builder = ratBuilder.fromParams(["label": "Annual Bonus 2027"])
       def builderId = builder.getIstanceId()
       
      Returns:
      the instance id of this builder
      See Also:
    • addLineItemWithId

      RATBuilder.RABuilder addLineItemWithId(String lineId, String rebateType)
      Adds a new line item to the Rebate Agreement, specified by the Rebate Type unique name. The line item is added at the top level of the agreement (under the ROOT line).

      The call only records the operation. When the recorded operations run, the application creates the line item with the given line ID. If no Rebate Type with the given unique name exists, the whole batch that contains this Rebate Agreement is rolled back (see RATBuilder).

      Example:

      
       def lineItemId = api.uuid()
       ratBuilder.fromParams(["label": "Annual Bonus 2027"])
         .addLineItemWithId(lineItemId, "RebateOnSale")
         .build()
       
      Parameters:
      lineId - usually a generated id
      rebateType - unique name of the Rebate Type of the new line item
      Returns:
      itself
      See Also:
    • addLineItemWithId

      RATBuilder.RABuilder addLineItemWithId(String parentId, String lineId, String rebateType)
      Adds a new line item to the specified parent folder of the Rebate Agreement.

      The call only records the operation. When the recorded operations run, the application creates the line item with the given line ID under the parentId folder. Use "ROOT" as parentId to add the line item at the top level, which is the same as addLineItemWithId(String, String). If no Rebate Type with the given unique name exists, the whole batch that contains this Rebate Agreement is rolled back (see RATBuilder).

      Example:

      
       def lineCustomerId = api.uuid()
       ratBuilder.fromParams(["label": "Annual Bonus 2027"])
         .addLineItemWithId("ROOT", lineCustomerId, "RebateOnSale")
         .build()
       
      Parameters:
      parentId - the name of the folder you want to add a line item to
      lineId - usually a randomly generated id
      rebateType - unique name of the Rebate Type of the new line item
      Returns:
      itself
      See Also:
    • applyPlaceholder

      RATBuilder.RABuilder applyPlaceholder(String placeholder, Object value)
      Applies a value to a previously registered placeholder.

      The call only records the operation. When the recorded operations run, the application writes the value to every Rebate Agreement field that the user mapped to this placeholder when running the template. If the placeholder has no mapping, nothing is changed and no error is raised. If writing to a mapped field fails, the remaining fields of that placeholder are skipped and the failure is only logged.

      Example:

      
       ratBuilder.registerPlaceholder(InputType.USERENTRY, "discount")
      
       ratBuilder.fromParams(["label": "Annual Bonus 2027"])
         .applyPlaceholder("discount", 0.05)
         .build()
       
      Parameters:
      placeholder - the placeholder name, as registered with RATBuilder.registerPlaceholder(InputType, String)
      value - the value to apply
      Returns:
      itself
      See Also:
    • submitAfterBuild

      RATBuilder.RABuilder submitAfterBuild()
      Marks that the built Rebate Agreement should be submitted after build.

      The call only records the operation. It takes effect when build() is processed: the application saves the Rebate Agreement and then submits it, so its workflow status becomes Submitted. If the Rebate Agreement could not be created (for example, RATBuilder.fromExisting(String) found no agreement), nothing is submitted.

      Example:

      
       ratBuilder.fromParams(["label": "Annual Bonus 2027"])
         .submitAfterBuild()
         .build()
       
      Returns:
      itself
      See Also: