# Path: konfera/models/abstract.py
# class KonferaModel(models.Model):
# 
#     class Meta:
#         abstract = True
# 
#     uuid = models.UUIDField(default=uuid.uuid4, editable=False)
#     date_created = models.DateTimeField(verbose_name=_('Created'), auto_now_add=True)
#     date_modified = models.DateTimeField(verbose_name=_('Last modified'), auto_now=True)
# 
# Path: konfera/models/receipt.py
# class Receipt(AddressModel):
#     order = models.OneToOneField('Order', on_delete=models.CASCADE, related_name='receipt_of')
#     title = models.CharField(max_length=128, verbose_name=_('Name'), blank=True)
#     companyid = models.CharField(max_length=32, blank=True, verbose_name=_('Company ID'))
#     taxid = models.CharField(max_length=32, blank=True, verbose_name=_('TAX ID'))
#     vatid = models.CharField(max_length=32, blank=True, verbose_name=_('VAT ID'))
#     amount = models.DecimalField(decimal_places=2, max_digits=12, validators=[MinValueValidator(0)])
# 
#     def __str__(self):
#         return self.title
# 
# Path: konfera/settings.py
# UNPAID_ORDER_NOTIFICATION_REPEAT = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT', 3)
# 
# UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY', 5)


from datetime import timedelta
from decimal import Decimal
from django.core.validators import MinValueValidator
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.db.models import Q
from konfera.models.abstract import KonferaModel
from konfera.models.receipt import Receipt
from konfera.settings import UNPAID_ORDER_NOTIFICATION_REPEAT, UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY




class Order(KonferaModel):
    AWAITING = 'awaiting_payment'
    PAID = 'paid'
    PARTLY_PAID = 'partly_paid'
    EXPIRED = 'expired'
    CANCELLED = 'cancelled'

    ORDER_CHOICES = (
        (AWAITING, _('Awaiting payment')),
        (PARTLY_PAID, _('Partly paid')),
        (PAID, _('Paid')),

# Path: konfera/models/abstract.py
# class KonferaModel(models.Model):
# 
#     class Meta:
#         abstract = True
# 
#     uuid = models.UUIDField(default=uuid.uuid4, editable=False)
#     date_created = models.DateTimeField(verbose_name=_('Created'), auto_now_add=True)
#     date_modified = models.DateTimeField(verbose_name=_('Last modified'), auto_now=True)
# 
# Path: konfera/models/receipt.py
# class Receipt(AddressModel):
#     order = models.OneToOneField('Order', on_delete=models.CASCADE, related_name='receipt_of')
#     title = models.CharField(max_length=128, verbose_name=_('Name'), blank=True)
#     companyid = models.CharField(max_length=32, blank=True, verbose_name=_('Company ID'))
#     taxid = models.CharField(max_length=32, blank=True, verbose_name=_('TAX ID'))
#     vatid = models.CharField(max_length=32, blank=True, verbose_name=_('VAT ID'))
#     amount = models.DecimalField(decimal_places=2, max_digits=12, validators=[MinValueValidator(0)])
# 
#     def __str__(self):
#         return self.title
# 
# Path: konfera/settings.py
# UNPAID_ORDER_NOTIFICATION_REPEAT = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT', 3)
# 
# UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY = getattr(settings, 'UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY', 5)


# Path: konfera/models/order.py
from datetime import timedelta
from decimal import Decimal
from django.core.validators import MinValueValidator
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.db.models import Q
from konfera.models.abstract import KonferaModel
from konfera.models.receipt import Receipt
from konfera.settings import UNPAID_ORDER_NOTIFICATION_REPEAT, UNPAID_ORDER_NOTIFICATION_REPEAT_DELAY





class Order(KonferaModel):
    AWAITING = 'awaiting_payment'
    PAID = 'paid'
    PARTLY_PAID = 'partly_paid'
    EXPIRED = 'expired'
    CANCELLED = 'cancelled'

    ORDER_CHOICES = (
        (AWAITING, _('Awaiting payment')),
        (PARTLY_PAID, _('Partly paid')),
        (PAID, _('Paid')),

        (EXPIRED, _('Expired')),