# Generated by Django 5.2.8 on 2025-11-13 20:20

import django.core.validators
import django.db.models.deletion
import django.db.models.expressions
import encrypted_field.fields
import terminusgps.wialon.flags
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('terminusgps_payments', '0002_alter_customerprofile_user'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='TerminusgpsNotificationsCustomer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('company', models.CharField(blank=True, default=None, max_length=64, null=True)),
                ('date_format', models.CharField(choices=[('%Y-%m-%d %H:%M:%S', 'YYYY-MM-DD HH:MM:SS'), ('%Y-%m-%d %H:%M', 'YYYY-MM-DD HH:MM')], default='%Y-%m-%d %H:%M:%S', help_text='Select a date format for notification messages.', max_length=24)),
                ('tax_rate', models.DecimalField(decimal_places=4, default=0.0825, help_text='Enter a tax rate as a decimal.', max_digits=9)),
                ('subtotal', models.DecimalField(decimal_places=2, default=60.0, help_text='Programatically generated customer subtotal amount (base + packages).', max_digits=9)),
                ('tax', models.GeneratedField(db_persist=True, expression=django.db.models.expressions.CombinedExpression(django.db.models.expressions.CombinedExpression(models.F('subtotal'), '*', django.db.models.expressions.CombinedExpression(models.F('tax_rate'), '+', models.Value(1))), '-', models.F('subtotal')), help_text='Automatically generated tax amount.', output_field=models.DecimalField(decimal_places=2, max_digits=9))),
                ('grand_total', models.GeneratedField(db_persist=True, expression=django.db.models.expressions.CombinedExpression(models.F('subtotal'), '*', django.db.models.expressions.CombinedExpression(models.F('tax_rate'), '+', models.Value(1))), help_text='Automatically generated grand total amount (subtotal+tax).', output_field=models.DecimalField(decimal_places=2, max_digits=9))),
                ('messages_max', models.PositiveIntegerField(default=500, verbose_name='maximum executions')),
                ('messages_max_base', models.PositiveIntegerField(default=500, verbose_name='maximum executions base')),
                ('messages_count', models.PositiveIntegerField(default=0, verbose_name='current executions')),
                ('subscription', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='terminusgps_notifications_customer', to='terminusgps_payments.subscription')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='terminusgps_notifications_customer', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'customer',
                'verbose_name_plural': 'customers',
            },
        ),
        migrations.CreateModel(
            name='MessagePackage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('price', models.DecimalField(decimal_places=2, default=40.0, max_digits=9)),
                ('count', models.IntegerField(default=0)),
                ('max', models.IntegerField(default=500)),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='packages', to='terminusgps_notifications.terminusgpsnotificationscustomer')),
            ],
            options={
                'verbose_name': 'message package',
                'verbose_name_plural': 'message packages',
            },
        ),
        migrations.CreateModel(
            name='WialonNotification',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Provide a memorable name.', max_length=64)),
                ('message', models.CharField(help_text='Enter a message.', max_length=1024)),
                ('method', models.CharField(choices=[('sms', 'SMS'), ('voice', 'Voice')], default='sms', help_text='Select a delivery method.', max_length=5)),
                ('activation_time', models.DateTimeField(blank=True, default=None, help_text='Provide a valid date and time in the format: YYYY-MM-DD HH:MM:SS. Leave this blank to activate immediately.', null=True)),
                ('deactivation_time', models.DateTimeField(blank=True, default=None, help_text='Provide a valid date and time in the format: YYYY-MM-DD HH:MM:SS. Leave this blank to never deactivate.', null=True)),
                ('max_alarms', models.PositiveIntegerField(default=0, help_text='Provide the maximum number of alarms. 0 = unlimited alarms.')),
                ('max_message_interval', models.PositiveIntegerField(choices=[(0, 'Any time'), (60, '1 minute'), (600, '10 minutes'), (1800, '30 minutes'), (3600, '1 hour'), (21600, '6 hours'), (43200, '12 hours'), (86400, '1 day'), (864000, '10 days')], default=3600, help_text='Select the maximum allowed time between messages.')),
                ('alarm_timeout', models.PositiveIntegerField(default=0, help_text='Provide the alarm timeout in seconds. 0 = never timeout.', validators=[django.core.validators.MaxValueValidator(1800)])),
                ('control_period', models.PositiveIntegerField(choices=[(0, 'Any time'), (60, 'Last minute'), (600, 'Last 10 minutes'), (3600, 'Last hour'), (86400, 'Last day')], default=3600, help_text='Select a control period relative to current time.')),
                ('min_duration_alarm', models.PositiveIntegerField(default=0, help_text='Provide the minimum duration of alarm state in seconds.', validators=[django.core.validators.MaxValueValidator(86400)])),
                ('min_duration_prev', models.PositiveIntegerField(default=0, validators=[django.core.validators.MaxValueValidator(86400)])),
                ('language', models.CharField(choices=[('en', 'English')], default='en', help_text='Select a valid language.', max_length=2)),
                ('flags', models.PositiveSmallIntegerField(choices=[(0, 'Trigger on first message'), (1, 'Trigger on every message'), (2, 'Disabled')], default=0)),
                ('timezone', models.IntegerField(default=0)),
                ('unit_list', models.JSONField(blank=True, default=list)),
                ('trigger_type', models.CharField(choices=[('geozone', 'Geofence'), ('address', 'Address'), ('speed', 'Speed'), ('alarm', 'Alarm'), ('digital_input', 'Digital input'), ('msg_param', 'Parameter in a message'), ('sensor_value', 'Sensor value'), ('outage', 'Connection loss'), ('interposition', 'Interposition of units'), ('msgs_counter', 'Excess of messages'), ('route_control', 'Route progress'), ('driver', 'Driver'), ('trailer', 'Trailer'), ('service_interals', 'Maintenance'), ('fuel_filling', 'Fuel filling/battery charge'), ('fuel_theft', 'Fuel drain/theft'), ('health_check', 'Health check')], default='sensor_value')),
                ('trigger_parameters', models.JSONField(blank=True, default=dict)),
                ('schedule', models.JSONField(blank=True, default=dict)),
                ('control_schedule', models.JSONField(blank=True, default=dict)),
                ('actions', models.JSONField(blank=True, default=dict)),
                ('text', models.CharField(blank=True, max_length=1024)),
                ('activations', models.PositiveIntegerField(default=0)),
                ('enabled', models.BooleanField(default=True)),
                ('date_created', models.DateTimeField(auto_now_add=True)),
                ('wialon_id', models.PositiveBigIntegerField()),
                ('resource_id', models.PositiveBigIntegerField()),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications', to='terminusgps_notifications.terminusgpsnotificationscustomer')),
            ],
            options={
                'verbose_name': 'wialon notification',
                'verbose_name_plural': 'wialon notifications',
            },
        ),
        migrations.CreateModel(
            name='WialonToken',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', encrypted_field.fields.EncryptedField(max_length=72)),
                ('flags', models.PositiveIntegerField(default=terminusgps.wialon.flags.TokenFlag['VIEW_ACCESS'] | terminusgps.wialon.flags.TokenFlag['MANAGE_NONSENSITIVE'] | terminusgps.wialon.flags.TokenFlag['MANAGE_SENSITIVE'])),
                ('customer', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='token', to='terminusgps_notifications.terminusgpsnotificationscustomer')),
            ],
        ),
    ]
