Merge branch 'master' into feature/6561/invoices-webhook
This commit is contained in:
commit
6873d901c9
25 changed files with 892 additions and 182 deletions
|
|
@ -78,13 +78,17 @@ class GenericProduct(AssignPermissionsMixin, models.Model):
|
|||
product_price = models.DecimalField(max_digits=6, decimal_places=2)
|
||||
product_vat = models.DecimalField(max_digits=6, decimal_places=4, default=0)
|
||||
product_is_subscription = models.BooleanField(default=True)
|
||||
product_subscription_interval = models.CharField(
|
||||
max_length=10, default="month",
|
||||
help_text="Choose between `year` and `month`")
|
||||
|
||||
def __str__(self):
|
||||
return self.product_name
|
||||
|
||||
def get_actual_price(self):
|
||||
def get_actual_price(self, vat_rate=None):
|
||||
VAT = vat_rate if vat_rate is not None else self.product_vat
|
||||
return round(
|
||||
self.product_price + (self.product_price * self.product_vat), 2
|
||||
float(self.product_price) + float(self.product_price) * float(VAT), 2
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -322,7 +326,10 @@ class MonthlyHostingBill(AssignPermissionsMixin, models.Model):
|
|||
logger.debug("Neither subscription id nor vm_id available")
|
||||
logger.debug("Can't import invoice")
|
||||
return None
|
||||
|
||||
if args['order'] is None:
|
||||
logger.error(
|
||||
"Order is None for {}".format(args['invoice_id']))
|
||||
return None
|
||||
instance = cls.objects.create(
|
||||
created=datetime.utcfromtimestamp(
|
||||
args['created']).replace(tzinfo=pytz.utc),
|
||||
|
|
@ -340,7 +347,10 @@ class MonthlyHostingBill(AssignPermissionsMixin, models.Model):
|
|||
args['period_start']).replace(tzinfo=pytz.utc),
|
||||
period_end=datetime.utcfromtimestamp(
|
||||
args['period_end']).replace(tzinfo=pytz.utc),
|
||||
billing_reason=args['billing_reason'],
|
||||
billing_reason=(
|
||||
args['billing_reason']
|
||||
if args['billing_reason'] is not None else ''
|
||||
),
|
||||
discount=args['discount'],
|
||||
total=args['total'],
|
||||
lines_data_count=args['lines_data_count'],
|
||||
|
|
@ -469,7 +479,7 @@ class HostingBillLineItem(AssignPermissionsMixin, models.Model):
|
|||
on_delete=models.CASCADE)
|
||||
stripe_plan = models.ForeignKey(StripePlan, null=True,
|
||||
on_delete=models.CASCADE)
|
||||
amount = models.PositiveSmallIntegerField()
|
||||
amount = models.IntegerField()
|
||||
description = models.CharField(max_length=255)
|
||||
discountable = models.BooleanField()
|
||||
metadata = models.CharField(max_length=128)
|
||||
|
|
@ -722,6 +732,16 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
|
|||
return None
|
||||
|
||||
|
||||
class VATRates(AssignPermissionsMixin, models.Model):
|
||||
start_date = models.DateField(blank=True, null=True)
|
||||
stop_date = models.DateField(blank=True, null=True)
|
||||
territory_codes = models.TextField(blank=True, default='')
|
||||
currency_code = models.CharField(max_length=10)
|
||||
rate = models.FloatField()
|
||||
rate_type = models.TextField(blank=True, default='')
|
||||
description = models.TextField(blank=True, default='')
|
||||
|
||||
|
||||
class FailedInvoice(AssignPermissionsMixin, models.Model):
|
||||
permissions = ('view_failedinvoice',)
|
||||
stripe_customer = models.ForeignKey(StripeCustomer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue