mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-30 22:46:49 +00:00
Function to count stock item
This commit is contained in:
parent
f158b0cd12
commit
80f7694abb
@ -157,6 +157,26 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
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 {
|
||||
|
||||
// Cannot add stock to a serialized StockItem
|
||||
@ -169,14 +189,12 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> data = {
|
||||
return api.post("/stock/add/", body: {
|
||||
"item": {
|
||||
"pk": "${pk}",
|
||||
"quantity": "${quan}",
|
||||
}
|
||||
};
|
||||
|
||||
return api.post("/stock/add/", body: data);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user