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

View File

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

View File

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

View File

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

View File

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

View File

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