user_wallets

This table includes all the wallets for all users in the system.

FieldTypeNullableConstraints

id

varchar

NO

user_id

int4

Foreign key (person table)

balance

int8

NO

wallet_for

varchar

NO

version_id

int4

NO

created_at

timestamp

updated_at

timestamp

balance_unit

varchar

NO

date_of_transaction

timestamp

Description of fields

id

This is the a unique identifier of the user wallet.

user_id

The id of the user to which this wallet belongs to.

There are 4 entries where user id is set to NULL. Details about those wallets are mentioned at the end of this document under Bank Wallets.

balance

The current balance amount in the wallet. This value is multiple of 1000 when balance_unit field is set to token.

wallet_for

This represents the wallet type for the user. Each user can have four wallets:

  1. membership - This denotes that the wallet type is membership wallet. The balance field will be considered as the token amount available in the membership wallet. The tokens are credited to this wallet when a user purchases a membership plan and debited when a user views the sale receipts data (once per day).

  2. rewards - This denotes that the wallet type is rewards wallet. The balance field will be considered as the token amount available in the reward wallet. The balance is credited to this wallet when a user receives a reward and debited when a user redeems reward tokens.

  3. payback - This denotes the payback wallet for the user. The balance field will be considered as the total amount paid back to the user.

version_id

This is a custom field that copies the value from inbuilt postgres index about the number of times a row has been modified. Each operation that leads to a modification in a user wallet row increments this value by 1.

The exact intent of this field is yet to be identified. This field may help analyse how many changes are being made to a user wallet. The primary change would be the credit/debit to the wallet balance amount to see which wallets are more active.

created_at

Timestamp on which the wallet entry is created.

updated_at

Timestamp on which the wallet entry is last updated.

balance_unit

This represents the wallet balance unit amount. Default value is token. For payback wallet, this is set to INR. If the balance is 10000 and balance_unit is token, it means user has 10 tokens in their wallet. However, if the balance is 10000 and balance_unit is INR, the wallet holds 10000 INR.

Bank Wallets

Bolbhav follows a fundamental rule during all wallet transactions that every transaction must have a source and target. It means that if a wallet is being credited an amount, the same amount must be debited from another wallet. Consider a simple payment that when you transfer some money to your friend, your bank account is debited and your friend's bank account is credited. The same philosophy is applied here.

We utilise a concept of bank wallets. There are 4 types of bank wallets:

  1. Membership wallet

  2. External wallet

  3. Reward wallet

  4. Payback wallet

Each bank wallet is stored in user_wallets table but they do not have a user_id associated with them. The bank wallets hold the same information as the user wallet, meaning the balance, wallet_for, balance_unit etc.

The bank wallets work in the following ways:

  1. Membership wallet - This wallet started with an initial balance of 10,000,000 (10 million) tokens. When a user purchases a plan, the tokens are credited to their membership wallet and debited from the bank membership wallet.

  2. External wallet - This wallet simply holds the total amount ever paid by a user. When a user purchases a plan, the payable_amount field value is added to this wallet balance. This represents the total amount paid to Bolbhav by users. It represents INR value and contains a multiple of 1000.

  3. Reward wallet - Similar to membership wallet, this started with an initial balance of 10 million tokens. When a user is rewarded, the tokens are credited to their reward wallet and debited from bank reward wallet.

  4. Payback wallet - This wallet started with an initial balance of 10 million INR. When a user is paid back, the amount is credited to their payback wallet and debited from bank payback wallet.

The external wallet entry has balance_unit set to "token" which looks incorrect as it represents the actual INR value contribution.

Last updated