Skip to content

Commit

Permalink
Added spaces to invoice lines + formatted previoiusly paid amt dollar…
Browse files Browse the repository at this point in the history
… value + adjusted filename so that only alphatnumeric values are present
  • Loading branch information
Aman-Hundal committed Feb 6, 2024
1 parent c225a4e commit cf32306
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion request-management-api/request_api/resources/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions request-management-api/request_api/services/paymentservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pytz
import maya
import logging
import re

class paymentservice:
""" FOI payment management service
Expand Down Expand Up @@ -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')
Expand All @@ -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': {
Expand All @@ -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)
Expand Down

0 comments on commit cf32306

Please sign in to comment.