Invoice API v2 Rounding Error

dirtyDan11
Contributor
Contributor

I am trying to create an invoice with the invoicing api v2.

It works most of the time, but sometimes the API claims that the tax total is wrong. I assume this is a rounding error, but I don't know what I can do about it.

 

My example:
Item 1: unit_amount 44.28 plus 19% tax ([Removed. Phone #s not permitted]/p>

Item 2: unit_amount 42.75 plus 19% tax (8.1225) = 50.8725

Item Total: 103.5657 => Rounded to 103.57 for the API request.

Item Total without Tax 87.03 => No Rounding

Tax Total: 16.5357 => Rounded to 16.54 for the API request. This is where the API claims the error is.

I do not see the problem. How do I resolve this?

 

This is a request that fails in the sandbox:

 

{
    "detail": {
        "currency_code": "EUR",
        "invoice_number": "100822",
        "invoice_date": "2021-04-30",
        "payment_term": {
            "term_type": "DUE_ON_RECEIPT"
        }
    },
    "primary_recipients": [
        {
            "billing_info": {
                "name": {
                    "surname": "name"
                },
                "business_name": "name",
                "address": {
                    "address_line_1": "Hauptstr. 1",
                    "admin_area_3": "Ortsteil",
                    "admin_area_2": "12345 Ort",
                    "country_code": "DE"
                },
                "email_address": "sandboxemail",
                "language": "de"
            },
            "shipping_info": {
                "business_name": "Sanitär Kleber GmbH",
                "name": {
                    "prefix": "Firma"
                },
                "address": {
                    "address_line_1": "Hauptstr. 1",
                    "admin_area_3": "Ortsteil",
                    "admin_area_2": "12345 Ort",
                    "country_code": "DE"
                }
            }
        }
    ],
    "items": [
        {
            "id": "000010",
            "name": "Kaltwasserleitung DIN 1988 Teil2",
            "description": "Materialausprägung: Polyethylen HD\r\nEigenschaft: UV-beständig\r\nMax. Wasserdruck: 16 bar\r\n\r\n(Vetriebstext aus Mat.stamm)\r\n",
            "quantity": "1.000 ",
            "unit_amount": {
                "currency_code": "EUR",
                "value": "44.28 "
            },
            "tax": {
                "name": "Mehrwertsteuer",
                "percent": "19.00 "
            },
            "item_date": "2021-04-30",
            "unit_of_measure": "QUANTITY"
        },
        {
            "id": "000020",
            "name": "Warmwasserleitung DIN 1988 Teil2",
            "quantity": "1.000 ",
            "unit_amount": {
                "currency_code": "EUR",
                "value": "42.75 "
            },
            "tax": {
                "name": "Mehrwertsteuer",
                "percent": "19.00 "
            },
            "item_date": "2021-04-30",
            "unit_of_measure": "QUANTITY"
        }
    ],
    "amount": {
        "currency_code": "EUR",
        "value": "103.57 ",
        "breakdown": {
            "item_total": {
                "currency_code": "EUR",
                "value": "87.0300000 "
            },
            "tax_total": {
                "currency_code": "EUR",
                "value": "16.5400000 "
            }
        }
    }
}

 

This is the response:

 

{
    "name": "INVALID_REQUEST",
    "message": "Request is not well-formed, syntactically incorrect, or violates schema.",
    "debug_id": "974bef5678d42",
    "details": [
        {
            "field": "amount/breakdown/tax_total",
            "value": "16.5400000",
            "location": "BODY",
            "issue": "calculation_error",
            "description": "Tax total is invalid."
        }
    ],
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/invoicing/#errors",
            "method": "GET"
        }
    ]
}

 

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.