Add monthlyhostingbill model + code
This commit is contained in:
parent
46c3bb1ce4
commit
0e84081880
2 changed files with 42 additions and 0 deletions
|
@ -232,6 +232,28 @@ class HostingBill(AssignPermissionsMixin, models.Model):
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
class MonthlyHostingBill(AssignPermissionsMixin, models.Model):
|
||||||
|
customer = models.ForeignKey(StripeCustomer)
|
||||||
|
order = models.ForeignKey(HostingOrder)
|
||||||
|
receipt_number = models.CharField(
|
||||||
|
help_text="The receipt number that is generated on Stripe"
|
||||||
|
)
|
||||||
|
invoice_number = models.CharField(
|
||||||
|
help_text="The invoice number that is generated on Stripe"
|
||||||
|
)
|
||||||
|
billing_period = models.CharField(
|
||||||
|
help_text="The billing period for which the bill is valid"
|
||||||
|
)
|
||||||
|
date_paid = models.DateField(help_text="Date on which the bill was paid")
|
||||||
|
|
||||||
|
permissions = ('view_monthlyhostingbill',)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
permissions = (
|
||||||
|
('view_monthlyhostingbill', 'View Monthly Hosting'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class VMDetail(models.Model):
|
class VMDetail(models.Model):
|
||||||
user = models.ForeignKey(CustomUser)
|
user = models.ForeignKey(CustomUser)
|
||||||
vm_id = models.IntegerField(default=0)
|
vm_id = models.IntegerField(default=0)
|
||||||
|
|
|
@ -122,6 +122,26 @@ class StripeUtils(object):
|
||||||
}
|
}
|
||||||
return card_details
|
return card_details
|
||||||
|
|
||||||
|
@handleStripeError
|
||||||
|
def get_all_invoices(self, customer_id):
|
||||||
|
invoices = stripe.Invoice.list(limit=100, customer=customer_id)
|
||||||
|
return_list = []
|
||||||
|
for invoice in invoices:
|
||||||
|
invoice_details = {
|
||||||
|
'created': invoice.created,
|
||||||
|
'receipt_number': invoice.receipt_number,
|
||||||
|
'invoice_number': invoice.number,
|
||||||
|
'date_paid': invoice.date_paid,
|
||||||
|
'period_start': invoice.period_start,
|
||||||
|
'period_end': invoice.period_end,
|
||||||
|
'paid': invoice.paid,
|
||||||
|
'billing_reason': invoice.billing_reason,
|
||||||
|
'discount': invoice.discount.coupon.amount_off if invoice.discount else 0,
|
||||||
|
'total': invoice.total
|
||||||
|
}
|
||||||
|
return_list.append(invoice_details)
|
||||||
|
return return_list
|
||||||
|
|
||||||
@handleStripeError
|
@handleStripeError
|
||||||
def get_cards_details_from_token(self, token):
|
def get_cards_details_from_token(self, token):
|
||||||
stripe_token = stripe.Token.retrieve(token)
|
stripe_token = stripe.Token.retrieve(token)
|
||||||
|
|
Loading…
Reference in a new issue