# Generated by Django 5.2.12 on 2026-03-16 04:46

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0003_customuser_branch'),
    ]

    operations = [
        migrations.AddField(
            model_name='customuser',
            name='pin_hash',
            field=models.CharField(blank=True, help_text='Hashed PIN for protected actions', max_length=128),
        ),
        migrations.CreateModel(
            name='AuditLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.CharField(choices=[('login', 'Login'), ('logout', 'Logout'), ('create_user', 'Create User'), ('edit_user', 'Edit User'), ('delete_user', 'Delete User'), ('set_pin', 'Set PIN'), ('pin_verified', 'PIN Verified'), ('add_product', 'Add Product'), ('edit_product', 'Edit Product'), ('delete_product', 'Delete Product'), ('add_category', 'Add Category'), ('edit_category', 'Edit Category'), ('delete_category', 'Delete Category'), ('complete_order', 'Complete Order'), ('cancel_order', 'Cancel Order'), ('clear_credit', 'Clear Credit'), ('stock_adjustment', 'Stock Adjustment'), ('add_customer', 'Add Customer'), ('edit_customer', 'Edit Customer'), ('delete_customer', 'Delete Customer'), ('view_transactions', 'View Transactions'), ('view_pnl', 'View P&L Report'), ('export_data', 'Export Data'), ('other', 'Other')], default='other', max_length=50)),
                ('target', models.CharField(blank=True, help_text="What was acted on, e.g. 'Product: Garri 1kg'", max_length=300)),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('extra', models.JSONField(blank=True, default=dict, help_text='Additional context as JSON')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='audit_logs', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Audit Log',
                'verbose_name_plural': 'Audit Logs',
                'ordering': ['-timestamp'],
            },
        ),
    ]
