fix: print split bill

This commit is contained in:
efrilm 2025-09-01 22:25:15 +07:00
parent dcd739e4a4
commit 0d91d43866
6 changed files with 30 additions and 24 deletions

View File

@ -133,6 +133,7 @@ Future<void> onPrintRecipt(
required String paymentMethod, required String paymentMethod,
required int nominalBayar, required int nominalBayar,
required int kembalian, required int kembalian,
required List<ProductQuantity> productQuantity,
}) async { }) async {
final receiptPrinter = final receiptPrinter =
await ProductLocalDatasource.instance.getPrinterByCode('receipt'); await ProductLocalDatasource.instance.getPrinterByCode('receipt');
@ -152,7 +153,7 @@ Future<void> onPrintRecipt(
receiptPrinter.paper.toIntegerFromText, receiptPrinter.paper.toIntegerFromText,
order.orderType ?? "", order.orderType ?? "",
outlet, outlet,
); productQuantity);
await PrinterService() await PrinterService()
.printWithPrinter(receiptPrinter, printValue, context); .printWithPrinter(receiptPrinter, printValue, context);
} catch (e) { } catch (e) {

View File

@ -751,6 +751,7 @@ class PrintDataoutputs {
int paper, int paper,
String orderType, String orderType,
Outlet outlet, Outlet outlet,
List<ProductQuantity> products,
) async { ) async {
List<int> bytes = []; List<int> bytes = [];
@ -865,15 +866,16 @@ class PrintDataoutputs {
? '------------------------------------------------' ? '------------------------------------------------'
: '--------------------------------', : '--------------------------------',
styles: const PosStyles(bold: false, align: PosAlign.center)); styles: const PosStyles(bold: false, align: PosAlign.center));
for (final product in (order.orderItems ?? <OrderItem>[])) { for (final product in (products ?? <ProductQuantity>[])) {
bytes += generator.row([ bytes += generator.row([
PosColumn( PosColumn(
text: '${product.quantity} x ${product.productName}', text: '${product.quantity} x ${product.product.name}',
width: 8, width: 8,
styles: const PosStyles(bold: true, align: PosAlign.left), styles: const PosStyles(bold: true, align: PosAlign.left),
), ),
PosColumn( PosColumn(
text: (product.totalPrice ?? 0).currencyFormatRpV2, text: (((product.product.price ?? 0) * product.quantity))
.currencyFormatRpV2,
width: 4, width: 4,
styles: const PosStyles(bold: true, align: PosAlign.right), styles: const PosStyles(bold: true, align: PosAlign.right),
), ),
@ -887,7 +889,7 @@ class PrintDataoutputs {
bytes += generator.row([ bytes += generator.row([
PosColumn( PosColumn(
text: 'Subtotal ${order.orderItems?.length ?? "0"} Product', text: 'Subtotal ${products.length} Product',
width: 6, width: 6,
styles: const PosStyles(align: PosAlign.left), styles: const PosStyles(align: PosAlign.left),
), ),

View File

@ -246,6 +246,7 @@ class _SalesPageState extends State<SalesPage> {
), ),
], ],
if (widget.status == 'completed') if (widget.status == 'completed')
if (orderDetail?.isRefund == false)
Button.outlined( Button.outlined(
onPressed: () { onPressed: () {
context.push(RefundPage( context.push(RefundPage(

View File

@ -932,7 +932,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
Order splitOrder = Order( Order splitOrder = Order(
id: widget.order.id, id: widget.order.id,
orderNumber: widget.order.orderNumber, orderNumber: widget.order.orderNumber,
orderItems: getOrderItemPending(), // Keep all items for reference orderItems: [], // Keep all items for reference
subtotal: splitAmount, subtotal: splitAmount,
totalAmount: splitAmount, totalAmount: splitAmount,
taxAmount: 0, // You might want to calculate proportional values taxAmount: 0, // You might want to calculate proportional values

View File

@ -1012,6 +1012,7 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
: widget.order.totalAmount ?? 0, : widget.order.totalAmount ?? 0,
kembalian: widget.nominalBayar - kembalian: widget.nominalBayar -
(widget.order.totalAmount ?? 0), (widget.order.totalAmount ?? 0),
productQuantity: widget.productQuantity,
); );
onPrint( onPrint(
context, context,

View File

@ -798,6 +798,7 @@ class _SuccessPaymentPageState extends State<SuccessPaymentPage> {
: order.totalAmount ?? 0, : order.totalAmount ?? 0,
kembalian: kembalian:
widget.nominalBayar - (order.totalAmount ?? 0), widget.nominalBayar - (order.totalAmount ?? 0),
productQuantity: widget.productQuantity,
); );
}, },
child: const Row( child: const Row(