ShoppinPal / vend-tools

A command-line-interface (CLI) which allows you to easily perform custom tasks for your vendhq.com instance
http://shoppinpal.github.io/vend-tools/
GNU General Public License v2.0
3 stars 3 forks source link

Add a command to delete frivolous stock orders #7

Open pulkitsinghal opened 9 years ago

pulkitsinghal commented 9 years ago

Reference: https://developers.vendhq.com/documentation/api/0.x/consignments.html#post-api-consignment-product

$ vend-tools delete-stock-orders --status OPEN
1. OPEN - Order - Wed 28 Jan 2015 - 2015-01-28 21:45:34
2. OPEN - blah - 2015-02-27 23:57:06
3. OPEN - test123 - 2015-03-03 22:33:51
Which stock order should be deleted?
pulkitsinghal commented 9 years ago

Some open questions:

  1. Is there some way to query for consignments that don't have any products attached to them? That way perhaps only those can be offered up for deletion in the presented options.
  2. Do bad things happen if we delete a consignment and do not delete associated consignment products beforehand?
  3. Is there a way to get a total count for the products attached to a consignment? Other than counting the results from: GET /api/consignment_product/?consignment_id

cc @pzurek and @jtrotsky ... please feel free to weigh-in

pzurek commented 9 years ago
  1. Nope but if you look at the /api/stock_movements endpoint that should help. Stock movements give you the consignment along with all the products included. This way it's easy to fine the ones without any product on them.
  2. Don't think so.
  3. No but as in point 1, stock_movements should help.
pulkitsinghal commented 9 years ago

@pzurek - At first look, the GET /api/stock_movements endpoint looks pretty shocking. It returns all consignments and it does not accept any parameters. That's a lot of raw data to page through (download-wise) ... just to figure out if a given consignment has products attached ... no?

I'm not bashing anyone, I'm just trying to make sure I understand the API impact properly before I add this command.

pzurek commented 9 years ago

An absolutely fair point but I'm just suggesting workarounds. This endpoint wasn't made for this, but it probably offers the easiest way to achieve what you are trying to do. I think it will actually accept the since parameter.