forked from uncloud/uncloud
Add initial generate-bills and charge-negative-balance uncloud-pay
commands
This commit is contained in:
parent
ef5e7e8035
commit
059791e2f2
10 changed files with 275 additions and 12 deletions
|
|
@ -19,21 +19,26 @@ class RecurringPeriod(models.TextChoices):
|
|||
PER_SECOND = 'SECOND', _('Per Second')
|
||||
|
||||
class Bill(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
owner = models.ForeignKey(get_user_model(),
|
||||
on_delete=models.CASCADE)
|
||||
|
||||
creation_date = models.DateTimeField()
|
||||
creation_date = models.DateTimeField(auto_now_add=True)
|
||||
starting_date = models.DateTimeField()
|
||||
ending_date = models.DateTimeField()
|
||||
due_date = models.DateField()
|
||||
|
||||
paid = models.BooleanField(default=False)
|
||||
valid = models.BooleanField(default=True)
|
||||
|
||||
@property
|
||||
def amount(self):
|
||||
# iterate over all related orders
|
||||
return 20
|
||||
orders = Order.objects.filter(bill=self)
|
||||
amount = 0
|
||||
for order in orders:
|
||||
amount += order.recurring_price
|
||||
|
||||
return amount
|
||||
|
||||
|
||||
|
||||
class Order(models.Model):
|
||||
|
|
@ -49,8 +54,7 @@ class Order(models.Model):
|
|||
|
||||
bill = models.ManyToManyField(Bill,
|
||||
editable=False,
|
||||
blank=True,
|
||||
null=True)
|
||||
blank=True)
|
||||
|
||||
|
||||
recurring_price = models.FloatField(editable=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue