Skip to content

Instantly share code, notes, and snippets.

@PCreations
Last active August 29, 2015 14:25
Show Gist options
  • Save PCreations/06d6e52d102bc4d93ffa to your computer and use it in GitHub Desktop.
Save PCreations/06d6e52d102bc4d93ffa to your computer and use it in GitHub Desktop.
from decimal import Decimal
from django.db import models
from django.utils.translation import ugettext_lazy as _
VAT_CHOICES = (
(Decimal("0.00"), '0%'),
(Decimal("2.10"), '2.1%'),
(Decimal("5.50"), '5.5%'),
(Decimal("8.50"), '8.5%'),
(Decimal("10.00"), '10%'),
(Decimal("20.00"), '20%'),
)
class Service(models.Model):
name = models.CharField(max_length=255)
buying_vat = models.DecimalField(_("buying VAT"),
max_digits=8,
decimal_places=2,
choices=VAT_CHOICES,
selling_vat = models.DecimalField(_("selling VAT"),
max_digits=8,
decimal_places=2,
choices=VAT_CHOICES,
class Option(models.Model):
name = models.CharField(max_length=255)
services = models.ManyToManyField(Service, through="OptionService")
class OptionService(models.Model):
option = models.ForeignKey(Option)
service = models.ForeignKey(Service)
price = models.DecimalField(_("Selling price with tax"),
max_digits=8,
decimal_places=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment