update printer
This commit is contained in:
@@ -32,8 +32,6 @@ class PrintUi {
|
||||
phoneNumber: outlet.phoneNumber,
|
||||
);
|
||||
|
||||
bytes += builder.dateTime(DateTime.now());
|
||||
|
||||
bytes += builder.orderInfo(
|
||||
orderNumber: order.orderNumber,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
@@ -90,34 +88,34 @@ class PrintUi {
|
||||
|
||||
bytes += generator.reset();
|
||||
|
||||
// Header
|
||||
bytes += builder.textCenter('Table Checker', bold: true);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.textCenter(
|
||||
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||
bold: true,
|
||||
);
|
||||
bytes += builder.separator();
|
||||
|
||||
// Order info — label : value, left aligned
|
||||
bytes += builder.orderInfoSimple(
|
||||
orderNumber: order.orderNumber,
|
||||
orderType: order.orderType,
|
||||
cashierName: cashierName,
|
||||
);
|
||||
|
||||
bytes += builder.separator();
|
||||
|
||||
// Items — qty NAMA (uppercase), variant indent
|
||||
for (final item in order.orderItems) {
|
||||
bytes += builder.separator();
|
||||
bytes += builder.printerType(printerType: 'CHECKER');
|
||||
bytes += builder.separator();
|
||||
|
||||
bytes += builder.dateTime(DateTime.now());
|
||||
bytes += builder.orderInfo(
|
||||
orderNumber: order.orderNumber,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
cashierName: cashierName,
|
||||
paymentMethod: order.payments.isEmpty
|
||||
? ''
|
||||
: order.payments.last.paymentMethodName,
|
||||
tableNumber: order.tableNumber,
|
||||
);
|
||||
|
||||
bytes += builder.orderType(order.orderType);
|
||||
|
||||
bytes += builder.emptyLines(1);
|
||||
|
||||
bytes += builder.orderItem(
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
unitPrice: item.unitPrice.currencyFormatRpV2,
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
notes: item.notes,
|
||||
);
|
||||
final name = item.productName.toUpperCase();
|
||||
bytes += builder.itemText('${item.quantity} $name');
|
||||
if (item.productVariantName.isNotEmpty) {
|
||||
bytes += builder.itemText(' ${item.productVariantName.toUpperCase()}', bold: false);
|
||||
}
|
||||
if (item.notes.isNotEmpty) {
|
||||
bytes += builder.itemText(' *${item.notes}', bold: false);
|
||||
}
|
||||
}
|
||||
|
||||
bytes += builder.separator();
|
||||
@@ -144,47 +142,39 @@ class PrintUi {
|
||||
paperSize: paper,
|
||||
);
|
||||
|
||||
// Group items by category
|
||||
final Map<String, List<OrderItem>> groupedItems = {};
|
||||
for (final item in order.orderItems) {
|
||||
final key = item.categoryName.isNotEmpty ? item.categoryName : 'Lainnya';
|
||||
groupedItems.putIfAbsent(key, () => []).add(item);
|
||||
}
|
||||
|
||||
for (final entry in groupedItems.entries) {
|
||||
final categoryName = entry.key;
|
||||
final items = entry.value;
|
||||
|
||||
bytes += generator.reset();
|
||||
|
||||
// Header
|
||||
bytes += builder.textCenter('Kitchen', bold: true);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.printerType(printerType: 'KITCHEN');
|
||||
bytes += builder.textCenter(
|
||||
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||
bold: true,
|
||||
);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.dateTime(DateTime.now());
|
||||
bytes += builder.orderInfo(
|
||||
|
||||
// Order info
|
||||
bytes += builder.orderInfoSimple(
|
||||
orderNumber: order.orderNumber,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
orderType: order.orderType,
|
||||
cashierName: cashierName,
|
||||
tableNumber: order.tableNumber,
|
||||
);
|
||||
|
||||
bytes += builder.orderType(categoryName);
|
||||
bytes += builder.separator();
|
||||
|
||||
bytes += builder.emptyLines(1);
|
||||
|
||||
for (final item in items) {
|
||||
bytes += builder.orderItem(
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
unitPrice: item.unitPrice.currencyFormatRpV2,
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
notes: item.notes,
|
||||
);
|
||||
// Single item
|
||||
final name = item.productName.toUpperCase();
|
||||
bytes += builder.itemText('${item.quantity} $name');
|
||||
if (item.productVariantName.isNotEmpty) {
|
||||
bytes += builder.itemText(' ${item.productVariantName.toUpperCase()}', bold: false);
|
||||
}
|
||||
if (item.notes.isNotEmpty) {
|
||||
bytes += builder.itemText(' *${item.notes}', bold: false);
|
||||
}
|
||||
|
||||
bytes += builder.separator();
|
||||
bytes += builder.footer();
|
||||
bytes += builder.cutOnly();
|
||||
}
|
||||
|
||||
return bytes;
|
||||
@@ -307,8 +297,6 @@ class PrintUi {
|
||||
phoneNumber: outlet.phoneNumber,
|
||||
);
|
||||
|
||||
bytes += builder.dateTime(DateTime.now());
|
||||
|
||||
bytes += builder.orderInfo(
|
||||
orderNumber: order.orderNumber,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
|
||||
Reference in New Issue
Block a user