mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 04:05:28 +00:00
Format code
This commit is contained in:
@ -20,7 +20,6 @@ import "package:inventree/widget/snacks.dart";
|
||||
* - If location or quantity information wasn't provided, show a form to fill it in
|
||||
*/
|
||||
class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
|
||||
POReceiveBarcodeHandler({this.purchaseOrder, this.location, this.lineItem});
|
||||
|
||||
InvenTreePurchaseOrder? purchaseOrder;
|
||||
@ -33,9 +32,9 @@ class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
@override
|
||||
Future<void> processBarcode(String barcode,
|
||||
{String url = "barcode/po-receive/",
|
||||
Map<String, dynamic> extra_data = const {}}) async {
|
||||
|
||||
final bool confirm = await InvenTreeSettingsManager().getBool(INV_PO_CONFIRM_SCAN, true);
|
||||
Map<String, dynamic> extra_data = const {}}) async {
|
||||
final bool confirm =
|
||||
await InvenTreeSettingsManager().getBool(INV_PO_CONFIRM_SCAN, true);
|
||||
|
||||
final po_extra_data = {
|
||||
"purchase_order": purchaseOrder?.pk,
|
||||
@ -50,7 +49,6 @@ class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
|
||||
@override
|
||||
Future<void> onBarcodeMatched(Map<String, dynamic> data) async {
|
||||
|
||||
if (data.containsKey("lineitem") || data.containsKey("success")) {
|
||||
barcodeSuccess(L10().receivedItem);
|
||||
return;
|
||||
@ -66,7 +64,8 @@ class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
}
|
||||
|
||||
final lineItemData = data["lineitem"] as Map<String, dynamic>;
|
||||
if (!lineItemData.containsKey("pk") || !lineItemData.containsKey("purchase_order")) {
|
||||
if (!lineItemData.containsKey("pk") ||
|
||||
!lineItemData.containsKey("purchase_order")) {
|
||||
barcodeFailureTone();
|
||||
showSnackIcon(L10().missingData, success: false);
|
||||
}
|
||||
@ -79,7 +78,8 @@ class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
InvenTreePOLineItem? lineItem = await InvenTreePOLineItem().get(lineItemId) as InvenTreePOLineItem?;
|
||||
InvenTreePOLineItem? lineItem =
|
||||
await InvenTreePOLineItem().get(lineItemId) as InvenTreePOLineItem?;
|
||||
|
||||
if (lineItem == null) {
|
||||
barcodeFailureTone();
|
||||
@ -89,7 +89,8 @@ class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
// Next, extract the "optional" fields
|
||||
|
||||
// Extract information from the returned server response
|
||||
double? quantity = double.tryParse((lineItemData["quantity"] ?? "0").toString());
|
||||
double? quantity =
|
||||
double.tryParse((lineItemData["quantity"] ?? "0").toString());
|
||||
int? destination = lineItemData["location"] as int?;
|
||||
String? barcode = data["barcode_data"] as String?;
|
||||
|
||||
@ -98,33 +99,26 @@ class POReceiveBarcodeHandler extends BarcodeHandler {
|
||||
OneContext().pop();
|
||||
}
|
||||
|
||||
await lineItem.receive(
|
||||
OneContext().context!,
|
||||
destination: destination,
|
||||
quantity: quantity,
|
||||
barcode: barcode,
|
||||
onSuccess: () {
|
||||
showSnackIcon(L10().receivedItem, success: true);
|
||||
}
|
||||
);
|
||||
await lineItem.receive(OneContext().context!,
|
||||
destination: destination,
|
||||
quantity: quantity,
|
||||
barcode: barcode, onSuccess: () {
|
||||
showSnackIcon(L10().receivedItem, success: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onBarcodeUnknown(Map<String, dynamic> data) async {
|
||||
barcodeFailureTone();
|
||||
showSnackIcon(
|
||||
data["error"] as String? ?? L10().barcodeError,
|
||||
success: false
|
||||
);
|
||||
showSnackIcon(data["error"] as String? ?? L10().barcodeError,
|
||||
success: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Barcode handler to add a line item to a purchase order
|
||||
*/
|
||||
class POAllocateBarcodeHandler extends BarcodeHandler {
|
||||
|
||||
POAllocateBarcodeHandler({this.purchaseOrder});
|
||||
|
||||
InvenTreePurchaseOrder? purchaseOrder;
|
||||
@ -133,11 +127,9 @@ class POAllocateBarcodeHandler extends BarcodeHandler {
|
||||
String getOverlayText(BuildContext context) => L10().scanSupplierPart;
|
||||
|
||||
@override
|
||||
Future<void> processBarcode(String barcode, {
|
||||
String url = "barcode/po-allocate/",
|
||||
Map<String, dynamic> extra_data = const {}}
|
||||
) {
|
||||
|
||||
Future<void> processBarcode(String barcode,
|
||||
{String url = "barcode/po-allocate/",
|
||||
Map<String, dynamic> extra_data = const {}}) {
|
||||
final po_extra_data = {
|
||||
"purchase_order": purchaseOrder?.pk,
|
||||
...extra_data,
|
||||
@ -189,10 +181,9 @@ class POAllocateBarcodeHandler extends BarcodeHandler {
|
||||
|
||||
@override
|
||||
Future<void> onBarcodeUnhandled(Map<String, dynamic> data) async {
|
||||
|
||||
print("onBarcodeUnhandled:");
|
||||
print(data.toString());
|
||||
|
||||
super.onBarcodeUnhandled(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user