Hi I have a program that needs to be fix. Here is the problem:
For example I have :
Free credit of 2 and regular credit of 5.
For example I want to buy an item for 3 credits.
I want to deduct 2 free credits and 1 regular credits.
so the remaining balance will be 0 free credits and 4 regular credits.
Free credits will be the first to deduct before regular credit deducted.
In my existing program if I buy 1 item for 3 credits
here is the balance come out:
-1 free credits
5 regular credits
Which is not be like that.
I want to have like this:
0 free credits
4 regular credits
I hope someone can help me on this issue.
Thank you.
Or preferably in the SQL directly:
As a technicality, for this to work the datatype for free_credits needs to be signed.