allegro/ralph_pricing — pull request #110 by mkurek (2014-03-02 21:58:09+00:00)
Title: Feature/universal plugins and services

Added Service and it's usage types models. Modified usage type model - from now UsageType can has one of three types assigned: BU (base usage type), RU (regular usage type) or SU (service usage type). Services and usage types can use universal plugins or have dedicated plugins, called using service or usage type symbol.

Service can dependent on other services, can have it's own usage types (marked as SU) and be billed for it's base usage types (BU). Each of ventures can provide max one service, each service can use many ventures. Because service can have more than one service usage types, there is possibility to define percentage division of service ventures base usage types costs between service usage types in period of time.

Steps to calculate service costs per venture:
1) get smallest dates intervals (contained in total report dates interval) in which percentage division is constant
2) for each date interval:
2.1) calculate total service cost in this period of time (cost of base usage types used by ventures associated with service and cost of dependent services (but only for ventures associatied with considered service))
2.2) if there is more than one service usage type, get it's percent from total cost
2.3) distribute total cost between all other ventures, proportionally to their usage of service usage type

Reports plugins are now classes (plugins classes hierarchy was created). Reorganization of reports plugins: all services should use ServicePlugin (removed hamster, splunk etc separate plugins) and all simple usages should use UsagePlugin (removed power consumption, physical cpu cores etc plugins). Deprec(i)ation is special case and it has it's own, dedicated plugin.

Ventures report adapted to new reports plugins - first of all, information plugin is used. Then all base usage types plugins (BU) are called, then regular usages (RU) and at the end all services plugins.