Compare commits
No commits in common. "9a5f0c7415203042c4c3ad229dfecd8c735ed526" and "ea29c62af1800d6fec61776caa9943b16e1bcb1d" have entirely different histories.
9a5f0c7415
...
ea29c62af1
@ -149,26 +149,6 @@ 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(
|
||||||
|
|||||||
@ -30,9 +30,6 @@ class PrintUi {
|
|||||||
outletName: outlet.name,
|
outletName: outlet.name,
|
||||||
address: outlet.address,
|
address: outlet.address,
|
||||||
phoneNumber: outlet.phoneNumber,
|
phoneNumber: outlet.phoneNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.orderInfo(
|
bytes += builder.orderInfo(
|
||||||
@ -41,14 +38,9 @@ class PrintUi {
|
|||||||
cashierName: cashierName,
|
cashierName: cashierName,
|
||||||
paymentMethod: order.payments.last.paymentMethodName,
|
paymentMethod: order.payments.last.paymentMethodName,
|
||||||
tableNumber: order.tableNumber,
|
tableNumber: order.tableNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.orderType(order.orderType, fontType: PosFontType.fontA,
|
bytes += builder.orderType(order.orderType);
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,);
|
|
||||||
|
|
||||||
bytes += builder.emptyLines(1);
|
bytes += builder.emptyLines(1);
|
||||||
|
|
||||||
@ -60,9 +52,6 @@ class PrintUi {
|
|||||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||||
variantName: item.productVariantName,
|
variantName: item.productVariantName,
|
||||||
notes: item.notes,
|
notes: item.notes,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,9 +61,6 @@ class PrintUi {
|
|||||||
discount: order.discountAmount.currencyFormatRpV2,
|
discount: order.discountAmount.currencyFormatRpV2,
|
||||||
total: order.totalAmount.currencyFormatRpV2,
|
total: order.totalAmount.currencyFormatRpV2,
|
||||||
paid: order.totalPaid.currencyFormatRpV2,
|
paid: order.totalPaid.currencyFormatRpV2,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.footer();
|
bytes += builder.footer();
|
||||||
@ -104,14 +90,18 @@ class PrintUi {
|
|||||||
|
|
||||||
// Header
|
// Header
|
||||||
bytes += builder.textCenter('Table Checker', bold: true);
|
bytes += builder.textCenter('Table Checker', bold: true);
|
||||||
bytes += builder.tableName(order.tableNumber.isNotEmpty ? order.tableNumber : '-', height: PosTextSize.size3, width: PosTextSize.size3);
|
bytes += builder.separator();
|
||||||
|
bytes += builder.textCenter(
|
||||||
|
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||||
|
bold: true,
|
||||||
|
);
|
||||||
|
bytes += builder.separator();
|
||||||
|
|
||||||
// Order info — label : value, left aligned
|
// Order info — label : value, left aligned
|
||||||
bytes += builder.orderInfoSimple(
|
bytes += builder.orderInfoSimple(
|
||||||
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();
|
||||||
@ -156,7 +146,7 @@ class PrintUi {
|
|||||||
bytes += generator.reset();
|
bytes += generator.reset();
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
bytes += builder.row2Columns('Kitchen', order.orderType.toUpperCase(), bold: true);
|
bytes += builder.row2Columns('Kitchen', order.orderType, 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 : '-'}',
|
||||||
@ -168,7 +158,6 @@ class PrintUi {
|
|||||||
bytes += builder.orderInfoSimple(
|
bytes += builder.orderInfoSimple(
|
||||||
orderNumber: order.orderNumber,
|
orderNumber: order.orderNumber,
|
||||||
cashierName: cashierName,
|
cashierName: cashierName,
|
||||||
customerName: order.metadata['customer_name'] ?? '-',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.separator();
|
bytes += builder.separator();
|
||||||
@ -212,7 +201,7 @@ class PrintUi {
|
|||||||
bytes += generator.reset();
|
bytes += generator.reset();
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
bytes += builder.row2Columns('Bar', order.orderType.toUpperCase(), bold: true);
|
bytes += builder.textCenter('Bar', 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 : '-'}',
|
||||||
@ -223,7 +212,7 @@ class PrintUi {
|
|||||||
// Order info
|
// Order info
|
||||||
bytes += builder.orderInfoSimple(
|
bytes += builder.orderInfoSimple(
|
||||||
orderNumber: order.orderNumber,
|
orderNumber: order.orderNumber,
|
||||||
customerName: order.metadata['customer_name'] ?? '-',
|
orderType: order.orderType,
|
||||||
cashierName: cashierName,
|
cashierName: cashierName,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -310,9 +299,6 @@ class PrintUi {
|
|||||||
outletName: outlet.name,
|
outletName: outlet.name,
|
||||||
address: outlet.address,
|
address: outlet.address,
|
||||||
phoneNumber: outlet.phoneNumber,
|
phoneNumber: outlet.phoneNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.orderInfo(
|
bytes += builder.orderInfo(
|
||||||
@ -323,14 +309,9 @@ class PrintUi {
|
|||||||
? null
|
? null
|
||||||
: order.payments.last.paymentMethodName,
|
: order.payments.last.paymentMethodName,
|
||||||
tableNumber: order.tableNumber,
|
tableNumber: order.tableNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.orderType(order.orderType, fontType: PosFontType.fontA,
|
bytes += builder.orderType(order.orderType);
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,);
|
|
||||||
|
|
||||||
bytes += builder.emptyLines(1);
|
bytes += builder.emptyLines(1);
|
||||||
|
|
||||||
@ -342,9 +323,6 @@ class PrintUi {
|
|||||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||||
variantName: item.productVariantName,
|
variantName: item.productVariantName,
|
||||||
notes: item.notes,
|
notes: item.notes,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,9 +332,6 @@ class PrintUi {
|
|||||||
discount: order.discountAmount.currencyFormatRpV2,
|
discount: order.discountAmount.currencyFormatRpV2,
|
||||||
total: order.totalAmount.currencyFormatRpV2,
|
total: order.totalAmount.currencyFormatRpV2,
|
||||||
paid: order.totalPaid.currencyFormatRpV2,
|
paid: order.totalPaid.currencyFormatRpV2,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.footer(message: 'Kasir');
|
bytes += builder.footer(message: 'Kasir');
|
||||||
@ -388,9 +363,6 @@ class PrintUi {
|
|||||||
outletName: outlet.name,
|
outletName: outlet.name,
|
||||||
address: outlet.address,
|
address: outlet.address,
|
||||||
phoneNumber: outlet.phoneNumber,
|
phoneNumber: outlet.phoneNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.dateTime(DateTime.now());
|
bytes += builder.dateTime(DateTime.now());
|
||||||
@ -403,14 +375,9 @@ class PrintUi {
|
|||||||
? null
|
? null
|
||||||
: order.payments.last.paymentMethodName,
|
: order.payments.last.paymentMethodName,
|
||||||
tableNumber: order.tableNumber,
|
tableNumber: order.tableNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.orderType('Void', fontType: PosFontType.fontA,
|
bytes += builder.orderType('Void');
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,);
|
|
||||||
|
|
||||||
bytes += builder.emptyLines(1);
|
bytes += builder.emptyLines(1);
|
||||||
|
|
||||||
@ -422,9 +389,6 @@ class PrintUi {
|
|||||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||||
variantName: item.productVariantName,
|
variantName: item.productVariantName,
|
||||||
notes: item.notes,
|
notes: item.notes,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
bytes += builder.summary(
|
bytes += builder.summary(
|
||||||
@ -433,9 +397,6 @@ class PrintUi {
|
|||||||
discount: order.discountAmount.currencyFormatRpV2,
|
discount: order.discountAmount.currencyFormatRpV2,
|
||||||
total: order.totalAmount.currencyFormatRpV2,
|
total: order.totalAmount.currencyFormatRpV2,
|
||||||
paid: order.totalPaid.currencyFormatRpV2,
|
paid: order.totalPaid.currencyFormatRpV2,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.footer(message: 'Kasir');
|
bytes += builder.footer(message: 'Kasir');
|
||||||
@ -467,14 +428,9 @@ class PrintUi {
|
|||||||
outletName: outlet.name,
|
outletName: outlet.name,
|
||||||
address: outlet.address,
|
address: outlet.address,
|
||||||
phoneNumber: outlet.phoneNumber,
|
phoneNumber: outlet.phoneNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.dateTime(DateTime.now(), fontType: PosFontType.fontA,
|
bytes += builder.dateTime(DateTime.now());
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,);
|
|
||||||
|
|
||||||
bytes += builder.orderInfo(
|
bytes += builder.orderInfo(
|
||||||
orderNumber: order.orderNumber,
|
orderNumber: order.orderNumber,
|
||||||
@ -484,21 +440,13 @@ class PrintUi {
|
|||||||
? null
|
? null
|
||||||
: order.payments.last.paymentMethodName,
|
: order.payments.last.paymentMethodName,
|
||||||
tableNumber: order.tableNumber,
|
tableNumber: order.tableNumber,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.orderType('Split', fontType: PosFontType.fontA,
|
bytes += builder.orderType('Split');
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,);
|
|
||||||
|
|
||||||
bytes += builder.row2Columns(
|
bytes += builder.row2Columns(
|
||||||
'Split',
|
'Split',
|
||||||
'${order.payments.last.splitNumber} / ${order.payments.last.splitTotal}',
|
'${order.payments.last.splitNumber} / ${order.payments.last.splitTotal}',
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.separator();
|
bytes += builder.separator();
|
||||||
@ -513,9 +461,6 @@ class PrintUi {
|
|||||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||||
variantName: item.productVariantName,
|
variantName: item.productVariantName,
|
||||||
notes: item.notes,
|
notes: item.notes,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,9 +472,6 @@ class PrintUi {
|
|||||||
discount: 0.currencyFormatRpV2,
|
discount: 0.currencyFormatRpV2,
|
||||||
total: order.payments.last.amount.currencyFormatRpV2,
|
total: order.payments.last.amount.currencyFormatRpV2,
|
||||||
paid: order.payments.last.amount.currencyFormatRpV2,
|
paid: order.payments.last.amount.currencyFormatRpV2,
|
||||||
fontType: PosFontType.fontA,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bytes += builder.footer(message: 'Terima Kasih');
|
bytes += builder.footer(message: 'Terima Kasih');
|
||||||
|
|||||||
@ -9,26 +9,26 @@ class ReceiptComponentBuilder {
|
|||||||
|
|
||||||
ReceiptComponentBuilder({required this.generator, this.paperSize = 58});
|
ReceiptComponentBuilder({required this.generator, this.paperSize = 58});
|
||||||
|
|
||||||
PosFontType get _font =>
|
/// Helper: returns size2 for 80mm paper, size1 for 58mm
|
||||||
paperSize == 80 ? PosFontType.fontB : PosFontType.fontA;
|
PosTextSize get _titleSize =>
|
||||||
|
paperSize == 80 ? PosTextSize.size3 : PosTextSize.size1;
|
||||||
|
|
||||||
PosTextSize get _bodyHeight =>
|
/// Font type per paper size — easy to change here
|
||||||
|
/// 58mm → fontA, 80mm → fontA
|
||||||
|
PosFontType get _font =>
|
||||||
|
paperSize == 80 ? PosFontType.fontA : PosFontType.fontA;
|
||||||
|
|
||||||
|
/// Text size for body — height size2 for 80mm to appear taller, size1 for 58mm
|
||||||
|
PosTextSize get _bodySize =>
|
||||||
paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
||||||
|
|
||||||
PosTextSize get _bodyWidth => paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
/// Body width stays size1 always to prevent overflow
|
||||||
|
PosTextSize get _bodyWidth => PosTextSize.size1;
|
||||||
|
|
||||||
/// Characters per line based on paper size and font
|
/// Characters per line based on paper size (always size1 font)
|
||||||
String get _separatorLine {
|
String get _separatorLine => paperSize == 80
|
||||||
if (paperSize == 80) {
|
? '------------------------------------------------'
|
||||||
return _font == PosFontType.fontB
|
|
||||||
? '----------------------------------------------------------------'
|
|
||||||
: '------------------------------------------------';
|
|
||||||
} else {
|
|
||||||
return _font == PosFontType.fontB
|
|
||||||
? '------------------------------------------'
|
|
||||||
: '--------------------------------';
|
: '--------------------------------';
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Basic text
|
// Basic text
|
||||||
@ -37,48 +37,43 @@ class ReceiptComponentBuilder {
|
|||||||
List<int> textCenter(
|
List<int> textCenter(
|
||||||
String text, {
|
String text, {
|
||||||
bool bold = false,
|
bool bold = false,
|
||||||
PosTextSize? height,
|
PosTextSize height = PosTextSize.size1,
|
||||||
PosTextSize? width,
|
PosTextSize width = PosTextSize.size1,
|
||||||
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 ?? _bodyHeight,
|
height: height,
|
||||||
width: width ?? _bodyWidth,
|
width: width,
|
||||||
fontType: fontType ?? _font,
|
fontType: _font,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> textLeft(String text, {bool bold = false, PosTextSize? height,
|
List<int> textLeft(String text, {bool bold = false}) {
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,}) {
|
|
||||||
return generator.text(
|
return generator.text(
|
||||||
text,
|
text,
|
||||||
styles: PosStyles(
|
styles: PosStyles(
|
||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.left,
|
align: PosAlign.left,
|
||||||
height: height ?? _bodyHeight,
|
fontType: _font,
|
||||||
width: width ?? _bodyWidth,
|
height: _bodySize,
|
||||||
fontType: fontType ?? _font,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<int> textRight(String text, {bool bold = false, PosTextSize? height,
|
List<int> textRight(String text, {bool bold = false}) {
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,}) {
|
|
||||||
return generator.text(
|
return generator.text(
|
||||||
text,
|
text,
|
||||||
styles: PosStyles(
|
styles: PosStyles(
|
||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.right,
|
align: PosAlign.right,
|
||||||
height: height ?? _bodyHeight,
|
fontType: _font,
|
||||||
width: width ?? _bodyWidth,
|
height: _bodySize,
|
||||||
fontType: fontType ?? _font,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -106,9 +101,6 @@ class ReceiptComponentBuilder {
|
|||||||
bool bold = false,
|
bool bold = false,
|
||||||
int leftWidth = 6,
|
int leftWidth = 6,
|
||||||
int rightWidth = 6,
|
int rightWidth = 6,
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
}) {
|
||||||
return generator.row([
|
return generator.row([
|
||||||
PosColumn(
|
PosColumn(
|
||||||
@ -117,9 +109,9 @@ class ReceiptComponentBuilder {
|
|||||||
styles: PosStyles(
|
styles: PosStyles(
|
||||||
align: PosAlign.left,
|
align: PosAlign.left,
|
||||||
bold: bold,
|
bold: bold,
|
||||||
height: height ?? _bodyHeight,
|
fontType: _font,
|
||||||
width: width ?? _bodyWidth,
|
height: _bodySize,
|
||||||
fontType: fontType ?? _font,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PosColumn(
|
PosColumn(
|
||||||
@ -128,9 +120,9 @@ class ReceiptComponentBuilder {
|
|||||||
styles: PosStyles(
|
styles: PosStyles(
|
||||||
align: PosAlign.right,
|
align: PosAlign.right,
|
||||||
bold: bold,
|
bold: bold,
|
||||||
height: height ?? _bodyHeight,
|
fontType: _font,
|
||||||
width: width ?? _bodyWidth,
|
height: _bodySize,
|
||||||
fontType: fontType ?? _font,
|
width: _bodyWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@ -171,8 +163,8 @@ class ReceiptComponentBuilder {
|
|||||||
bold: bold,
|
bold: bold,
|
||||||
align: PosAlign.left,
|
align: PosAlign.left,
|
||||||
fontType: _font,
|
fontType: _font,
|
||||||
height: _bodyHeight,
|
height: PosTextSize.size2,
|
||||||
width: _bodyWidth,
|
width: PosTextSize.size2,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -190,34 +182,25 @@ class ReceiptComponentBuilder {
|
|||||||
required String outletName,
|
required String outletName,
|
||||||
required String address,
|
required String address,
|
||||||
required String phoneNumber,
|
required String phoneNumber,
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
}) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
bytes += textCenter(outletName, height: PosTextSize.size2, width: PosTextSize.size2, fontType: fontType, bold: true);
|
bytes += textCenter(outletName, bold: true, height: _titleSize, width: _titleSize);
|
||||||
bytes += textCenter(address, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textCenter(address);
|
||||||
bytes += textCenter(phoneNumber, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textCenter(phoneNumber);
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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);
|
return textCenter(printerType, bold: true, height: _titleSize, width: _titleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Date + time row (receipt style)
|
/// Date + time row (receipt style)
|
||||||
List<int> dateTime(DateTime dateTime, { PosTextSize? height,
|
List<int> dateTime(DateTime dateTime) {
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
|
||||||
return row2Columns(
|
return row2Columns(
|
||||||
DateFormat('dd MMM yyyy').format(dateTime),
|
DateFormat('dd MMM yyyy').format(dateTime),
|
||||||
DateFormat('HH:mm').format(dateTime),
|
DateFormat('HH:mm').format(dateTime),
|
||||||
height: height ?? _bodyHeight,
|
|
||||||
width: width ?? _bodyWidth,
|
|
||||||
fontType: fontType ?? _font,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,19 +209,13 @@ 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(customerName != null) {
|
|
||||||
bytes += textLeft('Customer : $customerName');
|
|
||||||
}
|
|
||||||
if(orderType != null) {
|
if(orderType != null) {
|
||||||
bytes += textLeft('Purpose : ${orderType.toUpperCase()}');
|
bytes += textLeft('Purpose : $orderType');
|
||||||
}
|
}
|
||||||
bytes += textLeft('Waiter : $cashierName');
|
bytes += textLeft('Waiter : $cashierName');
|
||||||
return bytes;
|
return bytes;
|
||||||
@ -251,48 +228,29 @@ class ReceiptComponentBuilder {
|
|||||||
required String cashierName,
|
required String cashierName,
|
||||||
String? paymentMethod,
|
String? paymentMethod,
|
||||||
String? tableNumber,
|
String? tableNumber,
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
}) {
|
||||||
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', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft('Order : $orderNumber');
|
||||||
bytes += textLeft('Date : $dateStr', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft('Date : $dateStr');
|
||||||
if (tableNumber != null && tableNumber.isNotEmpty) {
|
if (tableNumber != null && tableNumber.isNotEmpty) {
|
||||||
bytes += textLeft('Table : $tableNumber', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft('Table : $tableNumber');
|
||||||
}
|
}
|
||||||
bytes += textLeft('Waiter : $cashierName', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft('Waiter : $cashierName');
|
||||||
bytes += textLeft('Customer : $customerName', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft('Customer : $customerName');
|
||||||
|
|
||||||
if (paymentMethod != null) {
|
if (paymentMethod != null) {
|
||||||
bytes += textLeft('Payment : $paymentMethod', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft('Payment : $paymentMethod');
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Order type banner (separator + type + separator)
|
/// Order type banner (separator + type + separator)
|
||||||
List<int> orderType(String type, {
|
List<int> orderType(String type) {
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
bytes += textCenter(type.toUpperCase(), fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, bold: true);
|
bytes += textCenter(type, bold: true, height: _titleSize, width: _titleSize);
|
||||||
bytes += separator();
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<int> tableName(String table, {
|
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
|
||||||
List<int> bytes = [];
|
|
||||||
bytes += separator();
|
|
||||||
bytes += textCenter( 'Table : ${table.isNotEmpty ? table : '-'}', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, bold: true);
|
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
@ -305,18 +263,15 @@ class ReceiptComponentBuilder {
|
|||||||
required String totalPrice,
|
required String totalPrice,
|
||||||
String? variantName,
|
String? variantName,
|
||||||
String? notes,
|
String? notes,
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
}) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
final displayName = (variantName != null && variantName.isNotEmpty)
|
final displayName = (variantName != null && variantName.isNotEmpty)
|
||||||
? '$productName ($variantName)'
|
? '$productName ($variantName)'
|
||||||
: productName;
|
: productName;
|
||||||
bytes += textLeft(displayName, bold: true, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
bytes += textLeft(displayName, bold: paperSize == 80);
|
||||||
bytes += row2Columns('${quantity}x $unitPrice', totalPrice, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
bytes += row2Columns('$quantity x $unitPrice', totalPrice, leftWidth: 8, rightWidth: 4);
|
||||||
if (notes != null && notes.isNotEmpty) {
|
if (notes != null && notes.isNotEmpty) {
|
||||||
bytes += row2Columns('Note', notes, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, leftWidth: 4, rightWidth: 8);
|
bytes += row2Columns('Note', notes, leftWidth: 4, rightWidth: 8);
|
||||||
}
|
}
|
||||||
bytes += emptyLines(1);
|
bytes += emptyLines(1);
|
||||||
return bytes;
|
return bytes;
|
||||||
@ -329,20 +284,17 @@ class ReceiptComponentBuilder {
|
|||||||
required String discount,
|
required String discount,
|
||||||
required String total,
|
required String total,
|
||||||
required String paid,
|
required String paid,
|
||||||
PosTextSize? height,
|
|
||||||
PosTextSize? width,
|
|
||||||
PosFontType? fontType,
|
|
||||||
}) {
|
}) {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
if (totalItems > 0) {
|
if (totalItems > 0) {
|
||||||
bytes += row2Columns('Total Item', totalItems.toString(), fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
bytes += row2Columns('Total Item', totalItems.toString());
|
||||||
}
|
}
|
||||||
bytes += row2Columns('Subtotal', subtotal, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
bytes += row2Columns('Subtotal', subtotal);
|
||||||
bytes += row2Columns('Diskon', discount, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
bytes += row2Columns('Diskon', discount);
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
bytes += row2Columns('Total', total, bold: true, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
bytes += row2Columns('Total', total, bold: true);
|
||||||
bytes += row2Columns('Bayar', paid, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
bytes += row2Columns('Bayar', paid);
|
||||||
bytes += separator();
|
bytes += separator();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
@ -351,7 +303,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);
|
bytes += textCenter(message, bold: true, height: _titleSize, width: _titleSize);
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
bytes += textCenter('$paperSize MM');
|
bytes += textCenter('$paperSize MM');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,6 @@ class SettingPrinterForm extends StatefulWidget {
|
|||||||
|
|
||||||
class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
||||||
final TextEditingController _nameController = TextEditingController();
|
final TextEditingController _nameController = TextEditingController();
|
||||||
final TextEditingController _networkController = TextEditingController();
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
if (widget.printer != null) {
|
if (widget.printer != null) {
|
||||||
context.read<PrinterFormBloc>().add(
|
context.read<PrinterFormBloc>().add(
|
||||||
@ -52,7 +50,6 @@ class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
|||||||
PrinterFormEvent.paperChanged(widget.printer!.paper),
|
PrinterFormEvent.paperChanged(widget.printer!.paper),
|
||||||
);
|
);
|
||||||
_nameController.text = widget.printer!.name;
|
_nameController.text = widget.printer!.name;
|
||||||
_networkController.text = widget.printer!.address;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +163,6 @@ class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
|||||||
)
|
)
|
||||||
: AppTextFormField(
|
: AppTextFormField(
|
||||||
label: 'Network',
|
label: 'Network',
|
||||||
controller: _networkController,
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context.read<PrinterFormBloc>().add(
|
context.read<PrinterFormBloc>().add(
|
||||||
PrinterFormEvent.addressChanged(value),
|
PrinterFormEvent.addressChanged(value),
|
||||||
|
|||||||
42
pubspec.lock
42
pubspec.lock
@ -189,10 +189,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
|
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.1"
|
version: "1.4.0"
|
||||||
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: b938f77d042cbcd822936a7a359a7235bad8bd72070de1f827efc2cc297ac888
|
sha256: d3f82f4a38e33ba23d05a08ff304d7d8b22d2a59a5503f20bd802966e915db89
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.1.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: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
|
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "11.0.2"
|
version: "10.0.9"
|
||||||
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: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
|
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.10"
|
version: "3.0.9"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
|
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.2"
|
version: "3.0.1"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -836,26 +836,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.19"
|
version: "0.12.17"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
|
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.13.0"
|
version: "0.11.1"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.0"
|
version: "1.16.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: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.10"
|
version: "0.7.4"
|
||||||
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: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.1.4"
|
||||||
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.9.0-0 <4.0.0"
|
dart: ">=3.8.1 <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.1
|
fl_chart: ^1.1.0
|
||||||
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