print on sales
This commit is contained in:
parent
7b12793618
commit
6acfbdc4ca
@ -1,5 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
|
||||
class OrderDetailResponseModel {
|
||||
final bool? success;
|
||||
final Order? data;
|
||||
@ -380,3 +383,21 @@ class Payment {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extension OrderItemListExtension on List<OrderItem> {
|
||||
List<ProductQuantity> toProductQuantities() => map((e) => ProductQuantity(
|
||||
product: Product(
|
||||
id: e.productId,
|
||||
name: e.productName,
|
||||
price: e.unitPrice,
|
||||
printerType: e.printerType,
|
||||
),
|
||||
variant: ProductVariant(
|
||||
id: e.productVariantId,
|
||||
name: e.productVariantName,
|
||||
productId: e.productId,
|
||||
),
|
||||
notes: e.notes ?? '',
|
||||
quantity: e.quantity ?? 0,
|
||||
)).toList();
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/core/function/app_function.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/payment/pages/payment_page.dart';
|
||||
@ -256,6 +257,37 @@ class _SalesPageState extends State<SalesPage> {
|
||||
label: 'Refund',
|
||||
icon: Icon(Icons.autorenew),
|
||||
),
|
||||
SpaceWidth(8),
|
||||
Button.outlined(
|
||||
onPressed: () {
|
||||
if (widget.status == 'completed') {
|
||||
onPrintRecipt(
|
||||
context,
|
||||
order: orderDetail!,
|
||||
paymentMethod: orderDetail!.payments
|
||||
?.map((p) => p.paymentMethodName)
|
||||
.join(', ') ??
|
||||
"",
|
||||
nominalBayar: orderDetail?.totalPaid ?? 0,
|
||||
kembalian: 0,
|
||||
productQuantity: orderDetail!.orderItems!
|
||||
.toProductQuantities(),
|
||||
);
|
||||
} else {
|
||||
onPrint(
|
||||
context,
|
||||
productQuantity: orderDetail!.orderItems!
|
||||
.toProductQuantities(),
|
||||
order: orderDetail!,
|
||||
);
|
||||
}
|
||||
},
|
||||
label: 'Print',
|
||||
icon: Icon(
|
||||
Icons.print,
|
||||
),
|
||||
),
|
||||
SpaceWidth(8),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user