2
0
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:
Oliver
2021-10-03 22:26:45 +11:00
parent 69c15797e8
commit 488df25758
3 changed files with 60 additions and 2 deletions

View File

@ -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);