Skip to content

Commit

Permalink
20596 - Minor clean up and changes for jobs (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Jul 17, 2024
1 parent 8cd67a3 commit 107c843
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 62 deletions.
111 changes: 56 additions & 55 deletions jobs/payment-jobs/invoke_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,61 +96,62 @@ def run(job_name, argument=None):
application = create_app(job_name=job_name, init_oracle=job_name in jobs_with_oracle_connections)

application.app_context().push()
if job_name == 'UPDATE_GL_CODE':
DistributionTask.update_failed_distributions()
application.logger.info(f'<<<< Completed Updating GL Codes >>>>')
elif job_name == 'GENERATE_STATEMENTS':
StatementTask.generate_statements(argument)
application.logger.info(f'<<<< Completed Generating Statements >>>>')
elif job_name == 'SEND_NOTIFICATIONS':
StatementNotificationTask.send_notifications()
application.logger.info(f'<<<< Completed Sending notifications >>>>')
elif job_name == 'UPDATE_STALE_PAYMENTS':
StalePaymentTask.update_stale_payments()
application.logger.info(f'<<<< Completed Updating stale payments >>>>')
elif job_name == 'CREATE_CFS_ACCOUNTS':
CreateAccountTask.create_accounts()
application.logger.info(f'<<<< Completed creating cfs accounts >>>>')
elif job_name == 'CREATE_INVOICES':
CreateInvoiceTask.create_invoices()
application.logger.info(f'<<<< Completed creating cfs invoices >>>>')
elif job_name == 'ACTIVATE_PAD_ACCOUNTS':
ActivatePadAccountTask.activate_pad_accounts()
application.logger.info(f'<<<< Completed Activating PAD accounts >>>>')
elif job_name == 'EJV_PARTNER':
EjvPartnerDistributionTask.create_ejv_file()
application.logger.info(f'<<<< Completed Creating EJV File for partner distribution>>>>')
elif job_name == 'NOTIFY_UNPAID_INVOICE_OB':
UnpaidInvoiceNotifyTask.notify_unpaid_invoices()
application.logger.info(f'<<<< Completed Sending notification for OB invoices >>>>')
elif job_name == 'STATEMENTS_DUE':
StatementDueTask.process_unpaid_statements()
application.logger.info(f'<<<< Completed Sending notification for unpaid statements >>>>')
elif job_name == 'ROUTING_SLIP':
RoutingSlipTask.link_routing_slips()
RoutingSlipTask.process_void()
RoutingSlipTask.process_nsf()
RoutingSlipTask.process_correction()
RoutingSlipTask.adjust_routing_slips()
application.logger.info(f'<<<< Completed Routing Slip tasks >>>>')
elif job_name == 'EFT':
EFTTask.link_electronic_funds_transfers_cfs()
EFTTask.reverse_electronic_funds_transfers_cfs()
application.logger.info(f'<<<< Completed EFT tasks >>>>')
elif job_name == 'EJV_PAYMENT':
EjvPaymentTask.create_ejv_file()
application.logger.info(f'<<<< Completed running EJV payment >>>>')
elif job_name == 'AP':
ApTask.create_ap_files()
application.logger.info(f'<<<< Completed running AP Job for refund >>>>')
elif job_name == 'DIRECT_PAY_REFUND':
DirectPayAutomatedRefundTask.process_cc_refunds()
application.logger.info(f'<<<< Completed running Direct Pay Automated Refund Job >>>>')
elif job_name == 'BCOL_REFUND_CONFIRMATION':
BcolRefundConfirmationTask.update_bcol_refund_invoices()
application.logger.info(f'<<<< Completed running BCOL Refund Confirmation Job >>>>')
else:
application.logger.debug('No valid args passed. Exiting job without running any ***************')
match job_name:
case 'UPDATE_GL_CODE':
DistributionTask.update_failed_distributions()
application.logger.info('<<<< Completed Updating GL Codes >>>>')
case 'GENERATE_STATEMENTS':
StatementTask.generate_statements(argument)
application.logger.info('<<<< Completed Generating Statements >>>>')
case 'SEND_NOTIFICATIONS':
StatementNotificationTask.send_notifications()
application.logger.info('<<<< Completed Sending notifications >>>>')
case 'UPDATE_STALE_PAYMENTS':
StalePaymentTask.update_stale_payments()
application.logger.info('<<<< Completed Updating stale payments >>>>')
case 'CREATE_CFS_ACCOUNTS':
CreateAccountTask.create_accounts()
application.logger.info('<<<< Completed creating cfs accounts >>>>')
case 'CREATE_INVOICES':
CreateInvoiceTask.create_invoices()
application.logger.info('<<<< Completed creating cfs invoices >>>>')
case 'ACTIVATE_PAD_ACCOUNTS':
ActivatePadAccountTask.activate_pad_accounts()
application.logger.info('<<<< Completed Activating PAD accounts >>>>')
case 'EJV_PARTNER':
EjvPartnerDistributionTask.create_ejv_file()
application.logger.info('<<<< Completed Creating EJV File for partner distribution>>>>')
case 'NOTIFY_UNPAID_INVOICE_OB':
UnpaidInvoiceNotifyTask.notify_unpaid_invoices()
application.logger.info('<<<< Completed Sending notification for OB invoices >>>>')
case 'STATEMENTS_DUE':
StatementDueTask.process_unpaid_statements()
application.logger.info('<<<< Completed Sending notification for unpaid statements >>>>')
case 'ROUTING_SLIP':
RoutingSlipTask.link_routing_slips()
RoutingSlipTask.process_void()
RoutingSlipTask.process_nsf()
RoutingSlipTask.process_correction()
RoutingSlipTask.adjust_routing_slips()
application.logger.info('<<<< Completed Routing Slip tasks >>>>')
case 'EFT':
EFTTask.link_electronic_funds_transfers_cfs()
EFTTask.reverse_electronic_funds_transfers_cfs()
application.logger.info('<<<< Completed EFT tasks >>>>')
case 'EJV_PAYMENT':
EjvPaymentTask.create_ejv_file()
application.logger.info('<<<< Completed running EJV payment >>>>')
case 'AP':
ApTask.create_ap_files()
application.logger.info('<<<< Completed running AP Job for refund >>>>')
case 'DIRECT_PAY_REFUND':
DirectPayAutomatedRefundTask.process_cc_refunds()
application.logger.info('<<<< Completed running Direct Pay Automated Refund Job >>>>')
case 'BCOL_REFUND_CONFIRMATION':
BcolRefundConfirmationTask.update_bcol_refund_invoices()
application.logger.info('<<<< Completed running BCOL Refund Confirmation Job >>>>')
case _:
application.logger.debug('No valid args passed. Exiting job without running any ***************')


if __name__ == "__main__":
Expand Down
8 changes: 7 additions & 1 deletion jobs/payment-jobs/logging.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[loggers]
keys=root,api,invoke_jobs
keys=root,api,invoke_jobs,sqlalchemy.engine.Engine

[handlers]
keys=console
Expand All @@ -23,6 +23,12 @@ handlers=console
qualname=invoke_jobs
propagate=0

[logger_sqlalchemy.engine.Engine]
level=DEBUG
handlers=console
qualname=sqlalchemy.engine.Engine
propagate=0

[handler_console]
class=StreamHandler
level=DEBUG
Expand Down
4 changes: 2 additions & 2 deletions jobs/payment-jobs/run_eft_task.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /bin/sh
echo 'run invoke_jobs.py EFT_TRANSFER'
python3 invoke_jobs.py EFT_TRANSFER
echo 'run invoke_jobs.py EFT'
python3 invoke_jobs.py EFT
8 changes: 7 additions & 1 deletion pay-api/src/pay_api/logging.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[loggers]
keys=root,api,api-exceptions
keys=root,api,api-exceptions,sqlalchemy.engine.Engine

[handlers]
keys=console
Expand All @@ -23,6 +23,12 @@ handlers=console
qualname=api-exceptions
propagate=0

[logger_sqlalchemy.engine.Engine]
level=DEBUG
handlers=console
qualname=sqlalchemy.engine.Engine
propagate=0

[handler_console]
class=StreamHandler
level=DEBUG
Expand Down
4 changes: 1 addition & 3 deletions pay-api/src/pay_api/services/cfs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,17 @@ def reverse_rs_receipt_in_cfs(cls, cfs_account, receipt_number, operation: Rever
@classmethod
def apply_receipt(cls, cfs_account: CfsAccountModel, receipt_number: str, invoice_number: str) -> Dict[str, any]:
"""Apply Invoice to Routing slip receipt from CFS."""
current_app.logger.debug(f'Apply receipt: {receipt_number} to invoice {invoice_number}')
return cls._modify_rs_receipt_in_cfs(cfs_account, invoice_number, receipt_number)

@classmethod
def unapply_receipt(cls, cfs_account: CfsAccountModel, receipt_number: str, invoice_number: str) -> Dict[str, any]:
"""Unapply Invoice to Routing slip receipt from CFS."""
current_app.logger.debug(f'Unapply receipt: {receipt_number} from invoice {invoice_number}')
return cls._modify_rs_receipt_in_cfs(cfs_account, invoice_number, receipt_number, verb='unapply')

@classmethod
def _modify_rs_receipt_in_cfs(cls, cfs_account, invoice_number, receipt_number, verb='apply'):
"""Apply and unapply using the verb passed."""
current_app.logger.debug('>Apply receipt: %s invoice:%s', receipt_number, invoice_number)
current_app.logger.debug('>%s receipt: %s invoice:%s', verb, receipt_number, invoice_number)
access_token: str = CFSService.get_token().json().get('access_token')
cfs_base: str = current_app.config.get('CFS_BASE_URL')
receipt_url = f'{cfs_base}/cfs/parties/{cfs_account.cfs_party}/accs/{cfs_account.cfs_account}' \
Expand Down
40 changes: 40 additions & 0 deletions pay-queue/src/pay_queue/logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[loggers]
keys=root,api,api-exceptions,sqlalchemy.engine.Engine

[handlers]
keys=console

[formatters]
keys=simple

[logger_root]
level=DEBUG
handlers=console

[logger_api]
level=DEBUG
handlers=console
qualname=pay_api
propagate=0

[logger_api-exceptions]
level=ERROR
handlers=console
qualname=api-exceptions
propagate=0

[logger_sqlalchemy.engine.Engine]
level=DEBUG
handlers=console
qualname=sqlalchemy.engine.Engine
propagate=0

[handler_console]
class=StreamHandler
level=DEBUG
formatter=simple
args=(sys.stdout,)

[formatter_simple]
format=%(asctime)s - %(name)s - %(levelname)s in %(module)s:%(filename)s:%(lineno)d - %(funcName)s: %(message)s
datefmt=

0 comments on commit 107c843

Please sign in to comment.