Hello! My hands got to my long-suffering protracted panel.
It is necessary to resolve the issue of withdrawing money from customers using the services of my panel.
I imagine it so. There is a user, and there is a users table, in which, among other user fields (name, nickname, email, etc.), there is a balance DECIMAL field (12.2). In fact, the value of this field is displayed on the site wherever it is needed (navigation bar, for example). I suppose that the user id is also the account of this user at the same time, and the state of the account is recorded in the balance field.
Every time a user deposits money into an account, or a billing mechanism is triggered, which runs once a day and charges services consumed, the balance field is recalculated (well, just in case). How do you think this is the right approach?
When a user wants to replenish his balance, which document is created, an invoice, or an order? And when do I want to charge the user’s services ?. Do I need to create the payment entity and link it to the documents being created?
A user can simultaneously be ordered several services (services), the cost of each is calculated at the time of ordering services, and is written in the services table in the cost field. Services can be paid only using funds on the account, i.e., one cannot order a service, or use an already ordered service with 0 or a negative balance.
I apologize for the confusion. Ask your requests. I created this topic to try to figure it out myself, because I got confused: (