# Path: authenticating/models.py
# class User(AbstractBaseUser):
#     PasswordsDontMatch = PasswordsDontMatch
#     IncorrectPassword = IncorrectPassword
# 
#     objects = UserManager()
# 
#     id = models.UUIDField(primary_key=True,
#                           unique=True,
#                           editable=False,
#                           default=uuid4)
# 
#     email = models.EmailField(unique=True)
#     verified = models.BooleanField(default=False)
#     verify_key = models.UUIDField(default=uuid4, editable=False, unique=True)
#     timezone = TimeZoneField(default=get_default_timezone)
#     is_staff = models.BooleanField(default=False)
#     is_active = models.BooleanField(default=True)
# 
#     USERNAME_FIELD = 'email'
#     REQUIRED_FIELDS = []
# 
#     def get_full_name(self):
#         return self.get_short_name()
# 
#     def get_short_name(self):
#         return self.email
# 
#     def has_perm(self, *args, **kwargs):
#         return self.is_staff
# 
#     def has_module_perms(self, *args):
#         return self.is_staff
# 
#     def activate_timezone(self):
#         timezone.activate(self.timezone)
# 
#     def send_verification_email(self):
#         if self.verified:
#             return False
#         VerifyUserEmail(user=self).send()
# 
#     def get_verify_link(self):
#         key = str(self.verify_key)
#         path = reverse('verify', args=[key])
#         return expand_url_path(path)
# 
#     def change_password(self, old, new):
#         new, new_copy = new
#         if not new == new_copy:
#             raise self.PasswordsDontMatch
# 
#         if not self.check_password(old):
#             raise self.IncorrectPassword
# 
#         self.set_password(new)
# 
#         self.save()
#         return self


from uuid import uuid4
from decimal import Decimal
from django.db import models
from django.core.validators import MinValueValidator
from django.utils import timezone
from authenticating.models import User
import datetime
        if start_of_day:
            start_of_day = timezone.datetime.combine(start_of_day, datetime.time.min)
            query_set = query_set.filter(timestamp__gte=start_of_day)

        if end_of_day:
            end_of_day = timezone.datetime.combine(end_of_day, datetime.time.max)
            query_set = query_set.filter(timestamp__lte=end_of_day)

        return query_set

    def create_transaction_from_rate_balance(self, user):
        instance = self.model()
        instance.description = 'Rate Total'
        instance.amount = Rate.objects.user(user).total()
        instance.user = user
        return instance

    def bulk_transact_rate_total(self, users):
        return self.bulk_create([self.create_transaction_from_rate_balance(user)
                                 for user in users])


class Transaction(models.Model):
    objects = TransactionQuerySet.as_manager()

    id = models.UUIDField(primary_key=True,
                          editable=False,
                          default=uuid4,
                          unique=True)


# Path: authenticating/models.py
# class User(AbstractBaseUser):
#     PasswordsDontMatch = PasswordsDontMatch
#     IncorrectPassword = IncorrectPassword
# 
#     objects = UserManager()
# 
#     id = models.UUIDField(primary_key=True,
#                           unique=True,
#                           editable=False,
#                           default=uuid4)
# 
#     email = models.EmailField(unique=True)
#     verified = models.BooleanField(default=False)
#     verify_key = models.UUIDField(default=uuid4, editable=False, unique=True)
#     timezone = TimeZoneField(default=get_default_timezone)
#     is_staff = models.BooleanField(default=False)
#     is_active = models.BooleanField(default=True)
# 
#     USERNAME_FIELD = 'email'
#     REQUIRED_FIELDS = []
# 
#     def get_full_name(self):
#         return self.get_short_name()
# 
#     def get_short_name(self):
#         return self.email
# 
#     def has_perm(self, *args, **kwargs):
#         return self.is_staff
# 
#     def has_module_perms(self, *args):
#         return self.is_staff
# 
#     def activate_timezone(self):
#         timezone.activate(self.timezone)
# 
#     def send_verification_email(self):
#         if self.verified:
#             return False
#         VerifyUserEmail(user=self).send()
# 
#     def get_verify_link(self):
#         key = str(self.verify_key)
#         path = reverse('verify', args=[key])
#         return expand_url_path(path)
# 
#     def change_password(self, old, new):
#         new, new_copy = new
#         if not new == new_copy:
#             raise self.PasswordsDontMatch
# 
#         if not self.check_password(old):
#             raise self.IncorrectPassword
# 
#         self.set_password(new)
# 
#         self.save()
#         return self


# Path: tracking/models.py
from uuid import uuid4
from decimal import Decimal
from django.db import models
from django.core.validators import MinValueValidator
from django.utils import timezone
from authenticating.models import User
import datetime

        if start_of_day:
            start_of_day = timezone.datetime.combine(start_of_day, datetime.time.min)
            query_set = query_set.filter(timestamp__gte=start_of_day)

        if end_of_day:
            end_of_day = timezone.datetime.combine(end_of_day, datetime.time.max)
            query_set = query_set.filter(timestamp__lte=end_of_day)

        return query_set

    def create_transaction_from_rate_balance(self, user):
        instance = self.model()
        instance.description = 'Rate Total'
        instance.amount = Rate.objects.user(user).total()
        instance.user = user
        return instance

    def bulk_transact_rate_total(self, users):
        return self.bulk_create([self.create_transaction_from_rate_balance(user)
                                 for user in users])


class Transaction(models.Model):
    objects = TransactionQuerySet.as_manager()

    id = models.UUIDField(primary_key=True,
                          editable=False,
                          default=uuid4,
                          unique=True)


    user = models.ForeignKey(User)