> ## Documentation Index
> Fetch the complete documentation index at: https://help.lobyco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Loyalty and Promotion - loy_*

> Tables in the Loyalty and Promotion data package (loy_*).

The Loyalty and Promotion package contains data on how customers earn bonus and receive discounts through campaigns, challenges, games, and coupons.

## Scope

This package includes:

* Promotion campaign activities
* Challenge and game participation and rewards
* Bonus balances and movements
* Issued coupons and redemption

It does not include internal calculation engines, detailed rule mechanics, operational import logs, or purely technical configuration data.

## Key Principle

The Loyalty and Promotion package represents how value is created and distributed to customers in the form of bonus or discount.

## Accounting — Account — `loy_accounting_account`

### Definition

| Property         | Type      | Description                                                                                                  |
| ---------------- | --------- | ------------------------------------------------------------------------------------------------------------ |
| Id               | long      | Identifier for each account (Primary Key)                                                                    |
| IsActive         | boolean   | Indicates whether the account is active. If false, DeactivatedAt should be set                               |
| IsAllowedToSpend | boolean   | Account-specific flag to enable spending. Effectively allows spending only if the AccountType also allows it |
| CreatedAt        | timestamp | Timestamp when the account was created                                                                       |
| AccountTypeId    | int       | Determines the rules for this account                                                                        |
| ExternalId       | string    | External identifier for the account                                                                          |
| DeactivatedAt    | timestamp | Timestamp when the account was deactivated. Populated when IsActive becomes false                            |

### Sample data

| Id  | IsActive | IsAllowedToSpend | CreatedAt           | AccountTypeId | ExternalId | DeactivatedAt       |
| --- | -------- | ---------------- | ------------------- | ------------- | ---------- | ------------------- |
| 001 | true     | true             | 2026-01-12 09:00:00 | 1             | 041        | NULL                |
| 002 | false    | false            | 2025-12-03 14:20:00 | 56            | 072        | 2026-02-18 11:45:00 |
| 003 | true     | false            | 2026-02-10 08:30:00 | 34            | 093        | NULL                |

## Accounting — Account Type — `loy_accounting_account_type`

### Definition

| Property         | Type    | Description                                        |
| ---------------- | ------- | -------------------------------------------------- |
| Id               | int     | Identifier for each account type (Primary Key)     |
| IsAllowedToSpend | boolean | Indicates whether the account type allows spending |
| Description      | string  | Description of the account type                    |
| Name             | string  | Name of the account type                           |
| MaxBalance       | decimal | Maximum balance for the account type               |
| ConversionRate   | decimal | Rate of conversion for the account type            |

### Sample data

| Id | IsAllowedToSpend | Description              | Name    | MaxBalance | ConversionRate |
| -- | ---------------- | ------------------------ | ------- | ---------- | -------------- |
| 1  | true             | Default account type     | Default | 1000.25    | 1.00           |
| 2  | false            | Unspecified account type | NULL    | 0.00       | 1.00           |
| 3  | true             | Default account type     | Default | 1000.25    | 1.00           |

## Accounting — Entry — `loy_accounting_entry`

### Definition

| Property      | Type      | Description                                                         |
| ------------- | --------- | ------------------------------------------------------------------- |
| Id            | int       | Identifier for each accounting entry (Primary Key)                  |
| TransactionId | long      | Identifier for the transaction associated with the accounting entry |
| Amount        | decimal   | Monetary amount of the accounting entry                             |
| AccountId     | long      | Identifier for the account related to the accounting entry          |
| CreationDate  | timestamp | Timestamp when the accounting entry was created                     |
| OperationId   | string    | External operation identifier associated with the entry             |
| Type          | string    | Nature of the accounting action                                     |
| PartitionType | string    | Partition type required for balance calculation                     |

### Sample data

| Id | TransactionId | Amount | AccountId | CreationDate        | OperationId | Type    | PartitionType |
| -- | ------------- | ------ | --------- | ------------------- | ----------- | ------- | ------------- |
| 1  | 340           | 125.50 | 1001      | 2026-02-10 09:15:00 | 081         | Capture | Base          |
| 2  | 560           | -48.00 | 1002      | 2026-02-11 14:42:00 | 052         | Reserve | Reserve       |
| 3  | 67            | 300.00 | 1003      | 2026-02-12 08:05:00 | 023         | Cancel  | Base          |

