In this document, it will be explained how to setup basic loyalty points implementation.

 

How It Works?

 

1. Adding Loyalty Card Entity Type and Loyalty Card Entity

1.1. Adding Loyalty Card Entity Type

Go to Main Menu > Manage > Entities > Entity Types > here click on Add Entity Type.

General Settings Section;

Name: Loyalty Card

Entity Name: Loyalty Card

Display Format: [Holder Name] – [Points] Points

Primary Field Name: Card Number

 

Custom Fields Section;

Add two custom fields by clicking on Add Custom Field and configure them as in the above image.

Holder Name|String|Simple

Points|String|Simple|Hidden(Yes)

 

After completing necessary editings, click on Save button.

 

 

1.2. Adding Loyalty Card Entity

Go to Main Menu > Manage > Entities > Entities > here click on Add Entity.

Entity Type: Loyalty Card

Card Number: LC00

Holder Name: Nizam Seyhun

Points: Currently there is no points in the Loyalty Card.

 

After completing necessary editings, click on Save button.

 

 

2. Adding Automation Commands

2.1. Apply Loyalty Discount

Go to Main Menu > Manage > Automation > Automation Commands > here click on Add Automation Command.

General Settings Section;

Name: LC-Apply Loyalty Discount

Button Header: Apply Loyalty Discount\r{ENTITY DATA:Loyalty Card:Points} = [=TN('{ENTITY DATA:Loyalty Card:Points}')*0.01] ₺

₺ Symbol: You can put your own Currency Symbol in here.

Clear Selection: Must be selected.

 

Mappings Section;

Add a row by clicking on Add button and configure the setting as shown in the above image.

Visible States: LoyaltyDiscountButton=Available

Visibility: Ticket

 

After completing necessary editings, click on Save button.

 

 

2.2. Claim Unused Points

Go to Main Menu > Manage > Automation > Automation Commands > here click on Add Automation Command.

General Settings Section;

Name: LC-Claim Unused Points

Button Header: Claim Unused\rLoyalty Points

Clear Selection: Must be selected.

 

Mappings Section;

Add a row by clicking on Add button and configure the setting as shown in the above image.

Visible States: State=

Visibility: Ticket

 

After completing necessary editings, click on Save button.

 

3. Adding Discount Account, Transaction Type and  Calculation Type for Loyalty

3.1. Adding Loyalty Discount Account

Go to Main Menu > Manage > Accounts > Accounts > here click on Add Account.

Account Name: Loyalty Discount

Account Type: Discount Accounts

 

After completing necessary editings, click on Save button.

 

 

3.2. Adding Loyalty Discount Transaction Type

Go to Main Menu > Manage > Accounts > Transaction Types > here click on Add Transaction Type.

Account Transaction Type Name: Loyalty Discount Transaction

Source Account Type (Debit): Receivable Accounts

Target Account Type (Credit): Discount Accounts

Default Source Account: Receivables

Default Target Account: Loyalty Discount

 

After completing necessary editings, click on Save button.

 

3.3. Adding Loyalty Discount Calculation Type

Go to Main Menu > Manage > Tickets > Calculation Types > here click on Add Calculation Type

Template Name: Loyalty Discount

Account Transaction Type: Loyalty Discount Transaction

Calculation Method: Fixed Amount

Include Tax: Must be selected

Decrase Amount: Must be selected

 

After completing necessary editings, click on Save button.

 

 

4. Adding Actions

4.1. Generic Ask Question Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Generic Ask Question

Action Type: Ask Question

Parameters:

Question: [:Question]

Buttons: [:Buttons]

Automation Command Name: [:Command Name]

Background Color: [:Background Color]

 

After completing necessary editings, click on Save button.

 

 

4.2. Search Loyalty Card Entity Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Search Loyalty Card Entity

Action Type: Change Ticket Entity

Parameters:

Can Create Ticket: True

Entity Type Name: Loyalty Card

Entity Search Value: [:Search Value]

 

After completing necessary editings, click on Save button.

 

 

4.3. Refresh Ticket Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Refresh Ticket

Action Type: Display Ticket

 

After completing necessary editings, click on Save button.

 

 

4.4. Display Ticket Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Display Ticket

Action Type: Display Ticket

Parameters:

Ticket Id: [:Ticket ID]

 

After completing necessary editings, click on Save button.

 

 

4.5. Generic Execute Automation Command Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Generic Execute Automation Command

Action Type: Execute Automation Command

Parameters:

Automation Command Name: [:Automation Command]

Command Value: [:Command Value]

Background: [:Background]

Delay: [:Delay]

 

After completing necessary editings, click on Save button.

 

 

4.6. Reopen Closed Ticket Action

In order to create this action, you need to install Reopen Closed Ticket Action Type from;

Main Menu > Samba Market > More Ticket Actions > here, click on Install button and then Restart  SambaPOS to apply the changes.

Once you finish with above step, then go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Reopen Closed Ticket

Action Type: Reopen Closed Ticket

 

After completing necessary editings, click on Save button.

 

 

4.7. Update Loyalty Card Points Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Update Loyalty Card Points

Action Type: Update Entity Data

Parameters:

Entity Type Name: Loyalty Card

Field Name: Points

Field Value: [:Points]

 

After completing necessary editings, click on Save button.

 

 

4.8. Apply Loyalty Discount Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Apply Loyalty Discount

Action Type: Update Ticket Calculation

Parameters:

Calculation Type: Loyalty Discount

Amount: [:Amount]

Round Amount: True

 

After completing necessary editings, click on Save button.

 

 

4.9. Generic Update Ticket State Action

Go to Main Menu > Manage > Automation > Actions > here click on Add Action.

Action Name: LC-Generic Update Ticket State

Action Type: Update Ticket State

Parameters:

State Name: [:State Name]

Current State: [:Current State]

State: [:New State]

State Value: [:State Value]

 

After completing necessary editings, click on Save button.

 

 

5. Adding Rules

5.1. Apply Loyalty Discount Button Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

 

Rule Name: LC-Apply Loyalty Discount Button

Event Name: Automation Command Executed

Execute Rule if: Matches

Add Custom Constraint:

Automation Command Name|Equals|LC-Apply Loyalty Discount

[=TN('{ENTITY DATA:Loyalty Card:Points}')]|Greater|0

 

Select Actions:

In order to add same action multiple times into a rule, in the Select Action Window from Action List part, you need to right click on anywhere and select Display All Values. So that all the actions which already selected for the rule, will be selectable again.

Action 1: LC-Apply Loyalty Discount

Constraint: TN('{ENTITY DATA:Loyalty Card:Points}')*0.01 > TN('{REMAINING TOTAL}')

Amount: [=TN('{REMAINING TOTAL}')]

 

Action 2: LC-Apply Loyalty Discount

Constraint: TN('{ENTITY DATA:Loyalty Card:Points}')*0.01 <= TN('{REMAINING TOTAL}')

Amount:[=TN('{ENTITY DATA:Loyalty Card:Points}')*0.01]

 

Action 3: LC-Update Loyalty Card Points

Constraint:(TN('{ENTITY DATA:Loyalty Card:Points}')*0.01) > TN('{REMAINING TOTAL}')

Points:[=TN('{ENTITY DATA:Loyalty Card:Points}')+TN('{CALCULATION TOTAL:Loyalty Discount}')*100]

 

Action 4: LC-Update Loyalty Card Points

Constraint:(TN('{ENTITY DATA:Loyalty Card:Points}')*0.01) <= TN('{REMAINING TOTAL}')

Points: 0

 

Action 5: LC-Generic Update Ticket State

State Name: LoyaltyDiscountButton

 

After completing necessary editings, click on Save button.

 

 

5.2. Claim Unused Loyalty Points Button Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Claim Unused Loyalty Points Button

Event Name: Automation Command Executed

Execute Rule if: Matches

Add Custom Constraint:

Automation Command Name|Equals|LC-Claim Unused Points

Select Actions:

Action: LC-Generic Execute Automation Command

Automation Command: ClaimUnusedLoyaltyPointsCommand

Command Value: [?Ticket ID;;;OC;55,56,57|52,53,54|49,50,51|8,445,190]

 

After completing necessary editings, click on Save button.

 

 

5.3. Claim Unused Loyalty Points Command Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Claim Unused Loyalty Points Command

Event Name: Automation Command Executed

Execute Rule if: Matches

Add Custom Constraint:

Automation Command Name|Equals|ClaimUnusedLoyaltyPointsCommand

Command Value|Is Not Null|

 

Select Actions:

Action 1: LC-Generic Ask Question

Constraint: '{REPORT TICKET DETAILS:TS.Loyalty Points:T.Id=[:CommandValue]}' == 'Claimed'

Question: The Loyalty Points have already been claimed for this ticket.

Buttons: OK

Background Color: Red

 

Action 2: LC-Display Ticket

Constraint: '{REPORT TICKET DETAILS:TS.Loyalty Points:T.Id=[:CommandValue]}' == 'Unclaimed'

Ticket ID: [:CommandValue]

 

Action 3: LC-Generic Execute Automation Command

