Update VMPricing and add get_default_pricing class method

This commit is contained in:
PCoder 2018-04-09 21:17:48 +02:00
parent 2a08c1efd3
commit d07cc41d0a

View file

@ -15,14 +15,33 @@ class VMTemplate(models.Model):
class VMPricing(models.Model): class VMPricing(models.Model):
name = models.CharField(max_length=255, unique=True) name = models.CharField(max_length=255, unique=True)
vat_inclusive = models.BooleanField(default=True) vat_inclusive = models.BooleanField(default=True)
vat_percentage = models.DecimalField(decimal_places=2, blank=True) vat_percentage = models.DecimalField(
cores_unit_price = models.DecimalField(decimal_places=2, default=0) max_digits=7, decimal_places=2, blank=True, default=0
ram_unit_price = models.DecimalField(decimal_places=2, default= 0) )
ssd_unit_price = models.DecimalField(decimal_places=2, default=0) cores_unit_price = models.DecimalField(
hdd_unit_price = models.DecimalField(decimal_places=2, default=0) max_digits=7, decimal_places=2, default=0
)
ram_unit_price = models.DecimalField(
max_digits=7, decimal_places=2, default=0
)
ssd_unit_price = models.DecimalField(
max_digits=7, decimal_places=2, default=0
)
hdd_unit_price = models.DecimalField(
max_digits=7, decimal_places=2, default=0
)
def __str__(self): def __str__(self):
return self.name return self.name + '-' + 'VAT' if self.vat_inclusive else 'NO_VAT'
@classmethod
def get_default_pricing(cls):
""" Returns the default pricing or None """
try:
default_pricing = VMPricing.objects.get(name='default')
except:
default_pricing = None
return default_pricing
class StripePlan(models.Model): class StripePlan(models.Model):