## Accounting — Customer Account — `loy_accounting_customer_account`

### Definition

| Property     | Type      | Description                                                                                     |
| ------------ | --------- | ----------------------------------------------------------------------------------------------- |
| Id           | long      | Identifier for the customer-account association (Primary Key)                                   |
| AccountId    | long      | Identifier of the account                                                                       |
| CustomerId   | string    | Identifier for the customer associated with the account                                         |
| CreationDate | timestamp | Timestamp when the account was associated with the customer                                     |
| IsActive     | boolean   | Indicates whether the association is currently active. If false, DeleteDate should be set       |
| DeleteDate   | timestamp | Timestamp when the association was removed / deactivated. Populated when IsActive becomes false |

### Sample data

| Id   | AccountId | CustomerId | CreationDate        | IsActive | DeleteDate          |
| ---- | --------- | ---------- | ------------------- | -------- | ------------------- |
| 1001 | 1081      | 001        | 2026-01-15 10:00:00 | true     | NULL                |
| 1002 | 1032      | 045        | 2025-12-20 08:30:00 | false    | 2026-02-05 14:10:00 |
| 1003 | 1053      | 023        | 2026-02-10 16:45:00 | true     | NULL                |

## Accounting — Transaction — `loy_accounting_transaction`

### Definition

| Property       | Type      | Description                                               |
| -------------- | --------- | --------------------------------------------------------- |
| Id             | long      | Identifier for each transaction (Primary Key)             |
| Type           | string    | Semantic type of the transaction                          |
| OperationId    | string    | Identifier for the operation, used to ensure idempotency  |
| CreationDate   | timestamp | Timestamp when the transaction was created                |
| SettlementDate | timestamp | Timestamp when the transaction was successfully processed |
| Metadata       | string    | Additional context or details stored                      |
| ExpirationDate | timestamp | Timestamp when the transaction expires                    |
| State          | string    | Current state of the transaction                          |

### Sample data

| Id   | Type   | OperationId | CreationDate        | SettlementDate      | Metadata                | ExpirationDate      | State      |
| ---- | ------ | ----------- | ------------------- | ------------------- | ----------------------- | ------------------- | ---------- |
| 1001 | Cash   | 061         | 2026-02-10 09:00:00 | 2026-02-10 09:05:00 | "storeId":"023"         | 2026-03-10 00:00:00 | Waiting    |
| 1002 | Credit | 052         | 2026-02-11 14:30:00 | 2026-02-11 14:45:00 | "description":"voucher" | 2026-03-11 00:00:00 | Successful |
| 1003 | Cash   | 053         | 2026-02-12 08:20:00 | 2026-02-12 08:50:00 | "customerId":"049"      | 2026-03-12 00:00:00 | Cancelled  |

## Accounting — Transaction Type — `loy_accounting_transaction_type`

### Definition

| Property            | Type    | Description                                                        |
| ------------------- | ------- | ------------------------------------------------------------------ |
| Id                  | int     | Identifier for each transaction type (Primary Key)                 |
| Name                | string  | Name of the transaction type                                       |
| IsUsedForStatistics | boolean | Indicates if the transaction type is used for statistical purposes |
| IsUsedForAdjustment | boolean | Indicates if the transaction type is used for adjustments          |

### Sample data

| Id | Name         | IsUsedForStatistics | IsUsedForAdjustment |
| -- | ------------ | ------------------- | ------------------- |
| 1  | Bonus        | true                | false               |
| 2  | Card         | false               | true                |
| 3  | ExternalCard | true                | true                |

## Bonus Calculation — Campaign — `loy_bonuscalculation_campaign`

### Definition

| Property           | Type      | Description                                                             |
| ------------------ | --------- | ----------------------------------------------------------------------- |
| Id                 | int       | Identifier for each bonus calculation campaign (Primary Key)            |
| Name               | string    | Name of the bonus calculation campaign                                  |
| StartDate          | timestamp | Start date of the bonus calculation campaign                            |
| EndDate            | timestamp | End date of the bonus calculation campaign                              |
| Audiences          | string    | Audiences targeted for the bonus calculation campaign                   |
| AudienceTargetMode | string    | Mode used for targeting the audiences in the bonus calculation campaign |
| Type               | string    | Type of the bonus calculation campaign                                  |
| Status             | string    | Status of the bonus calculation campaign                                |

### Sample data

| Id | Name           | StartDate           | EndDate             | Audiences | AudienceTargetMode | Type              | Status   |
| -- | -------------- | ------------------- | ------------------- | --------- | ------------------ | ----------------- | -------- |
| 1  | Spring Bonus   | 2026-03-01 00:00:00 | 2026-03-31 23:59:59 | 001,004   | Inclusion          | ProductBonusChain | Enabled  |
| 2  | Loyalty Reward | 2026-01-10 08:00:00 | 2026-02-10 23:59:59 | 003       | Exclusion          | ProductBonusStore | Disabled |
| 3  | Weekend Flash  | 2026-02-15 12:00:00 | 2026-02-18 23:59:59 | 002,005   | Inclusion          | ProductBonusChain | Draft    |

## Challenge — Campaign Configuration — `loy_challenge_campaign_configuration`

### Definition

| Property          | Type      | Description                                                           |
| ----------------- | --------- | --------------------------------------------------------------------- |
| ActivityId        | string    | Id of the challenge (Primary Key)                                     |
| ActivityName      | string    | Name of the challenge                                                 |
| RequiredProgress  | int       | Required progress to complete the challenge (OUT OF USE)              |
| StartTime         | timestamp | Time when customers can start accumulating progress for the challenge |
| EndTime           | timestamp | Time when customers stop accumulating progress for the challenge      |
| ActivationLimit   | int       | Maximum number of activations allowed for the challenge               |
| Audiences         | string    | Comma-separated list of audiences                                     |
| UnifiedCampaignId | string    | Id of Turboflow challenge                                             |
| DeletedAt         | timestamp | Time when the challenge was deleted                                   |

### Sample data

| ActivityId | ActivityName      | RequiredProgress | StartTime           | EndTime             | ActivationLimit | Audiences | UnifiedCampaignId | DeletedAt           |
| ---------- | ----------------- | ---------------- | ------------------- | ------------------- | --------------- | --------- | ----------------- | ------------------- |
| 001        | Stella Artois     | 5                | 2026‑03‑01 00:00:00 | 2026‑03‑31 23:59:59 | 1               | 001,004   | 001               | 2026‑02‑25 12:30:00 |
| 002        | Coca Cola Bottle  | 3                | 2026‑02‑15 08:00:00 | 2026‑04‑01 20:00:00 | 3               | 004,005   | 005               | NULL                |
| 003        | Nestle KitKat Bar | 2                | 2026‑01‑10 00:00:00 | 2026‑06‑30 23:59:59 | 2               | 003       | 008               | 2026‑02‑01 12:30:00 |

## Challenge — Lottery Winner — `loy_challenge_lottery_winner`

### Definition

| Property     | Type      | Description                                          |
| ------------ | --------- | ---------------------------------------------------- |
| Id           | long      | Internal Id (Primary Key)                            |
| ActivityId   | string    | Id of the challenge                                  |
| CustomerId   | string    | Id of the customer who won the lottery               |
| RewardId     | string    | Id of the reward won by the customer                 |
| RewardTitle  | string    | Title of the reward won by the customer              |
| DrawDate     | timestamp | Time when the lottery draw was done                  |
| RemoveDate   | timestamp | Time when the customer was removed from a draw       |
| RemoveReason | string    | Reason for removing the customer from the lottery    |
| CardId       | string    | Id of the customer card randomly selected as winning |
| IsBackup     | boolean   | Indicates whether the winner is primary or backup    |

### Sample data

| Id   | ActivityId | CustomerId | RewardId | RewardTitle         | DrawDate            | RemoveDate          | RemoveReason    | CardId | IsBackup |
| ---- | ---------- | ---------- | -------- | ------------------- | ------------------- | ------------------- | --------------- | ------ | -------- |
| 1001 | 061        | 003        | 005      | Free Coffee Voucher | 2026-02-10 10:00:00 | NULL                | NULL            | 001    | false    |
| 1002 | 032        | 045        | 022      | Free KitKat Bar     | 2026-02-11 15:30:00 | 2026-02-12 12:00:00 | Duplicate entry | 017    | true     |
| 1003 | 083        | 078        | 031      | Gift Card €20       | 2026-02-12 09:45:00 | NULL                | NULL            | 009    | false    |

## Challenge — Challenge Reward — `loy_challenge_challengereward`

### Definition

| Property   | Type   | Description                          |
| ---------- | ------ | ------------------------------------ |
| Id         | long   | Internal Id (Primary Key)            |
| ActivityId | string | Id of the challenge                  |
| RewardId   | string | Id of the reward won by the customer |

### Sample data

| Id   | ActivityId | RewardId |
| ---- | ---------- | -------- |
| 1001 | 001        | 001      |
| 1005 | 002        | 002      |
| 1003 | 003        | 004      |

## Challenge — Customer Card — `loy_challenge_customer_card`

### Definition

| Property    | Type      | Description                                               |
| ----------- | --------- | --------------------------------------------------------- |
| Id          | long      | Internal Id (Primary Key)                                 |
| CardId      | string    | Id of the card                                            |
| ActivityId  | string    | Id of the challenge                                       |
| CustomerId  | string    | Id of the customer to whom the card belongs               |
| ActivatedAt | timestamp | Time when the card was activated                          |
| ClosedAt    | timestamp | Time when the card was closed and the reward was assigned |
| ExpiresAt   | timestamp | Time when the card expires for the triggered challenge    |

### Sample data

| Id   | CardId | ActivityId | CustomerId | ActivatedAt         | ClosedAt            | ExpiresAt           |
| ---- | ------ | ---------- | ---------- | ------------------- | ------------------- | ------------------- |
| 1001 | 001    | 001        | 001        | 2026‑03‑01 09:12:00 | 2026‑03‑05 10:00:00 | 2026‑04‑01 00:00:00 |
| 1002 | 002    | 002        | 002        | 2026‑02‑20 14:45:33 | 2026‑02‑28 16:22:11 | 2026‑03‑15 00:00:00 |
| 1003 | 003    | 003        | 003        | 2026‑01‑18 07:30:10 | 2026‑01‑25 12:40:55 | 2026‑02‑20 00:00:00 |

## Challenge — Progress Operations — `loy_challenge_progress_operations`

### Definition

| Property     | Type           | Description                                       |
| ------------ | -------------- | ------------------------------------------------- |
| Id           | long           | Internal Id (Primary Key)                         |
| CardId       | string         | Id of the customer card                           |
| PurchaseId   | string         | Id of the purchase for which progress was granted |
| Progress     | decimal(19, 2) | Amount of progress that was granted               |
| StoreId      | string         | Id of the store where the purchase was made       |
| PurchaseTime | timestamp      | Time when the purchase was made                   |

### Sample data

| Id   | CardId | PurchaseId | Progress | StoreId | PurchaseTime        |
| ---- | ------ | ---------- | -------- | ------- | ------------------- |
| 1001 | 001    | 001        | 12.50    | 001     | 2026‑03‑01 09:12:00 |
| 1002 | 006    | 009        | 7.00     | 004     | 2026‑02‑20 14:45:33 |
| 1003 | 003    | 002        | 3.75     | 003     | 2026‑01‑18 07:30:10 |

## Challenge — Progress Rule — `loy_challenge_progress_rule` (NOT AVAILABLE IN THE CURRENT VERSION)

### Definition

| Property                | Type          | Description                                                                    |
| ----------------------- | ------------- | ------------------------------------------------------------------------------ |
| Id                      | int           | Id of the progress rule (Primary Key)                                          |
| ActivityId              | string        | Id of the challenge                                                            |
| ProgressCalculationType | string        | Type of progress calculation                                                   |
| RequiredProgress        | int           | Progress required to complete a single card of the challenge                   |
| UnitsOfMeasure          | string        | Unit of measure for the progress rule                                          |
| PaymentTypes            | string        | Type of payment (e.g. Cash, Card)                                              |
| MinimumPurchaseAmount   | decimal(13,4) | Minimum amount for purchase to grant progress for Store Visit calculation type |

### Sample data

| Id | ActivityId | ProgressCalculationType | RequiredProgress | UnitsOfMeasure | PaymentTypes | MinimumPurchaseAmount |
| -- | ---------- | ----------------------- | ---------------- | -------------- | ------------ | --------------------- |
| 1  | 001        | ProductCount            | 5                | Kilogram       | Cash         | NULL                  |
| 2  | 002        | StoreVisit              | 2                | NULL           | Cash         | NULL                  |
| 3  | 003        | PurchaseAmount          | 50               | NULL           | Card         | 5.5000                |

## Challenge — Reward — `loy_challenge_reward`

### Definition

