Skip to content

Commit

Permalink
Add in change for invoice.disbursment_date (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Jan 30, 2023
1 parent b60b4a0 commit 86b3e5f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pay-api/migrations/versions/286acad5d366_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Add in disbursement_date, that we we know exactly when a transaction was disbursed.
Revision ID: 286acad5d366
Revises: 39c2491d0a07
Create Date: 2023-01-30 10:31:10.226000
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '286acad5d366'
down_revision = '39c2491d0a07'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('invoices', sa.Column('disbursement_date', sa.DateTime(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('invoices', 'disbursement_date')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions pay-api/src/pay_api/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Invoice(Audit): # pylint: disable=too-many-instance-attributes
payment_method_code = db.Column(db.String(15), ForeignKey('payment_methods.code'), nullable=False, index=True)
corp_type_code = db.Column(db.String(10), ForeignKey('corp_types.code'), nullable=True)
disbursement_status_code = db.Column(db.String(20), ForeignKey('disbursement_status_codes.code'), nullable=True)
disbursement_date = db.Column(db.DateTime, nullable=True)
created_on = db.Column('created_on', db.DateTime, nullable=False, default=datetime.now, index=True)

business_identifier = db.Column(db.String(20), nullable=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def _fix_invoice_line(line):

async def _update_invoice_status(invoice):
"""Update status to reversed if its a refund, else to completed."""
invoice.disbursement_date = datetime.now()
if invoice.invoice_status_code in (InvoiceStatus.REFUNDED.value, InvoiceStatus.REFUND_REQUESTED.value):
invoice.disbursement_status_code = DisbursementStatus.REVERSED.value
else:
Expand Down

0 comments on commit 86b3e5f

Please sign in to comment.