update printer checker
This commit is contained in:
parent
ea29c62af1
commit
beb86f6259
@ -149,6 +149,26 @@ class Order with _$Order {
|
|||||||
categoryId: 'CAT-002',
|
categoryId: 'CAT-002',
|
||||||
categoryName: 'Makanan',
|
categoryName: 'Makanan',
|
||||||
),
|
),
|
||||||
|
OrderItem(
|
||||||
|
id: 'ITEM-003',
|
||||||
|
orderId: 'ORD-001',
|
||||||
|
productId: 'PROD-003',
|
||||||
|
productName: 'Pasta',
|
||||||
|
productVariantId: 'VAR-002',
|
||||||
|
productVariantName: '',
|
||||||
|
quantity: 1,
|
||||||
|
unitPrice: 50000,
|
||||||
|
totalPrice: 50000,
|
||||||
|
modifiers: [],
|
||||||
|
notes: '',
|
||||||
|
status: 'Served',
|
||||||
|
createdAt: DateTime.now().subtract(const Duration(hours: 1)),
|
||||||
|
updatedAt: DateTime.now(),
|
||||||
|
printerType: 'Kitchen',
|
||||||
|
paidQuantity: 1,
|
||||||
|
categoryId: 'CAT-002',
|
||||||
|
categoryName: 'Makanan',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
payments: [
|
payments: [
|
||||||
Payment(
|
Payment(
|
||||||
|
|||||||
@ -102,6 +102,7 @@ class PrintUi {
|
|||||||
orderNumber: order.orderNumber,
|
orderNumber: order.orderNumber,
|
||||||
orderType: order.orderType,
|
orderType: order.orderType,
|
||||||
cashierName: cashierName,
|
cashierName: cashierName,
|
||||||
|
customerName: order.metadata['customer_name'] ?? '-',
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.separator();
|
bytes += builder.separator();
|
||||||
@ -146,7 +147,7 @@ class PrintUi {
|
|||||||
bytes += generator.reset();
|
bytes += generator.reset();
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
bytes += builder.row2Columns('Kitchen', order.orderType, bold: true);
|
bytes += builder.row2Columns('Kitchen', order.orderType.toUpperCase(), bold: true);
|
||||||
bytes += builder.separator();
|
bytes += builder.separator();
|
||||||
bytes += builder.textCenter(
|
bytes += builder.textCenter(
|
||||||
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||||
|
|||||||
@ -9,26 +9,26 @@ class ReceiptComponentBuilder {
|
|||||||
|
|
||||||
ReceiptComponentBuilder({required this.generator, this.paperSize = 58});
|
ReceiptComponentBuilder({required this.generator, this.paperSize = 58});
|
||||||
|
|
||||||
/// Helper: returns size2 for 80mm paper, size1 for 58mm
|
|
||||||
PosTextSize get _titleSize =>
|
|
||||||
paperSize == 80 ? PosTextSize.size3 : PosTextSize.size1;
|
|
||||||
|
|
||||||
/// Font type per paper size — easy to change here
|
|
||||||
/// 58mm → fontA, 80mm → fontA
|
|
||||||
PosFontType get _font =>
|
PosFontType get _font =>
|
||||||
paperSize == 80 ? PosFontType.fontA : PosFontType.fontA;
|
paperSize == 80 ? PosFontType.fontB : PosFontType.fontA;
|
||||||
|
|
||||||
/// Text size for body — height size2 for 80mm to appear taller, size1 for 58mm
|
PosTextSize get _bodyHeight =>
|
||||||
PosTextSize get _bodySize =>
|
|
||||||
paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
||||||
|
|
||||||
/// Body width stays size1 always to prevent overflow
|
PosTextSize get _bodyWidth => paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
||||||
PosTextSize get _bodyWidth => PosTextSize.size1;
|
|
||||||
|
|
||||||
/// Characters per line based on paper size (always size1 font)
|
/// Characters per line based on paper size and font
|
||||||
String get _separatorLine => paperSize == 80
|
String get _separatorLine {
|
||||||
? '------------------------------------------------'
|
if (paperSize == 80) {
|
||||||
: '--------------------------------';
|
return _font == PosFontType.fontB
|
||||||
|
? '----------------------------------------------------------------'
|
||||||
|
: '------------------------------------------------';
|
||||||
|
} else {
|
||||||
|
return _font == PosFontType.fontB
|
||||||
|
? '------------------------------------------'
|
||||||
|
: '--------------------------------';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Basic text
|
// Basic text
|
||||||
@ -37,17 +37,18 @@ class ReceiptComponentBuilder {
|
|||||||
List<int> textCenter(
|
List<int> textCenter(
|
||||||
String text, {
|
String text, {
|
||||||
bool bold = false,
|
bool bold = false,
|
||||||
PosTextSize height = PosTextSize.size1,
|
PosTextSize? height,
|
||||||
PosTextSize width = PosTextSize.size1,
|
PosTextSize? width,
|
||||||
|
PosFontType? fontType,
|
||||||
}) {
|
}) {
|
||||||
return generator.text(
|
return generator.text(
|
||||||
text,
|
text,
|
||||||
styles: PosStyles(
|
styles: PosStyles(
|
||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.center,
|
align: PosAlign.center,
|
||||||
height: height,
|
height: height ?? _bodyHeight,
|
||||||
width: width,
|
width: width ?? _bodyWidth,
|
||||||
fontType: _font,
|
fontType: fontType ?? _font,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ class ReceiptComponentBuilder {
|
|||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.left,
|
align: PosAlign.left,
|
||||||
fontType: _font,
|
fontType: _font,
|
||||||
height: _bodySize,
|
height: _bodyHeight,
|
||||||
width: _bodyWidth,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -72,7 +73,7 @@ class ReceiptComponentBuilder {
|
|||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.right,
|
align: PosAlign.right,
|
||||||
fontType: _font,
|
fontType: _font,
|
||||||
height: _bodySize,
|
height: _bodyHeight,
|
||||||
width: _bodyWidth,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -110,8 +111,6 @@ class ReceiptComponentBuilder {
|
|||||||
align: PosAlign.left,
|
align: PosAlign.left,
|
||||||
bold: bold,
|
bold: bold,
|
||||||
fontType: _font,
|
fontType: _font,
|
||||||
height: _bodySize,
|
|
||||||
width: _bodyWidth,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
@ -121,8 +120,6 @@ class ReceiptComponentBuilder {
|
|||||||
align: PosAlign.right,
|
align: PosAlign.right,
|
||||||
bold: bold,
|
bold: bold,
|
||||||
fontType: _font,
|
fontType: _font,
|
||||||
height: _bodySize,
|
|
||||||
width: _bodyWidth,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@ -163,8 +160,8 @@ class ReceiptComponentBuilder {
|
|||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.left,
|
align: PosAlign.left,
|
||||||
fontType: _font,
|
fontType: _font,
|
||||||
height: PosTextSize.size2,
|
height: _bodyHeight,
|
||||||
width: PosTextSize.size2,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -184,7 +181,7 @@ class ReceiptComponentBuilder {
|
|||||||
required String phoneNumber,
|
required String phoneNumber,
|
||||||
}) {
|
}) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
bytes += textCenter(outletName, bold: true, height: _titleSize, width: _titleSize);
|
bytes += textCenter(outletName, bold: true);
|
||||||
bytes += textCenter(address);
|
bytes += textCenter(address);
|
||||||
bytes += textCenter(phoneNumber);
|
bytes += textCenter(phoneNumber);
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
@ -193,7 +190,7 @@ class ReceiptComponentBuilder {
|
|||||||
|
|
||||||
/// Centered printer type label (e.g. KITCHEN, BAR)
|
/// Centered printer type label (e.g. KITCHEN, BAR)
|
||||||
List<int> printerType({required String printerType}) {
|
List<int> printerType({required String printerType}) {
|
||||||
return textCenter(printerType, bold: true, height: _titleSize, width: _titleSize);
|
return textCenter(printerType, bold: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Date + time row (receipt style)
|
/// Date + time row (receipt style)
|
||||||
@ -209,15 +206,21 @@ class ReceiptComponentBuilder {
|
|||||||
required String orderNumber,
|
required String orderNumber,
|
||||||
String? orderType,
|
String? orderType,
|
||||||
required String cashierName,
|
required String cashierName,
|
||||||
|
String? customerName,
|
||||||
}) {
|
}) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
final dateStr = DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now());
|
final dateStr = DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now());
|
||||||
bytes += textLeft('Order : $orderNumber');
|
bytes += textLeft('Order : $orderNumber');
|
||||||
bytes += textLeft('Date : $dateStr');
|
bytes += textLeft('Date : $dateStr');
|
||||||
if(orderType != null) {
|
|
||||||
bytes += textLeft('Purpose : $orderType');
|
|
||||||
|
if(customerName != null) {
|
||||||
|
bytes += textLeft('Customer : $customerName');
|
||||||
}
|
}
|
||||||
bytes += textLeft('Waiter : $cashierName');
|
if(orderType != null) {
|
||||||
|
bytes += textLeft('Purpose : ${orderType.toUpperCase()}');
|
||||||
|
}
|
||||||
|
bytes += textLeft('Waiter : $cashierName');
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +253,7 @@ class ReceiptComponentBuilder {
|
|||||||
List<int> orderType(String type) {
|
List<int> orderType(String type) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
bytes += textCenter(type, bold: true, height: _titleSize, width: _titleSize);
|
bytes += textCenter(type, bold: true);
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
@ -268,8 +271,8 @@ class ReceiptComponentBuilder {
|
|||||||
final displayName = (variantName != null && variantName.isNotEmpty)
|
final displayName = (variantName != null && variantName.isNotEmpty)
|
||||||
? '$productName ($variantName)'
|
? '$productName ($variantName)'
|
||||||
: productName;
|
: productName;
|
||||||
bytes += textLeft(displayName, bold: paperSize == 80);
|
bytes += textLeft(displayName, bold: true);
|
||||||
bytes += row2Columns('$quantity x $unitPrice', totalPrice, leftWidth: 8, rightWidth: 4);
|
bytes += row2Columns('${quantity}x $unitPrice', totalPrice);
|
||||||
if (notes != null && notes.isNotEmpty) {
|
if (notes != null && notes.isNotEmpty) {
|
||||||
bytes += row2Columns('Note', notes, leftWidth: 4, rightWidth: 8);
|
bytes += row2Columns('Note', notes, leftWidth: 4, rightWidth: 8);
|
||||||
}
|
}
|
||||||
@ -303,7 +306,7 @@ class ReceiptComponentBuilder {
|
|||||||
List<int> footer({String message = 'Terima kasih'}) {
|
List<int> footer({String message = 'Terima kasih'}) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
bytes += emptyLines(2);
|
bytes += emptyLines(2);
|
||||||
bytes += textCenter(message, bold: true, height: _titleSize, width: _titleSize);
|
bytes += textCenter(message, bold: true);
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
bytes += textCenter('$paperSize MM');
|
bytes += textCenter('$paperSize MM');
|
||||||
}
|
}
|
||||||
|
|||||||
42
pubspec.lock
42
pubspec.lock
@ -189,10 +189,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.1"
|
||||||
checked_yaml:
|
checked_yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -493,10 +493,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: fl_chart
|
name: fl_chart
|
||||||
sha256: d3f82f4a38e33ba23d05a08ff304d7d8b22d2a59a5503f20bd802966e915db89
|
sha256: b938f77d042cbcd822936a7a359a7235bad8bd72070de1f827efc2cc297ac888
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -796,26 +796,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.0.9"
|
version: "11.0.2"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_flutter_testing
|
name: leak_tracker_flutter_testing
|
||||||
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.9"
|
version: "3.0.10"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.2"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -836,26 +836,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.17"
|
version: "0.12.19"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.11.1"
|
version: "0.13.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.17.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1337,10 +1337,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.4"
|
version: "0.7.10"
|
||||||
time:
|
time:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1409,10 +1409,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.2.0"
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1502,5 +1502,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.8.1 <4.0.0"
|
dart: ">=3.9.0-0 <4.0.0"
|
||||||
flutter: ">=3.29.0"
|
flutter: ">=3.29.0"
|
||||||
|
|||||||
@ -41,7 +41,7 @@ dependencies:
|
|||||||
cached_network_image: ^3.4.1
|
cached_network_image: ^3.4.1
|
||||||
shimmer: ^3.0.0
|
shimmer: ^3.0.0
|
||||||
dropdown_search: ^5.0.6
|
dropdown_search: ^5.0.6
|
||||||
fl_chart: ^1.1.0
|
fl_chart: ^1.1.1
|
||||||
permission_handler: ^12.0.1
|
permission_handler: ^12.0.1
|
||||||
print_bluetooth_thermal: ^1.1.7
|
print_bluetooth_thermal: ^1.1.7
|
||||||
flutter_esc_pos_network: ^1.0.3
|
flutter_esc_pos_network: ^1.0.3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user