-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
37 lines (26 loc) · 1.35 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from django.db import models
from model_utils import Choices
from wingtel.subscriptions.models import Subscription
class DataUsageRecord(models.Model):
"""Raw data usage record for a subscription"""
subscription_id = models.ForeignKey(Subscription, null=True, on_delete=models.PROTECT)
price = models.DecimalField(decimal_places=2, max_digits=5, default=0)
usage_date = models.DateTimeField(null=False)
kilobytes_used = models.IntegerField(null=False)
class VoiceUsageRecord(models.Model):
"""Raw voice usage record for a subscription"""
subscription_id = models.ForeignKey(Subscription, null=True, on_delete=models.PROTECT)
price = models.DecimalField(decimal_places=2, max_digits=5, default=0)
usage_date = models.DateTimeField(null=False)
seconds_used = models.IntegerField(null=False)
class UsageRecord(models.Model):
"""Aggregate representation for usage record"""
USAGE_TYPES = Choices(
("data", "DataUsage"),
("voice", "VoiceUsage"),
)
type_of_usage = models.CharField(max_length=100, choices=USAGE_TYPES, db_index=True)
subscription = models.ForeignKey(Subscription, null=True, on_delete=models.PROTECT)
price = models.DecimalField(decimal_places=2, max_digits=10, default=0)
usage_date = models.DateField(null=False, db_index=True)
used = models.IntegerField(null=False)