# Generated by Django 3.2.8 on 2022-01-11 05:36

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='EInvoice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('07', 'General'), ('08', 'Special')], default='07', max_length=2)),
                ('track', models.CharField(db_index=True, max_length=2)),
                ('no', models.CharField(max_length=8)),
                ('carrier_type', models.CharField(choices=[('3J0002', 'Mobile barcode')], db_index=True, default='', max_length=6)),
                ('carrier_id1', models.CharField(db_index=True, default='', max_length=64)),
                ('carrier_id2', models.CharField(db_index=True, default='', max_length=64)),
                ('npoban', models.CharField(db_index=True, default='', max_length=7)),
                ('print_mark', models.BooleanField(default=False)),
                ('random_number', models.CharField(db_index=True, max_length=4)),
                ('generate_time', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('generate_no', models.CharField(default='', max_length=40)),
                ('generate_no_sha1', models.CharField(default='', max_length=10)),
                ('batch_id', models.SmallIntegerField(default=0)),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('seller_identifier', models.CharField(db_index=True, max_length=8)),
                ('seller_name', models.CharField(db_index=True, default='', max_length=60)),
                ('seller_address', models.CharField(db_index=True, default='', max_length=100)),
                ('seller_person_in_charge', models.CharField(db_index=True, default='', max_length=30)),
                ('seller_telephone_number', models.CharField(db_index=True, default='', max_length=26)),
                ('seller_facsimile_number', models.CharField(db_index=True, default='', max_length=26)),
                ('seller_email_address', models.CharField(db_index=True, default='', max_length=80)),
                ('seller_customer_number', models.CharField(db_index=True, default='', max_length=20)),
                ('seller_role_remark', models.CharField(db_index=True, default='', max_length=40)),
                ('buyer_identifier', models.CharField(db_index=True, max_length=10)),
                ('buyer_name', models.CharField(db_index=True, default='', max_length=60)),
                ('buyer_address', models.CharField(db_index=True, default='', max_length=100)),
                ('buyer_person_in_charge', models.CharField(db_index=True, default='', max_length=30)),
                ('buyer_telephone_number', models.CharField(db_index=True, default='', max_length=26)),
                ('buyer_facsimile_number', models.CharField(db_index=True, default='', max_length=26)),
                ('buyer_email_address', models.CharField(db_index=True, default='', max_length=80)),
                ('buyer_customer_number', models.CharField(db_index=True, default='', max_length=20)),
                ('buyer_role_remark', models.CharField(db_index=True, default='', max_length=40)),
                ('details', models.JSONField()),
                ('amounts', models.JSONField()),
            ],
        ),
        migrations.CreateModel(
            name='EInvoiceSellerAPI',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('AppId', models.CharField(max_length=18, unique=True)),
                ('APIKey', models.CharField(max_length=24)),
                ('proxy', models.CharField(max_length=64, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='ESCPOSWeb',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=32)),
                ('slug', models.CharField(default='', max_length=5)),
                ('hash_key', models.CharField(default='', max_length=40)),
            ],
            options={
                'permissions': (('operate_te_escposweb', 'Operate ESCPOSWeb'), ('edit_te_escposweboperator', 'Edit the operators of ESCPOSWeb')),
            },
        ),
        migrations.CreateModel(
            name='LegalEntity',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('identifier', models.CharField(db_index=True, max_length=10)),
                ('name', models.CharField(db_index=True, default='', max_length=60)),
                ('address', models.CharField(db_index=True, default='', max_length=100)),
                ('person_in_charge', models.CharField(db_index=True, default='', max_length=30)),
                ('telephone_number', models.CharField(db_index=True, default='', max_length=26)),
                ('facsimile_number', models.CharField(db_index=True, default='', max_length=26)),
                ('email_address', models.CharField(db_index=True, default='', max_length=80)),
                ('customer_number_char', models.CharField(db_index=True, default='', max_length=20)),
                ('role_remark', models.CharField(db_index=True, default='', max_length=40)),
            ],
            options={
                'unique_together': {('identifier', 'customer_number_char')},
            },
            bases=(models.Model, taiwan_einvoice.models.IdentifierRule),
        ),
        migrations.CreateModel(
            name='Seller',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('print_with_seller_optional_fields', models.BooleanField(default=False)),
                ('print_with_buyer_optional_fields', models.BooleanField(default=False)),
                ('legal_entity', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.legalentity', unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='UserConnectESCPOSWebLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('channel_name', models.CharField(default='', max_length=255)),
                ('is_connected', models.BooleanField(default=True)),
                ('escpos_web', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.escposweb')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='TurnkeyWeb',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('on_working', models.BooleanField(default=True)),
                ('name', models.CharField(max_length=32, unique=True)),
                ('hash_key', models.CharField(max_length=40)),
                ('transport_id', models.CharField(max_length=10)),
                ('party_id', models.CharField(max_length=10)),
                ('routing_id', models.CharField(max_length=39)),
                ('qrcode_seed', models.CharField(max_length=40)),
                ('turnkey_seed', models.CharField(max_length=40)),
                ('download_seed', models.CharField(max_length=40)),
                ('epl_base_set', models.CharField(default='', max_length=64)),
                ('warning_above_amount', models.IntegerField(default=10000)),
                ('forbidden_above_amount', models.IntegerField(default=20000)),
                ('note', models.TextField()),
                ('seller', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.seller')),
            ],
            options={
                'permissions': (('edit_te_turnkeywebgroup', 'Edit the groups of TurnkeyWebnn'), ('view_te_sellerinvoicetrackno', 'View Seller Invoice Track No'), ('add_te_sellerinvoicetrackno', 'Add Seller Invoice Track No'), ('delete_te_sellerinvoicetrackno', 'Delete Seller Invoice Track No'), ('view_te_einvoice', 'View E-Invoice'), ('view_te_canceleinvoice', 'View Cancel E-Invoice'), ('add_te_canceleinvoice', 'Add Cancel E-Invoice'), ('view_te_einvoiceprintlog', 'View E-Invoice Print Log')),
                'unique_together': {('seller', 'name')},
            },
        ),
        migrations.CreateModel(
            name='StaffProfile',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nickname', models.CharField(default='', max_length=255)),
                ('is_active', models.BooleanField(default=True)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='SellerInvoiceTrackNo',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('07', 'General'), ('08', 'Special')], default='07', max_length=2)),
                ('begin_time', models.DateTimeField()),
                ('end_time', models.DateTimeField()),
                ('track', models.CharField(max_length=2)),
                ('begin_no', models.IntegerField()),
                ('end_no', models.IntegerField()),
                ('turnkey_web', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.turnkeyweb')),
            ],
            options={
                'unique_together': {('type', 'begin_time', 'end_time', 'track', 'begin_no', 'end_no')},
            },
        ),
        migrations.CreateModel(
            name='Printer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('serial_number', models.CharField(max_length=128, unique=True)),
                ('nickname', models.CharField(max_length=64, unique=True)),
                ('receipt_type', models.CharField(choices=[('5', '58mm Receipt'), ('6', '58mm E-Invoice'), ('8', '80mm Receipt')], max_length=1)),
                ('escpos_web', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.escposweb')),
            ],
        ),
        migrations.CreateModel(
            name='HistoricalTurnkeyWeb',
            fields=[
                ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('on_working', models.BooleanField(default=True)),
                ('name', models.CharField(db_index=True, max_length=32)),
                ('hash_key', models.CharField(max_length=40)),
                ('transport_id', models.CharField(max_length=10)),
                ('party_id', models.CharField(max_length=10)),
                ('routing_id', models.CharField(max_length=39)),
                ('qrcode_seed', models.CharField(max_length=40)),
                ('turnkey_seed', models.CharField(max_length=40)),
                ('download_seed', models.CharField(max_length=40)),
                ('epl_base_set', models.CharField(default='', max_length=64)),
                ('warning_above_amount', models.IntegerField(default=10000)),
                ('forbidden_above_amount', models.IntegerField(default=20000)),
                ('note', models.TextField()),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('seller', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='taiwan_einvoice.seller')),
            ],
            options={
                'verbose_name': 'historical turnkey web',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='EInvoicePrintLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_original_copy', models.BooleanField(default=True)),
                ('done_status', models.BooleanField(default=False)),
                ('print_time', models.DateTimeField(null=True)),
                ('reason', models.TextField(default='')),
                ('einvoice', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.einvoice')),
                ('printer', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.printer')),
                ('user', models.ForeignKey(default=102, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='EInvoiceAPIResult',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('1', 'mobile-barcode'), ('2', 'donate-mark'), ('3', 'seller-enable-einvoice'), ('4', 'seller-identifier')], max_length=1)),
                ('key', models.CharField(max_length=40)),
                ('success', models.BooleanField(default=False)),
                ('value', models.TextField()),
            ],
            options={
                'unique_together': {('type', 'key')},
            },
        ),
        migrations.AddField(
            model_name='einvoice',
            name='buyer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.legalentity'),
        ),
        migrations.AddField(
            model_name='einvoice',
            name='content_type',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='contenttypes.contenttype'),
        ),
        migrations.AddField(
            model_name='einvoice',
            name='creator',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='einvoice',
            name='seller_invoice_track_no',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.sellerinvoicetrackno'),
        ),
        migrations.CreateModel(
            name='CancelEInvoice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('seller_identifier', models.CharField(db_index=True, max_length=8)),
                ('buyer_identifier', models.CharField(db_index=True, max_length=10)),
                ('generate_time', models.DateTimeField()),
                ('reason', models.CharField(max_length=20)),
                ('return_tax_document_number', models.CharField(blank=True, default='', max_length=60, null=True)),
                ('remark', models.CharField(blank=True, default='', max_length=200, null=True)),
                ('creator', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
                ('einvoice', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.einvoice')),
                ('new_einvoice', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='new_einvoice_cancel_einvoice_set', to='taiwan_einvoice.einvoice')),
            ],
        ),
        migrations.CreateModel(
            name='ESCPOSWebConnectionLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('seed', models.CharField(max_length=15)),
                ('escpos_web', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='taiwan_einvoice.escposweb')),
            ],
            options={
                'unique_together': {('escpos_web', 'seed')},
            },
        ),
        migrations.AlterUniqueTogether(
            name='einvoice',
            unique_together={('seller_invoice_track_no', 'track', 'no')},
        ),
    ]
