Coverage for modules\erp\migrations\0001_initial.py: 100%
10 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-05 09:24 +0800
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-05 09:24 +0800
1# Generated by Django 5.1.15 on 2026-09-01 14:58
3import django.db.models.deletion
4import django.utils.timezone
5import uuid
6from decimal import Decimal
7from django.conf import settings
8from django.db import migrations, models
11class Migration(migrations.Migration):
13 initial = True
15 dependencies = [
16 migrations.swappable_dependency(settings.AUTH_USER_MODEL),
17 ]
19 operations = [
20 migrations.CreateModel(
21 name='Account',
22 fields=[
23 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
24 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
25 ('updated_at', models.DateTimeField(auto_now=True)),
26 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
27 ('code', models.CharField(db_index=True, max_length=32)),
28 ('name', models.CharField(max_length=128)),
29 ('type', models.CharField(choices=[('ASSET', 'Asset'), ('LIABILITY', 'Liability'), ('EQUITY', 'Equity'), ('REVENUE', 'Revenue'), ('EXPENSE', 'Expense')], max_length=32)),
30 ('currency', models.CharField(default='PHP', max_length=3)),
31 ('is_active', models.BooleanField(default=True)),
32 ],
33 options={
34 'ordering': ['code'],
35 'unique_together': {('tenant_id', 'code')},
36 },
37 ),
38 migrations.CreateModel(
39 name='Invoice',
40 fields=[
41 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
42 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
43 ('updated_at', models.DateTimeField(auto_now=True)),
44 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
45 ('invoice_number', models.CharField(db_index=True, max_length=64)),
46 ('customer_name', models.CharField(max_length=255)),
47 ('customer_email', models.EmailField(blank=True, max_length=254, null=True)),
48 ('deal_id', models.UUIDField(blank=True, null=True)),
49 ('issue_date', models.DateField(default=django.utils.timezone.now)),
50 ('due_date', models.DateField()),
51 ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('SENT', 'Sent'), ('PAID', 'Paid'), ('PARTIALLY_PAID', 'Partially Paid'), ('VOID', 'Void'), ('OVERDUE', 'Overdue')], default='DRAFT', max_length=32)),
52 ('currency', models.CharField(default='PHP', max_length=3)),
53 ('subtotal', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
54 ('tax_total', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
55 ('total_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
56 ('amount_paid', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
57 ('notes', models.TextField(blank=True, null=True)),
58 ('terms', models.TextField(blank=True, null=True)),
59 ],
60 options={
61 'ordering': ['-issue_date', '-created_at'],
62 'unique_together': {('tenant_id', 'invoice_number')},
63 },
64 ),
65 migrations.CreateModel(
66 name='JournalEntry',
67 fields=[
68 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
69 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
70 ('updated_at', models.DateTimeField(auto_now=True)),
71 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
72 ('entry_number', models.CharField(db_index=True, max_length=64)),
73 ('date', models.DateField(default=django.utils.timezone.now)),
74 ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('POSTED', 'Posted'), ('VOIDED', 'Voided')], default='DRAFT', max_length=16)),
75 ('reference_type', models.CharField(blank=True, max_length=64, null=True)),
76 ('reference_id', models.UUIDField(blank=True, null=True)),
77 ('posted_at', models.DateTimeField(blank=True, null=True)),
78 ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
79 ],
80 options={
81 'ordering': ['-date', '-created_at'],
82 'unique_together': {('tenant_id', 'entry_number')},
83 },
84 ),
85 migrations.CreateModel(
86 name='JournalItem',
87 fields=[
88 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
89 ('tenant_id', models.UUIDField(db_index=True)),
90 ('debit_amount', models.DecimalField(decimal_places=4, default=Decimal('0.0000'), max_digits=18)),
91 ('credit_amount', models.DecimalField(decimal_places=4, default=Decimal('0.0000'), max_digits=18)),
92 ('description', models.CharField(blank=True, max_length=255, null=True)),
93 ('account', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='journal_items', to='erp.account')),
94 ('journal_entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='erp.journalentry')),
95 ],
96 options={
97 'abstract': False,
98 },
99 ),
100 migrations.CreateModel(
101 name='Product',
102 fields=[
103 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
104 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
105 ('updated_at', models.DateTimeField(auto_now=True)),
106 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
107 ('sku', models.CharField(db_index=True, max_length=64)),
108 ('name', models.CharField(max_length=255)),
109 ('description', models.TextField(blank=True, null=True)),
110 ('category', models.CharField(blank=True, max_length=64, null=True)),
111 ('cost_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
112 ('selling_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
113 ('tax_rate', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=5)),
114 ('unit_of_measure', models.CharField(default='pcs', max_length=32)),
115 ('is_active', models.BooleanField(default=True)),
116 ('reorder_level', models.IntegerField(default=10)),
117 ],
118 options={
119 'ordering': ['name'],
120 'unique_together': {('tenant_id', 'sku')},
121 },
122 ),
123 migrations.CreateModel(
124 name='InvoiceLine',
125 fields=[
126 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
127 ('tenant_id', models.UUIDField(db_index=True)),
128 ('description', models.CharField(max_length=255)),
129 ('quantity', models.DecimalField(decimal_places=2, default=Decimal('1.00'), max_digits=14)),
130 ('unit_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
131 ('tax_rate', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=5)),
132 ('subtotal', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
133 ('tax_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
134 ('total', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
135 ('invoice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='erp.invoice')),
136 ('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='erp.product')),
137 ],
138 options={
139 'abstract': False,
140 },
141 ),
142 migrations.CreateModel(
143 name='Shipment',
144 fields=[
145 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
146 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
147 ('updated_at', models.DateTimeField(auto_now=True)),
148 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
149 ('reference_number', models.CharField(max_length=32)),
150 ('customer_name', models.CharField(max_length=255)),
151 ('customer_email', models.EmailField(blank=True, max_length=254, null=True)),
152 ('shipment_type', models.CharField(choices=[('IMPORT', 'Import'), ('EXPORT', 'Export'), ('TRANSIT', 'Transit')], default='IMPORT', max_length=16)),
153 ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('DOCUMENTS_PENDING', 'Documents Pending'), ('CUSTOMS_CLEARED', 'Customs Cleared'), ('IN_TRANSIT', 'In Transit'), ('DELIVERED', 'Delivered'), ('ON_HOLD', 'On Hold'), ('CANCELLED', 'Cancelled')], default='DRAFT', max_length=32)),
154 ('origin', models.CharField(max_length=255)),
155 ('destination', models.CharField(max_length=255)),
156 ('carrier', models.CharField(blank=True, max_length=255, null=True)),
157 ('tracking_number', models.CharField(blank=True, max_length=128, null=True)),
158 ('bill_of_lading', models.CharField(blank=True, max_length=128, null=True)),
159 ('customs_entry_number', models.CharField(blank=True, max_length=128, null=True)),
160 ('estimated_arrival', models.DateField(blank=True, null=True)),
161 ('declared_value', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
162 ('duty_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
163 ('freight_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
164 ('currency', models.CharField(default='PHP', max_length=3)),
165 ('notes', models.TextField(blank=True, null=True)),
166 ],
167 options={
168 'ordering': ['-created_at'],
169 'unique_together': {('tenant_id', 'reference_number')},
170 },
171 ),
172 migrations.CreateModel(
173 name='Warehouse',
174 fields=[
175 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
176 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
177 ('updated_at', models.DateTimeField(auto_now=True)),
178 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
179 ('name', models.CharField(max_length=128)),
180 ('code', models.CharField(max_length=32)),
181 ('address', models.TextField(blank=True, null=True)),
182 ('is_active', models.BooleanField(default=True)),
183 ],
184 options={
185 'unique_together': {('tenant_id', 'code')},
186 },
187 ),
188 migrations.CreateModel(
189 name='StockMove',
190 fields=[
191 ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
192 ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
193 ('updated_at', models.DateTimeField(auto_now=True)),
194 ('tenant_id', models.UUIDField(db_index=True, help_text='Organization / Tenant ID')),
195 ('quantity', models.DecimalField(decimal_places=4, max_digits=14)),
196 ('unit_cost', models.DecimalField(decimal_places=4, default=Decimal('0.0000'), max_digits=18)),
197 ('move_type', models.CharField(choices=[('INCOMING', 'Incoming'), ('OUTGOING', 'Outgoing'), ('INTERNAL_TRANSFER', 'Internal Transfer'), ('ADJUSTMENT', 'Adjustment')], max_length=32)),
198 ('reference_doc', models.CharField(blank=True, max_length=64, null=True)),
199 ('product', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='stock_moves', to='erp.product')),
200 ('dest_warehouse', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='moves_in', to='erp.warehouse')),
201 ('source_warehouse', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='moves_out', to='erp.warehouse')),
202 ],
203 options={
204 'ordering': ['-created_at'],
205 },
206 ),
207 ]