Stocktakings¶
API endpoint for manage stocktaking results.
Data management¶
/api/stocktakings
¶
-
GET
/storekeeper/api/stocktakings
¶ List stocktakings
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
Example request:
GET /storekeeper/api/stocktakings HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "close_timestamp": null, "close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "comment": "Maybe missing some items", "id": 1, "timestamp": "2016-03-18T07:57:54.972033+00:00" }, { "close_timestamp": null, "close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "comment": null, "id": 2, "timestamp": "2016-03-18T07:57:54.972076+00:00" } ]
-
POST
/storekeeper/api/stocktakings
¶ Create stocktaking
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 422 Unprocessable Entity – there is wrong type / missing field
Example request:
POST /storekeeper/api/stocktakings HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "comment": "Maybe missing some items" }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "close_timestamp": null, "close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "comment": "Maybe missing some items", "id": 1, "timestamp": "2016-03-18T07:57:54.972033+00:00" }
/api/stocktakings/<id>
¶
-
GET
/storekeeper/api/stocktakings/
(int: id)¶ Get stocktaking
Parameters: - id – ID of selected stocktaking for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no stocktaking
Example request:
GET /storekeeper/api/stocktakings/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "close_timestamp": null, "close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "comment": "Maybe missing some items", "id": 1, "timestamp": "2016-03-18T07:57:54.972033+00:00" }
-
PUT
/storekeeper/api/stocktakings/
(int: id)¶ Update stocktaking
Parameters: - id – ID of selected stocktaking for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no stocktaking
- 422 Unprocessable Entity – there is wrong type / missing field
Example request:
PUT /storekeeper/api/stocktakings/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "comment": "A box has been damaged" }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "close_timestamp": null, "close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "comment": "A box has been damaged", "id": 1, "timestamp": "2016-03-18T07:57:54.972033+00:00" }
-
DELETE
/storekeeper/api/stocktakings/
(int: id)¶ Delete stocktaking
Parameters: - id – ID of selected stocktaking for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no stocktaking
Example request:
DELETE /storekeeper/api/stocktakings/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null
/api/stocktakings/<id>/items
¶
-
GET
/storekeeper/api/stocktakings/
(int: id)/items
¶ List stocktaking items.
Parameters: - id – ID of stocktaking
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no item
Example request:
GET /storekeeper/api/stocktakings/1/items HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "quantity": 52.1 }, { "id": 2, "item": { "article_number": "SK132465", "id": 1, "location": "A12/12", "name": "Spray", "purchase_price": 60.4, "quantity": 0.0, "unit": { "id": 2, "unit": "pcs" }, "vendor": { "id": 1, "name": "Heavy Duty Ltd." }, "warning_quantity": 4.0 }, "quantity": 26.8 } ]
-
POST
/storekeeper/api/stocktakings/
(int: id)/items
¶ Create stocktaking item
Parameters: - id – ID of stocktaking
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – can not add new stocktakings item after items was closed
- 404 Not Found – there is no item
- 422 Unprocessable Entity – there is wrong type / missing field / can not add one item twice
Example request:
POST /storekeeper/api/stocktakings/1/items HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "quantity": 52.1 }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "quantity": 52.1 }
/api/stocktakings/<id>/items/<item_id>
¶
-
GET
/storekeeper/api/stocktakings/
(int: id)/items/
(int: item_id)¶ Get stocktaking item
Parameters: - id – ID of stocktaking
- item_id – ID of selected stocktaking item for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no stocktaking item
Example request:
GET /storekeeper/api/stocktakings/1/items/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "quantity": 52.1 }
-
PUT
/storekeeper/api/stocktakings/
(int: id)/items/
(int: item_id)¶ Update stocktaking item
Parameters: - id – ID of stocktaking
- item_id – ID of selected stocktaking item for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – can not change work item after outbound/returned items was closed
- 404 Not Found – there is no stocktaking item
- 422 Unprocessable Entity – there is wrong type / missing field / can not add one item twice
Example request:
PUT /storekeeper/api/stocktakings/1/items/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "quantity": 52.1 }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "quantity": 52.1 }
-
DELETE
/storekeeper/api/stocktakings/
(int: id)/items/
(int: item_id)¶ Delete stocktaking item
Parameters: - id – ID of stocktaking
- item_id – ID of selected stocktaking item for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – can not delete stocktaking item after items was closed
- 404 Not Found – there is no stocktaking item
Example request:
DELETE /storekeeper/api/stocktakings/1/items/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null
Commands¶
/api/stocktakings/<id>/close
¶
-
PUT
/storekeeper/api/stocktakings/
(int: id)/close
¶ Close items on stocktaking
Parameters: - id – ID of selected stocktaking for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no stocktaking
- 422 Unprocessable Entity – there is wrong type / missing field / items have been closed / insufficient quantities for close the stocktaking items
Example request:
PUT /storekeeper/api/stocktakings/1/close HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "close_timestamp": "2016-03-18T07:57:54.972111+00:00", "close_user": { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" }, "comment": "Maybe missing some items", "id": 1, "timestamp": "2016-03-18T07:57:54.972033+00:00" }