Added backend logic to allow property update#23
Conversation
1c7f223 to
a95486b
Compare
|
Hi Evence, thank you so much for your contributions! I have quite a few personal things that came up recently, and I'm currently resolving them, so this PR will likely be reviewed later. Thank you for your patience! |
|
No worries Jimmy, wouldn't want it any other way. Make sure you settle down first! |
…/habits-restapi into feature/allow-property-update
jimmy-lan
left a comment
There was a problem hiding this comment.
Hey Evence,
Thanks for the contributions.
Maybe I have a misunderstanding or am missing context, so please correct me if I'm wrong. I think to update the property associating with a transaction, we do the following:
- Add/Subtract the current transaction amount from the old property; and
- Add/Subtract a new transaction amount or the amount from the current transaction to the new property.
So I'm not sure if I understand this pull request fully, as I'm not sure if it is doing the above. Also, if you're not aware of this, there is a function in updateTransaction.ts named updatePropertyAmount, which seems to have a lot of duplicate code when it compares to the new function that you created in this pull request updateOldAndNewPropertyAmount.
|
Hi Jimmy, the difference between |
No, I think the steps that I described in the previous comment might work.
So step # 1 means to call Not sure if this makes sense to you, but the new function |
|
Understood, I will make the changes. |
There was a problem hiding this comment.
Thanks, Evence!
I'll probably need to change a few minor places to make the code more aligned code style in this repo. I'll approve the PR for now but will merge this later.
These changes are quite minor so I don't see a value to bother you too much. I'll eventually do this myself later. I added two examples below of these things to give an idea. We can chat more offline.
@evencewang Thanks again for helping the growth of habits CLI and providing user feedback. By merging this and future pull requests, the contributor agreement that we previously agreed on will apply. If you have any questions or concerns, feel free to chat any time.
| import { validateRequest } from "../../middlewares"; | ||
| import { body, param } from "express-validator"; | ||
| import { ResBody } from "../../types"; | ||
| import { MongoDocument, ResBody } from "../../types"; |
| ); | ||
| } | ||
| const transactionProperty = transaction.property as PropertyDocument; | ||
| let transactionProperty = transaction.property as PropertyDocument; |
There was a problem hiding this comment.
This change from const to let probably has no effect.
Added backend logic to allow property update, also updated logic for difference amount in amountChange depending on whether the old property id and the new property id are the same.
Now if a property is changed, then the amount would be deducted from the original property, and added to the new property.