Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not update stock movements from api #2698

Open
congpc73 opened this issue Oct 16, 2021 · 14 comments
Open

Can not update stock movements from api #2698

congpc73 opened this issue Oct 16, 2021 · 14 comments

Comments

@congpc73
Copy link

Can not update stock movements. Not found. But get exist in system

image

image

@jmiranda
Copy link
Member

Hmm that's odd. The request looks ok. Can you look at the logs to see what that 404 error is actually for? And can you show me your headers?

In fact can you share your postman request / collection with me?

Otherwise I'll try to replicate it on Monday.

Also please share the OpenBoxes version you're testing against.

@jmiranda
Copy link
Member

jmiranda commented Oct 16, 2021 via email

@congpc73
Copy link
Author

This is my version application
image

@congpc73
Copy link
Author

my request login api was include location

@congpc73
Copy link
Author

My header request create stock movement
image

@jmiranda
Copy link
Member

Shoot. I'm seeing the same behavior.

image

And I've looked at the code now and ... I'm stunned by this ... but I don't think we have an endpoint to update a stock movement through the API. I think we only needed to be able to create the stock movement.

The following URL mapping shows that we're only supporting the GET method on the Stock Movement API

        "/api/stockMovementItems/$id"(parseRequest: true) {
            controller = "stockMovementItemApi"
            action = [GET: "read"]
        }

I'll add in the API to handle updating and deleting. But there are ways to do this with an explicit update endpoint.

In fact, we created a bunch of REST and RPC-style endpoints to update different aspects of the stock movement (status, line items, picklist, etc). So it's possible one of these could work for you. Let me know what properties / associations you're looking to update and I can provide an alternative until the aforementioned API is ready.

Note: I've always hated that we implemented RPC-style endpoints for some of these things, but they'll exist at least through 0.9.0 so you can be free to use them until then. Again, just let me know what you're looking to do and I'll point you in the right direction.

URL Mappings

// Stock Movement API

"/api/stockMovements/$id/removeAllItems"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [DELETE: "removeAllItems"]
}

"/api/stockMovements/$id/reviseItems"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "reviseItems"]
}

"/api/stockMovements/$id/updateItems"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "updateItems"]
}

"/api/stockMovements/$id/updateInventoryItems"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "updateInventoryItems"]
}

"/api/stockMovements/$id/updateShipmentItems"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "updateShipmentItems"]
}

"/api/stockMovements/$id/updateRequisition"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "updateRequisition"]
}

"/api/stockMovements/$id/updateShipment"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "updateShipment"]
}

"/api/stockMovements/$id/validatePicklist"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [GET: "validatePicklist"]
}

"/api/stockMovements/importPickListItems/$id"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "importPickListItems"]
}

"/api/stockMovements/exportPickListItems/$id"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [GET: "exportPickListItems"]
}

"/api/stockMovements/createPickList/$id"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [GET: "createPickList"]
}

"/api/stockMovements/$id/updateAdjustedItems"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "updateAdjustedItems"]
}

// TODO Remove it later once all inbound types are shipment
"/api/stockMovements/createCombinedShipments"(parseRequest: true) {
    controller = "stockMovementApi"
    action = [POST: "createCombinedShipments"]
}

And then even more RPC-style endpoints were added for the Stock Movement Item API

"/api/stockMovementItems/$id/updatePicklist"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [POST: "updatePicklist"]
}

"/api/stockMovementItems/$id/createPicklist"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [POST: "createPicklist"]
}

"/api/stockMovementItems/$id/clearPicklist"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [POST: "clearPicklist"]
}

"/api/stockMovementItems/$id/substituteItem"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [POST: "substituteItem"]
}

"/api/stockMovementItems/$id/revertItem"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [POST: "revertItem"]
}

"/api/stockMovementItems/$id/cancelItem"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [POST: "cancelItem"]
}

"/api/stockMovementItems/$id/removeItem"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [DELETE: "removeItem"]
}

"/api/stockMovements/$id/stockMovementItems"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [GET: "getStockMovementItems"]
}

"/api/stockMovements/$id/substitutionItems"(parseRequest: true) {
    controller = "stockMovementItemApi"
    action = [GET: "getSubstitutionItems"]
}

@congpc73
Copy link
Author

Im using api to magerer order. inventoy .... Please update the document api. Thank you for support

@congpc73
Copy link
Author

I want to create order from api. Add item to order. Then update status of order

  • api create order (include items)
  • api update order. ex total, pirce, items ...
  • api update status of order

@jmiranda
Copy link
Member

All of those operations are supported by the current API. I'll either write up more explicit instructions or add some requests to your postman collection.

One caveat: stock movement items do not currently support price. Stock movements are more like transfer / delivery orders. We haven't had a need to support Sales Orders yet but we could add that feature in the future.

Basically that just means you can't associate a price with a line item. Almost everything else you need should be available. For now you can use the price associated with the product to calculate the total for the order but that might be less than ideal depending on your requirements.

Justin

@congpc73
Copy link
Author

Please add document api. I don't know the input param/body to using api.

@jmiranda
Copy link
Member

Sorry, what do you mean by "add document API"? Are you asking me to document the Stock Movement API? Or are you asking me to provide information about our Document API?

@congpc73
Copy link
Author

https://docs.openboxes.com/en/latest/api-guide/reasonCode/
This is link doccument api.

@congpc73
Copy link
Author

Please update and add new api doccument there

@jmiranda
Copy link
Member

Yes, will update the API docs as soon as I can, which might not be until later in the week.

In the meantime, here's some sample React code showing how a stock movement is created / saved.
https://github.com/openboxes/openboxes/blob/develop/src/js/components/stock-movement-wizard/outbound/CreateStockMovement.jsx#L295

Here's an example of how to save stock movement items
https://github.com/openboxes/openboxes/blob/develop/src/js/components/stock-movement-wizard/outbound/AddItemsPage.jsx#L691

And here's an example of how to update the status once all items have been added
https://github.com/openboxes/openboxes/blob/develop/src/js/components/stock-movement-wizard/outbound/AddItemsPage.jsx#L880

Valid statues are

  • CREATED
  • REQUESTED
  • VALIDATED
  • PICKING
  • PICKED
  • PACKED
  • CHECKING
  • CHECKED
  • DISPATCHED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants