From c977ab5b070a779665ad34322c674b56ae4ccccf Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Mon, 25 Sep 2023 14:46:16 -0700 Subject: [PATCH] 17828 - EFT - A start on some of the database model changes. (#1255) * A start on some of the database model changes. * Change code owners * revert __init__.py * add in insert for invoice_status_codes. * Update version.py. --- .github/CODEOWNERS | 2 +- ...{pay-api-1.0.4.yaml => pay-api-1.0.5.yaml} | 10 +++++-- .../2023_09_25_3a21a14b4137_overdue_date.py | 30 +++++++++++++++++++ pay-api/src/pay_api/models/invoice.py | 4 ++- pay-api/src/pay_api/utils/enums.py | 1 + pay-api/src/pay_api/version.py | 2 +- pay-api/tests/docker/docker-compose.yml | 2 +- 7 files changed, 44 insertions(+), 7 deletions(-) rename docs/docs/api_contract/{pay-api-1.0.4.yaml => pay-api-1.0.5.yaml} (99%) create mode 100644 pay-api/migrations/versions/2023_09_25_3a21a14b4137_overdue_date.py diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8abb0ae10..6afcc641b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @seeker25 @jxio @kialj876 +* @seeker25 @jxio @ochiu diff --git a/docs/docs/api_contract/pay-api-1.0.4.yaml b/docs/docs/api_contract/pay-api-1.0.5.yaml similarity index 99% rename from docs/docs/api_contract/pay-api-1.0.4.yaml rename to docs/docs/api_contract/pay-api-1.0.5.yaml index 191f63ee7..f06c992dc 100644 --- a/docs/docs/api_contract/pay-api-1.0.4.yaml +++ b/docs/docs/api_contract/pay-api-1.0.5.yaml @@ -5,7 +5,7 @@ info:

BC Registries Pay system is used by the BC Registries account services and integrated systems to create payment transactions to pay for the products purchased. This abstracts the integrated systems from the underlying payment integrations and payment methods.
With this API you can submit the following transactions:

All requests must include an Account ID.

- version: 1.0.4 + version: 1.0.5 contact: name: BC Registries paths: @@ -1610,13 +1610,16 @@ components: description: username of the account createdBy: type: string - description: invoice creation date + description: user who created the invoice createdOn: type: string - description: date made payment + description: date made invoice disbursementDate: type: string description: date when disbursement status code was set + overdueDate: + type: string + description: date when payment is overdue (EFT / ONLINE_BANKING) paid: type: number description: amount paid @@ -1644,6 +1647,7 @@ components: - SETTLEMENT_SCHED - CANCELLED - CREDITED + - OVERDUE references: type: array items: diff --git a/pay-api/migrations/versions/2023_09_25_3a21a14b4137_overdue_date.py b/pay-api/migrations/versions/2023_09_25_3a21a14b4137_overdue_date.py new file mode 100644 index 000000000..0223f2194 --- /dev/null +++ b/pay-api/migrations/versions/2023_09_25_3a21a14b4137_overdue_date.py @@ -0,0 +1,30 @@ +"""Add overdue date to invoices. + +Revision ID: 3a21a14b4137 +Revises: 33bbd4d9a85c +Create Date: 2023-09-25 13:20:03.578472 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '3a21a14b4137' +down_revision = '33bbd4d9a85c' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('invoices', sa.Column('overdue_date', sa.DateTime(), nullable=True)) + op.execute('insert into invoice_status_codes (code, description) values (\'OVERDUE\', \'Overdue\')') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('invoices', 'overdue_date') + op.execute('delete from invoice_status_codes where code = \'OVERDUE\'') + # ### end Alembic commands ### diff --git a/pay-api/src/pay_api/models/invoice.py b/pay-api/src/pay_api/models/invoice.py index ea05d8c9a..938590e61 100644 --- a/pay-api/src/pay_api/models/invoice.py +++ b/pay-api/src/pay_api/models/invoice.py @@ -70,12 +70,13 @@ class Invoice(Audit): # pylint: disable=too-many-instance-attributes 'payment_account_id', 'payment_date', 'payment_method_code', - 'total', 'paid', + 'overdue_date', 'refund', 'refund_date', 'routing_slip', 'service_fees', + 'total', 'updated_by', 'updated_name', 'updated_on' @@ -97,6 +98,7 @@ class Invoice(Audit): # pylint: disable=too-many-instance-attributes total = db.Column(db.Numeric(19, 2), nullable=False) paid = db.Column(db.Numeric(19, 2), nullable=True) payment_date = db.Column(db.DateTime, nullable=True) + overdue_date = db.Column(db.DateTime, nullable=True) refund_date = db.Column(db.DateTime, nullable=True) refund = db.Column(db.Numeric(19, 2), nullable=True) routing_slip = db.Column(db.String(50), nullable=True, index=True) diff --git a/pay-api/src/pay_api/utils/enums.py b/pay-api/src/pay_api/utils/enums.py index 032ac15fa..1927c2e3c 100644 --- a/pay-api/src/pay_api/utils/enums.py +++ b/pay-api/src/pay_api/utils/enums.py @@ -57,6 +57,7 @@ class InvoiceStatus(Enum): REFUNDED = 'REFUNDED' CANCELLED = 'CANCELLED' CREDITED = 'CREDITED' + OVERDUE = 'OVERDUE' class TransactionStatus(Enum): diff --git a/pay-api/src/pay_api/version.py b/pay-api/src/pay_api/version.py index f58f31733..c7ff7349a 100644 --- a/pay-api/src/pay_api/version.py +++ b/pay-api/src/pay_api/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '1.19.0' # pylint: disable=invalid-name +__version__ = '1.20.0' # pylint: disable=invalid-name diff --git a/pay-api/tests/docker/docker-compose.yml b/pay-api/tests/docker/docker-compose.yml index c9adb5ac7..70fe7faa1 100644 --- a/pay-api/tests/docker/docker-compose.yml +++ b/pay-api/tests/docker/docker-compose.yml @@ -57,7 +57,7 @@ services: image: stoplight/prism:3.3.0 command: > mock -p 4010 --host 0.0.0.0 - https://raw.githubusercontent.com/bcgov/sbc-pay/main/docs/docs/api_contract/pay-api-1.0.4.yaml + https://raw.githubusercontent.com/bcgov/sbc-pay/main/docs/docs/api_contract/pay-api-1.0.5.yaml reports: image: stoplight/prism:3.3.0 command: >