Help with Zoho Books Deluge code error

Help with Zoho Books Deluge code error

I have this deluge code im writing for Zoho Books button, it  throws an error: 

  • Check and update the code in line 12 as there is a Exception : Error at line :14 Improper Statement Error might be due to missing ';' at end of the line or incomplete expression

Im finding the deluge syntax is super tricky . Can anyone please help point me in the right direction

  1. sales_order_id = "";
    if (salesorder != null && salesorder.isMap()) 
    {
        sales_order_id = salesorder.get("sales_order_id");
    }

    organization_id = "00000000etc";

    validated_sales_order_id = ifnull(sales_order_id, "");  

    if (validated_sales_order_id == "") 
    {
        info "Error: Sales Order ID not found.";
    else 
    {
        sales_order_url = "https://www.zohoapis.eu/books/v3/salesorders/" + validated_sales_order_id + "?organization_id=" + organization_id;

        sales_order_details = zoho.books.invokeUrl([
            url : sales_order_url,
            type : GET,
            connection : "ZohoBooks"
        ]);

        if (sales_order_details.get("code") != 0 || sales_order_details.get("salesorder") == null) 
        {
            info "Error fetching Sales Order details: " + sales_order_details.get("message");
        } 
        else 
        {
            sales_order_data = sales_order_details.get("salesorder");

            if (sales_order_data != null) 
            {
                customer_id = sales_order_data.get("customer_id");
                total_amount = sales_order_data.get("total");
                sales_order_number = sales_order_data.get("salesorder_number");

                // Creating the Retainer Invoice Data
                retainer_invoice_map = Map();
                retainer_invoice_map.put("customer_id", customer_id);
                retainer_invoice_map.put("status", "draft");
                retainer_invoice_map.put("reference_number", "Payment for sales order: " + sales_order_number);
                retainer_invoice_map.put("amount", total_amount);

                line_item = Map();
                line_item.put("description", "Payment for sales order: " + sales_order_number);
                line_item.put("rate", total_amount);
                line_item.put("quantity", 1);

                line_items = List();
                line_items.add(line_item);
                retainer_invoice_map.put("line_items", line_items);

                // Convert Map to JSON String
                json_parameters = Map();
                json_parameters.put("JSONString", zoho.encryption.toJSON(retainer_invoice_map));

                create_response = zoho.books.invokeUrl([
                    url : "https://www.zohoapis.eu/books/v3/retainerinvoices?organization_id=" + organization_id,
                    type : POST,
                    parameters : json_parameters,
                    connection : "ZohoBooks"
                ]);
                
                info create_response;
            } 
            else 
            {
                info "Error: Invalid Sales Order data received.";
            }
        }
    }