Initial commit from monorepo

This commit is contained in:
Ruslan Bakiev
2026-01-07 09:17:45 +07:00
commit 72db63f956
38 changed files with 3012 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
# Generated by Django 5.2.9 on 2025-12-10 11:19
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Account',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(help_text='Name or identifier for the account', max_length=255)),
('account_type', models.CharField(choices=[('USER', 'User Account'), ('SERVICE', 'Service Account'), ('ASSET', 'Asset Account'), ('LIABILITY', 'Liability Account'), ('REVENUE', 'Revenue Account'), ('EXPENSE', 'Expense Account')], default='USER', help_text='Type of the account (e.g., User, Service, Revenue)', max_length=50)),
('description', models.TextField(blank=True, help_text='Detailed description of the account', null=True)),
('tigerbeetle_account_id', models.BigIntegerField(help_text='The unique ID of this account in TigerBeetle', unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name': 'Billing Account',
'verbose_name_plural': 'Billing Accounts',
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='TransactionReason',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Unique name for the transaction reason', max_length=255, unique=True)),
('description', models.TextField(blank=True, help_text='Detailed description of this transaction reason', null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name': 'Transaction Reason',
'verbose_name_plural': 'Transaction Reasons',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='Operation',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('amount', models.DecimalField(decimal_places=4, help_text='The amount transferred in this operation', max_digits=20)),
('state', models.CharField(choices=[('PENDING', 'Pending TigerBeetle transfer'), ('COMPLETED', 'TigerBeetle transfer completed'), ('FAILED', 'TigerBeetle transfer failed')], default='PENDING', help_text='Current state of the TigerBeetle transfer for this operation', max_length=50)),
('tigerbeetle_transfer_id', models.BigIntegerField(blank=True, help_text='The unique ID of the transfer in TigerBeetle, set after successful transfer', null=True, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('destination_account', models.ForeignKey(help_text='The account to which funds are moved', on_delete=django.db.models.deletion.PROTECT, related_name='incoming_operations', to='billing_app.account')),
('source_account', models.ForeignKey(help_text='The account from which funds are moved', on_delete=django.db.models.deletion.PROTECT, related_name='outgoing_operations', to='billing_app.account')),
('reason', models.ForeignKey(help_text='The business reason for this operation', on_delete=django.db.models.deletion.PROTECT, related_name='operations', to='billing_app.transactionreason')),
],
options={
'verbose_name': 'Business Operation',
'verbose_name_plural': 'Business Operations',
'ordering': ['-created_at'],
},
),
]

View File

@@ -0,0 +1,17 @@
# Generated manually
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('billing_app', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='account',
name='tigerbeetle_account_id',
),
]

View File

@@ -0,0 +1,78 @@
# Generated manually - refactor billing models
import django.db.models.deletion
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('billing_app', '0002_remove_account_tigerbeetle_account_id'),
]
operations = [
# 1. Delete old models
migrations.DeleteModel(
name='Operation',
),
migrations.DeleteModel(
name='TransactionReason',
),
# 2. Alter Account model - update account_type choices and remove name help_text
migrations.AlterField(
model_name='account',
name='account_type',
field=models.CharField(
choices=[('USER', 'User Account'), ('SERVICE', 'Service Account')],
default='USER',
max_length=50,
),
),
migrations.AlterField(
model_name='account',
name='name',
field=models.CharField(help_text='Название аккаунта', max_length=255),
),
migrations.AlterModelOptions(
name='account',
options={'ordering': ['-created_at'], 'verbose_name': 'Account', 'verbose_name_plural': 'Accounts'},
),
# 3. Create OperationCode model
migrations.CreateModel(
name='OperationCode',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.PositiveIntegerField(help_text='Числовой код для TigerBeetle', unique=True)),
('name', models.CharField(help_text='Название операции', max_length=255, unique=True)),
('description', models.TextField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name': 'Operation Code',
'verbose_name_plural': 'Operation Codes',
'ordering': ['code'],
},
),
# 4. Create ServiceAccount model
migrations.CreateModel(
name='ServiceAccount',
fields=[
('account', models.OneToOneField(
on_delete=models.deletion.CASCADE,
primary_key=True,
related_name='service_info',
serialize=False,
to='billing_app.account'
)),
('slug', models.SlugField(help_text='Уникальный идентификатор (bank, revenue, etc)', unique=True)),
],
options={
'verbose_name': 'Service Account',
'verbose_name_plural': 'Service Accounts',
},
),
]

View File