Creating a bill always sets value to 0.00

Hi, I wonder if anyone is able to assist. I have been attempting to create bills using the API. The bill creates fine but the value sets as 0.00. I have added line items, I’ve set the total value and lots of different methods but none of them appear to work. Does anyone know why this might happen.

def create_freeagent_bill():
“”" Create a bill in FreeAgent. “”"
refresh_token_if_needed()

headers = {'Authorization': f'Bearer {ACCESS_TOKEN}', 'Content-Type': 'application/json'}

bill_data = {
    'bill': {
        'contact': f'https://api.freeagent.com/v2/contacts/{CONTACT_REFERENCE}',
        'dated_on': datetime.now().strftime('%Y-%m-%d'),
        'due_on': datetime.now().strftime('%Y-%m-%d'),
        'reference': f'TestBill{datetime.now().strftime("%Y%m%d")}',
        'status': 'Draft',
        'input_total_values_inc_tax': True,  # Allow FreeAgent to calculate total
        'bill_items': [
            {
                'description': 'Manual Test Entry',
                'quantity': '1.0',
                'unit_price': '10.00',  # Ensure unit_price is passed as a string
                'sales_tax_rate': '20.0',  # Passed as a string
                'category': '250'
            }
        ]
    }
}

response = requests.post(FREEAGENT_BILL_URL, json=bill_data, headers=headers)
logging.debug(f"Bill creation data: {bill_data}")
if response.status_code == 201:
    logging.info("Bill created successfully.")
    logging.debug(f"Full Response: {response.json()}")
else:
    logging.error(f"Failed to create FreeAgent bill: {response.status_code}, {response.text}")

Hi Christopher

Trust you are well.

We are facing the same issue and i note you raised this case back in Sep 2024.

Have you resolved this issue? If so please can you share how you resolved this issue.

Your reply will be greatly appreciated and thank you in advance.

Regards

SK