diff --git a/request-management-api/request_api/receipt_templates/cfr_fee_payment_receipt_full.docx b/request-management-api/request_api/receipt_templates/cfr_fee_payment_receipt_full.docx index 97c71e521..768956827 100644 Binary files a/request-management-api/request_api/receipt_templates/cfr_fee_payment_receipt_full.docx and b/request-management-api/request_api/receipt_templates/cfr_fee_payment_receipt_full.docx differ diff --git a/request-management-api/request_api/resources/fee.py b/request-management-api/request_api/resources/fee.py index 84f8952f8..b3b8216ef 100644 --- a/request-management-api/request_api/resources/fee.py +++ b/request-management-api/request_api/resources/fee.py @@ -96,7 +96,7 @@ def put(request_id: int, ministry_request_id: int, payment_id: int): response, parsed_args = fee.complete_payment(request_json) if (response['status'] == 'PAID'): latest_cfr = cfrfeeservice().getcfrfeehistory(ministry_request_id)[0] - previously_paid_amount = latest_cfr['feedata']['amountpaid'] if latest_cfr['feedata']['amountpaid'] is not None else "0.00" + previously_paid_amount = latest_cfr['feedata']['amountpaid'] if latest_cfr['feedata']['amountpaid'] is not None else 0 amountpaid = float(parsed_args.get('trnAmount')) cfrfeeservice().paycfrfee(ministry_request_id, amountpaid) paymentservice().createpaymentversion(request_id, ministry_request_id, amountpaid) diff --git a/request-management-api/request_api/services/paymentservice.py b/request-management-api/request_api/services/paymentservice.py index 0bf3c6b21..3bf598034 100644 --- a/request-management-api/request_api/services/paymentservice.py +++ b/request-management-api/request_api/services/paymentservice.py @@ -19,6 +19,7 @@ import pytz import maya import logging +import re class paymentservice: """ FOI payment management service @@ -86,15 +87,14 @@ def getpaymentexpirydate(self, requestid, ministryrequestid): def createpaymentreceipt(self, request_id, ministry_request_id, data, parsed_args, previously_paid_amount): try: - data['previous_amt_paid'] = previously_paid_amount + data['previous_amt_paid'] = '{:.2f}'.format(previously_paid_amount) templatename = self.__getlatesttemplatename(ministry_request_id) balancedue = float(data['cfrfee']['feedata']["balanceDue"]) prevstate = data["stateTransition"][1]["status"] if "stateTransition" in data and len(data["stateTransition"]) > 2 else None basepath = 'request_api/receipt_templates/' receiptname = 'cfr_fee_payment_receipt' attachmentcategory = "FEE-ESTIMATE-PAYMENT-RECEIPT" - filename = f"Fee Estimate Payment Receipt {data['cfrfee']['created_at']}.pdf" - print(data) + filename = f"Fee Estimate Payment Receipt {re.sub(r'[^a-zA-Z0-9]', '', data['cfrfee']['created_at'])}.pdf" if balancedue > 0: receipt_template_path= basepath + self.getreceiptename('HALFPAYMENT') +".docx" receiptname = self.getreceiptename('HALFPAYMENT') @@ -103,7 +103,7 @@ def createpaymentreceipt(self, request_id, ministry_request_id, data, parsed_arg if prevstate.lower() == "response" or (templatename and templatename == 'PAYOUTSTANDING'): receiptname = self.getreceiptename('PAYOUTSTANDING') attachmentcategory = "OUTSTANDING-PAYMENT-RECEIPT" - filename = f"Fee Balance Outstanding Payment Receipt {data['cfrfee']['created_at']}.pdf" + filename = f"Fee Balance Outstanding Payment Receipt {re.sub(r'[^a-zA-Z0-9]', '', data['cfrfee']['created_at'])}.pdf" receipt_template_path= basepath + receiptname + ".docx" data['waivedAmount'] = data['cfrfee']['feedata']['estimatedlocatinghrs'] * 30 if data['cfrfee']['feedata']['estimatedlocatinghrs'] < 3 else 90 data.update({'paymentInfo': { @@ -112,7 +112,6 @@ def createpaymentreceipt(self, request_id, ministry_request_id, data, parsed_arg 'transactionId': parsed_args.get('pbcTxnNumber'), 'cardType': parsed_args.get('cardType') }}) - print(data) document_service : DocumentGenerationService = DocumentGenerationService(receiptname) receipt = document_service.generate_receipt(data,receipt_template_path) document_service.upload_receipt(filename, receipt.content, ministry_request_id, data['bcgovcode'], data['idNumber'], attachmentcategory)