initSettlement method
Future<void>
initSettlement(- BuildContext context
)
Implementation
Future<void> initSettlement(BuildContext context) async {
final InterfaceProvider interfaceProvider = Provider.of(
context,
listen: false,
);
interfaceProvider.loading = true;
final Map<dynamic, dynamic>? result = await doSettlement(context);
interfaceProvider.loading = false;
if (result == null) {
Navigator.pop(context);
interfaceProvider.loading = false;
showDialog(
context: context,
builder: (context) => ErrorDialog(
supportSubject: AppMailMessages.settlementError,
title: 'Error',
iconColor: ApplicationTheme.orange,
text: const <String>[
'Ocurrió un error desconocido',
'Si el problema persiste por favor comuníquese con soporte',
],
buttonText: 'Aceptar',
),
);
return;
}
if (result.containsKey(false)) {
Navigator.pop(context);
interfaceProvider.loading = false;
showDialog(
context: context,
builder: (context) => ErrorDialog(
supportSubject: AppMailMessages.settlementError,
title: 'Error',
iconColor: ApplicationTheme.orange,
text: <String>[
result[false],
],
buttonText: 'Aceptar',
),
);
return;
} else if (result.containsKey(true)) {
await closeDay(context).then(
(value) async => await serviceResolution(
context,
response: value,
resolution: () async {
interfaceProvider.loading = false;
await showDialog(
context: context,
builder: (context) => const SuccessDialog(
description: 'Ha cerrado un lote de ventas',
additionalInfo:
'Podrá abrir otro para seguir transaccionando cuando usted desee',
),
);
},
),
);
} else {
Navigator.pop(context);
interfaceProvider.loading = false;
showDialog(
context: context,
builder: (context) => ErrorDialog(
supportSubject: AppMailMessages.settlementError,
title: 'Error',
iconColor: ApplicationTheme.orange,
text: const <String>[
'Ocurrió un error desconocido',
'Si el problema persiste por favor comuníquese con soporte',
],
buttonText: 'Aceptar',
),
);
return;
}
}