from django.db import models from django.contrib.auth.models import User class Artikal(models.Model): artikal_id = models.AutoField(primary_key=True) sifra = models.CharField(max_length=10) artikal_ime = models.CharField(max_length=100) cena = models.DecimalField(max_digits=10, decimal_places=2) cenasoddv = models.DecimalField(max_digits=10, decimal_places=2) ddvid = models.ForeignKey('Ddv', models.DO_NOTHING, db_column='ddvid', blank=True, null=True) class Meta: managed = False db_table = 'artikal' def __str__(self): return self.artikal_ime class Bank(models.Model): bankid = models.AutoField(primary_key=True) bankime = models.CharField(unique=True, max_length=100) class Meta: managed = False db_table = 'bank' def __str__(self): return self.bankime class Ddv(models.Model): ddvid = models.AutoField(primary_key=True) ddvval = models.SmallIntegerField(unique=True) class Meta: managed = False db_table = 'ddv' def __str__(self): return str(self.ddvval) class Grad(models.Model): gradid = models.AutoField(primary_key=True) gradime = models.CharField(unique=True, max_length=50) postbroj = models.SmallIntegerField(unique=True, blank=True, null=True) class Meta: managed = False db_table = 'grad' def __str__(self): return self.gradime class Klient(models.Model): klientid = models.AutoField(primary_key=True) klientime = models.CharField(max_length=100) adresa = models.CharField(max_length=100, blank=True, null=True) gradid = models.ForeignKey(Grad, models.DO_NOTHING, db_column='gradid', blank=True, null=True) phone = models.CharField(max_length=20, blank=True, null=True) email = models.CharField(max_length=100, blank=True, null=True) edb = models.CharField(unique=True, max_length=13) class Meta: managed = False db_table = 'klient' def __str__(self): return self.klientime class Lagerlist(models.Model): lagerlist_id = models.AutoField(primary_key=True) stavkaid = models.ForeignKey('Stavka', models.DO_NOTHING, db_column='stavkaid', blank=True, null=True) artikal = models.ForeignKey(Artikal, models.DO_NOTHING, blank=True, null=True) kolicina = models.SmallIntegerField() avg_cena = models.DecimalField(max_digits=10, decimal_places=2) class Meta: managed = False db_table = 'lagerlist' class Stavka(models.Model): stavkaid = models.AutoField(primary_key=True) tipid = models.ForeignKey('Tipdok', models.DO_NOTHING, db_column='tipid', blank=True, null=True) created_by = models.ForeignKey('Vraboteni', models.DO_NOTHING, db_column='created_by', blank=True, null=True) datum = models.DateField() broj = models.IntegerField() klientid = models.ForeignKey(Klient, models.DO_NOTHING, db_column='klientid', blank=True, null=True) cena_osnova = models.DecimalField(max_digits=10, decimal_places=2) cena_ddv = models.DecimalField(max_digits=10, decimal_places=2) cena_vkupno = models.DecimalField(max_digits=10, decimal_places=2) class Meta: managed = False db_table = 'stavka' ordering = ['-datum'] class Tipdok(models.Model): tipid = models.SmallIntegerField(primary_key=True) tipime = models.CharField(unique=True, max_length=50) class Meta: managed = False db_table = 'tipdok' def __str__(self): return self.tipime class Vraboteni(models.Model): userid = models.OneToOneField(User, on_delete=models.CASCADE) username = models.CharField(unique=True, max_length=100) password = models.CharField(max_length=100) email = models.CharField(max_length=100) displayname = models.CharField(max_length=100, blank=True, null=True) isadmin = models.BooleanField(blank=True, null=True) class Meta: managed = False db_table = 'vraboteni' class Zirosmetki(models.Model): zirosmetkiid = models.AutoField(primary_key=True) klientid = models.ForeignKey(Klient, models.DO_NOTHING, db_column='klientid', blank=True, null=True) bankid = models.ForeignKey(Bank, models.DO_NOTHING, db_column='bankid', blank=True, null=True) broj = models.CharField(unique=True, max_length=15) class Meta: managed = False db_table = 'zirosmetki' def __str__(self): return self.broj