See https://laracasts.com/discuss/channels/eloquent/make-sales-records-immutable Read through whole post.
Working with variable monthly prices
Not so much a coding issue but more like a general issue/question.
I am working on my budgetting app and I have a "Payment" model and an "Expense" model. To the payments, I can add monthly payments, such as Spotify, Netflix, etc. These are all fixed prices. So I can easily check if a montly payment was done by comparing the "Expense" amount against what the monthly payment should be.
But when adding variable amounts, such as Digital Ocean payments, these fluctuate and are not the same every month. My general question is, how would YOU fix this "issue"?
Some background: Right now on my "Payment" show view, I show all details of a payment. And there I also show if the payment has been done this month (by checking against the monthly expenses). Which is an easy task, when working with fixed prices such as rent, netflix, etc. But when it comes to payments that are not the same every month, what would be a good solution?
Something I came up with but I don't think is very good, is, when adding an expense for a particular payment, I update that payment amount to whatever the amount was for this last payment. But it feels a bit off to me, especially when I delete this last expense, to what will I update the payment amount?
So my general question is, which "logic would you use" to solve this problem? Any pointers?
You might consider marking certain Payments as variable, then take all of the ones to an individual payee and calculate the average amount. Once the charge comes in and you have an exact amount you can update the Expense as you are probably already doing.
If you have some months that are obviously outliers you could flag those to not be included in the average calculation, and perhaps apply a rolling 12-month average as you see fit.
It's a fuzzy approach (just like budgeting!), but probably a little better than assuming last month's amount will be an exact match.
Please or to participate in this conversation.