Topic: Structure of tables for auxiliary aggregation
I think over implementation of the agency program.
- The agent receives % from connection cost
- The agent receives % from a client license fee for services
- The license fee can be different (, monthly, annual)
- At different types of service the different interest rate
- In some cases clients can use in a minus ("the Promised payment", the letter of guarantee etc.), however for clients with the negative balance agency reward is not calculated
- At the agent should be not less than 3 active clients for program action
- Payment to the agent is produced once a month
services of clients the system conducts , all charges for services in it are registered.
However the table of charges very big and its direct usage in requests at me it is impossible to make effective (fast).
Therefore I think to launch a script of times a day (a minimum rated period of a license fee - days) and to accumulate the license fee calculated for days in approximately such table:
[CSV =;] the Field; Type; the Description
client_id; number; the Identifier of the client
pediod; date; the Rated period of payments of the agent (1st date)
day; date; Date to which the license fee is calculated
type; number; service Type on which the interest rate is defined
sum_all; number; the Total sum of the calculated license fee from period on day
sum_clear; number; the license fee Total on clients with the positive balance
By means of such table I define charges for the rated period on each client and each type of services and on their basis I can calculate the total of reward to the agent.
Do not advise, how such tasks normally dare?