Tripletex / Tripletex/tripletex-api2

Buggy POST /v2/inventory/stocktaking/productline/list

Open
#95 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
49
Forks
47
Avg merge
1h 1m
Merged PRs (30d)
1

Description

While implementing stock-taking using the API we encountered a bug in the API.

Field count and location.id has no effect when issuing POST /v2/inventory/stocktaking/productline/list

POST /v2/inventory/stocktaking/productline/list
[
    {
        "stocktaking": {
            "id": 1040
        },
        "product": {
            "id": 21494313
        },
        "location": {
            "id": 13
        },
        "count": 5
    }
]

response payload:

{
    "fullResultSize": 0,
    "from": 0,
    "count": 1,
    "versionDigest": null,
    "values": [
        {
            "id": 1412118,
            "version": 0,
            "url": "api.tripletex.io/v2/inventory/stocktaking/productline/1412118",
            "stocktaking": {
                "id": 1040,
                "url": "api.tripletex.io/v2/inventory/stocktaking/1040"
            },
            "product": {
                "id": 21494313,
                "url": "api.tripletex.io/v2/product/21494313"
            },
            "count": 0,
            "unitCostCurrency": 0,
            "costCurrency": 0.00,
            "comment": "",
            "counted": false,
            "counter": null,
            "dateCounted": null,
            "expectedStock": 0,
            "location": null
        }
    ]
}

as count is 0 and location is null in the response.

One could work around this in a less performant way by issuing a single POST for each line to add:

POST /v2/inventory/stocktaking/productline
{
    "stocktaking": {
        "id": 1040
    },
    "product": {
        "id": 21494313
    },
    "location": {
        "id": 13
    },
    "count": 5
}

response payload:

{
    "value": {
        "url": "api.tripletex.io/v2/inventory/stocktaking/productline/0"
    }
}

in this request, the field count is working, but location.id does not. Since response payload nor headers do not contain the ID of the line added, one could not go further by issuing PUT /v2/inventory/stocktaking/productline/{ID}/:changeLocation?warehouseLocationId=39 to update the location on the line.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing POST /v2/inventory/stocktaking/productline/list with the payload shown, then compare it with POST /v2/inventory/stocktaking/productline. Trace the handling of count and location.id for both endpoints, including the subsequent :changeLocation operation. Done means the list endpoint persists both fields and the single-line endpoint returns enough information to update the location.

Written by the indexing model from the issue text.

Assessment

Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.