I'm currently doing a transaction tracker system.
I have a wallets table where your current fund amount is and transactions table.
The question is, do you always deduct the amount of the transactions in your wallets or do you just save the transaction and do subtraction on runtime? Will you allow the transactions to be able to edit?
If the wallet table contains the amount of money and it's just one type of money then I would store the amount in the table and update it according to any transactions. If it contains different types of monetary records like credit, mortages, stocks and so on I would most likely not do that. The transactions table is just a tracker imho to keep track of where the money is transfered or received from.
When working with money I suggest you use Database Transactions to make sure everything has been processed successfully before commiting the change.
Yes, there are multiple types of transactions such as withdrawals, deposit, purchases, transfer, credit and so on. I am having difficult if I should allow the transaction to be editable or not.
When working with money I suggest you use Database Transactions to make sure everything has been processed successfully before commiting the change.
Yeah, I'm currently using DB::transactions()
Edit:
Yeah, regarding DB::transaction, is there a way to implement this in laravel events and listeners?