Approvals

The Store Launchpad for B2B Manufacturing provides Business Units with a flexible process for approving Orders.

The approval process consists of two parts:

  • Approval Flows: the overall process that lets you approve or reject an Order request.
  • Approval Rules: the conditions that determine whether an Order needs approval. When a new order matches an Approval Rule, the related Approval Flow is triggered. Only one Approval Rule can apply per Order, but you can add multiple conditions and approvers to a single rule.

Approval Rules

You can access Approval Rules only on desktop devices.

Approval Rules use Order Predicates to define the conditions for when an Order triggers an Approval Flow. By default, the launchpad offers currency, country, and totalPrice predicates, but you can also add additional Order Predicates.

When you create an Approval Rule, you must also set who can approve the Order. Users with admin, buyer, and approver associate roles can approve Orders. You can add up to five tiers of approvers, for more information about how tiers work, see Configuring Approval Rules.

Create an Approval Rule

To create an Approval Rule, follow these steps:

  1. In the My Account menu, select Approval Rules, then click Add approval rule.
  2. Complete the following fields:
    1. Rule Name: name for the Approval Rule.
    2. Description: optional description for the rule.
    3. Requester roles: the associate roles the rule applies to.
  3. In Rule, click Add and define the condition that will trigger the Approval Flow, then click Add rule. To add multiple conditions, click the Add icon. To trigger the Approval Flow when all conditions are met, use the AND operator, otherwise use the OR operator.
  4. Optional: To add a nested condition to a rule, add a new rule using the Add icon, then click Add subgroup and define another condition. Approval Rules page with a rule added
  5. In Approvers, click Add, then select the associate role that must approve the Order. To add multiple Approvers to a tier, click the Add icon again and select the role.
  6. Optional: To require approval from multiple users, click Add approval group and select another associate role.
  7. To add another approval tier, click Add approval tier. Approval Rules page with approvers selected
  8. Select whether the rule is active or inactive.
  9. Click Save. After you save an Approval Rule, you cannot delete it. However, you can set the rule to inactive if you don't want it to apply to incoming Order requests.

Add additional Order Predicates

By default, the launchpad offers currency, country, and totalPrice Order Predicates. However, you can manually add additional predicates using the ApprovalRuleConfig interface. To add additional predicates, follow these steps:

  1. Open the approval-rules.ts file at this location: /src/lib/tastics/approval-rules/config/approval-rules.ts.

  2. In the approvalRulesConfig object, add the new predicate as a key-value pair, where the key is an Order Predicate and the value contains the following fields from the ApprovalRuleConfig interface:

    • type: types supported by the interface. You can use text, enum, and number types.
    • name: name of the predicate.
    • operators: operators you can use on the new predicate—for example, = or >=.
    • values: for enum types only. These are the values you can use in the enum—for example, for adding a predicate for currency, the values could be USD, EUR, and GBP.
    • constructPredicateFromRule: returns a valid Order Predicate. You can edit what is returned to suit your needs. In the following example, totalPrice uses cents, so alongside key and operator, the value multiplied by 100 is returned. This converts the cents to a whole currency unit, such as dollars.
    • constructRuleFromPredicate: returns a valid rule based on the Order Predicate returned in constructPredicateFromRule. This adds the new predicate to the Approval Rule builder on the user interface (UI). You can view the valid rules at this location: /src/components/organisms/rule-builder/types/index.ts.

    The values you use for the name, operators[].name, and values[].name fields are translation keys that are passed to the translate function at /src/providers/I18n/hooks/useTranslation/index.ts to translate and display as the user's selected language on the UI.

Example: approval-rules.tsJavaScript
// Adding a text type predicate
'totalPrice.centAmount': {
type: 'text',
name: 'cart.cart.amount',
operators: [
{ name: 'common.is.equal', value: '=' },
{ name: 'common.is.more.than', value: '>' },
{ name: 'common.is.more.than.or.equal', value: '>=' },
{ name: 'common.is.less.than', value: '<' },
{ name: 'common.is.less.than.or.equal', value: '<=' },
],
constructPredicateFromRule(rule) {
return `${rule.key} ${rule.operator} ${parseInt(rule.value) * 100}`;
},
constructRuleFromPredicate(predicate: string) {
const [key, operator, value] = predicate.split(' ');
return {
key,
operator,
value: Math.floor(parseInt(value) / 100).toString(),
};
},
},
// Adding an enum type predicate
currency: {
type: 'enum',
name: 'common.currency',
operators: [
{ name: 'common.is', value: 'is' },
{ name: 'common.is.not', value: 'is_not' },
],
values: [
{ name: 'USD', value: 'USD' },
{ name: 'EUR', value: 'EUR' },
],
constructPredicateFromRule(rule) {
return `${rule.key} ${rule.operator === 'is' ? '=' : '!='} "${rule.value}"`;
},
constructRuleFromPredicate(predicate) {
const [key, operator, value] = predicate.split(' ');
return {
key,
operator: operator === '=' ? 'is' : 'is_not',
value,
};
},
},

Approval Flows

You can access Approval Flows on desktop or mobile devices.

If Orders are waiting for approval, a banner will notify the approver that there are Orders in the Approval Flows area. In this area, you can view pending, accepted, and rejected Orders.

Manage Orders

To review an Order, follow these steps:

  1. In the My Account menu, click Approval Flows.
  2. On the relevant Order, click View.
  3. Review the Order details and click either Accept or Decline. If you decline an Order, you can add a note to explain why.