Skip to content

Commit

Permalink
Adjusted invoice template to account for better trakcing of previous …
Browse files Browse the repository at this point in the history
…amount paid for revised fees. WIP Testing in dev + code clean after confirmation in dev
  • Loading branch information
Aman-Hundal committed Feb 5, 2024
1 parent 670b0ce commit c225a4e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 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']['paidamount'] if latest_cfr['feedata']['paidamount'] is not None else "0.00"
previously_paid_amount = latest_cfr['feedata']['amountpaid'] if latest_cfr['feedata']['amountpaid'] is not None else "0.00"
amountpaid = float(parsed_args.get('trnAmount'))
cfrfeeservice().paycfrfee(ministry_request_id, amountpaid)
paymentservice().createpaymentversion(request_id, ministry_request_id, amountpaid)
Expand Down
5 changes: 3 additions & 2 deletions request-management-api/request_api/services/paymentservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ 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
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"
#LOGIC -> if cfrformreasonid === 2 adjust file name to revised fee estimate and date.
#Logic for revised invoi -> You can also get and check balanceremainig here by accessingg fee data like above -> and if crfform id = 2 -> you can create a whole new invoice for the revised fee
filename = f"Fee Estimate Payment Receipt {data['cfrfee']['created_at']}.pdf"
print(data)
if balancedue > 0:
receipt_template_path= basepath + self.getreceiptename('HALFPAYMENT') +".docx"
receiptname = self.getreceiptename('HALFPAYMENT')
Expand All @@ -112,6 +112,7 @@ 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 c225a4e

Please sign in to comment.