Vaihe 1/2: asiakkaat, yhteyshenkilöt ja laskutusyksiköt
- customers-moduuli Clean Architecture -kerroksin: asiakas (yritys/kuluttaja), Y-tunnuksen tarkiste ja yksilöllisyys, yhteyshenkilöt, laskutusyksiköt (verkkolaskuosoite vaatii välittäjätunnuksen) - henkilötunnus salattuna (Fernet) ja HMAC-tiiviste päällekkäisyyksiin; pääkäyttäjä ja johto näkevät ja poistavat, muut näkevät peitettynä - sisäinen asiakas data-migraatiolla, ei poistettavissa - yleinen poistonesto käänteisten relaatioiden perusteella (tulevat PROTECT-viiteavaimet estävät poiston automaattisesti) - asiakkaan sivu: lisäys ja muokkaus dialogissa HTMX:llä, fokuksen hallinta ja ruudunlukijailmoitukset; HTMX näyttää nyt 422-validointivirheet - testit: domain, application, integraatio ja selaintestit (axe); yhteiset fixturet apps/conftest.py:hin, FakeUnitOfWork shared-moduuliin - import-linter: moduulien riippumattomuussäännöt - dokumentit päivitetty Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# Generated by Django 5.2.19 on 2026-11-29 11:39
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CustomerModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('type', models.CharField(default='company', max_length=20)),
|
||||
('business_id', models.CharField(blank=True, max_length=9, null=True, unique=True)),
|
||||
('personal_identity_code', models.TextField(blank=True, null=True)),
|
||||
('personal_identity_code_hash', models.CharField(blank=True, max_length=64, null=True, unique=True)),
|
||||
('is_internal', models.BooleanField(default=False)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'customers',
|
||||
'ordering': ['name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ContactModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('name', models.CharField(max_length=150)),
|
||||
('title', models.CharField(blank=True, max_length=150)),
|
||||
('phone', models.CharField(blank=True, max_length=50)),
|
||||
('email', models.EmailField(blank=True, max_length=254)),
|
||||
('note', models.TextField(blank=True)),
|
||||
('customer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='contacts', to='customers.customermodel')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'customer_contacts',
|
||||
'ordering': ['name', 'id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='BillingUnitModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('billing_address', models.TextField(blank=True)),
|
||||
('e_invoice_address', models.CharField(blank=True, max_length=35)),
|
||||
('e_invoice_operator', models.CharField(blank=True, max_length=35)),
|
||||
('reference', models.CharField(blank=True, max_length=100)),
|
||||
('customer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='billing_units', to='customers.customermodel')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'billing_units',
|
||||
'ordering': ['name', 'id'],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
"""Creates the company's own internal customer (specification 4, K39)."""
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_internal_customer(apps, schema_editor):
|
||||
customer = apps.get_model("customers", "CustomerModel")
|
||||
if not customer.objects.filter(is_internal=True).exists():
|
||||
customer.objects.create(name="Oma yritys (sisäinen)", type="company", is_internal=True)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("customers", "0001_initial")]
|
||||
|
||||
operations = [migrations.RunPython(create_internal_customer, migrations.RunPython.noop)]
|
||||
Reference in New Issue
Block a user