Constraint: '{REPORT TICKET DETAILS:TS.Loyalty Points:T.Id=[:CommandValue]}' == 'Unclaimed'

Automation Command: ClaimUnusedLoyaltyPointsToCard

Command Value: [?Loyalty Card Number]

 

After completing necessary editings, click on Save button.

 

 

5.4. Claim Unused Loyalty Points To Card Number Command Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Claim Unused Loyalty Points To Card Number Command

Event Name: Automation Command Executed

Execute Rule if: Matches

Add Custom Constraint:

Automation Command Name|Equals|ClaimUnusedLoyaltyPointsToCard

Command Value|Is Not Null|

 

Select Actions:

Action 1: LC-Reopen Closed Ticket

Action 2: LC-Search Loyalty Card Entity

Search Value: [:CommandValue]

Action 3: LC-Update Loyalty Card Points

Points:[=TN('{ENTITY DATA:Loyalty Card:Points}')+TN('{TICKET STATE VALUE:Loyalty Points}')]

Action 4: LC-Generic Update Ticket State

State Name: Loyalty Points

New State: Claimed

State Value: {TICKET STATE VALUE:Loyalty Points}

Action 5: LC-Generic Ask Question

Question: {TICKET STATE VALUE:Loyalty Points} points added to Loyalty Card: [:CommandValue]<linebreak/>New Loyalty Card points total is {ENTITY DATA:Loyalty Card:Points}

Buttons: OK

Background Color: Green

Action 6: Close Ticket

 

After completing necessary editings, click on Save button.

 

 

5.5. Allocate Points On Ticket Closing Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Allocate Points On Ticket Closing

Event Name: Before Ticket Closing

Execute Rule if: Matches

Add Custom Constraint:

Total Amount|Greater|0

Remaining Amount|Equals|0

{ENTITY NAME:Loyalty Card}|Is Not Null|

{TICKET STATE:Loyalty Points}|Not Equals|Claimed

 

Select Actions:

Action 1: LC-Update Loyalty Card Points

Points:[=TN('{ENTITY DATA:Loyalty Card:Points}')+TN('{TICKET STATE VALUE:Loyalty Points}')]

Action 2: LC-Generic Update Ticket State

State Name: Loyalty Points

New State: Claimed

State Value: {TICKET STATE VALUE:Loyalty Points}

 

After completing necessary editings, click on Save button.

 

 

5.6. Loyalty Card Scanned Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Loyalty Card Scanned

Event Name: Numberpad Value Entered

Execute Rule if: Matches

Add Custom Constraint:

Numberpad Value|Starts|LC

 

Select Actions:

Action 1: LC-Search Loyalty Card Entity

Search Value: [:NumberpadValue]

Action 2: LC-Refresh Ticket

 

After completing necessary editings, click on Save button.

 

 

5.7. Print Points Recipt On Closing Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Print Points Recipt On Closing

Event Name: Ticket Closing

Execute Rule if: Matches

Add Custom Constraint:

Total Amount|Greater|0

Remaining Amount|Equals|0

 

Select Actions:

Action: Execute Bill Print job

 

After completing necessary editings, click on Save button.

 

 

5.8. Loyalty Card Entity Changed Ticket State Discount Button Visible State Update Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Loyalty Card Entity Changed Ticket State Discount Button Visible State Update

Event Name: Ticket Entity Changed

Execute Rule if: Matches

Add Custom Constraint:

Entity Type Name|Equals|Loyalty Card

 

Select Actions:

In order to add same action multiple times into a rule, in the Select Action Window from Action List part, you need to right click on anywhere and select Display All Values. So that all the actions which already selected for the rule, will be selectable again.

Action 1: LC-Generic Update Ticket State

Constraint: [=TN('{ENTITY DATA:Loyalty Card:Points}')] > 0

State Name: LoyaltyDiscountButton

New State: Available

Action 2: LC-Generic Update Ticket State

Constraint: [=TN('{ENTITY DATA:Loyalty Card:Points}')] == 0

State Name: LoyaltyDiscountButton

 

After completing necessary editings, click on Save button.

 

 

5.9. Update Ticket Points Value State Rule

Go to Main Menu > Manage > Automation > Rules > here click on Add Rule.

Rule Name: LC-Update Ticket Points Value State

Event Name: Ticket Total Changed

Execute Rule if: Matches

 

Select Actions:

Action: LC-Generic Update Ticket State

State Name: Loyalty Points

New State: Unclaimed

State Value: [=Math.floor(TN('{TICKET TOTAL}')*5)]

 

After completing necessary editings, click on Save button.