from django import forms

from .models import Vehiculo, Repostaje


class VehiculoForm(forms.ModelForm):
    class Meta:
        model = Vehiculo
        fields = ['marca', 'modelo', 'matricula', 'foto']

    marca = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    modelo = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    matricula = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'}))


class RepostajeForm(forms.ModelForm):
    class Meta:
        model = Repostaje
        fields = ['fecha', 'vehiculo', 'kms', 'litros', 'importe']
        exclude = ['descuento', 'precioxlitro']

    fecha = forms.DateField(
            widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}))

    vehiculo = forms.ModelChoiceField(
        queryset=Vehiculo.objects.all(),
        widget=forms.Select(attrs={'class': 'form-control'}))

    kms = forms.DecimalField(
        widget=forms.TextInput(attrs={'class': 'form-control'}))

    litros = forms.DecimalField(
        widget=forms.NumberInput(attrs={'class': 'form-control'}))

    importe = forms.DecimalField(
        widget=forms.NumberInput(attrs={'class': 'form-control'}))

    aplica_descuento = forms.BooleanField(initial=False, required=False)
