getSubtotal method

Future<double> getSubtotal({
  1. bool? print,
  2. bool? display,
  3. DiscountType? discountType,
  4. double? discountValue,
})

Implementation

Future<double> getSubtotal({
  bool? print,
  bool? display,
  DiscountType? discountType,
  double? discountValue,
}) async {
  final message = await execute(
    Commands.readSubtotal.code,
    data: [
      print?.toInt(),
      display?.toInt(),
      discountType?.index,
      discountValue?.cleanDouble(),
    ].toCommand(),
  );

  final [$e, slip, subtotal, ...taxes] = message.data.response;
  final error = int.tryParse($e) ?? 0;

  if (error != 0) {
    throw FiscalCodeException('Error register sales', error);
  }

  return double.tryParse(subtotal) ?? 0.0;
}