mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 12:15:31 +00:00
Display link to purchase orders on the "company" page
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
import "dart:async";
|
||||
import "dart:io";
|
||||
|
||||
import "package:inventree/api.dart";
|
||||
import "package:inventree/inventree/model.dart";
|
||||
import "package:inventree/inventree/purchase_order.dart";
|
||||
|
||||
|
||||
/*
|
||||
@ -44,6 +48,32 @@ class InvenTreeCompany extends InvenTreeModel {
|
||||
|
||||
bool get isCustomer => (jsondata["is_customer"] ?? false) as bool;
|
||||
|
||||
// Request a list of purchase orders against this company
|
||||
Future<List<InvenTreePurchaseOrder>> getPurchaseOrders({bool? outstanding}) async {
|
||||
|
||||
Map<String, String> filters = {
|
||||
"supplier": "${pk}"
|
||||
};
|
||||
|
||||
if (outstanding != null) {
|
||||
filters["outstanding"] = outstanding ? "true" : "false";
|
||||
}
|
||||
|
||||
final List<InvenTreeModel> results = await InvenTreePurchaseOrder().list(
|
||||
filters: filters
|
||||
);
|
||||
|
||||
List<InvenTreePurchaseOrder> orders = [];
|
||||
|
||||
for (InvenTreeModel model in results) {
|
||||
if (model is InvenTreePurchaseOrder) {
|
||||
orders.add(model);
|
||||
}
|
||||
}
|
||||
|
||||
return orders;
|
||||
}
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var company = InvenTreeCompany.fromJson(json);
|
||||
|
Reference in New Issue
Block a user