getProductionPlanning method
This function is for getting production planning report for a given company
Implementation
Future<void> getProductionPlanning(
String companyName,
Function callBack,
) async {
List<dynamic> productionPlanning = [];
var headers = {'Cookie': cookieHeader, 'Accept': 'application/json'};
final filters = {"company": companyName, "based_on": "Sales Order"};
final queryParam = {
"report_name": "Production Planning Report",
"filters": jsonEncode(filters),
};
final response = await http.post(
createUri('$baseUrl/api/method/frappe.desk.query_report.run', queryParam),
headers: headers,
);
if (response.statusCode == 200) {
var bodyJson = jsonDecode(response.body);
productionPlanning = bodyJson["message"]["result"];
} else if (response.statusCode == 404) {
MyAlertDialog().showMyAlertDialog(
context,
'Error: Resource not found (404)',
);
} else if (response.statusCode >= 400 && response.statusCode < 500) {
MyAlertDialog().showMyAlertDialog(
context,
'Client Error: ${response.statusCode}',
);
} else if (response.statusCode >= 500 && response.statusCode < 600) {
MyAlertDialog().showMyAlertDialog(
context,
'Server Error: ${response.statusCode}',
);
} else {
MyAlertDialog().showMyAlertDialog(
context,
'Unknown Error: ${response.statusCode}',
);
}
callBack(productionPlanning);
}