Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify debts between two users when a new debt is added #43

Merged
merged 12 commits into from
Jul 25, 2022

Conversation

IsaacCheng9
Copy link
Owner

@IsaacCheng9 IsaacCheng9 commented Jul 24, 2022

Summary

  • Created a helper function, processNewDebts.
    • Removed unnecessary helper functions updateDebt and createDebt and integrated them into this new function.
  • Simplified debts between users by checking for a reverse debt and updating it accordingly if it exists.
    • When a user adds a new debt (directly or by adding an expense), the records are simplified so that only one debt exists between the pair of users.
      • X owes Y £5 and Y owes X £50 becomes:
        • Y owes X £45
  • Improved response messages by including specific info about who the debt is going from and to.
  • Removed unnecessary try-catch loops.

Related Issue

Fixes issue #42.

Testing

Tested the changes manually using Postman API calls for adding debts and adding expenses.

@IsaacCheng9 IsaacCheng9 requested review from gkSideProjects and removed request for gkSideProjects July 24, 2022 21:38
@IsaacCheng9 IsaacCheng9 changed the title Simplify debts between two users when a new debt is added [WIP] Simplify debts between two users when a new debt is added Jul 24, 2022
Copy link
Collaborator

@gkSideProjects gkSideProjects left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good!

IsaacCheng9 and others added 2 commits July 25, 2022 20:09
Co-authored-by: George Kombostiotis <71034989+gkSideProjects@users.noreply.github.com>
@IsaacCheng9 IsaacCheng9 changed the title [WIP] Simplify debts between two users when a new debt is added Simplify debts between two users when a new debt is added Jul 25, 2022
@IsaacCheng9 IsaacCheng9 merged commit 1ac7250 into main Jul 25, 2022
@IsaacCheng9 IsaacCheng9 deleted the simplify-debts-between-two-users branch July 25, 2022 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify debts between two users when a new debt is added
2 participants