You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
from django.db import migrations
|
|
from decimal import Decimal
|
|
|
|
|
|
def create_tariffs(apps, schema_editor):
|
|
ContainerTariffPeriod = apps.get_model('payments', 'ContainerTariffPeriod')
|
|
AdditionalFees = apps.get_model('payments', 'AdditionalFees')
|
|
|
|
tariffs_20 = [
|
|
('20', 1, 3, Decimal('5.00')),
|
|
('20', 4, 7, Decimal('10.00')),
|
|
('20', 8, 15, Decimal('15.00')),
|
|
('20', 16, None, Decimal('20.00')),
|
|
]
|
|
|
|
tariffs_40 = [
|
|
('40', 1, 3, Decimal('10.00')),
|
|
('40', 4, 7, Decimal('15.00')),
|
|
('40', 8, 15, Decimal('20.00')),
|
|
('40', 16, None, Decimal('25.00')),
|
|
]
|
|
|
|
for container_size, from_days, to_days, daily_rate in tariffs_20 + tariffs_40:
|
|
ContainerTariffPeriod.objects.create(
|
|
container_size=container_size,
|
|
from_days=from_days,
|
|
to_days=to_days,
|
|
daily_rate=daily_rate
|
|
)
|
|
|
|
AdditionalFees.objects.create(
|
|
reefer_daily_supplement=Decimal('3.00'),
|
|
sweeping_fee=Decimal('35.00'),
|
|
fumigation_fee=Decimal('75.00')
|
|
)
|
|
|
|
|
|
def reverse_tariffs(apps, schema_editor):
|
|
ContainerTariffPeriod = apps.get_model('payments', 'ContainerTariffPeriod')
|
|
AdditionalFees = apps.get_model('payments', 'AdditionalFees')
|
|
|
|
ContainerTariffPeriod.objects.all().delete()
|
|
AdditionalFees.objects.all().delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
('payments', '0003_auto_20250725_1920'), # Adjust this to your last migration
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(create_tariffs, reverse_tariffs),
|
|
] |