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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user