from django.db import models

class Entry(models.Model):
    
    PAYMENET_OPTIONS = [
        ('cash', 'Cash'),
        ('card', 'Card'),
        ('momo', 'Mobile Money'),
    ]
    
    APPROVAL_STATUS = [
        ('pending', 'Pending'),
        ('approved', 'Approved'),
        ('declined', 'Declined'),
    ]
    
    car = models.ForeignKey('car.Car', on_delete=models.CASCADE)
    battery_capacity = models.FloatField(null=True, blank=True)
    initial_soc = models.FloatField(null=True, blank=True)
    final_soc = models.FloatField(null=True, blank=True)
    energy = models.FloatField(null=True, blank=True)
    date_created = models.DateTimeField(auto_now_add=True)
    completed = models.BooleanField(default=False)
    total_cost = models.FloatField(null=True, blank=True)
    created_by = models.ForeignKey('account.User', on_delete=models.SET_NULL, null=True, blank=True)
    branch = models.ForeignKey('branch.Branch', on_delete=models.SET_NULL, null=True, blank=True)
    payment_option = models.CharField(max_length=10, choices=PAYMENET_OPTIONS, default='cash',null=True, blank=True)
    approval_status = models.CharField(max_length=10, choices=APPROVAL_STATUS, default='pending', null=True, blank=True)

    def __str__(self):
        return str(self.car.customer_name) + " - " + str(self.date_created)