Files
notifications-api/migrations/versions/0306_letter_rates_price_rise.py
Steven Reilly ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00

69 lines
2.1 KiB
Python

"""
All prices going up 5p
1 sheet (double-sided) increases from 30p to 35p (plus VAT)
2 sheets (double-sided) increases from 35p to 40p (plus VAT)
3 sheets (double-sided) increases from 40p to 45p (plus VAT)
4 sheets (double-sided) increases from 45p to 50p (plus VAT)
5 sheets (double-sided) increases from 50p to 55p (plus VAT)
First class letters:
1 sheet (double-sided) increases from 56p to 61p (plus VAT)
2 sheets (double-sided) increases from 61p to 66p (plus VAT)
3 sheets (double-sided) increases from 66p to 71p (plus VAT)
4 sheets (double-sided) increases from 71p to 76p (plus VAT)
5 sheets (double-sided) increases from 76p to 81p (plus VAT)
Revision ID: 0306_letter_rates_price_rise
Revises: 0305_add_gp_org_type
Create Date: 2019-09-25 15:43:09.388251
"""
import itertools
import uuid
from datetime import datetime
from alembic import op
from sqlalchemy.sql import text
revision = '0306_letter_rates_price_rise'
down_revision = '0305_add_gp_org_type'
CHANGEOVER_DATE = datetime(2019, 9, 30, 23, 0)
def upgrade():
# all old rates are going in the bin
conn = op.get_bind()
# conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE)
# base_prices = {
# 'second': 30,
# 'first': 56,
# }
# op.bulk_insert('letter_rates', [
# {
# 'id': uuid.uuid4(),
# 'start_date': CHANGEOVER_DATE,
# 'end_date': None,
# 'sheet_count': sheet_count,
# 'rate': (base_prices[post_class] + (5 * sheet_count)) / 100.0,
# 'crown': crown,
# 'post_class': post_class,
# }
# for sheet_count, crown, post_class in itertools.product(
# range(1, 6),
# [True, False],
# ['first', 'second']
# )
# ])
def downgrade():
# Make sure you've thought about billing implications etc before downgrading!
conn = op.get_bind()
conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE)
conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE)