commercetools / orders-update

A library that helps with updating orders into the commercetools platform.
https://npmjs.com/@commercetools/orders-update
MIT License
1 stars 1 forks source link

Rework error handling and some minor changes #18

Closed junajan closed 5 years ago

junajan commented 6 years ago

Support reference number

SUPPORT-4052

Description

As discussed in the ticket above:

I tried several things in order to update lineItem states and here is what I found: When I tried to import file import.csv with these fields:

orderNumber,lineItemId,fromState,toState,quantity
CT-TESTING-3,be81e62a-e6fb-4afa-bc17-163b43270b85,Initial,workInProgress,1

It was translated to this json:

[{
    "orderNumber": "CT-TESTING-3",
    "lineItems": [{
        "id": "be81e62a-e6fb-4afa-bc17-163b43270b85",
        "state": [{
            "quantity": 1,
            "fromState": "Initial",
            "toState": "workInProgress"
        }]
    }]
}]

Which did not work in Impex nor directly through CLI. Also, no error was thrown. Then I noticed here that we use a field named as "_fromStateQty" https://github.com/commercetools/orders-update

So I tried to run this new version:

orderNumber,lineItemId,fromState,toState,quantity,_fromStateQty
CT-TESTING-3,be81e62a-e6fb-4afa-bc17-163b43270b85,Initial,workInProgress,1,1

And it worked - lineItem.state was changed. So it looks like this field is mandatory for changing states.

I also tried to make lineItemId UUID empty which gave me this error: https://gist.github.com/junajan/c1626fd74a41318f1792d6604849db1f

And then I tried to remove the whole lineItemId column which did not give me any error, but the order-update CLI tool just died.

So to wrap it up:

junajan commented 5 years ago

I tried to run again the case without lineItemId column:

orderNumber,fromState,toState,quantity,_fromStateQty
CT-TESTING-3,Initial,workInProgress,1,1

And now I got an error:

ERR: Required headers missing: 'lineItemId'info:    Reading data from stdin...
info:    {
  "errors": [],
  "inserted": [],
  "successfullImports": 0
}