"""pad tos

Revision ID: 316ae45f54bc
Revises: 1c958b749a20
Create Date: 2020-12-01 13:12:57.873133

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.sql import column, table
from sqlalchemy import Integer, String


# revision identifiers, used by Alembic.
revision = '316ae45f54bc'
down_revision = '1c958b749a20'
branch_labels = None
depends_on = None



def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    documents = table('documents',
                      column('version_id', String),
                      column('type', String),
                      column('content_type', String),
                      column('content', String))

    html_content = """
      <section>
        <header>
          In this agreement:
        </header>
        <p>
          “the biller” refers to “Her Majesty the Queen in Right of the Province of British Columbia as represented by the Minister of Citizen’s Services - BC Registry and Online Services (Prov of BC);
        </p>
        <p>
          “the payor” refers to the Premium Account Subscriber of the BC Registry Service as defined in the BC Registry Terms and Conditions of Agreement (the “BC Registry Terms”); and</p>
        <p>
          unless defined herein, capitalized terms in this agreement will have the meaning as set out in BC Registry Terms.
        </p>
      </section>
      <section>
      <header>
        The payor acknowledges or understands:
      </header>
      <ol>
        <li>
          That this authorization is provided for the benefit of the biller and our financial institution, and is provided in consideration of the Payor’s Financial Institution agreeing to process debits (PADs) against the bank account as indicated in the biller’s PAD application webform and in accordance with the rules of <a href="http://www.payments.ca" target="_blank">Payments Canada</a>.
        </li>
        <li>
          Ticking the acceptance box on the biller’s PAD application webform will be considered equivalent to my signature and will constitute valid authorization for the processing financial institution to debit the payor’s account as identified in the biller’s PAD application webform (the “Payor’s Bank Account”).
        </li>
        <li>
          This authority will remain in effect until the biller has received written communication from the payor of cancellation or changes relating to the Payor’s Bank Account.
        </li>
        <li>
          The payor may cancel this PAD agreement at any time with written notification to the biller. Written notification of changes or cancellation must be received at least 10 business days prior to the next online order or withdrawal. Notification must be in writing and sent either through the biller’s BC Registry website or by mail to the address provided below. A sample cancellation form or more information on my right to cancel a PAD Agreement can be obtained at my financial institution or by visiting <a href="http://www.payments.ca" target="_blank">www.payments.ca</a>.
        </li>
        <li>
          That cancellation of this agreement by the payor or the biller:
          <ol type="a">
            <li>
              will result in the suspension of the payors’ Premium Account Subscriber account Access until the payor takes action to authorize another payment method; and
            </li>
            <li>
              does not cancel any amount owed for the Service received prior to cancellation.
            </li>
          </ol>
        </li>
        <li>
          Correspondence regarding this agreement will be sent to the payor at the email address associated with the payor’s Premium Subscriber Account (the “Payor’s Email Address”). The payor agrees that any communication sent by the biller to that email address will be deemed to have been received by the payor and acknowledges that it is the payor’s responsibility to notify the biller as soon as possible of changes to the Payor’s Email Address.
        </li>
        <li>
          <strong>The biller notification of enrollment or cancellation of this Pre-Authorized Debit Agreement to the Payor is being reduced from 15 calendar days to 3 calendar days in accordance with the H1 rule of Payments Canada.  Notification will be delivered electronically to the Payor’s Email Address.</strong>
        </li>
        <li>
          The payor has certain recourse rights if any debit does not comply with the terms of this business PAD agreement (for example, the right to receive reimbursement for any PAD that is not authorized or is not consistent with terms and conditions of this PAD Agreement). To obtain a form for reimbursement or for more information on recourse rights, contact your financial institution or visit <a href="http://www.payments.ca" target="_blank">www.payments.ca</a>.
        </li>
        <li>
          Any payment dishonoured by the payor’s financial institution may result in a dishonoured banking instrument service fee, as prescribed by the Minister of Finance, being applied to the payor’s Premium Account Subscriber account.  The biller is not responsible for any additional service fees charged by your financial institution.
        </li>
        <li>
          In the event of a dishonoured payment, the biller reserves the right to suspend the payor’s Access until the payor has taken action to re-activate Access by paying any outstanding Fees and dishonoured banking instrument service fees by credit card.
        </li>
        <li>
          Due to a delay in payment processing, the biller may subsequently suspend the payor’s Access after a payor has taken action to re-activate Access if another PAD is dishonoured in the intervening period.
        </li>
        <li>
          The amount of the daily (excludes weekends and holidays) withdrawal is variable and dependent on the total daily Transactions charged to the payors’ Premium Account Subscriber’s account by Team Members who are authorized to order BC Registry Services.
        </li>
        <li>
          <strong>The standard 10 calendar day pre-notification period for the sporadic and variable pre-authorized withdrawals will be reduced to 1-2 business days.</strong>
        </li>
        <li>
          The biller will provide PAD pre-notification 1-2 business days prior to the withdrawal date. This notification will confirm the amount and estimated date of the pre-authorized withdrawal, will provide a list of all services ordered & other account adjustments and will be delivered electronically to the Payor’s Email Address.
        </li>
        <li>
          Your financial institution is not responsible for verifying whether payment has been issued in accordance with the particulars of this agreement.
        </li>
      </ol>
      </section>
      <section>
        <header>
          <strong>Payor Authorization:</strong>
        </header>
        <p>
          I have read, understood and agree to the terms and conditions of the Business Pre-Authorized Debit Terms and Conditions for BC Registry Services
        </p>
        <p>
          I confirm, I am an authorized representative for the payor and authorized signatory on the account to be debited under this agreement.
        </p>
        <p>
          I authorize the biller to withdraw funds from the bank account as indicated above as per the terms and conditions of this agreement.
        </p>
        <p>
          Dated: Month Day, Year
        </p>
      </section>
    """

    op.bulk_insert(
        documents,
        [
            {'version_id': 'p1', 'type': 'termsofuse_pad', 'content': html_content, 'content_type': 'text/html'}
        ]
    )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("DELETE FROM DOCUMENTS WHERE version_id='p1' AND type='termsofuse_pad'")
    # ### end Alembic commands ###
