Enhance model and service documentation with detailed comments and descriptions
- Updated Group, Trip, User, and other model classes to include comprehensive documentation for better understanding and maintainability. - Improved error handling and logging in services, including AuthService, ErrorService, and StorageService. - Added validation and business logic explanations in ExpenseService and TripService. - Refactored method comments to follow a consistent format across the codebase. - Translated error messages and comments from French to English for consistency.
This commit is contained in:
@@ -2,13 +2,27 @@ import 'dart:io';
|
||||
import '../models/expense.dart';
|
||||
import '../repositories/expense_repository.dart';
|
||||
import 'error_service.dart';
|
||||
import 'storage_service.dart'; // Pour upload des reçus
|
||||
import 'storage_service.dart';
|
||||
|
||||
/// Service for managing expense operations with business logic validation.
|
||||
///
|
||||
/// This service provides high-level expense management functionality including
|
||||
/// validation, receipt image uploading, and coordination with the expense repository.
|
||||
/// It acts as a business logic layer between the UI and data persistence.
|
||||
class ExpenseService {
|
||||
/// Repository for expense data operations.
|
||||
final ExpenseRepository _expenseRepository;
|
||||
|
||||
/// Service for error handling and logging.
|
||||
final ErrorService _errorService;
|
||||
|
||||
/// Service for handling file uploads (receipts).
|
||||
final StorageService _storageService;
|
||||
|
||||
/// Creates a new [ExpenseService] with required dependencies.
|
||||
///
|
||||
/// [expenseRepository] is required for data operations.
|
||||
/// [errorService] and [storageService] have default implementations if not provided.
|
||||
ExpenseService({
|
||||
required ExpenseRepository expenseRepository,
|
||||
ErrorService? errorService,
|
||||
@@ -17,13 +31,22 @@ class ExpenseService {
|
||||
_errorService = errorService ?? ErrorService(),
|
||||
_storageService = storageService ?? StorageService();
|
||||
|
||||
// Création avec validation et upload d'image
|
||||
/// Creates an expense with validation and optional receipt image upload.
|
||||
///
|
||||
/// Validates the expense data, uploads receipt image if provided, and
|
||||
/// creates the expense record in the database.
|
||||
///
|
||||
/// [expense] - The expense data to create
|
||||
/// [receiptImage] - Optional receipt image file to upload
|
||||
///
|
||||
/// Returns the ID of the created expense.
|
||||
/// Throws exceptions if validation fails or creation errors occur.
|
||||
Future<String> createExpenseWithValidation(Expense expense, File? receiptImage) async {
|
||||
try {
|
||||
// Validation métier
|
||||
// Business logic validation
|
||||
_validateExpenseData(expense);
|
||||
|
||||
// Upload du reçu si présent
|
||||
// Upload receipt image if provided
|
||||
String? receiptUrl;
|
||||
if (receiptImage != null) {
|
||||
receiptUrl = await _storageService.uploadReceiptImage(
|
||||
|
||||
Reference in New Issue
Block a user