Skip to content

Commit

Permalink
fix: Convert Decimal to int
Browse files Browse the repository at this point in the history
Decimal is not JSON serializable to fails to send message, convert to int before sending
  • Loading branch information
dhaselhan committed Dec 12, 2024
1 parent e7f429e commit 2c0941e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/api/services/TransactionMessageService.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
from decimal import Decimal

import pika
from pika.exceptions import AMQPError
from tfrs.settings import AMQP_CONNECTION_PARAMETERS
Expand All @@ -13,8 +15,9 @@ class TransactionDeliveryFailure(Exception):
class TransactionMessageService:
@staticmethod
def send_transaction_message(
tfrs_id: int, organization_id: int, compliance_units_amount: int
tfrs_id: int, organization_id: int, compliance_units_amount: Decimal
):

try:
# Use existing AMQP connection parameters from settings
parameters = AMQP_CONNECTION_PARAMETERS
Expand All @@ -28,7 +31,7 @@ def send_transaction_message(
message = {
"tfrs_id": tfrs_id,
"organization_id": organization_id,
"compliance_units_amount": compliance_units_amount,
"compliance_units_amount": int(compliance_units_amount.to_integral_value()),
}

# Publish the message to the queue
Expand Down

0 comments on commit 2c0941e

Please sign in to comment.