Shahrayar123 / Shahrayar123/Python-Projects

Balance of receiver gets overwritten instead of increased

Open
#319 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
582
Forks
441
PR merge metrics
No merged PRs in 30d

Description

Hi, I found an issue in the money transfer logic.

When transferring money, the receiver’s balance doesn’t get incremented.
Instead, it gets replaced by the transfer amount.

The problem comes from this variable:

self.receiver_balance

It’s initialized to 0 and never updated from the database, so the code ends up doing:

balance = transfer_amount

This means the receiver’s old balance is lost.

Example:
If the receiver originally has 300 and I transfer 50 → the final balance becomes 50, not 350.

Expected:

The balance should increase by the transfer amount.

Suggestion:

Update the DB directly using something like:

UPDATE card SET balance = balance + ? WHERE number = ?

This way the balance is always based on the value stored in the database.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the money transfer logic that uses self.receiver_balance, then inspect how the receiver’s balance is read and written. Verify the fix with a receiver balance of 300 and a transfer of 50; the stored final balance should be 350 rather than 50.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
database, payments
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.