Skip to content

Balance of receiver gets overwritten instead of increased #319

Description

@liruobing60-alt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions