2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-05-01 06:56:50 +00:00

Function to count stock item

This commit is contained in:
Oliver Walters 2020-04-09 23:21:53 +10:00
parent f158b0cd12
commit 80f7694abb

View File

@ -157,6 +157,26 @@ class InvenTreeStockItem extends InvenTreeModel {
return item; return item;
} }
Future<http.Response> countStock(double quan) async {
// Cannot 'count' a serialized StockItem
if (isSerialized()) {
return null;
}
// Cannot count negative stock
if (quan < 0) {
return null;
}
return api.post("/stock/count/", body: {
"item": {
"pk": "${pk}",
"quantity": "${quan}"
}
});
}
Future<http.Response> addStock(double quan) async { Future<http.Response> addStock(double quan) async {
// Cannot add stock to a serialized StockItem // Cannot add stock to a serialized StockItem
@ -169,14 +189,12 @@ class InvenTreeStockItem extends InvenTreeModel {
return null; return null;
} }
Map<String, dynamic> data = { return api.post("/stock/add/", body: {
"item": { "item": {
"pk": "${pk}", "pk": "${pk}",
"quantity": "${quan}", "quantity": "${quan}",
} }
}; });
return api.post("/stock/add/", body: data);
} }
} }