split struct

This commit is contained in:
efrilm
2025-11-10 13:28:18 +07:00
parent c5673a147c
commit f5256fb33d
10 changed files with 405 additions and 56 deletions
@@ -414,4 +414,62 @@ class PrintUi {
return bytes;
}
Future<List<int>> printSplit({
required Order order,
required Outlet outlet,
required String cashierName,
int paper = 58,
}) async {
List<int> bytes = [];
final profile = await CapabilityProfile.load();
final generator = Generator(
paper == 58 ? PaperSize.mm58 : PaperSize.mm80,
profile,
);
final builder = ReceiptComponentBuilder(
generator: generator,
paperSize: 58,
);
bytes += generator.reset();
bytes += builder.header(
outletName: outlet.name,
address: outlet.address,
phoneNumber: outlet.phoneNumber,
);
bytes += builder.dateTime(DateTime.now());
bytes += builder.orderInfo(
orderNumber: order.orderNumber,
customerName: order.metadata['customer_name'] ?? 'John Doe',
cashierName: cashierName,
paymentMethod: order.payments.isEmpty
? null
: order.payments.last.paymentMethodName,
tableNumber: order.tableNumber,
);
bytes += builder.orderType('Split');
bytes += builder.row2Columns(
'Split',
'${order.payments.last.splitNumber} / ${order.payments.last.splitTotal}',
);
bytes += builder.summary(
totalItems: 0,
subtotal: order.payments.last.amount.currencyFormatRpV2,
discount: 0.currencyFormatRpV2,
total: order.payments.last.amount.currencyFormatRpV2,
paid: order.payments.last.amount.currencyFormatRpV2,
);
bytes += builder.footer(message: 'Kasir');
return bytes;
}
}
@@ -241,7 +241,9 @@ class ReceiptComponentBuilder {
List<int> bytes = [];
bytes += separator();
bytes += row2Columns('Total Item', totalItems.toString());
if (totalItems > 0) {
bytes += row2Columns('Total Item', totalItems.toString());
}
bytes += row2Columns('Subtotal', subtotal);
bytes += row2Columns('Diskon', discount);
bytes += separator();