From 4c33afa4e611d07c7b626d67f9f9f05fd3ed8c78 Mon Sep 17 00:00:00 2001 From: Sumesh Punakkal Kariyil Date: Tue, 14 Dec 2021 10:30:41 -0800 Subject: [PATCH] Adding refund_amount column and update its value on routing_slips model --- jobs/payment-jobs/tasks/routing_slip_task.py | 1 + ...0d885750ded9_routing_slip_refund_amount.py | 27 +++++++++++++++++++ pay-api/src/pay_api/models/routing_slip.py | 1 + 3 files changed, 29 insertions(+) create mode 100644 pay-api/migrations/versions/0d885750ded9_routing_slip_refund_amount.py diff --git a/jobs/payment-jobs/tasks/routing_slip_task.py b/jobs/payment-jobs/tasks/routing_slip_task.py index 0b5c45b71..6962e6d7c 100644 --- a/jobs/payment-jobs/tasks/routing_slip_task.py +++ b/jobs/payment-jobs/tasks/routing_slip_task.py @@ -200,6 +200,7 @@ def adjust_routing_slips(cls): # Adjust the receipt to zero in CFS CFSService.adjust_receipt_to_zero(cfs_account, receipt_number, is_refund) + routing_slip.refund_amount = routing_slip.remaining_amount routing_slip.remaining_amount = 0 routing_slip.save() diff --git a/pay-api/migrations/versions/0d885750ded9_routing_slip_refund_amount.py b/pay-api/migrations/versions/0d885750ded9_routing_slip_refund_amount.py new file mode 100644 index 000000000..bd96ca7bb --- /dev/null +++ b/pay-api/migrations/versions/0d885750ded9_routing_slip_refund_amount.py @@ -0,0 +1,27 @@ +"""routing_slip_refund_amount + +Revision ID: 0d885750ded9 +Revises: aa9207187d6b +Create Date: 2021-12-14 10:19:33.738170 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '0d885750ded9' +down_revision = 'aa9207187d6b' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('routing_slips', sa.Column('refund_amount', sa.Numeric(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('routing_slips', 'refund_amount') + # ### end Alembic commands ### diff --git a/pay-api/src/pay_api/models/routing_slip.py b/pay-api/src/pay_api/models/routing_slip.py index 39c69c403..c694229a4 100644 --- a/pay-api/src/pay_api/models/routing_slip.py +++ b/pay-api/src/pay_api/models/routing_slip.py @@ -50,6 +50,7 @@ class RoutingSlip(Audit): # pylint: disable=too-many-instance-attributes remaining_amount = db.Column(db.Numeric(), nullable=True, default=0) routing_slip_date = db.Column(db.Date, nullable=False) parent_number = db.Column(db.String(), ForeignKey('routing_slips.number'), nullable=True) + refund_amount = db.Column(db.Numeric(), nullable=True, default=0) payment_account = relationship(PaymentAccount, foreign_keys=[payment_account_id], lazy='select', innerjoin=True) payments = relationship(Payment,