This commit is contained in:
parent
a6ac12c36a
commit
7b12793618
@ -23,6 +23,9 @@ Future<void> onPrint(
|
||||
required Order order,
|
||||
}) async {
|
||||
final outlet = await OutletLocalDatasource().get();
|
||||
final settings = await SettingsLocalDatasource().getTax();
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
|
||||
if (outlet.businessType == BusinessType.restaurant) {
|
||||
final checkerPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('checker');
|
||||
@ -30,18 +33,59 @@ Future<void> onPrint(
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('kitchen');
|
||||
final barPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('bar');
|
||||
final receiptPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
if (receiptPrinter != null) {
|
||||
try {
|
||||
final printValue = await PrintDataoutputs.instance.printOrderV4(
|
||||
order,
|
||||
authData.user?.name ?? "",
|
||||
'',
|
||||
0,
|
||||
0,
|
||||
settings.value,
|
||||
receiptPrinter.paper.toIntegerFromText,
|
||||
order.orderType ?? "",
|
||||
outlet,
|
||||
productQuantity);
|
||||
await PrinterService()
|
||||
.printWithPrinter(receiptPrinter, printValue, context);
|
||||
} catch (e, stackTrace) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
e,
|
||||
stackTrace,
|
||||
reason: 'Print receipt failed',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
'Printer: ${receiptPrinter.name}',
|
||||
],
|
||||
);
|
||||
log("Error printing receipt order: $e");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error printing receipt order: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Receipt printer not found',
|
||||
null,
|
||||
reason:
|
||||
'Receipt printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer receipt')),
|
||||
);
|
||||
}
|
||||
|
||||
// Checker printer
|
||||
if (checkerPrinter != null) {
|
||||
try {
|
||||
final productByPrinter = productQuantity
|
||||
.where((item) => item.product.printerType == 'checker')
|
||||
.toList();
|
||||
|
||||
final printValue = await PrintDataoutputs.instance.printChecker(
|
||||
productByPrinter,
|
||||
productQuantity,
|
||||
order.tableNumber ?? "",
|
||||
order.orderNumber ?? "",
|
||||
authData.user?.name ?? "",
|
||||
@ -50,7 +94,7 @@ Future<void> onPrint(
|
||||
order.orderType ?? "",
|
||||
);
|
||||
|
||||
if (productByPrinter.isNotEmpty) {
|
||||
if (productQuantity.isNotEmpty) {
|
||||
await PrinterService()
|
||||
// ignore: use_build_context_synchronously
|
||||
.printWithPrinter(checkerPrinter, printValue, context);
|
||||
@ -70,6 +114,19 @@ Future<void> onPrint(
|
||||
SnackBar(content: Text('Error printing checker: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Checker printer not found',
|
||||
null,
|
||||
reason:
|
||||
'Checker printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer checker')),
|
||||
);
|
||||
}
|
||||
|
||||
// Kitchen printer
|
||||
@ -107,6 +164,19 @@ Future<void> onPrint(
|
||||
SnackBar(content: Text('Error printing kitchen order: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Kitchen printer not found',
|
||||
null,
|
||||
reason:
|
||||
'Kitchen printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer kitchen')),
|
||||
);
|
||||
}
|
||||
|
||||
// Bar printer
|
||||
@ -145,6 +215,18 @@ Future<void> onPrint(
|
||||
SnackBar(content: Text('Error printing bar order: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Bar printer not found',
|
||||
null,
|
||||
reason: 'Bar printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer bar')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,6 +262,19 @@ Future<void> onPrint(
|
||||
SnackBar(content: Text('Error printing ticket: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Ticket printer not found',
|
||||
null,
|
||||
reason:
|
||||
'Ticket printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer ticket')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,6 +324,18 @@ Future<void> onPrintRecipt(
|
||||
SnackBar(content: Text('Error printing receipt order: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Kitchen printer not found',
|
||||
null,
|
||||
reason: 'Kitchen printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer kitchen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class DioClient {
|
||||
static final Dio _dio = Dio(BaseOptions(
|
||||
connectTimeout: const Duration(seconds: 10),
|
||||
receiveTimeout: const Duration(seconds: 10),
|
||||
connectTimeout: const Duration(minutes: 1),
|
||||
receiveTimeout: const Duration(minutes: 1),
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
|
||||
@ -534,7 +534,7 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: 'JF-${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
text: '${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
@ -799,7 +799,7 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: 'JF-${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
text: DateFormat('yyyyMMddhhmm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
@ -841,18 +841,20 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Pembayaran',
|
||||
width: 8,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: paymentMethod,
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
if (paymentMethod != '') {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Payment',
|
||||
width: 8,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: paymentMethod,
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
@ -866,7 +868,7 @@ class PrintDataoutputs {
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
for (final product in (products ?? <ProductQuantity>[])) {
|
||||
for (final product in (products)) {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: '${product.quantity} x ${product.product.name}',
|
||||
@ -1057,7 +1059,7 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: 'JF-${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
text: '${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
@ -1112,7 +1114,7 @@ class PrintDataoutputs {
|
||||
),
|
||||
]);
|
||||
|
||||
for (final product in (productItemVoid ?? <OrderItem>[])) {
|
||||
for (final product in (productItemVoid)) {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: '${product.quantity} x ${product.productName}',
|
||||
@ -1326,7 +1328,7 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: 'JF-${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
text: '${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
|
||||
@ -217,37 +217,35 @@ class _SuccessPaymentPageState extends State<SuccessPaymentPage> {
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Order Details
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
icon: Icons.receipt_long_outlined,
|
||||
label: 'No. Pesanan',
|
||||
value: order.orderNumber ?? "-",
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.receipt_long_outlined,
|
||||
label: 'Metode Pembayaran',
|
||||
value: widget.paymentMethod,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.access_time_rounded,
|
||||
label: 'Waktu',
|
||||
value: (order.createdAt ?? DateTime.now())
|
||||
.toFormattedDate3(),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.check_circle_outline,
|
||||
label: 'Status Pembayaran',
|
||||
value: 'Lunas',
|
||||
valueColor: Colors.green,
|
||||
showBadge: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
icon: Icons.receipt_long_outlined,
|
||||
label: 'No. Pesanan',
|
||||
value: order.orderNumber ?? "-",
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.receipt_long_outlined,
|
||||
label: 'Metode Pembayaran',
|
||||
value: widget.paymentMethod,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.access_time_rounded,
|
||||
label: 'Waktu',
|
||||
value: (order.createdAt ?? DateTime.now())
|
||||
.toFormattedDate3(),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.check_circle_outline,
|
||||
label: 'Status Pembayaran',
|
||||
value: 'Lunas',
|
||||
valueColor: Colors.green,
|
||||
showBadge: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user