* How to handle billing in general ** Orders - Orders are the heart of uncloud billing - Have a starting date - Have an ending date *** Statuses - CREATING/PREPARING - INACTIVE (?) - TO_BILL / NOT_TO_BILL *** Updating status of orders - If has succeeding order and billing date is last month -> set inactive ** Bills - Are always for a month - Can be preliminary *** Which orders to include - Not the cancelled ones / not active ones - ** Flows / Approach *** Finding all orders for a bill - Get all orders, state != NOT_TO_BILL; for each order do: - is it a one time order? - has it a bill assigned? - yes: set to NOT_TO_BILL - no: - get_or_create_bill_for_this_month - assign bill to this order - set to NOT_TO_BILL - First of month - Last of month