update
This commit is contained in:
parent
1fbacae1f4
commit
290360674f
@ -280,6 +280,114 @@ Future<void> onPrint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onPrintBill(
|
||||||
|
BuildContext context, {
|
||||||
|
required List<ProductQuantity> productQuantity,
|
||||||
|
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 receiptPrinter =
|
||||||
|
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||||
|
|
||||||
|
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')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outlet.businessType == BusinessType.ticketing) {
|
||||||
|
final ticketPrinter =
|
||||||
|
await PrinterLocalDatasource.instance.getPrinterByCode('ticket');
|
||||||
|
|
||||||
|
final barcode = await generateBarcodeAsUint8List(order.orderNumber ?? "");
|
||||||
|
|
||||||
|
if (ticketPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs.instance.printTicket(
|
||||||
|
order.totalAmount ?? 0,
|
||||||
|
barcode,
|
||||||
|
ticketPrinter.paper.toIntegerFromText,
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService()
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
.printWithPrinter(ticketPrinter, printValue, context);
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
FirebaseCrashlytics.instance.recordError(
|
||||||
|
e,
|
||||||
|
stackTrace,
|
||||||
|
reason: 'Error printing ticket ${ticketPrinter.name}',
|
||||||
|
information: [
|
||||||
|
'Printer: ticket',
|
||||||
|
'data: ${ticketPrinter.toMap()}',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
log("Error printing ticket: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
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')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> onPrintRecipt(
|
Future<void> onPrintRecipt(
|
||||||
context, {
|
context, {
|
||||||
required Order order,
|
required Order order,
|
||||||
|
|||||||
@ -371,8 +371,8 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
orElse: () {},
|
orElse: () {},
|
||||||
success: (data) {
|
success: (data) {
|
||||||
context.pushReplacement(SuccessPaymentPage(
|
context.pushReplacement(SuccessPaymentPage(
|
||||||
productQuantity: widget.order.orderItems
|
productQuantity: getOrderItemPending()
|
||||||
?.map(
|
.map(
|
||||||
(item) => ProductQuantity(
|
(item) => ProductQuantity(
|
||||||
product: Product(
|
product: Product(
|
||||||
name: item.productName,
|
name: item.productName,
|
||||||
@ -443,6 +443,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
final itemPending = widget.order.orderItems
|
final itemPending = widget.order.orderItems
|
||||||
?.where((item) => item.status == "pending")
|
?.where((item) => item.status == "pending")
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (widget.isSplit == false) {
|
if (widget.isSplit == false) {
|
||||||
final request = PaymentRequestModel(
|
final request = PaymentRequestModel(
|
||||||
amount: widget.order.totalAmount ?? 0,
|
amount: widget.order.totalAmount ?? 0,
|
||||||
|
|||||||
@ -274,7 +274,7 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
.toProductQuantities(),
|
.toProductQuantities(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
onPrint(
|
onPrintBill(
|
||||||
context,
|
context,
|
||||||
productQuantity: orderDetail!.orderItems!
|
productQuantity: orderDetail!.orderItems!
|
||||||
.toProductQuantities(),
|
.toProductQuantities(),
|
||||||
@ -282,7 +282,7 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
label: 'Print',
|
label: 'Print Bill',
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.print,
|
Icons.print,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.2+5
|
version: 1.0.2+6
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.2.4 <4.0.0"
|
sdk: ">=3.2.4 <4.0.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user