Skip to content

Commit

Permalink
Merge pull request #149 from bcgov/development
Browse files Browse the repository at this point in the history
Merge to master pay release 1.6.0
  • Loading branch information
sumesh-aot authored Jan 30, 2020
2 parents 8fd4d91 + d05d4f4 commit 7ff6526
Show file tree
Hide file tree
Showing 26 changed files with 342 additions and 44 deletions.
11 changes: 11 additions & 0 deletions COMPLIANCE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: compliance
description: |
This document is used to track a projects PIA and STRA
compliance.
spec:
- name: PIA
status: completed
last-updated: '2020-01-17T17:40:59.150Z'
- name: STRA
status: completed
last-updated: '2020-01-17T17:41:09.050Z'
58 changes: 58 additions & 0 deletions docs/docs/api_contract/report-api-1.0.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
openapi: 3.0.0
info:
title: report-api-1.0.0.yaml
version: '1.0'
description: Report API
paths:
/reports:
post:
summary: Create pdf report.
responses:
'200':
description: OK
content:
application/pdf:
schema:
type: object
properties: {}
'400':
description: Bad Request
content:
application/json:
schema:
type: object
properties:
code:
type: string
message:
type: string
'':
content:
application/pdf:
schema:
type: object
properties: {}
examples: {}
description: Create pdf report.
operationId: post_report
requestBody:
description: ''
content:
application/json:
schema:
type: object
properties:
reportName:
type: string
templateVars:
type: string
populatePageNumber:
type: boolean
templateName:
type: string
template:
type: string
examples: {}
parameters: []
components:
schemas: {}
34 changes: 34 additions & 0 deletions pay-api/migrations/versions/78951cf14ae9_waived_fee_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""waived_fee_changes
Revision ID: 78951cf14ae9
Revises: 7d16423bc042
Create Date: 2020-01-24 11:29:27.828781
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '78951cf14ae9'
down_revision = '7d16423bc042'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('payment_line_item', sa.Column('waived_by', sa.String(length=50), nullable=True))
op.add_column('payment_line_item', sa.Column('waived_fees', sa.Float(), nullable=True))
op.alter_column('payment_line_item', 'filing_fees',
existing_type=sa.INTEGER,
type_=sa.FLOAT,
existing_nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('payment_line_item', 'waived_fees')
op.drop_column('payment_line_item', 'waived_by')
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion pay-api/openshift/templates/pay-api-deploy.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"envFrom": [
{
"configMapRef": {
"name": "${NAME}-${TAG_NAME}-config"
"name": "api-${TAG_NAME}-config"
}
}
],
Expand Down
31 changes: 17 additions & 14 deletions pay-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Flask-Moment==0.9.0
Flask-SQLAlchemy==2.4.1
Flask-Script==2.0.6
Flask==1.1.1
Jinja2==2.10.3
Mako==1.1.0
Jinja2==2.11.0
Mako==1.1.1
MarkupSafe==1.1.1
SQLAlchemy==1.3.12
Werkzeug==0.16.0
alembic==1.3.2
SQLAlchemy==1.3.13
Werkzeug==0.16.1
alembic==1.3.3
aniso8601==8.0.0
asyncio-nats-client==0.10.0
asyncio-nats-streaming==0.4.0
Expand All @@ -24,26 +24,29 @@ flask-marshmallow==0.10.1
flask-restplus==0.13.0
gunicorn==20.0.4
idna==2.8
importlib-metadata==1.3.0
importlib-metadata==1.4.0
itsdangerous==1.1.0
jaeger-client==4.3.0
jsonschema==3.2.0
marshmallow-sqlalchemy==0.21.0
marshmallow==3.0.0rc7
more-itertools==8.0.2
opentracing==2.3.0
protobuf==3.11.2
psycopg2-binary==2.8.4
pyasn1==0.4.8
pyrsistent==0.15.6
pyrsistent==0.15.7
python-dateutil==2.8.1
python-dotenv==0.10.3
python-dotenv==0.10.5
python-editor==1.0.4
python-jose==3.1.0
pytz==2019.3
requests==2.22.0
rsa==4.0
sentry-sdk==0.13.5
six==1.13.0
urllib3==1.25.7
zipp==0.6.0
-e git://github.com/pwei1018/jaeger-client-python.git@186f14e14758273ed108508c0d388a4f4de5c75b#egg=jaeger-client
sentry-sdk==0.14.1
six==1.14.0
threadloop==1.0.2
thrift==0.13.0
tornado==6.0.3
urllib3==1.25.8
zipp==2.1.0
-e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components-1.0.0&subdirectory=python
1 change: 0 additions & 1 deletion pay-api/requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ pydocstyle<4

# docker
lovely-pytest-docker
pytest_docker
pytest-asyncio

3 changes: 2 additions & 1 deletion pay-api/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ asyncio-nats-client
asyncio-nats-streaming
croniter
sentry-sdk[flask]
attrs<=19.1.0
attrs<=19.1.0
jaeger-client
1 change: 0 additions & 1 deletion pay-api/requirements/repo-libraries.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
-e git://github.com/pwei1018/jaeger-client-python.git@186f14e14758273ed108508c0d388a4f4de5c75b#egg=jaeger-client
-e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components-1.0.0&subdirectory=python
2 changes: 1 addition & 1 deletion pay-api/src/pay_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
app.config.from_object(config.CONFIGURATION[run_mode])

# Configure Sentry
if app.config.get('SENTRY_DSN', None): # pragma: no cover
if app.config.get('SENTRY_DSN', None): # pragma: no cover
sentry_sdk.init(
dsn=app.config.get('SENTRY_DSN'),
integrations=[FlaskIntegration()]
Expand Down
2 changes: 1 addition & 1 deletion pay-api/src/pay_api/jwt_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class JWTWrapper: # pylint: disable=too-few-public-methods
@staticmethod
def get_instance():
"""Retrieve singleton JwtManager."""
if JWTWrapper.__instance is None: # pragma: no cover
if JWTWrapper.__instance is None: # pragma: no cover
JWTWrapper()
return JWTWrapper.__instance

Expand Down
4 changes: 3 additions & 1 deletion pay-api/src/pay_api/models/payment_line_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentLineItem(BaseModel):

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
invoice_id = db.Column(db.Integer, ForeignKey('invoice.id'), nullable=False)
filing_fees = db.Column(db.Integer, nullable=False)
filing_fees = db.Column(db.Float, nullable=False)
fee_schedule_id = db.Column(db.Integer, ForeignKey('fee_schedule.fee_schedule_id'), nullable=False)
quantity = db.Column(db.Integer, nullable=True)
priority_fees = db.Column(db.Float, nullable=True)
Expand All @@ -39,6 +39,8 @@ class PaymentLineItem(BaseModel):
pst = db.Column(db.Float, nullable=True)
total = db.Column(db.Float, nullable=False)
line_item_status_code = db.Column(db.String(20), ForeignKey('status_code.code'), nullable=False)
waived_fees = db.Column(db.Float, nullable=True)
waived_by = db.Column(db.String(50), nullable=True, default=None)

fee_schedule = relationship(FeeSchedule, foreign_keys=[fee_schedule_id], lazy='joined', innerjoin=True)

Expand Down
6 changes: 5 additions & 1 deletion pay-api/src/pay_api/resources/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def get(corp_type, filing_type_code):
is_priority = convert_to_bool(request.args.get('priority', 'False'))
is_future_effective = convert_to_bool(request.args.get('futureEffective', 'False'))
jurisdiction = request.args.get('jurisdiction', DEFAULT_JURISDICTION)
waive_fees = False
if _jwt.validate_roles([Role.STAFF.value]):
waive_fees = convert_to_bool(request.args.get('waiveFees', 'False'))

try:
response, status = (
Expand All @@ -54,7 +57,8 @@ def get(corp_type, filing_type_code):
valid_date=date,
jurisdiction=jurisdiction,
is_priority=is_priority,
is_future_effective=is_future_effective
is_future_effective=is_future_effective,
waive_fees=waive_fees
).asdict(),
HTTPStatus.OK,
)
Expand Down
9 changes: 9 additions & 0 deletions pay-api/src/pay_api/schemas/schemas/filing_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
true
]
},
"waiveFees": {
"$id": "#/properties/filing_types/items/properties/futureEffective",
"type": "boolean",
"title": "Override fees to zero. Only for staff users.",
"default": false,
"examples": [
true
]
},
"filingDescription": {
"$id": "#/properties/filing_types/items/properties/filingDescription",
"type": "string",
Expand Down
2 changes: 0 additions & 2 deletions pay-api/src/pay_api/services/bcol_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@

from flask import current_app

from pay_api.exceptions import BusinessException
from pay_api.services.base_payment_system import PaymentSystemService
from pay_api.services.invoice import Invoice
from pay_api.services.invoice_reference import InvoiceReference
from pay_api.services.payment_account import PaymentAccount
from pay_api.utils.enums import AuthHeaderType, ContentType
from pay_api.utils.enums import PaymentSystem as PaySystemCode
from pay_api.utils.errors import Error

from .oauth_service import OAuthService
from .payment_line_item import PaymentLineItem
Expand Down
16 changes: 16 additions & 0 deletions pay-api/src/pay_api/services/fee_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
self._filing_type: str = None
self._priority_fee: float = 0
self._future_effective_fee: float = 0
self._waived_fee_amount: float = 0

@property
def _dao(self):
Expand Down Expand Up @@ -140,6 +141,19 @@ def fee_amount(self):
"""Return the fee amount."""
return self._fee_amount

@fee_amount.setter
def fee_amount(self, fee_amount):
"""Override the fee amount."""
# set waived fees attribute to original fee amount
self._waived_fee_amount = self._fee_amount
# Override the fee amount
self._fee_amount = fee_amount

@property
def waived_fee_amount(self):
"""Return waived fee amount."""
return self._waived_fee_amount

@property
def priority_fee(self):
"""Return the priority fee."""
Expand Down Expand Up @@ -229,6 +243,8 @@ def find_by_corp_type_and_filing_type( # pylint: disable=too-many-arguments
fee_schedule.priority_fee = fee_schedule_dao.priority_fee.amount
if kwargs.get('is_future_effective') and fee_schedule_dao.future_effective_fee:
fee_schedule.future_effective_fee = fee_schedule_dao.future_effective_fee.amount
if kwargs.get('waive_fees'):
fee_schedule.fee_amount = 0

current_app.logger.debug('>get_fees_by_corp_type_and_filing_type')
return fee_schedule
2 changes: 1 addition & 1 deletion pay-api/src/pay_api/services/paybc_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def __add_adjustment(self, account_details: Tuple[str], # pylint: disable=too-m
current_app.logger.debug(f'>Creating PayBC Adjustment For Invoice: {inv_number}')
adjustment_url = current_app.config.get('PAYBC_BASE_URL') + '/cfs/parties/{}/accs/{}/sites/{}/invs/{}/adjs/' \
.format(account_details[0], account_details[1], account_details[2], inv_number)
current_app.logger.debug('>Creating PayBC Adjustment URL {}', adjustment_url)
current_app.logger.debug(f'>Creating PayBC Adjustment URL {adjustment_url}')

adjustment = dict(
comment=comment,
Expand Down
Loading

0 comments on commit 7ff6526

Please sign in to comment.