181186 - Criar PDV Android para rodar em maquinas P.O.S.
This commit is contained in:
commit
c9983cbad5
204 files changed
+11453
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import '../entities/app_settings.dart';
|
||||
import '../entities/app_session.dart';
|
||||
import '../entities/pos_device.dart';
|
||||
|
||||
abstract interface class AuthRepository {
|
||||
bool get isAuthenticated;
|
||||
|
||||
AppSession? get currentSession;
|
||||
|
||||
Future<AppSession> authenticate({
|
||||
required String username,
|
||||
required String password,
|
||||
required AppSettings settings,
|
||||
required PosDevice device,
|
||||
required String appVersion,
|
||||
});
|
||||
|
||||
Future<void> logout();
|
||||
}
|
||||
|
||||
class AuthUnavailableException implements Exception {
|
||||
const AuthUnavailableException(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../entities/cart_item.dart';
|
||||
import '../entities/product.dart';
|
||||
|
||||
abstract interface class CartRepository implements Listenable {
|
||||
List<CartItem> get items;
|
||||
|
||||
int get itemCount;
|
||||
|
||||
int? get totalMinorUnits;
|
||||
|
||||
void addProduct(Product product);
|
||||
|
||||
void increaseQuantity(Product product);
|
||||
|
||||
void decreaseQuantity(Product product);
|
||||
|
||||
void removeProduct(Product product);
|
||||
|
||||
void clear();
|
||||
}
|
||||
|
||||
class InMemoryCartRepository extends ChangeNotifier implements CartRepository {
|
||||
final Map<String, CartItem> _items = {};
|
||||
|
||||
@override
|
||||
List<CartItem> get items => List.unmodifiable(_items.values);
|
||||
|
||||
@override
|
||||
int get itemCount =>
|
||||
_items.values.fold(0, (count, item) => count + item.quantity);
|
||||
|
||||
@override
|
||||
int? get totalMinorUnits {
|
||||
if (_items.values.any((item) => item.product.priceMinorUnits == null)) {
|
||||
return null;
|
||||
}
|
||||
return _items.values.fold<int>(
|
||||
0,
|
||||
(total, item) => total + item.product.priceMinorUnits! * item.quantity,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void addProduct(Product product) {
|
||||
increaseQuantity(product);
|
||||
}
|
||||
|
||||
@override
|
||||
void increaseQuantity(Product product) {
|
||||
final key = product.cartKey;
|
||||
final existing = _items[key];
|
||||
_items[key] = CartItem(
|
||||
product: product,
|
||||
quantity: (existing?.quantity ?? 0) + 1,
|
||||
);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void decreaseQuantity(Product product) {
|
||||
final key = product.cartKey;
|
||||
final existing = _items[key];
|
||||
if (existing == null || existing.quantity <= 1) return;
|
||||
_items[key] = CartItem(
|
||||
product: existing.product,
|
||||
quantity: existing.quantity - 1,
|
||||
);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void removeProduct(Product product) {
|
||||
if (_items.remove(product.cartKey) != null) notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void clear() {
|
||||
if (_items.isEmpty) return;
|
||||
_items.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import '../entities/department.dart';
|
||||
import '../entities/product.dart';
|
||||
|
||||
abstract interface class CatalogRepository {
|
||||
Future<List<Department>> fetchDepartments();
|
||||
|
||||
Future<List<Product>> fetchProductsByDepartment(int departmentId);
|
||||
|
||||
Future<Product?> fetchProductByBarcode(String barcode);
|
||||
}
|
||||
|
||||
class CatalogException implements Exception {
|
||||
const CatalogException(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class ConnectionTestResult {
|
||||
const ConnectionTestResult({
|
||||
required this.isAvailable,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
final bool isAvailable;
|
||||
final String message;
|
||||
}
|
||||
|
||||
abstract interface class ConnectionTester {
|
||||
Future<ConnectionTestResult> test(Uri serverUri);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import '../entities/customer.dart';
|
||||
|
||||
abstract interface class CustomerRepository {
|
||||
Future<List<Customer>> search(String query);
|
||||
}
|
||||
|
||||
class CustomerSearchException implements Exception {
|
||||
const CustomerSearchException(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import '../entities/payment_method.dart';
|
||||
|
||||
abstract interface class PaymentMethodsRepository {
|
||||
Future<List<PaymentMethod>> loadAvailable();
|
||||
}
|
||||
|
||||
class PaymentMethodsException implements Exception {
|
||||
const PaymentMethodsException(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import '../entities/cart_item.dart';
|
||||
import '../entities/customer.dart';
|
||||
import '../entities/sale_completion.dart';
|
||||
import '../entities/sale_payment.dart';
|
||||
|
||||
abstract interface class SaleCheckoutRepository {
|
||||
Future<SaleCompletion> finalizeCashSale({
|
||||
required List<CartItem> items,
|
||||
required List<SalePayment> payments,
|
||||
Customer? customer,
|
||||
String? customerCpf,
|
||||
required String checkoutKey,
|
||||
});
|
||||
}
|
||||
|
||||
class SaleCheckoutException implements Exception {
|
||||
const SaleCheckoutException(this.code, this.message);
|
||||
|
||||
final String code;
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import '../entities/sale_view_mode.dart';
|
||||
|
||||
abstract interface class SaleViewPreferenceRepository {
|
||||
Future<SaleViewMode> loadForUser(int userId);
|
||||
|
||||
Future<void> saveForUser(int userId, SaleViewMode mode);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import '../entities/historical_sale.dart';
|
||||
|
||||
abstract interface class SalesHistoryRepository {
|
||||
Future<List<HistoricalSale>> fetchSales();
|
||||
}
|
||||
|
||||
class SalesHistoryException implements Exception {
|
||||
const SalesHistoryException(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import '../entities/app_settings.dart';
|
||||
|
||||
abstract interface class SettingsRepository {
|
||||
Future<AppSettings?> load();
|
||||
|
||||
Future<void> save(AppSettings settings);
|
||||
}
|
||||
Reference in new issue
Block a user