| Property     | Type           | Description                                                       |
| ------------ | -------------- | ----------------------------------------------------------------- |
| Id           | long           | Id of the reward (Primary Key)                                    |
| OfferId      | string         | Id of the offer for Coupon rewards                                |
| Title        | string         | Title of the coupon or manually inputted reward in the admin tool |
| Type         | string         | Type of reward                                                    |
| TotalRewards | long           | Number of rewards that can be assigned to a customer              |
| BonusAmount  | decimal(10, 2) | Amount of bonus to be granted when the Bonus reward is won        |

### Sample data

| Id   | OfferId | Title          | Type   | TotalRewards | BonusAmount |
| ---- | ------- | -------------- | ------ | ------------ | ----------- |
| 1001 | 001     | Welcome Bonus  | Coupon | 100          | 10.00       |
| 1002 | 004     | Holiday Coupon | Bonus  | 250          | 25.00       |
| 1003 | 002     | Loyalty Reward | Coupon | 50           | 5.00        |

## Game — Attempt — `loy_game_attempt`

### Definition

| Property      | Type      | Description                                       |
| ------------- | --------- | ------------------------------------------------- |
| AttemptId     | string    | Id of the attempt (Primary Key)                   |
| GameId        | long      | Id of the game                                    |
| CustomerId    | string    | Id of the customer                                |
| IsWin         | boolean   | Indicates whether the attempt allows winning      |
| StartDate     | timestamp | Start time of the attempt                         |
| EndDate       | timestamp | End time of the attempt                           |
| RewardId      | string    | Id of the reward                                  |
| IsWinOnFinish | boolean   | Indicates whether the attempt was a win on finish |

### Sample data

| AttemptId | GameId | CustomerId | IsWin | StartDate           | EndDate             | RewardId | IsWinOnFinish |
| --------- | ------ | ---------- | ----- | ------------------- | ------------------- | -------- | ------------- |
| 001       | 1001   | 001        | true  | 2026‑03‑01 09:12:00 | 2026‑03‑01 09:15:00 | 002      | true          |
| 002       | 1007   | 003        | false | 2026‑02‑20 14:45:33 | 2026‑02‑20 14:50:00 | 008      | false         |
| 003       | 1003   | 009        | true  | 2026‑01‑18 07:30:10 | 2026‑01‑18 07:35:00 | 004      | true          |

## Game — Configuration — `loy_game_configuration`

### Definition

| Property          | Type      | Description                  |
| ----------------- | --------- | ---------------------------- |
| StartDate         | timestamp | Start time of the game       |
| EndDate           | timestamp | End time of the game         |
| Name              | string    | Name of the game             |
| Id                | long      | Id of the game (Primary Key) |
| Url               | string    | URL of the game              |
| Audiences         | string    | List of audiences            |
| UnifiedCampaignId | string    | Id of Turboflow campaign     |

### Sample data

