expephalon/core/helpers/billable.py

21 lines
No EOL
889 B
Python

from core.models.billable import Billable, ActionChoices
from core.models.services import Service
from django.utils import timezone
def generate_invoices():
todo = {}
for billable in Billable.objects.filter(recur_cycle=ActionChoices.DATE):
date = billable.next_invoicing()
if date and date <= timezone.now():
if not billable.brand in todo.keys():
todo[billable.brand] = {}
if not billable.currency in todo[billable.brand].keys():
todo[billable.brand][billable.currency] = {}
if not billable.client in todo[billable.brand][billable.currency].keys():
todo[billable.brand][billable.currency][billable.client] = {"billable": []}
todo[billable.brand][billable.currency][billable.client]["billable"].append(billable)
for service in Service.objects.all():
pass