Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18767 - Add in new sequence column via model, migration and job. #1335

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion jobs/payment-jobs/tasks/ejv_partner_distribution_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ def _create_ejv_file_for_partner(cls, batch_type: str): # pylint:disable=too-ma

control_total += 1

sequence = 1
# Create ejv invoice link records and set invoice status
for inv in invoices:
# Create Ejv file link and flush
link_model = EjvInvoiceLinkModel(invoice_id=inv.id,
ejv_header_id=ejv_header_model.id,
disbursement_status_code=DisbursementStatus.UPLOADED.value)
disbursement_status_code=DisbursementStatus.UPLOADED.value,
sequence=sequence)
# Set distribution status to invoice
db.session.add(link_model)
sequence += 1
inv.disbursement_status_code = DisbursementStatus.UPLOADED.value

db.session.flush()
Expand Down
5 changes: 4 additions & 1 deletion jobs/payment-jobs/tasks/ejv_payment_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,15 @@ def _create_ejv_file_for_gov_account(cls, batch_type: str): # pylint:disable=to

# Create ejv invoice link records and set invoice status
current_app.logger.info('Creating ejv invoice link records and setting invoice status.')
sequence = 1
for inv in invoices:
current_app.logger.debug(f'Creating EJV Invoice Link for invoice id: {inv.id}')
# Create Ejv file link and flush
ejv_invoice_link = EjvInvoiceLinkModel(invoice_id=inv.id, ejv_header_id=ejv_header_model.id,
disbursement_status_code=DisbursementStatus.UPLOADED.value)
disbursement_status_code=DisbursementStatus.UPLOADED.value,
sequence=sequence)
db.session.add(ejv_invoice_link)
sequence += 1
# Set distribution status to invoice
# Create invoice reference record
current_app.logger.debug(f'Creating Invoice Reference for invoice id: {inv.id}')
Expand Down
23 changes: 23 additions & 0 deletions pay-api/migrations/versions/2023_11_30_49eaec3210e0_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Add in a sequence column to the ejv_invoice_links table

Revision ID: 49eaec3210e0
Revises: 598bbfce4dad
Create Date: 2023-11-30 10:38:00.644319

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '49eaec3210e0'
down_revision = '598bbfce4dad'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('ejv_invoice_links', sa.Column('sequence', sa.Integer(), nullable=True))


def downgrade():
op.drop_column('ejv_invoice_links', 'sequence')
4 changes: 3 additions & 1 deletion pay-api/src/pay_api/models/ejv_invoice_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class EjvInvoiceLink(BaseModel): # pylint: disable=too-few-public-methods
'disbursement_status_code',
'ejv_header_id',
'invoice_id',
'message'
'message',
'sequence'
]
}

Expand All @@ -48,3 +49,4 @@ class EjvInvoiceLink(BaseModel): # pylint: disable=too-few-public-methods
ejv_header_id = db.Column(db.Integer, ForeignKey('ejv_headers.id'), nullable=False)
disbursement_status_code = db.Column(db.String(20), ForeignKey('disbursement_status_codes.code'), nullable=True)
message = db.Column('message', db.String, nullable=True, index=False)
sequence = db.Column(db.Integer, nullable=True)
Loading