/// Payment Term Model
///
/// Data model for payment term from API responses.
library;

import 'package:equatable/equatable.dart';
import 'package:worker/features/orders/domain/entities/payment_term.dart';

/// Payment Term Model
class PaymentTermModel extends Equatable {
  final String name;
  final String? customDescription;

  const PaymentTermModel({
    required this.name,
    this.customDescription,
  });

  /// Create from JSON
  factory PaymentTermModel.fromJson(Map<String, dynamic> json) {
    return PaymentTermModel(
      name: json['name'] as String,
      customDescription: json['custom_description'] as String?,
    );
  }

  /// Convert to JSON
  Map<String, dynamic> toJson() {
    return {
      'name': name,
      'custom_description': customDescription,
    };
  }

  /// Convert to entity
  PaymentTerm toEntity() {
    return PaymentTerm(
      name: name,
      customDescription: customDescription ?? '',
    );
  }

  /// Create from entity
  factory PaymentTermModel.fromEntity(PaymentTerm entity) {
    return PaymentTermModel(
      name: entity.name,
      customDescription: entity.customDescription,
    );
  }

  @override
  List<Object?> get props => [name, customDescription];
}
