Printer Local data and remove unused
This commit is contained in:
@@ -23,7 +23,7 @@ class DatabaseHelper {
|
||||
|
||||
return await openDatabase(
|
||||
path,
|
||||
version: 1,
|
||||
version: 2, // Updated version for printer table
|
||||
onCreate: _onCreate,
|
||||
onUpgrade: _onUpgrade,
|
||||
);
|
||||
@@ -66,17 +66,49 @@ class DatabaseHelper {
|
||||
)
|
||||
''');
|
||||
|
||||
// Printer table - NEW
|
||||
await db.execute('''
|
||||
CREATE TABLE printers (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
code TEXT UNIQUE NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
address TEXT,
|
||||
paper TEXT,
|
||||
type TEXT,
|
||||
created_at TEXT,
|
||||
updated_at TEXT
|
||||
)
|
||||
''');
|
||||
|
||||
// Create indexes for better performance
|
||||
await db.execute(
|
||||
'CREATE INDEX idx_products_category_id ON products(category_id)');
|
||||
await db.execute('CREATE INDEX idx_products_name ON products(name)');
|
||||
await db.execute('CREATE INDEX idx_products_sku ON products(sku)');
|
||||
await db.execute(
|
||||
'CREATE INDEX idx_products_description ON products(description)');
|
||||
await db.execute('CREATE INDEX idx_printers_code ON printers(code)');
|
||||
await db.execute('CREATE INDEX idx_printers_type ON printers(type)');
|
||||
}
|
||||
|
||||
Future<void> _onUpgrade(Database db, int oldVersion, int newVersion) async {
|
||||
// Handle database upgrades here
|
||||
if (oldVersion < 2) {
|
||||
// Add printer table in version 2
|
||||
await db.execute('''
|
||||
CREATE TABLE printers (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
code TEXT UNIQUE NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
address TEXT,
|
||||
paper TEXT,
|
||||
type TEXT,
|
||||
created_at TEXT,
|
||||
updated_at TEXT
|
||||
)
|
||||
''');
|
||||
|
||||
// Add indexes for printer table
|
||||
await db.execute('CREATE INDEX idx_printers_code ON printers(code)');
|
||||
await db.execute('CREATE INDEX idx_printers_type ON printers(type)');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> close() async {
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:enaklo_pos/core/utils/printer_service.dart';
|
||||
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/printer/printer_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/settings_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:enaklo_pos/data/type/bussines_type.dart';
|
||||
@@ -28,13 +28,13 @@ Future<void> onPrint(
|
||||
|
||||
if (outlet.businessType == BusinessType.restaurant) {
|
||||
final checkerPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('checker');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('checker');
|
||||
final kitchenPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('kitchen');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('kitchen');
|
||||
final barPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('bar');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('bar');
|
||||
final receiptPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
|
||||
if (receiptPrinter != null) {
|
||||
try {
|
||||
@@ -232,7 +232,7 @@ Future<void> onPrint(
|
||||
|
||||
if (outlet.businessType == BusinessType.ticketing) {
|
||||
final ticketPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('ticket');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('ticket');
|
||||
|
||||
final barcode = await generateBarcodeAsUint8List(order.orderNumber ?? "");
|
||||
|
||||
@@ -288,7 +288,7 @@ Future<void> onPrintRecipt(
|
||||
required List<ProductQuantity> productQuantity,
|
||||
}) async {
|
||||
final receiptPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final settings = await SettingsLocalDatasource().getTax();
|
||||
final outlet = await OutletLocalDatasource().get();
|
||||
@@ -346,7 +346,7 @@ Future<void> onPrinVoidRecipt(
|
||||
required int totalVoid,
|
||||
}) async {
|
||||
final receiptPrinter =
|
||||
await ProductLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final settings = await SettingsLocalDatasource().getTax();
|
||||
final outlet = await OutletLocalDatasource().get();
|
||||
|
||||
Reference in New Issue
Block a user