user_wallets
This table includes all the wallets for all users in the system.
Last updated
This table includes all the wallets for all users in the system.
Last updated
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
This is the a unique identifier of the user wallet.
The id of the user to which this wallet belongs to.
The current balance amount in the wallet. This value is multiple of 1000 when balance_unit field is set to token.
This represents the wallet type for the user. Each user can have four wallets:
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).
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.
payback - This denotes the payback wallet for the user. The balance field will be considered as the total amount paid back to the user.
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.
Timestamp on which the wallet entry is created.
Timestamp on which the wallet entry is last updated.
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.
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:
Membership wallet
External wallet
Reward wallet
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:
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.
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.
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.
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.