예제 #1
0
class Info(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    cli = models.ForeignKey(Client, on_delete=models.CASCADE)
    partenaire = models.ForeignKey(Partenaire, on_delete=models.CASCADE)
    typ = models.ForeignKey(Type, on_delete=models.CASCADE)
    etat = models.ForeignKey(Etat, on_delete=models.CASCADE)
    facture = models.BooleanField()
    dateCreation = MonthField()
    dateCloture = MonthField()
    dateInstallation = models.DateField(null=True)
예제 #2
0
class Education(models.Model):

    resume = models.ForeignKey(Resume)
    institution = models.CharField(max_length=100)
    degree = models.CharField(max_length=100)
    graduation = MonthField("Month Value",
                            help_text="Year-month of graduation")
    start = MonthField("Month Value", help_text="Year-month of start")
    text = models.TextField(
        help_text=
        "Please enter few words regarding the education in the institute.")
예제 #3
0
class Experience(models.Model):

    resume = models.ForeignKey(Resume)
    institution = models.CharField(max_length=100)
    title = models.CharField(max_length=100)
    start_date = MonthField("Month Value", help_text="Year-month of start")
    end_date = MonthField("Month Value",
                          help_text="Year-month of end",
                          null=True,
                          blank=True)
    still_working = models.BooleanField(default=False)
    text = models.TextField(
        help_text="Please enter few words regarding the work in the institute."
    )
예제 #4
0
class Info(models.Model):
    cli = models.ForeignKey(Client, on_delete=models.CASCADE)
    partenaire = models.ForeignKey(Partenaire, on_delete=models.CASCADE)
    typ = models.ForeignKey(Type, on_delete=models.CASCADE)
    marge = models.FloatField(null=True)
    recurrent = models.FloatField(null=True)
    etat = models.ForeignKey(Etat, on_delete=models.CASCADE)
    facture = models.BooleanField()
    dateCreation = MonthField()
    dateCloture = MonthField()
    dateInstallation = models.DateField(null=True)

    def __unicode__(self):
        return unicode(self.month)
예제 #5
0
class Fee(models.Model):
    date = MonthField(db_index=True, default=timezone.now)
    lot = models.ForeignKey(Lot, on_delete=models.PROTECT)
    amount = models.DecimalField(max_digits=13, decimal_places=2)

    class Meta:
        ordering = ["date"]

    def __str__(self):
        return date(self.date, "Y/m") + ' ' + self.lot.name + ' ' + str(
            self.amount)

    @staticmethod
    def create_fees(ids, start_date, end_date):
        from django.db import connection
        with connection.cursor() as cursor:
            sql = '''INSERT INTO revenue_fee ("date", amount, lot_id)
              SELECT t::date, default_fee, id
              FROM lots_lot
              CROSS JOIN generate_series(timestamp %s, timestamp %s, '1 month') t
              WHERE id IN %s
            '''

            cursor.execute(sql, [start_date, end_date, ids])
            return cursor.rowcount
예제 #6
0
class DadosDasEmpresas(models.Model):
    arquivo = models.FileField(
        'Arquivo de registros, favor entrar com formato .json',
        validators=[
            FileExtensionValidator(allowed_extensions=['json']), file_size
        ])
    empresa = models.ForeignKey(Empresa, on_delete=models.CASCADE)
    month = MonthField("Selecione o ano e o mês do registro")
예제 #7
0
파일: models.py 프로젝트: DieNice/Plutos
class Personalbudget(models.Model):
    id_user = models.ForeignKey(User,
                                related_name='budgets',
                                on_delete=models.CASCADE)
    balance = models.FloatField(null=False)
    month = MonthField(null=True)

    def __unicode__(self):
        return str(self.month)
예제 #8
0
class FeeLine(models.Model):
    receipt = models.ForeignKey(Receipt, on_delete=models.CASCADE)
    amount = models.DecimalField(max_digits=13, decimal_places=2)
    discount = models.DecimalField(max_digits=13,
                                   decimal_places=2,
                                   default=Decimal('0.00'))
    date = MonthField(db_index=True, default=timezone.now)
    lot = models.ForeignKey(Lot, on_delete=models.PROTECT)

    def __str__(self):
        return date(self.date, "Y/m") + ' ' + self.lot.name + ' ' + str(
            self.amount)
예제 #9
0
class HomeWaterConsumption(models.Model):
    id = models.AutoField(primary_key=True)
    home = models.ForeignKey("home_details.Home", on_delete=models.CASCADE)
    date = MonthField("Month Value", help_text="Month Value")
    water_consumption = models.IntegerField()
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ["home", "date"]
        unique_together = ['home', 'date']

    def __str__(self):
        return f'Home Water Consumption : Date: {self.date} , Water Consumption {self.water_consumption}, Home : {self.home.home_name}, Reservoir : {self.home.reservoir.name}'
예제 #10
0
파일: models.py 프로젝트: lgoldbach/parkour
class InvoicingReport(DateTimeMixin):
    month = MonthField('Month', unique=True)
    report = models.FileField(
        verbose_name='Report',
        upload_to='invoicing/%Y/%m/',
    )

    class Meta:
        verbose_name = 'Invoicing Report'
        verbose_name_plural = 'Invoicing Report'
        ordering = ['-month']

    def __str__(self):
        return f'{calendar.month_name[self.month.month]} {self.month.year}'
예제 #11
0
class OrderReport(models.Model):

    customer = models.ForeignKey(CustomerProfile,
                                 on_delete=models.CASCADE,
                                 related_name='monthly_reports')

    month = MonthField()

    orders = models.PositiveIntegerField(default=0)

    weights = models.DecimalField(default=0, max_digits=10, decimal_places=2)

    class Meta:
        ordering = ('-month', )
예제 #12
0
class WaterLevel(models.Model):
    id = models.AutoField(primary_key=True)
    reservoir = models.ForeignKey(
        "reservoirs.Reservoir", on_delete=models.CASCADE)
    date = MonthField("Month Value", help_text="Month Value")
    water_level = models.IntegerField()
    rainfall = models.IntegerField()
    temperature = models.IntegerField()
    evaporation = models.IntegerField()
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ["reservoir", "date"]
        unique_together = ['reservoir', 'date']

    def __str__(self):
        return 'Water Level : ' + self.reservoir.name + ", " + str(self.date)
예제 #13
0
class WaterConsumptionDomestic(models.Model):
    id = models.AutoField(primary_key=True)
    reservoir = models.ForeignKey("reservoirs.Reservoir",
                                  on_delete=models.CASCADE)
    date = MonthField("Month Value", help_text="Month Value")
    water_consumption_domestic = models.IntegerField()
    population = models.IntegerField()
    no_of_families = models.IntegerField()
    no_of_housing_units = models.IntegerField()
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ["reservoir", "date"]
        unique_together = ['reservoir', 'date']

    def __str__(self):
        return 'Water Consumption Domestic : ' + self.reservoir.name + ", " + str(
            self.date)
예제 #14
0
class CollectedCustomer(models.Model):
    collection_agent = models.ForeignKey(User, on_delete=models.CASCADE)
    customer = models.ForeignKey(to=customermodels.Customer,
                                 on_delete=models.CASCADE)
    collected_date = models.DateTimeField(auto_now_add=True)
    month = MonthField(auto_now_add=True)
    collected_amount = models.FloatField()
    street = models.CharField(max_length=50, blank=True)

    class Meta:
        constraints = [
            models.UniqueConstraint(fields=['customer', 'month'], name='ucc')
        ]

    def __str__(self):
        return f"{self.customer}"

    def save(self, *args, **kwargs):
        self.street = self.customer.street
        super(CollectedCustomer, self).save(*args, **kwargs)
예제 #15
0
class MonthlyBudget(models.Model):
    budget = models.ForeignKey('Budget',
                               on_delete=models.CASCADE,
                               related_name='months')
    month = MonthField()
    planned = models.DecimalField(max_digits=12, decimal_places=2)

    class Meta:
        unique_together = ('budget', 'month')
        ordering = ('month', 'budget__name')

    def __str__(self):
        return '{} ({})'.format(self.budget, self.month._date.strftime('%B'))

    @property
    def executed(self):
        return abs(
            self.transactions.aggregate(s=Coalesce(Sum('amount'), 0))['s'])

    @property
    def balance(self):
        return self.planned - self.executed
예제 #16
0
class JobReport(models.Model):

    driver = models.ForeignKey(User,
                               on_delete=models.CASCADE,
                               related_name='report')

    month = MonthField()

    total_mileage = models.PositiveIntegerField(default=0)

    empty_mileage = models.PositiveIntegerField(default=0)

    heavy_mileage = models.PositiveIntegerField(default=0)

    highway_mileage = models.PositiveIntegerField(default=0)

    normalway_mileage = models.PositiveIntegerField(default=0)

    def __str__(self):
        return '{}\'s {} report'.format(self.driver, self.month)

    class Meta:
        ordering = ('-month', )
class CustomerReport(models.Model):
    customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
    customer_name = models.CharField(max_length=50, blank=True)
    payment_amount = models.CharField(max_length=4, blank=True, null=True)
    payment_mode = models.CharField(choices=[('online', 'ONLINE'),
                                             ('offline', 'OFFLINE')],
                                    max_length=7,
                                    default='offline')
    payment_date = models.DateTimeField(auto_now_add=True)
    payment_month = MonthField(auto_now_add=True)

    class Meta:
        constraints = [
            models.UniqueConstraint(fields=['customer', 'payment_month'],
                                    name='um')
        ]

    def __str__(self):
        return f"{self.customer_name}"

    def save(self, *args, **kwargs):
        self.customer_name = self.customer.name
        self.payment_amount = self.customer.payment_amount
        super(CustomerReport, self).save(*args, **kwargs)
class Bug_Movimiento(models.Model):
    concepto = models.ForeignKey('prueba.Concepto', on_delete=models.PROTECT)
    mes_inicio = MonthField()
예제 #19
0
class Example(models.Model):
    name = models.CharField(max_length=20, blank=True)
    month = MonthField()
    def __unicode__(self):
        return unicode(self.month)
예제 #20
0
class RDate(models.Model):
    month = MonthField("Month Value")
    pourcentage = models.ForeignKey(Pourcentage, on_delete=models.CASCADE)

    def __str__(self):
        return f'{self.month}, {self.pourcentage.pourcentage}'
예제 #21
0
class Example(models.Model):
    name = models.CharField(max_length=20, blank=True)
    month = MonthField("Month Value", help_text="some help...")

    def __unicode__(self):
        return unicode(self.month)
예제 #22
0
파일: models.py 프로젝트: th-thomas/Frais
class FicheFrais(models.Model):
    class Etat(models.TextChoices):
        CLOTUREE = 'CL', _('Saisie clôturée')
        ENCOURS = 'CR', _('Fiche créée, saisie en cours')
        REMBOURSEE = 'RB', _('Remboursée')
        VALIDEE = 'VA', _('Validée et mise en paiement')

    etat = models.CharField(max_length=3,
                            choices=Etat.choices,
                            default=Etat.ENCOURS)
    visiteur = models.ForeignKey('Visiteur',
                                 on_delete=models.RESTRICT,
                                 default=None)
    mois = MonthField(null=False, blank=False)
    # nb_justificatifs = models.PositiveIntegerField(blank=True, default=0)
    # montant_valide = models.DecimalField(max_digits=10, decimal_places=2, blank=True, default=0)
    date_modif = models.DateField(blank=True, auto_now=True)

    def montant_valide(self):
        if (self.etat
                == FicheFrais.Etat.REMBOURSEE) or (self.etat
                                                   == FicheFrais.Etat.VALIDEE):
            return self.total_frais_forfaitaires(
            ) + self.total_frais_horsforfait()
        else:
            return 0

    def nb_justificatifs(self):
        return self.lignefraishorsforfait_set.count()

    def total_frais_forfaitaires(self):
        total = 0
        for ligne in self.lignefraisforfait_set.all():
            total += ligne.total
        return total

    def total_frais_horsforfait(self):
        total = 0
        for ligne in self.lignefraishorsforfait_set.all():
            total += ligne.montant
        return total

    class Meta:
        verbose_name = 'Fiche de frais'
        verbose_name_plural = 'Fiches de frais'
        unique_together = (('mois', 'visiteur'), )

    def __str__(self):
        return str(self.mois) + ' ' + self.visiteur.__str__()

    def save(self, *args, **kwargs):
        is_new = True if not self.id else False
        super(FicheFrais, self).save(*args, **kwargs)
        if is_new:
            LigneFraisForfait.objects.create(
                fiche=self, frais_forfait=LigneFraisForfait.FraisForfait.ETAPE)
            LigneFraisForfait.objects.create(
                fiche=self,
                frais_forfait=LigneFraisForfait.FraisForfait.FRAISKM)
            LigneFraisForfait.objects.create(
                fiche=self,
                frais_forfait=LigneFraisForfait.FraisForfait.NUITHOTEL)
            LigneFraisForfait.objects.create(
                fiche=self,
                frais_forfait=LigneFraisForfait.FraisForfait.RESTAU)

    def get_absolute_url(self):
        return reverse('une-fiche', args=[(self.mois.strftime('%Y%m'))])