fixes, orval, downloader functioning again
This commit is contained in:
0
backend/configuration/management/__init__.py
Normal file
0
backend/configuration/management/__init__.py
Normal file
20
backend/configuration/management/commands/seed_app_config.py
Normal file
20
backend/configuration/management/commands/seed_app_config.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from decimal import Decimal
|
||||
from django.core.management.base import BaseCommand
|
||||
from configuration.models import SiteConfiguration, VATRate
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Ensure SiteConfiguration singleton and default VAT rates exist."
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
config, created = SiteConfiguration.objects.get_or_create(pk=1)
|
||||
if created:
|
||||
self.stdout.write(self.style.SUCCESS("Created default SiteConfiguration."))
|
||||
else:
|
||||
self.stdout.write("SiteConfiguration already exists.")
|
||||
|
||||
if not VATRate.objects.filter(is_active=True).exists():
|
||||
VATRate.objects.create(name="Standard", rate=Decimal('21.0000'), is_default=True, is_active=True)
|
||||
self.stdout.write(self.style.SUCCESS("Created default VAT rate (21%)."))
|
||||
else:
|
||||
self.stdout.write("VAT rates already exist.")
|
||||
@@ -1,4 +1,4 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-24 22:44
|
||||
# Generated by Django 5.2.7 on 2026-04-20 17:54
|
||||
|
||||
import django.core.validators
|
||||
from decimal import Decimal
|
||||
|
||||
26
backend/configuration/migrations/0002_alter_vatrate_rate.py
Normal file
26
backend/configuration/migrations/0002_alter_vatrate_rate.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import django.core.validators
|
||||
from decimal import Decimal
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('configuration', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='vatrate',
|
||||
name='rate',
|
||||
field=models.DecimalField(
|
||||
decimal_places=4,
|
||||
help_text='VAT rate as percentage (e.g. 19.00 for 19%)',
|
||||
max_digits=6,
|
||||
validators=[
|
||||
django.core.validators.MinValueValidator(Decimal('0')),
|
||||
django.core.validators.MaxValueValidator(Decimal('100')),
|
||||
],
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -83,7 +83,7 @@ class VATRate(models.Model):
|
||||
)
|
||||
|
||||
rate = models.DecimalField(
|
||||
max_digits=5,
|
||||
max_digits=6,
|
||||
decimal_places=4, # Allows rates like 19.5000%
|
||||
validators=[MinValueValidator(Decimal('0')), MaxValueValidator(Decimal('100'))],
|
||||
help_text="VAT rate as percentage (e.g. 19.00 for 19%)"
|
||||
|
||||
Reference in New Issue
Block a user