second commit

This commit is contained in:
2026-07-29 11:41:53 +05:30
parent fcccf22bac
commit d72522e737
211 changed files with 19260 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import '../entities/customer.dart';
abstract class CustomerRepository {
/// Primary lookup on the Existing Customer screen.
Future<Customer?> findByMobile(String mobile);
Future<Customer?> findById(String id);
Future<Customer> create(Customer customer);
Future<Customer> update(Customer customer);
/// Applies loyalty and lifetime-spend changes once a sale completes.
Future<Customer> recordSale({
required String customerId,
required double amount,
required int pointsEarned,
required int pointsRedeemed,
});
Future<List<Customer>> search(String query);
Future<List<Customer>> recent({int limit = 20});
}

View File

@@ -0,0 +1,22 @@
import '../entities/product.dart';
/// Contract for catalogue access. Implemented in the data layer so the
/// presentation layer never depends on Hive, HTTP or any other detail.
abstract class ProductRepository {
Future<List<Product>> getAll();
Future<List<Product>> getByCategory(ProductCategory category);
/// Exact barcode lookup — the hot path for scanner billing.
Future<Product?> findByBarcode(String barcode);
Future<Product?> findById(String id);
/// Fuzzy search across name, barcode, SKU, brand and category.
Future<List<Product>> search(String query);
/// Decrements stock after a completed sale.
Future<void> decrementStock(Map<String, double> quantitiesByProductId);
Future<void> upsert(Product product);
}

View File

@@ -0,0 +1,38 @@
import '../entities/shift_report.dart';
import '../entities/sync_event.dart';
/// The terminal's two network touchpoints, plus the durable event log.
abstract class SyncRepository {
/// True once products have been pulled onto this terminal.
bool get hasCatalogue;
DateTime? get lastImportAt;
String? get catalogueRevision;
/// Pulls the catalogue and writes it locally.
///
/// Records a [SyncEventType.catalogueImport] event whether or not it
/// succeeds, so the log reflects every attempt.
Future<SyncEvent> importCatalogue({
void Function(double progress, String stage)? onProgress,
});
/// Builds the day's report from locally stored sales.
ShiftReport buildShiftReport({
required DateTime businessDate,
required String terminalId,
required String cashierName,
});
/// Queues the report and attempts to push it.
///
/// On failure the event is kept in [SyncStatus.failed] so nothing is lost.
Future<SyncEvent> pushShiftReport(ShiftReport report);
/// Retries a previously failed or pending push.
Future<SyncEvent> retry(String eventId);
List<SyncEvent> get events;
bool get hasUnsyncedEvents;
}

View File

@@ -0,0 +1,20 @@
import '../entities/transaction.dart';
abstract class TransactionRepository {
Future<SaleTransaction> save(SaleTransaction transaction);
Future<List<SaleTransaction>> history({int limit = 50});
Future<SaleTransaction?> findByInvoice(String invoiceNumber);
/// Next invoice sequence for the current month.
Future<int> nextInvoiceSequence();
Future<void> park(ParkedBill bill);
Future<List<ParkedBill>> parkedBills();
Future<void> removeParked(String id);
Future<double> salesTotalForDay(DateTime day);
}