using CommunityToolkit.Mvvm.ComponentModel;
using Elwig.Helpers.Billing;
using Elwig.Models.Entities;
using System;
using System.Collections.Generic;
using System.Windows;

namespace Elwig.ViewModels {
    public partial class PaymentVariantsViewModel : ObservableObject {

        [ObservableProperty]
        private PaymentVar? _selectedPaymentVariant;
        [ObservableProperty]
        private IEnumerable<PaymentVar> _paymentVariants = [];

        public BillingData? BillingData;
        public bool SeasonLocked;
        public bool WeightModifierChanged;

        [ObservableProperty]
        private string _name = "";
        [ObservableProperty]
        private string _comment = "";
        [ObservableProperty]
        private string _dateString = "";
        public DateOnly? Date {
            get => DateOnly.TryParseExact(DateString, "dd.MM.yyyy", out var d) ? d : null;
            set => DateString = $"{value:dd.MM.yyyy}";
        }
        [ObservableProperty]
        private string _transferDateString = "";
        public DateOnly? TransferDate {
            get => DateOnly.TryParseExact(TransferDateString, "dd.MM.yyyy", out var d) ? d : null;
            set => TransferDateString = $"{value:dd.MM.yyyy}";
        }
        [ObservableProperty]
        private string _weightModifierString = "";
        public double? WeightModifier {
            get => double.TryParse(WeightModifierString, out var d) ? d : null;
            set => WeightModifierString = $"{value}";
        }
        [ObservableProperty]
        private string _data = "";
        [ObservableProperty]
        private bool _considerModifiers;
        [ObservableProperty]
        private bool _considerPenalties;
        [ObservableProperty]
        private bool _considerPenalty;
        [ObservableProperty]
        private bool _considerAuto;
        [ObservableProperty]
        private bool _considerCustom;

        [ObservableProperty]
        private bool _isPaymentVariantSelected;
        [ObservableProperty]
        private bool _isReadOnly = true;
        [ObservableProperty]
        private bool _dataIsReadOnly = true;
        [ObservableProperty]
        private bool _isEnabled = false;
        [ObservableProperty]
        private bool _saveIsEnabled = false;
        [ObservableProperty]
        private bool _deleteIsEnabled = false;
        [ObservableProperty]
        private bool _calculateIsEnabled = false;
        [ObservableProperty]
        private bool _exportIsEnabled = false;
        [ObservableProperty]
        private bool _commitIsEnabled = false;
        [ObservableProperty]
        private Visibility _commitVisibility = Visibility.Visible;
        [ObservableProperty]
        private bool _revertIsEnabled = false;
        [ObservableProperty]
        private Visibility _revertVisibility = Visibility.Hidden;
        [ObservableProperty]
        private string _arrow = "\xF0AF";
        [ObservableProperty]
        private string _editText = "Bearbeiten";

        [ObservableProperty]
        private string _statusModifierSum = "-";
        [ObservableProperty]
        private string _statusTotalSum = "-";
        [ObservableProperty]
        private string _statusVatSum = "-";
        [ObservableProperty]
        private string _statusDeductionSum = "-";
        [ObservableProperty]
        private string _statusPaymentSum = "-";
    }
}
