39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
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;
|
|
}
|