Change to just using online auth for internal clients.

This effectively reverts 067e03b.
This commit is contained in:
Tom Price
2017-05-23 18:19:02 +01:00
parent 4d316c7a4a
commit c6b7bbc219
16 changed files with 123 additions and 183 deletions

View File

@@ -19,7 +19,6 @@ class Migration(migrations.Migration):
('name', models.CharField(max_length=255)),
('uni_id', models.CharField(max_length=10, null=True, verbose_name=b'University ID', blank=True)),
('account_code', models.CharField(max_length=50, null=True, blank=True)),
('po', models.CharField(max_length=255, null=True, verbose_name=b'purchase order', blank=True)),
('amount', models.DecimalField(verbose_name=b'authorisation amount', max_digits=10, decimal_places=2)),
('created_at', models.DateTimeField(auto_now_add=True)),
('event', models.ForeignKey(related_name='authroisations', to='RIGS.Event')),

View File

@@ -1,48 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.db.models import F, Sum, DecimalField
def POs_forward(apps, schema_editor):
VatRate = apps.get_model('RIGS', 'VatRate')
Event = apps.get_model('RIGS', 'Event')
EventItem = apps.get_model('RIGS', 'EventItem')
EventAuthorisation = apps.get_model('RIGS', 'EventAuthorisation')
db_alias = schema_editor.connection.alias
for event in Event.objects.using(db_alias).filter(purchase_order__isnull=False):
sum_total = EventItem.objects.filter(event=event).aggregate(
sum_total=Sum(models.F('cost') * F('quantity'),
output_field=DecimalField(
max_digits=10,
decimal_places=2)
)
)['sum_total']
vat = VatRate.objects.using(db_alias).filter(start_at__lte=event.start_date).latest()
total = sum_total + sum_total * vat.rate
EventAuthorisation.objects.using(db_alias).create(event=event, name='LEGACY',
email='treasurer@nottinghamtec.co.uk',
amount=total,
po=event.purchase_order)
def POs_reverse(apps, schema_editor):
EventAuthorisation = apps.get_model('RIGS', 'EventAuthorisation')
db_alias = schema_editor.connection.alias
for auth in EventAuthorisation.objects.using(db_alias).filter(po__isnull=False):
auth.event.purchase_order = auth.po
auth.delete()
class Migration(migrations.Migration):
dependencies = [
('RIGS', '0027_eventauthorisation_event_singular'),
]
operations = [
migrations.RunPython(POs_forward, POs_reverse),
migrations.RemoveField(model_name='event', name='purchase_order')
]

View File

@@ -8,7 +8,7 @@ from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('RIGS', '0028_migrate_purchase_order'),
('RIGS', '0027_eventauthorisation_event_singular'),
]
operations = [