| StartDate           | EndDate             | Name        | Id   | Url                                             | Audiences | UnifiedCampaignId |
| ------------------- | ------------------- | ----------- | ---- | ----------------------------------------------- | --------- | ----------------- |
| 2026‑03‑01 00:00:00 | 2026‑03‑31 23:59:59 | Summer Game | 1001 | [https://game1.example](https://game1.example/) | 001,002   | 001               |
| 2026‑02‑15 08:00:00 | 2026‑04‑01 20:00:00 | Winter Spin | 1002 | [https://game2.example](https://game2.example/) | 010,022   | 002               |
| 2026‑01‑10 00:00:00 | 2026‑06‑30 23:59:59 | Lucky Draw  | 1003 | [https://game3.example](https://game3.example/) | 005       | 003               |

## Game — Customer Reward — `loy_game_customer_reward`

### Definition

| Property           | Type      | Description                         |
| ------------------ | --------- | ----------------------------------- |
| Id                 | long      | Internal Id (Primary Key)           |
| RewardId           | string    | Id of the reward                    |
| CustomerId         | string    | Id of the customer                  |
| AssignedAt         | timestamp | Time when the reward was assigned   |
| ReservationValidTo | timestamp | Time until the reservation is valid |
| AttemptId          | string    | Id of the attempt                   |

### Sample data

| Id   | RewardId | CustomerId | AssignedAt          | ReservationValidTo  | AttemptId |
| ---- | -------- | ---------- | ------------------- | ------------------- | --------- |
| 1001 | 091      | 001        | 2026‑03‑01 09:12:00 | 2026‑03‑10 12:00:00 | 003       |
| 1002 | 022      | 004        | 2026‑02‑20 14:45:33 | 2026‑02‑28 09:45:00 | 002       |
| 1003 | 073      | 008        | 2026‑01‑18 07:30:10 | 2026‑02‑15 17:20:00 | 006       |

## Game — Game Reward — `loy_game_gamereward`

### Definition

| Property | Type   | Description               |
| -------- | ------ | ------------------------- |
| Id       | long   | Internal Id (Primary Key) |
| GameId   | long   | Id of the game            |
| RewardId | string | Id of the reward          |

### Sample data

| Id   | GameId | RewardId |
| ---- | ------ | -------- |
| 1001 | 1001   | 061      |
| 1002 | 1023   | 067      |
| 1003 | 1079   | 058      |

## Game — Lottery Winner — `loy_game_lottery_winner`

### Definition

| Property   | Type      | Description                              |
| ---------- | --------- | ---------------------------------------- |
| Id         | long      | Internal Id (Primary Key)                |
| GameId     | long      | Id of the game                           |
| CustomerId | string    | Id of the winning customer               |
| WinDate    | timestamp | Time when the lottery was won            |
| DrawDate   | timestamp | Time of the draw                         |
| RemoveDate | timestamp | Time when the lottery winner was removed |
| RewardId   | string    | Id of the reward                         |
| AttemptId  | string    | Id of the attempt                        |

### Sample data

| Id   | GameId | CustomerId | WinDate             | DrawDate            | RemoveDate          | RewardId | AttemptId |
| ---- | ------ | ---------- | ------------------- | ------------------- | ------------------- | -------- | --------- |
| 1001 | 1001   | 001        | 2026‑03‑01 09:15:00 | 2026‑03‑01 09:12:00 | 2026‑03‑10 12:00:00 | 001      | 011       |
| 1002 | 1072   | 033        | 2026‑02‑20 14:50:00 | 2026‑02‑20 14:45:33 | 2026‑02‑28 09:45:00 | 087      | 042       |
| 1003 | 1043   | 083        | 2026‑01‑18 07:35:00 | 2026‑01‑18 07:30:10 | 2026‑02‑15 17:20:00 | 093      | 063       |

## Game — Reward — `loy_game_reward`

### Definition

| Property     | Type          | Description                                                    |
| ------------ | ------------- | -------------------------------------------------------------- |
| Id           | long          | Internal Id (Primary Key)                                      |
| ExternalId   | string        | External Id referencing the offer that assigns a Coupon reward |
| Title        | string        | Title of the reward                                            |
| ValidFrom    | timestamp     | Start time when the Coupon reward is valid                     |
| ValidTo      | timestamp     | End time when the Coupon reward is valid                       |
| TotalRewards | long          | Total quantity of rewards available                            |
| IsActive     | boolean       | Indicates whether the reward is currently active               |
| BonusAmount  | decimal(10,2) | Additional amount or bonus associated with the reward          |
| Type         | string        | Type of reward                                                 |

### Sample data

| Id   | ExternalId | Title          | ValidFrom           | ValidTo             | TotalRewards | IsActive | BonusAmount | Type   |
| ---- | ---------- | -------------- | ------------------- | ------------------- | ------------ | -------- | ----------- | ------ |
| 1001 | 071        | Welcome Bonus  | 2026‑03‑01 00:00:00 | 2026‑03‑31 23:59:59 | 100          | true     | 10.00       | Bonus  |
| 1002 | 062        | Holiday Coupon | 2026‑02‑15 08:00:00 | 2026‑04‑01 20:00:00 | 250          | false    | 25.00       | Bonus  |
| 1003 | 033        | Loyalty Reward | 2026‑01‑10 00:00:00 | 2026‑06‑30 23:59:59 | 50           | true     | 5.00        | Coupon |

## Promotion — Coupon — `loy_promotion_coupon`

### Definition

| Property           | Type      | Description                                                  |
| ------------------ | --------- | ------------------------------------------------------------ |
| Id                 | long      | Internal Id (Primary Key)                                    |
| CouponId           | string    | Id of the coupon used in the promotion                       |
| ReservationId      | string    | Id of the reservation associated with the coupon             |
| AssignedAt         | timestamp | Time when the coupon was assigned to a customer              |
| DateToPickUp       | timestamp | Time for picking up the coupon                               |
| CustomerId         | string    | Id of the customer who received the coupon                   |
| CampaignId         | string    | Id of the promotional campaign linked to the coupon          |
| ActivatedAt        | timestamp | Time when the coupon was activated for use                   |
| PosCouponId        | string    | Id of the coupon used in the point of sale system            |
| DeletedAt          | timestamp | Time when the coupon entry was deleted (OUT OF USE)          |
| ReservationValidTo | timestamp | Time indicating the validity period of the reservation       |
| VisibleFrom        | timestamp | Time indicating when the coupon became visible for customers |

### Sample data

| Id   | CouponId | ReservationId | AssignedAt          | DateToPickUp        | CustomerId | CampaignId | ActivatedAt         | PosCouponId | DeletedAt           | ReservationValidTo  | VisibleFrom         |
| ---- | -------- | ------------- | ------------------- | ------------------- | ---------- | ---------- | ------------------- | ----------- | ------------------- | ------------------- | ------------------- |
| 1001 | 001      | 081           | 2026‑03‑01 09:10:00 | 2026‑03‑05 10:00:00 | 045        | 081        | 2026‑03‑01 09:12:00 | 001         | 2026‑03‑10 12:00:00 | 2026‑03‑15 23:59:59 | 2026‑03‑01 00:00:00 |
| 1002 | 082      | 082           | 2026‑02‑20 14:40:00 | 2026‑02‑25 16:00:00 | 001        | 052        | 2026‑02‑20 14:45:33 | 052         | NULL                | 2026‑03‑01 23:59:59 | 2026‑02‑15 08:00:00 |
| 1003 | 023      | 053           | 2026‑01‑18 07:25:00 | 2026‑01‑22 12:00:00 | 067        | 003        | 2026‑01‑18 07:30:10 | 023         | 2026‑02‑28 09:45:00 | 2026‑02‑20 23:59:59 | 2026‑01‑10 00:00:00 |

## Promotion — Coupon Redemption — `loy_promotion_coupon_redemption`

### Definition

| Property       | Type      | Description                                              |
| -------------- | --------- | -------------------------------------------------------- |
| Id             | int       | Internal Id (Primary Key)                                |
| CouponId       | string    | Id of the coupon being redeemed                          |
| RedeemedAt     | timestamp | Time when the coupon was redeemed                        |
| IdempotencyKey | string    | Unique key to ensure idempotent processing of redemption |
| CanceledAt     | timestamp | Time when the coupon redemption was cancelled            |

### Sample data

| Id | CouponId | RedeemedAt          | IdempotencyKey | CanceledAt          |
| -- | -------- | ------------------- | -------------- | ------------------- |
| 1  | 041      | 2026‑03‑01 09:12:00 | 061            | 2026‑03‑10 12:00:00 |
| 2  | 032      | 2026‑02‑20 14:45:33 | 062            | NULL                |
| 3  | 063      | 2026‑01‑18 07:30:10 | 083            | 2026‑02‑28 09:45:00 |

## Promotion — Offer — `loy_promotion_offer`

### Definition

| Property          | Type      | Description                                                                  |
| ----------------- | --------- | ---------------------------------------------------------------------------- |
| Id                | int       | Internal Id (Primary Key)                                                    |
| OfferId           | string    | Id of the offer                                                              |
| UnifiedCampaignId | string    | Id of the Turboflow campaign                                                 |
| Name              | string    | Name of the offer - visible to admins                                        |
| ValidFrom         | timestamp | Time when the coupons for the offer become available to pick up in store     |
| ValidTo           | timestamp | Time when the coupons for the offer stop being available to pick up in store |
| Title             | string    | Title of the offer - visible to customers                                    |
| OfferType         | string    | Type of offer                                                                |
| Audiences         | string    | Audiences targeted by the offer                                              |
| FundedBy          | string    | Entity responsible for funding the offer                                     |
| DeletedAt         | timestamp | Time when the offer was deleted                                              |

### Sample data

| Id | OfferId | UnifiedCampaignId | Name          | ValidFrom           | ValidTo             | Title          | OfferType          | Audiences | FundedBy | DeletedAt           |
| -- | ------- | ----------------- | ------------- | ------------------- | ------------------- | -------------- | ------------------ | --------- | -------- | ------------------- |
| 1  | 041     | 021               | Spring Promo  | 2026‑03‑01 00:00:00 | 2026‑03‑31 23:59:59 | Spring Savings | game               | 004,005   | Retailer | 2026‑03‑10 12:00:00 |
| 2  | 052     | 062               | Winter Deal   | 2026‑02‑15 08:00:00 | 2026‑04‑01 20:00:00 | Winter Rewards | appCoupon          | 005,023   | Retailer | NULL                |
| 3  | 023     | 093               | Loyalty Bonus | 2026‑01‑10 00:00:00 | 2026‑06‑30 23:59:59 | Loyalty Gift   | segmentedAppCoupon | 003,099   | Retailer | 2026‑02‑28 09:45:00 |

## Promotion — Personal Offer Coupon — `loy_promotion_personal_offer_coupon`

### Definition

| Property      | Type      | Description                                            |
| ------------- | --------- | ------------------------------------------------------ |
| Id            | long      | Internal Id (Primary Key)                              |
| CouponId      | string    | Id of the coupon                                       |
| ReservationId | string    | Id of the reservation                                  |
| AssignedAt    | timestamp | Time when the coupon was assigned                      |
| DateToPickUp  | timestamp | Time until the coupon has to be picked up in the store |
| CustomerId    | string    | Id of the customer to whom the coupon is assigned      |
| CampaignId    | string    | Id of the offer associated with the coupon             |
| ActivatedAt   | timestamp | Time when the coupon was activated                     |
| PosCouponId   | string    | External Id of the coupon used during redemption       |
| DeletedAt     | timestamp | Time when the coupon was deleted                       |
| VisibleFrom   | timestamp | Time when the coupon becomes visible in the mobile app |

### Sample data

| Id   | CouponId | ReservationId | AssignedAt          | DateToPickUp        | CustomerId | CampaignId | ActivatedAt         | PosCouponId | DeletedAt           | VisibleFrom         |
| ---- | -------- | ------------- | ------------------- | ------------------- | ---------- | ---------- | ------------------- | ----------- | ------------------- | ------------------- |
| 1001 | 071      | 001           | 2026-02-10 09:00:00 | 2026-02-15 23:59:59 | 081        | 067        | 2026-02-12 10:00:00 | 061         | NULL                | 2026-02-10 00:00:00 |
| 1002 | 091      | 044           | 2026-02-11 14:20:00 | 2026-02-16 20:00:00 | 005        | 078        | 2026-02-22 10:00:00 | NULL        | 2026-02-25 16:30:00 | 2026-02-23 00:00:00 |
| 1003 | 033      | 088           | 2026-02-12 08:45:00 | 2026-02-18 18:00:00 | 067        | 053        | 2026-02-13 09:30:00 | 019         | NULL                | 2026-02-12 00:00:00 |

## Promotion — Discount Rule — `loy_promotion_discount_rule`

### Definition

| Property | Type   | Description                                                  |
| -------- | ------ | ------------------------------------------------------------ |
| Id       | int    | Internal Id (Primary Key) used as Foreign Key in Affiliation |
| OfferId  | string | Id of the promotion offer, to which this rule belongs        |
| Type     | string | Type of applied discount                                     |

### Sample data

| Id | OfferId                              | Type       |
| -- | ------------------------------------ | ---------- |
| 24 | 7e63a9ee-a0ff-426f-822a-c4266375b017 | FixedPrice |
| 18 | fa72492a-b081-409d-a02f-b4088bff5acb | Percentage |
| 23 | 7e63a9ee-a0ff-426f-822a-c4266375b017 | Amount     |

## Promotion — Affiliation — `loy_promotion_affiliation`

### Definition

| Property        | Type   | Description                                                                               |
| --------------- | ------ | ----------------------------------------------------------------------------------------- |
| Id              | int    | Internal Id (Primary Key)                                                                 |
| Value           | string | Actual product/category id                                                                |
| DiscountRuleId  | int    | Id of the rule, to which this affiliation belongs                                         |
| AffiliationType | string | Indicates whether the discount rule targets a product or a whole product category         |
| ApplicationType | string | Indicates whether the listed items are included or excluded from the discount calculation |

### Sample data

| Id  | Value        | DiscountRuleId | AffiliationType | ApplicationType |
| --- | ------------ | -------------- | --------------- | --------------- |
| 13  | 352311881    | 13             | Product         | Include         |
| 169 | MixAndMatch2 | 172            | Category        | Include         |
| 224 | 352311881    | 237            | Product         | Exclude         |
