Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ClientData(models.Model):
- ApiKey = models.CharField(max_length=256)
- ApiSecretKey = models.CharField(max_length=256)
- FirstName = models.CharField(max_length=50)
- LastName = models.CharField(max_length=50)
- MobilePhone = models.CharField(max_length=11,unique=True)
- TransactionPin = models.CharField(max_length=4)
- Dni = models.CharField(max_length=20,unique=True)
- DniTypeChoice = {
- ('1', 'V'),
- ('2', 'E'),
- ('3', 'J'),
- ('4', 'P'),
- ('5', 'G'),
- }
- DniType = models.CharField(max_length=1,
- choices=DniTypeChoice)
- Country = models.ForeignKey(Country)
- State = models.ForeignKey(State)
- City = models.ForeignKey(City)
- Address = models.CharField(max_length=500)
- Email = models.EmailField(max_length=100,unique=True)
- Company = models.CharField(max_length=100)
- CompanySectorChoice = {
- ('1', 'Salud y Bienestar'),
- ('2', 'Alimentos y bebidas'),
- ('3', 'Casa y Oficina'),
- ('4', 'Ropa y Accesorios'),
- ('5', 'Entretenimiento y/o actividades recreativas'),
- ('6', 'Transportacion'),
- ('7', 'Alojamiento'),
- ('8', 'Recaudacion de fondos'),
- ('9', 'Venta al menudeo'),
- ('10', 'Servicios Profesionales'),
- ('11', 'Organizaciones civiles'),
- }
- CompanySector = models.CharField(max_length=2,
- choices=CompanySectorChoice,
- default=1)
- Username = models.CharField(max_length=15, unique=True)
- Password = models.CharField(max_length=128)
- RegisterDate = models.DateTimeField(auto_now_add=True)
- LastSeenDate = models.DateTimeField(auto_now_add=True)
- IpAddress = models.CharField(max_length=255,default="0")
- Balance = models.DecimalField(max_digits=9, decimal_places=2)
- android_token = models.CharField(max_length=250,default="0")
- ios_token = models.CharField(max_length=250,default="0")
- ClientStatus = (
- ('1', 'Auditando'),
- ('2', 'Activa'),
- ('3', 'Inactiva'),
- ('4', 'Bloqueada'),
- )
- Status = models.CharField(max_length=1,
- choices=ClientStatus,
- default=2)
- def __unicode__(self):
- return self.FirstName + ' ' + self.LastName
- def available_balance(self):
- return self.Balance
- # Check Client Balance
- def check_balance(self, amount, fee):
- available_amount = float(self.Balance)
- if amount != 0:
- if amount > 0:
- if available_amount >= (amount + fee):
- return True
- else:
- return False
- else:
- return False
- else:
- return False
- # Add Amount to Balance
- def deposit(self, amount):
- self.Balance = (self.Balance + amount)
- self.save()
- # Subtract Amount from Balance
- def withdraw(self, amount):
- self.Balance = (self.Balance - amount)
- self.save()
- def daily_limit(self, amount_limit):
- try:
- today = datetime.datetime.today()
- TransactionObject = Client_Transaction.objects.filter(
- ClientData=self,
- TransactionDate__year=today.year,
- TransactionDate__month=today.month,
- TransactionDate__day=today.day).aggregate(Sum('Amount'))
- if TransactionObject['Amount__sum'] <= amount_limit or TransactionObject['Amount__sum'] == None:
- return True
- else:
- return False
- except:
- return False
- def my_contacts(self):
- try:
- Contacts = ClientContactList.objects.filter(Client=self)
- return Contacts
- except ClientContactList.DoesNotExist:
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement