2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 04:35:26 +00:00

Add actions to issue or cancel purchase orders (#313)

This commit is contained in:
Oliver
2023-04-11 22:52:27 +10:00
committed by GitHub
parent 164295c3e2
commit 943104f20c
4 changed files with 99 additions and 1 deletions

View File

@ -93,6 +93,8 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
bool get isOpen => status == PO_STATUS_PENDING || status == PO_STATUS_PLACED;
bool get isPending => status == PO_STATUS_PENDING;
bool get isPlaced => status == PO_STATUS_PLACED;
bool get isFailed => status == PO_STATUS_CANCELLED || status == PO_STATUS_LOST || status == PO_STATUS_RETURNED;
@ -132,6 +134,25 @@ class InvenTreePurchaseOrder extends InvenTreeModel {
InvenTreeModel createFromJson(Map<String, dynamic> json) {
return InvenTreePurchaseOrder.fromJson(json);
}
/// Mark this order as "placed" / "issued"
Future<void> issueOrder() async {
// Order can only be placed when the order is 'pending'
if (!isPending) {
return;
}
await api.post("${url}issue/", expectedStatusCode: 201);
}
/// Mark this order as "cancelled"
Future<void> cancelOrder() async {
if (!isOpen) {
return;
}
await api.post("${url}cancel/", expectedStatusCode: 201);
}
}
class InvenTreePOLineItem extends InvenTreeModel {