Need Logical Help to Store the New Balance from Debit or Credit
I need logical help to make this "New Balance" on Debit-Credit Transection Type. How do I code from TextInput to store the old+new amount as new balance? Also this field could be hidden in form.
6 Replies
- Make your "Amount" and "New Balance" fields reactive
- Add
afterStateUpdate()
method to your "New balance" field (don't forget Get $get, Set $set
to retreive the "Amount" field value)
Make your maths here to set your new balance like $set('new_balance' $newBalanceResult)
And voilà !is this the right way am I going please?
Not totally:
Something like this for your "Amount" field
Should I add
->reactive()
in both 'amount'
and 'new balance'
field?Yep
I tried this code:
But it's
1. not giving me the last inserted value on balance filed
2. not inserting the value that I pass manually to the New balance field.