2

Here is the require fields of Create the Inventory Adjustment through Zoho API:

{
    "date": "2023-08-02",
    "reason": "my reason",
    "description": "Testing",
    "adjustment_type": "quantity",
    "line_items": [{
        "item_id": 2954987000000641651,     // This id is coming from Zoho
        "quantity_adjusted": -1
    }]
}

When I try to hit this API from Postman it is working good and have this message from zoho:

"code": 0,
"message": "Inventory Adjustment has been added",
"inventory_adjustment": {
  // other details
}

PROBLEM:

Now let's come to the my server when I try to "Create Inventory Adjustment" from my Express server. I have problem to pass item_id.

API require an bool data type for item_id but in JavaScript when I try to pass this ID: 2954987000000641651 it has 19 digits and JavaScript integer only support 15 digits. So it's convert every ID with like this 2954987000000641500 and I have this response from Zoho:

{
  code: 103003,
  message: 'Non-inventory items(s) are involved in this transaction.'
}

This is because When I try to adjust a specific item ID, it changes the id into different number that js maximum support. And that item is not exist in my zoho account. Like:

Expected:

{
    "date": "2023-08-02",
    "reason": "my reason",
    "description": "Testing",
    "adjustment_type": "quantity",
    "line_items": [{
        "item_id": 2954987000000641651,     // This id is coming from Zoho
        "quantity_adjusted": -1
    }]
}

What actually happening:

{
    "date": "2023-08-02",
    "reason": "my reason",
    "description": "Testing",
    "adjustment_type": "quantity",
    "line_items": [{
        "item_id": 2954987000000641500,     // This id is coming from Zoho
        "quantity_adjusted": -1
    }]
}

I also tried to use BigInt(2954987000000641651) but my server gives me error:

TypeError: Do not know how to serialize a BigInt
at JSON.stringify(<anonymous>)....

How can I solve this problem?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Add zoho wont allow you to pass the item as a string? – Nicholas Stom Aug 02 '23 at 18:40
  • No. It won't me allow to pass string. Here is the doc of zoho: https://www.zoho.com/inventory/api/v1/itemadjustments/#create-an-item-adjustment This is what exactly he wants: item_id long (Required) Unique ID generated by the server for the item. This is used as an identifier. – Zubair Javed Aug 03 '23 at 06:00

1 Answers1

1

I contact the Zoho team. They suggest me this way:

{
  "line_items": [
    {
      "item_id": "item_id",
      "quantity_adjusted": "-1",
      "adjustment_account_id": "adjustment_account_id",
      "warehouse_id": "warehouse_id",
      "serial_numbers": [
        "serial_number"
      ]
    }
  ],
  "date": "2022-02-17",
  "reason": "reason",
  "adjustment_type": "quantity"
}

Pass all the values in string, like

let reqData = 
{
    date: new Date().toISOString().slice(0, 10),
    reason: "Parts For Rental",
    description: "Testing...",
    adjustment_type: "quantity",
    line_items: [{
        item_id: `${Item.item_id}`,
        quantity_adjusted: `-${part.Quantity}`
    }]
}

When all values are in the format of string then no worries about the integer limit in js.