mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-02-04 14:13:17 +00:00
Part requirements (#761)
* Add setting to control if part requirements are shown * Split settings for Part and Stock * Fetch part requirements information * Add "building" indicator * Show order allocation progress for part requirements * Bump release notes * Remove unused import
This commit is contained in:
parent
e38c51e947
commit
ee553af93b
10 changed files with 357 additions and 70 deletions
|
|
@ -214,6 +214,27 @@ class InvenTreePart extends InvenTreeModel {
|
|||
});
|
||||
}
|
||||
|
||||
// Request requirements information for this part
|
||||
Future<InvenTreePartRequirements?> getRequirements() async {
|
||||
try {
|
||||
final response = await InvenTreeAPI().get(
|
||||
"/api/part/${pk}/requirements/",
|
||||
);
|
||||
if (response.isValid()) {
|
||||
final requirementsData = response.data;
|
||||
|
||||
if (requirementsData is Map<String, dynamic>) {
|
||||
return InvenTreePartRequirements.fromJson(requirementsData);
|
||||
}
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
print("Exception while fetching requirements data for part $pk: $e");
|
||||
sentryReportError("getRequirements", e, stackTrace);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Request pricing data for this part
|
||||
Future<InvenTreePartPricing?> getPricing() async {
|
||||
try {
|
||||
|
|
@ -437,6 +458,43 @@ class InvenTreePart extends InvenTreeModel {
|
|||
InvenTreePart.fromJson(json);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class representing requirements information for a given Part instance.
|
||||
*/
|
||||
class InvenTreePartRequirements extends InvenTreeModel {
|
||||
InvenTreePartRequirements() : super();
|
||||
|
||||
InvenTreePartRequirements.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json);
|
||||
|
||||
@override
|
||||
List<String> get rolesRequired => ["part"];
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) =>
|
||||
InvenTreePartRequirements.fromJson(json);
|
||||
|
||||
// Data accessors
|
||||
double get canBuild => getDouble("can_build");
|
||||
|
||||
double get ordering => getDouble("ordering");
|
||||
|
||||
double get building => getDouble("building");
|
||||
|
||||
double get scheduledToBuild => getDouble("scheduled_to_build");
|
||||
|
||||
double get requiredForBuildOrders => getDouble("required_for_build_orders");
|
||||
|
||||
double get allocatedToBuildOrders => getDouble("allocated_to_build_orders");
|
||||
|
||||
double get requiredForSalesOrders => getDouble("required_for_sales_orders");
|
||||
|
||||
double get allocatedToSalesOrders => getDouble("allocated_to_sales_orders");
|
||||
}
|
||||
|
||||
/*
|
||||
* Class representing pricing information for a given Part instance.
|
||||
*/
|
||||
class InvenTreePartPricing extends InvenTreeModel {
|
||||
InvenTreePartPricing() : super();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue