[add]: penal charge
This commit is contained in:
@@ -2,7 +2,10 @@ from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.schemas.penal_charge import PenalChargeSchema, CollectPenalFeeResponseSchema
|
||||
from app.api.schemas.penal_charge import (
|
||||
PenalChargeSchema,
|
||||
CollectPenalFeeResponseSchema,
|
||||
)
|
||||
|
||||
|
||||
class PenalChargeService:
|
||||
@@ -24,14 +27,20 @@ class PenalChargeService:
|
||||
schema = PenalChargeSchema()
|
||||
validated_data = schema.load(data)
|
||||
|
||||
# Simulated processing logic
|
||||
customerId = validated_data["customerId"]
|
||||
transactionId = validated_data["transactionId"]
|
||||
penalCharge = validated_data["penalCharge"]
|
||||
accountId = validated_data["accountId"]
|
||||
lienAmount = validated_data["lienAmount"]
|
||||
|
||||
response_data = {
|
||||
"customerId": validated_data.get("customerId"),
|
||||
"transactionId": validated_data.get("transactionId"),
|
||||
"amountCollected": validated_data.get("penalCharge", 0.0),
|
||||
"accountId": validated_data.get("accountId"),
|
||||
"responseCode": "00",
|
||||
"responseMessage": "Penal charge debited successfully"
|
||||
"responseMessage": "Penal Collection Successful",
|
||||
"customerId": customerId,
|
||||
"transactionId": transactionId,
|
||||
"amountCollected": penalCharge,
|
||||
"lienAmount": lienAmount,
|
||||
"accountId": accountId,
|
||||
}
|
||||
|
||||
# Optionally validate/serialize response using schema
|
||||
@@ -42,13 +51,11 @@ class PenalChargeService:
|
||||
|
||||
except ValidationError as err:
|
||||
logger.error(f"Validation Error: {err.messages}")
|
||||
return jsonify({
|
||||
"message": "Validation exception",
|
||||
"errors": err.messages
|
||||
}), 422
|
||||
return (
|
||||
jsonify({"message": "Validation exception", "errors": err.messages}),
|
||||
422,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||
return jsonify({
|
||||
"message": "Internal Server Error"
|
||||
}), 500
|
||||
return jsonify({"message": "Internal Server Error"}), 500
|
||||
|
||||
Reference in New Issue
Block a user