NETSUITE: Getting error while transforming sales order into invoice with REST API

233 Views Asked by At

I have a sales order in Netsuite and I'm trying to invoice a part of the sales order to have to possibility to invoice multiple time the customer.
I tried differents ways but each time I'm getting an error.

The Sales order have 3 item for the first line and 2 for the second line

URL: {{REST_SERVICES}}/record/v1/salesorder/18657/!transform/invoice

{
    "trandate":"2023-11-21",
    "startdate":"2023-11-21",
    "duedate":"2023-12-31",
    "memo": "This is apostman test!",
    "externalid":"PO000093",
    "salesrep":"209",
    "tranId": "T2023000024",
    "item":{
        "items" : [ 
            {
                "item": {
                    "id" : "578"
                },
                "quantity" : 1.00
            },
            {
                "item": {
                    "id" : "578"
                },
                "quantity" : 1.00
            }
        ]
    }
}

=> return:

{
    "type": "https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.1",
    "title": "Bad Request",
    "status": 400,
    "o:errorDetails": [
        {
            "detail": "Error while accessing a resource. Please choose an item to add.",
            "o:errorPath": "item.items[0]",
            "o:errorCode": "USER_ERROR"
        }
    ]
}

The ways as per the documentation:

{
    "trandate":"2023-11-21",
    "startdate":"2023-11-21",
    "duedate":"2023-12-31",
    "memo": "This is apostman test!",
    "externalid":"PO000093",
    "salesrep":"209",
    "tranId": "T2023000024",
    "item":{
        "items" : [ 
            {
                "orderLine" : 1,
                "quantity" : 1.00
            },
            {
                "orderLine" : 2,
                "quantity" : 1.00
            }
        ]
    }
}

Return:

{
    "type": "https://www.rfc-editor.org/rfc/rfc9110.html#section-15.6.1",
    "title": "Internal Server Error",
    "status": 500,
    "o:errorDetails": [
        {
            "detail": "An unexpected error occurred. Error ID: lod29zoc1fx69m8xhmt5i",
            "o:errorCode": "UNEXPECTED_ERROR"
        }
    ]
}
1

There are 1 best solutions below

3
On BEST ANSWER

I raised a case at Netsuite and I'm waiting for an answer.
The alternative will be to create a stand alone invoice and link the line to the sales order.
Here is an example:

{
    "entity": {
        "id": "1957"
    },
    "item": {
        "items": [
            {
                "account": {
                    "id": "307"
                },
                "amount": 2000.0,
                "description": "Testing invoicing",
                "item": {
                    "id": "578"
                },
                "orderDoc": {
                    "id": <your sales order id>
                },
                "orderLine": <your sales order line number>,
                "quantity": 1.0,
                "rate": 2000.0
            }
        ]
    },
    "memo": "Testing transformation alternative",
    "prevDate": "2023-10-30",
    "prevRep": 209,
    "salesEffectiveDate": "2023-10-30",
    "subsidiary": {
        "id": "5"
    },
    "tranDate": "2023-10-30",
    "tranId": "INV004 testing alternative - 0003"
}