Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Brief Description

This technical refinement is aimed at the need for a new option so that the value of the service fee can be added or removed in the value of crown coins when finalizing the customer's order, this option will be included within sanity where there will be a way to activate or disable this calculation.

Development

To do this, it will be necessary to make some adjustments to both the Sanity and the Loyalty Service so that we can know the value of the service fee, whereas today these systems are only aware of some fees and the value of the product.
You must pay attention to the fact that there are many factors that must be clear for this feature to work in the system, these points will be described in the next topics, but in short, you need to pay attention to whether the market/restaurant you are using has the option of active service fee as well as in sanity the crown points calculation options are configured correctly, this may affect the final calculation because it is necessary to look to which tax and fees will be considered in the final calculation.

Feature Flags

The first validation we need to do is to know if this feature flag has been enabled, it is responsible for enabling the service fee calculation in the user's request. If this feature flag is enabled, no fee calculation will be calculated.

enable-get-fees-and-discount-by-brand

Code Changes

The final solution was based on the following pull requests:

INTL - Loyalty

https://github.com/rbilabs/intl-loyalty/pull/442/files
https://github.com/rbilabs/intl-loyalty/pull/455/files

INTL - Sanity
https://github.com/rbilabs/intl-sanity-shared-schemas/pull/16

Loyalty

 loyalty-engine-sdk/api.ts - Update Types
export enum EnginePointsDependsOn {
    DeliveryFee = 'Delivery Fee',
    ServiceFee = 'Service Fee',
}
 models/configuration/configuration.enums.ts - Update Types
export enum PointsDependsOn {
  DeliveryFee = 'Delivery Fee',
  ServiceFee = 'ServiceFee',
}
 /rbi/rbi.service.ts - Handle the new type
if (loyaltyPointsCalculationUsing?.includes(EnginePointsDependsOn.ServiceFee)) {
    paymentAmount += (delivery?.serviceFeeCents ?? 0) - (delivery?.serviceFeeDiscountCents ?? 0);
}
 types/cms.types.ts - Update Types
export enum PointsDependsOn {
  DeliveryFee = 'Delivery Fee',
  ServiceFee = 'Service Fee'
}
 types/rbi.types.ts - Update the service fee types
export interface IDelivery {
  feeCents: number;
  feeDiscountCents: number;
  serviceFeeCents: number;
  serviceFeeDiscountCents: number;
}
 loyalty-engine-sdk/dist/api.d.ts - Ensure the type was generated
export declare enum EnginePointsDependsOn {
    DeliveryFee = "Delivery Fee",
    ServiceFee = "Service Fee",
}
 loyalty-engine-sdk/dist/api.d.ts - Ensure the type was generated
export declare enum EnginePointsDependsOn {
    DeliveryFee = "Delivery Fee",
    ServiceFee = "Service Fee",
}

In addition, it will be necessary to make unit tests to validate the solution.

CMS - Sanity

 loyalty/documents/earning-calculation.ts
export enum PointsDependsOn {
  DeliveryFee = 'Delivery Fee',
  ServiceFee = 'Service Fee',
}
export const LOYALTY_POINTS_DEPENDS_ON = [
  { title: 'Delivery Fee', value: PointsDependsOn.DeliveryFee },
  { title: 'Service Fee', value: PointsDependsOn.ServiceFee },
];

The final result of sanity screen is to be equal below, can be found at this link

sanity.png

Tests

DMP Process

To carry out the test, you must have access to the development environment DMP so that it is possible to change the order to the dropped off status, because loyalty calculations will only be calculated after the order is delivered and confirmed by the DMP. For PLK ES you can use this link: https://euw3-dev-plk-exp-tablet.com.rbi.tools/orders-management

Your order will start in the New Orders table and you must proceed to the last screen and after that, complete the order successfully

To confirm that your order has been completed, you need to be on the order confirmation page with the current order open and all steps must have been completed.

At the end of this process, your order is ready to generate crown coins.

Crown Coins

Once the order is completed and is in delivery status, you will need to go to the main whitelabel page, click on the "hamburger menu" and click on the first button called "Popeyes Rewards". On this page, the order statement and how many points you earned with each one will be displayed.

To check whether the value of crown coins received is valid, we use that every $1 spent is equivalent to 100 crown coins. This calculation is made by adding the "subtotal" (without the tax charged) + fees.

It should be noted whether the fees were applied to the total value, otherwise, these fees will not be considered in the value of the crown coins. You can find out which fees are enabled in sanity.

Possible Issues

Delivery Fee and Final Order value

When I did some tests in development I noticed that some values ​​did not match correctly with the final order value. For example, in the case of the Delivery Fee, the value is set to zero, but in the database it had a value of 2.99. This can create some confusion when carrying out some tests related to the amount of value that the user can receive from crown coins.

This issue is already under development, so you just need to confirm that everything is aligned.

  • No labels