some first models of pos & add required to attributes

This commit is contained in:
2025-07-21 09:39:31 +03:30
parent c87204c134
commit ebc79a7dbd
14 changed files with 446 additions and 17 deletions

View File

@@ -0,0 +1,92 @@
# Generated by Django 5.0 on 2025-07-21 06:06
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddField(
model_name='device',
name='acceptor',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='device',
name='company',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='devices', to='pos_device.paymentcompany'),
),
migrations.AddField(
model_name='device',
name='latitude',
field=models.DecimalField(decimal_places=10, max_digits=20, null=True),
),
migrations.AddField(
model_name='device',
name='longitude',
field=models.DecimalField(decimal_places=10, max_digits=20, null=True),
),
migrations.AddField(
model_name='device',
name='multi_device',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='device',
name='password',
field=models.CharField(max_length=25, null=True),
),
migrations.AddField(
model_name='device',
name='serial',
field=models.TextField(null=True),
),
migrations.AddField(
model_name='device',
name='server_in',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='device',
name='terminal',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='paymentcompany',
name='activation',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='paymentcompany',
name='name_en',
field=models.CharField(max_length=250, null=True),
),
migrations.AddField(
model_name='paymentcompany',
name='name_fa',
field=models.CharField(max_length=250, null=True),
),
migrations.CreateModel(
name='DeviceVersion',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('create_date', models.DateTimeField(auto_now_add=True)),
('modify_date', models.DateTimeField(auto_now=True)),
('creator_info', models.CharField(max_length=100, null=True)),
('modifier_info', models.CharField(max_length=100, null=True)),
('trash', models.BooleanField(default=False)),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_createddby', to=settings.AUTH_USER_MODEL)),
('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_modifiedby', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]

View File

@@ -3,10 +3,41 @@ from apps.core.models import BaseModel
class PaymentCompany(BaseModel):
pass
name_fa = models.CharField(max_length=250, null=True)
name_en = models.CharField(max_length=250, null=True)
activation = models.BooleanField(default=False)
def __str__(self):
return f'Payment Company: {self.name_fa}-{self.id}'
def save(self, *args, **kwargs):
return super(PaymentCompany, self).save(*args, **kwargs)
class Device(BaseModel):
acceptor = models.IntegerField(default=0)
terminal = models.IntegerField(default=0)
serial = models.TextField(null=True)
password = models.CharField(max_length=25, null=True)
multi_device = models.BooleanField(default=False)
server_in = models.BooleanField(default=False)
latitude = models.DecimalField(max_digits=20, decimal_places=10, null=True)
longitude = models.DecimalField(max_digits=20, decimal_places=10, null=True)
company = models.ForeignKey(
PaymentCompany,
on_delete=models.CASCADE,
related_name='devices',
null=True
)
def __str__(self):
return f'Device: {self.serial} - {self.id}'
def save(self, *args, **kwargs):
return super(Device, self).save(*args, **kwargs)
class DeviceVersion(BaseModel):
pass