O
O
Optimus2017-08-14 17:43:58
PHP
Optimus, 2017-08-14 17:43:58

What is the best withdrawal model?

The service costs 300 units. currency per month. You can write off:
1. On the last day of the month. But it is difficult to determine it and a problem arises if he paid on the 15th, then you need to calculate the share and write off half, and for the entire second month if the balance is not replenished, there will not be enough money.
2. Every 30 days. This is somewhat easier. On January 15 they laid it down - on February 15 they wrote it off.
3. Write off an amount equal to 1/30 of the monthly cost every day. I noticed that many people use this model. Why is she so popular? After all, transactions should then be done every day and a large transaction log should be kept + the balance could be stored in int, otherwise it will definitely become fractional and should be stored in decimal.
And for example 200 / 30 = 6.66
But 6.66 x 30 = 199.8 how to avoid error accumulation in this case?
Which write-off model do you think is better and why? Hosters usually have 2 or 3 models for example.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
pashted, 2019-04-06
@vaflya

Notice: Array to string conversion in C:\xampp\htdocs\test.php on line 15
Call Stack
#	Time	Memory	Function	Location
1	0.0003	389704	{main}( )	...\test.php:0

and this is how it works:
5ca87fb81babd725759112.png

X
xmoonlight, 2017-08-16
Pyan @marrk2

The most convenient option for users of the service: this is model No. 3.
How to write off?
In the base case, there are 3 variables:
1. User's balance
2. Subscription activation date
3. Cost per time period
Given (example):
1. User topped up 180 units. (previous - was: 20 units) and the final balance became: 200 units.
2. After some time - the user activated the subscription. Let's say August 15th.
3. Let the service cost 300 units for a (calendar!) month.
So its balance with an active subscription of N-days is:
20+180-300*12/365*N => based on a regular year (not a leap year!).
For example, the balance after 5 days (August 20th):
20+180-300*12/365*5 = 150.68493150684931506849315068493 units
We display in the user's personal account as a normal mathematical rounding up to the 2nd digit (inclusive) after the decimal point (0-4 - down, 5-9 - up): 150.68 units.
To maintain accuracy - never deduct the spent amount from the user's balance: always count ONLY through the coefficients in the formula!
All static coefficients of the formula (not involved in daily balance calculations) are calculated in advance (for acceleration and load relief) and stored with MAXIMUM accuracy!

A
Axian Ltd., 2017-08-14
@AxianLTD

It's hard to believe, but the write-off model depends on the methods of financial management of the enterprise, the indicators used in this case. And what payment plan are you talking about? Prepaid, postpaid, automatic billing? Or is it just an imitation of a debit from a client's virtual account as part of your billing?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question