Skip to content

Commit 7b3d83f

Browse files
committed
Added task description
1 parent 99d24d8 commit 7b3d83f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

TASK.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Backend task for implementation
2+
3+
Create a backend endpoints which implements following functionality:
4+
5+
- Introduce a new entity Wallet and Transaction.
6+
- Wallet should have fields: id, user_id (foreign key to User), balance (float), currency (string).
7+
- Available currencies: USD, EUR, RUB.
8+
- Transaction should have fields: id, wallet_id (foreign key to Wallet), amount (float), type (enum: 'credit', 'debit'), timestamp (datetime), currency (string).
9+
- Implement endpoint to create a wallet for a user.
10+
- Implement endpoint to get wallet details including current balance.
11+
- Implement endpoint to create a transaction (credit or debit) for a wallet.
12+
13+
# Rules for wallet
14+
15+
- A user can have three wallets.
16+
- Wallet balance should start at 0.0.
17+
- Arithmetic operations on balance should be precise up to two decimal places.
18+
19+
# Rules for transaction
20+
21+
- For 'credit' transactions, the amount should be added to the wallet balance.
22+
- For 'debit' transactions, the amount should be subtracted from the wallet balance.
23+
- Ensure that the wallet balance cannot go negative. If a debit transaction would cause the balance to go negative, the transaction should be rejected with an appropriate error message.
24+
- Transaction between wallets with different currencies must be converted using a fixed exchange rate (you can hardcode some exchange rates for simplicity) and fees should be applied.

0 commit comments

Comments
 (0)