agdar/finance/migrations/0004_csid.py
2025-11-02 14:35:35 +03:00

153 lines
5.6 KiB
Python

# Generated by Django 5.2.7 on 2025-10-27 17:08
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("core", "0002_tenant_address_tenant_city_tenant_country_code_and_more"),
("finance", "0003_alter_historicalinvoice_issue_time_and_more"),
]
operations = [
migrations.CreateModel(
name="CSID",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
(
"csid_type",
models.CharField(
choices=[
("COMPLIANCE", "Compliance CSID"),
("PRODUCTION", "Production CSID"),
],
default="PRODUCTION",
max_length=20,
verbose_name="CSID Type",
),
),
(
"certificate",
models.TextField(
help_text="Base64 encoded certificate", verbose_name="Certificate"
),
),
(
"secret",
models.CharField(
help_text="CSID secret (encrypted)", max_length=500, verbose_name="Secret"
),
),
(
"request_id",
models.CharField(
blank=True,
help_text="Request ID from compliance CSID",
max_length=100,
verbose_name="Request ID",
),
),
(
"egs_serial_number",
models.CharField(
help_text="Format: 1-Manufacturer|2-Model|3-SerialNumber",
max_length=200,
verbose_name="EGS Serial Number",
),
),
(
"common_name",
models.CharField(
help_text="Name or Asset Tracking Number for the Solution Unit",
max_length=200,
verbose_name="Common Name",
),
),
(
"organization_unit",
models.CharField(
blank=True,
help_text="Branch name or TIN for VAT groups",
max_length=200,
verbose_name="Organization Unit",
),
),
("issue_date", models.DateTimeField(verbose_name="Issue Date")),
("expiry_date", models.DateTimeField(verbose_name="Expiry Date")),
(
"status",
models.CharField(
choices=[
("ACTIVE", "Active"),
("EXPIRED", "Expired"),
("REVOKED", "Revoked"),
("PENDING", "Pending"),
],
default="ACTIVE",
max_length=20,
verbose_name="Status",
),
),
(
"revocation_date",
models.DateTimeField(blank=True, null=True, verbose_name="Revocation Date"),
),
(
"revocation_reason",
models.TextField(blank=True, verbose_name="Revocation Reason"),
),
(
"invoices_signed",
models.PositiveIntegerField(
default=0,
help_text="Number of invoices signed with this CSID",
verbose_name="Invoices Signed",
),
),
(
"last_used",
models.DateTimeField(blank=True, null=True, verbose_name="Last Used"),
),
(
"tenant",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="%(app_label)s_%(class)s_related",
to="core.tenant",
verbose_name="Tenant",
),
),
],
options={
"verbose_name": "CSID",
"verbose_name_plural": "CSIDs",
"ordering": ["-issue_date"],
"indexes": [
models.Index(
fields=["tenant", "status"], name="finance_csi_tenant__e5c333_idx"
),
models.Index(
fields=["expiry_date", "status"], name="finance_csi_expiry__aad57d_idx"
),
models.Index(
fields=["egs_serial_number"], name="finance_csi_egs_ser_e0fc55_idx"
),
],
},
),
]