// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'budget_model.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

BudgetModel _$BudgetModelFromJson(Map<String, dynamic> json) => BudgetModel(
  id: json['id'] as String,
  name: json['name'] as String,
  description: json['description'] as String?,
  organizationId: json['organizationId'] as String,
  period: $enumDecode(_$BudgetPeriodEnumMap, json['period']),
  year: (json['year'] as num).toInt(),
  month: (json['month'] as num?)?.toInt(),
  status: $enumDecode(_$BudgetStatusEnumMap, json['status']),
  lines: json['lines'] == null
      ? const []
      : BudgetModel._linesFromJson(json['lines'] as List?),
  totalPlanned: (json['totalPlanned'] as num).toDouble(),
  totalRealized: (json['totalRealized'] as num?)?.toDouble() ?? 0,
  currency: json['currency'] as String? ?? 'XOF',
  createdBy: json['createdBy'] as String,
  createdAt: DateTime.parse(json['createdAt'] as String),
  approvedAt: json['approvedAt'] == null
      ? null
      : DateTime.parse(json['approvedAt'] as String),
  approvedBy: json['approvedBy'] as String?,
  startDate: DateTime.parse(json['startDate'] as String),
  endDate: DateTime.parse(json['endDate'] as String),
  metadata: json['metadata'] as Map<String, dynamic>?,
);

Map<String, dynamic> _$BudgetModelToJson(BudgetModel instance) =>
    <String, dynamic>{
      'id': instance.id,
      'name': instance.name,
      'description': instance.description,
      'organizationId': instance.organizationId,
      'period': _$BudgetPeriodEnumMap[instance.period]!,
      'year': instance.year,
      'month': instance.month,
      'status': _$BudgetStatusEnumMap[instance.status]!,
      'totalPlanned': instance.totalPlanned,
      'totalRealized': instance.totalRealized,
      'currency': instance.currency,
      'createdBy': instance.createdBy,
      'createdAt': instance.createdAt.toIso8601String(),
      'approvedAt': instance.approvedAt?.toIso8601String(),
      'approvedBy': instance.approvedBy,
      'startDate': instance.startDate.toIso8601String(),
      'endDate': instance.endDate.toIso8601String(),
      'metadata': instance.metadata,
      'lines': BudgetModel._linesToJson(instance.lines),
    };

const _$BudgetPeriodEnumMap = {
  BudgetPeriod.monthly: 'monthly',
  BudgetPeriod.quarterly: 'quarterly',
  BudgetPeriod.semiannual: 'semiannual',
  BudgetPeriod.annual: 'annual',
};

const _$BudgetStatusEnumMap = {
  BudgetStatus.draft: 'draft',
  BudgetStatus.active: 'active',
  BudgetStatus.closed: 'closed',
  BudgetStatus.cancelled: 'cancelled',
};

BudgetLineModel _$BudgetLineModelFromJson(Map<String, dynamic> json) =>
    BudgetLineModel(
      id: json['id'] as String,
      category: $enumDecode(_$BudgetCategoryEnumMap, json['category']),
      name: json['name'] as String,
      description: json['description'] as String?,
      amountPlanned: (json['amountPlanned'] as num).toDouble(),
      amountRealized: (json['amountRealized'] as num?)?.toDouble() ?? 0,
      notes: json['notes'] as String?,
    );

Map<String, dynamic> _$BudgetLineModelToJson(BudgetLineModel instance) =>
    <String, dynamic>{
      'id': instance.id,
      'category': _$BudgetCategoryEnumMap[instance.category]!,
      'name': instance.name,
      'description': instance.description,
      'amountPlanned': instance.amountPlanned,
      'amountRealized': instance.amountRealized,
      'notes': instance.notes,
    };

const _$BudgetCategoryEnumMap = {
  BudgetCategory.contributions: 'contributions',
  BudgetCategory.savings: 'savings',
  BudgetCategory.solidarity: 'solidarity',
  BudgetCategory.events: 'events',
  BudgetCategory.operational: 'operational',
  BudgetCategory.investments: 'investments',
  BudgetCategory.other: 'other',
};
