generated from coulomb/repo-seed
50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
from decimal import Decimal
|
|
|
|
from django.core.exceptions import ValidationError
|
|
from django.db import models
|
|
|
|
from vergabe_teilnahme.apps.core.models import FlexibleModel
|
|
|
|
|
|
class Preispunkt(FlexibleModel):
|
|
ausschreibung = models.ForeignKey(
|
|
'ausschreibungen.Ausschreibung', on_delete=models.CASCADE, related_name='preispunkte'
|
|
)
|
|
los = models.ForeignKey(
|
|
'lose.Los', on_delete=models.SET_NULL, null=True, blank=True, related_name='preispunkte'
|
|
)
|
|
leistungstyp = models.CharField(max_length=200)
|
|
konkrete_leistung = models.CharField(max_length=400)
|
|
mengeneinheit = models.CharField(max_length=50, default='Stück')
|
|
waehrung = models.CharField(max_length=10, default='EUR')
|
|
menge = models.DecimalField(max_digits=14, decimal_places=4, null=True, blank=True)
|
|
einzelpreis = models.DecimalField(max_digits=14, decimal_places=2, null=True, blank=True)
|
|
gesamtpreis = models.DecimalField(max_digits=14, decimal_places=2, null=True, blank=True)
|
|
preisstand = models.DateField(null=True, blank=True)
|
|
wiederkehrend = models.BooleanField(default=False)
|
|
laufzeitbezug = models.CharField(max_length=100, blank=True)
|
|
subunternehmeranteil = models.BooleanField(default=False)
|
|
subunternehmer = models.ForeignKey(
|
|
'partner.Subunternehmer', on_delete=models.SET_NULL,
|
|
null=True, blank=True, related_name='preispunkte'
|
|
)
|
|
vergleichsgewicht = models.DecimalField(max_digits=3, decimal_places=1, default=Decimal('1.0'))
|
|
gewichtungsbegruendung = models.TextField(blank=True)
|
|
kommentar = models.TextField(blank=True)
|
|
ausschreibung_gewonnen = models.BooleanField(null=True)
|
|
|
|
class Meta:
|
|
ordering = ['leistungstyp', 'konkrete_leistung']
|
|
verbose_name = 'Preispunkt'
|
|
verbose_name_plural = 'Preispunkte'
|
|
|
|
def __str__(self):
|
|
return f'{self.leistungstyp} — {self.konkrete_leistung}'
|
|
|
|
def clean(self):
|
|
if self.vergleichsgewicht is not None:
|
|
if self.vergleichsgewicht < Decimal('0.0') or self.vergleichsgewicht > Decimal('2.0'):
|
|
raise ValidationError(
|
|
'Vergleichsgewicht muss zwischen 0,0 und 2,0 liegen.'
|
|
)
|