Initial commit: unionflow-mobile-apps
Application Flutter complète (sans build artifacts). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/// Use case: Approuver une transaction
|
||||
library approve_transaction;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/transaction_approval.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class ApproveTransaction {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
ApproveTransaction(this.repository);
|
||||
|
||||
Future<Either<Failure, TransactionApproval>> call({
|
||||
required String approvalId,
|
||||
String? comment,
|
||||
}) async {
|
||||
if (approvalId.isEmpty) {
|
||||
return Left(ValidationFailure('ID approbation requis'));
|
||||
}
|
||||
|
||||
return await repository.approveTransaction(
|
||||
approvalId: approvalId,
|
||||
comment: comment,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/// Use case: Créer un budget
|
||||
library create_budget;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/budget.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class CreateBudget {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
CreateBudget(this.repository);
|
||||
|
||||
Future<Either<Failure, Budget>> call({
|
||||
required String name,
|
||||
String? description,
|
||||
required String organizationId,
|
||||
required BudgetPeriod period,
|
||||
required int year,
|
||||
int? month,
|
||||
required List<BudgetLine> lines,
|
||||
}) async {
|
||||
// Validation
|
||||
if (name.trim().isEmpty) {
|
||||
return Left(ValidationFailure('Nom du budget requis'));
|
||||
}
|
||||
|
||||
if (organizationId.isEmpty) {
|
||||
return Left(ValidationFailure('ID organisation requis'));
|
||||
}
|
||||
|
||||
if (year < 2000 || year > 2100) {
|
||||
return Left(ValidationFailure('Année invalide'));
|
||||
}
|
||||
|
||||
if (period == BudgetPeriod.monthly && (month == null || month < 1 || month > 12)) {
|
||||
return Left(ValidationFailure('Mois requis pour budget mensuel (1-12)'));
|
||||
}
|
||||
|
||||
if (lines.isEmpty) {
|
||||
return Left(ValidationFailure('Au moins une ligne budgétaire requise'));
|
||||
}
|
||||
|
||||
return await repository.createBudget(
|
||||
name: name,
|
||||
description: description,
|
||||
organizationId: organizationId,
|
||||
period: period,
|
||||
year: year,
|
||||
month: month,
|
||||
lines: lines,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/// Use case: Récupérer une approbation par ID
|
||||
library get_approval_by_id;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/transaction_approval.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GetApprovalById {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
GetApprovalById(this.repository);
|
||||
|
||||
Future<Either<Failure, TransactionApproval>> call(String approvalId) async {
|
||||
if (approvalId.isEmpty) {
|
||||
return Left(ValidationFailure('ID approbation requis'));
|
||||
}
|
||||
|
||||
return await repository.getApprovalById(approvalId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/// Use case: Récupérer un budget par ID
|
||||
library get_budget_by_id;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/budget.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GetBudgetById {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
GetBudgetById(this.repository);
|
||||
|
||||
Future<Either<Failure, Budget>> call(String budgetId) async {
|
||||
if (budgetId.isEmpty) {
|
||||
return Left(ValidationFailure('ID budget requis'));
|
||||
}
|
||||
|
||||
return await repository.getBudgetById(budgetId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/// Use case: Récupérer le suivi budgétaire
|
||||
library get_budget_tracking;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GetBudgetTracking {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
GetBudgetTracking(this.repository);
|
||||
|
||||
Future<Either<Failure, Map<String, dynamic>>> call({
|
||||
required String budgetId,
|
||||
}) async {
|
||||
if (budgetId.isEmpty) {
|
||||
return Left(ValidationFailure('ID budget requis'));
|
||||
}
|
||||
|
||||
return await repository.getBudgetTracking(budgetId: budgetId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/// Use case: Récupérer les budgets
|
||||
library get_budgets;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/budget.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GetBudgets {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
GetBudgets(this.repository);
|
||||
|
||||
Future<Either<Failure, List<Budget>>> call({
|
||||
String? organizationId,
|
||||
BudgetStatus? status,
|
||||
int? year,
|
||||
}) async {
|
||||
return await repository.getBudgets(
|
||||
organizationId: organizationId,
|
||||
status: status,
|
||||
year: year,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/// Use case: Récupérer les approbations en attente
|
||||
library get_pending_approvals;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/transaction_approval.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GetPendingApprovals {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
GetPendingApprovals(this.repository);
|
||||
|
||||
Future<Either<Failure, List<TransactionApproval>>> call({
|
||||
String? organizationId,
|
||||
}) async {
|
||||
return await repository.getPendingApprovals(
|
||||
organizationId: organizationId,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/// Use case: Rejeter une transaction
|
||||
library reject_transaction;
|
||||
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../../../../core/error/failures.dart';
|
||||
import '../entities/transaction_approval.dart';
|
||||
import '../repositories/finance_workflow_repository.dart';
|
||||
|
||||
@lazySingleton
|
||||
class RejectTransaction {
|
||||
final FinanceWorkflowRepository repository;
|
||||
|
||||
RejectTransaction(this.repository);
|
||||
|
||||
Future<Either<Failure, TransactionApproval>> call({
|
||||
required String approvalId,
|
||||
required String reason,
|
||||
}) async {
|
||||
if (approvalId.isEmpty) {
|
||||
return Left(ValidationFailure('ID approbation requis'));
|
||||
}
|
||||
|
||||
if (reason.trim().isEmpty) {
|
||||
return Left(ValidationFailure('Raison du rejet requise'));
|
||||
}
|
||||
|
||||
return await repository.rejectTransaction(
|
||||
approvalId: approvalId,
|
||||
reason: reason,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user