print receipt

This commit is contained in:
efrilm
2025-11-06 18:15:54 +07:00
parent 896ea6c28c
commit bf7a5708f5
16 changed files with 1132 additions and 32 deletions
@@ -75,6 +75,92 @@ class Order with _$Order {
splitType: '',
refundReason: '',
);
factory Order.mockOrder() => Order(
id: 'ORD-001',
orderNumber: 'A-1001',
outletId: 'OUTLET-001',
userId: 'USER-001',
tableNumber: 'T01',
orderType: 'Dine In',
status: 'Completed',
subtotal: 150000,
taxAmount: 15000,
discountAmount: 5000,
totalAmount: 160000,
totalCost: 100000,
remainingAmount: 0,
paymentStatus: 'Paid',
refundAmount: 0,
refundReason: '',
isVoid: false,
isRefund: false,
notes: 'Customer requested less sugar',
metadata: {'source': 'POS', 'device': 'iPad', 'customer_name': "John Doe"},
createdAt: DateTime.now().subtract(const Duration(hours: 1)),
updatedAt: DateTime.now(),
orderItems: [
OrderItem(
id: 'ITEM-001',
orderId: 'ORD-001',
productId: 'PROD-001',
productName: 'Cappuccino',
productVariantId: 'VAR-001',
productVariantName: 'Hot',
quantity: 2,
unitPrice: 25000,
totalPrice: 50000,
modifiers: [
{'name': 'Extra Shot', 'price': 5000},
],
notes: 'No sugar',
status: 'Served',
createdAt: DateTime.now().subtract(const Duration(hours: 1)),
updatedAt: DateTime.now(),
printerType: 'Barista',
paidQuantity: 2,
),
OrderItem(
id: 'ITEM-002',
orderId: 'ORD-001',
productId: 'PROD-002',
productName: 'Spaghetti Carbonara',
productVariantId: 'VAR-002',
productVariantName: '',
quantity: 1,
unitPrice: 55000,
totalPrice: 55000,
modifiers: [],
notes: '',
status: 'Served',
createdAt: DateTime.now().subtract(const Duration(hours: 1)),
updatedAt: DateTime.now(),
printerType: 'Kitchen',
paidQuantity: 1,
),
],
payments: [
Payment(
id: 'PAY-001',
orderId: 'ORD-001',
paymentMethodId: 'PM-CASH',
paymentMethodName: 'Cash',
paymentMethodType: 'Cash',
amount: 160000,
status: 'Success',
splitNumber: 1,
splitTotal: 1,
splitDescription: 'Full payment by cash',
refundAmount: 0,
metadata: {'cashier': 'Efril', 'device': 'POS iPad'},
createdAt: DateTime.now().subtract(const Duration(minutes: 45)),
updatedAt: DateTime.now(),
),
],
totalPaid: 160000,
paymentCount: 1,
splitType: 'Single',
);
}
@freezed
@@ -23,4 +23,21 @@ class Printer with _$Printer {
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
factory Printer.fromTest({
required String code,
required String name,
required String address,
required String paper,
required String type,
}) => Printer(
id: generateRandomNumber(),
code: code,
name: name,
address: address,
paper: paper,
type: type,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
}
+1
View File
@@ -3,6 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:print_bluetooth_thermal/print_bluetooth_thermal.dart';
import '../../common/api/api_failure.dart';
import '../../common/function/app_function.dart';
part 'printer.freezed.dart';
@@ -10,4 +10,8 @@ abstract class IPrinterRepository {
Future<Either<PrinterFailure, Unit>> updatePrinter(Printer printer, int id);
Future<Either<PrinterFailure, Unit>> deletePrinter(int id);
Future<Either<PrinterFailure, Printer>> getPrinterByCode(String code);
Future<Either<PrinterFailure, bool>> printStruct(
Printer printer,
List<int> printValue,
);
}