diff --git a/app/entities.py b/app/entities.py index 5e06001..d138bbf 100644 --- a/app/entities.py +++ b/app/entities.py @@ -63,6 +63,9 @@ class Vehicle(db.Model): pitstops = db.relationship( 'Pitstop' ) + services = db.relationship( + 'Service' + ) consumables = db.relationship( 'Consumable', secondary=vehicles_consumables @@ -140,3 +143,23 @@ class Consumable(db.Model): def __repr__(self): return '' % (self.name, self.unit) + + +class Service(db.Model): + id = db.Column(db.Integer, primary_key=True) + date = db.Column(db.Date) + odometer = db.Column(db.Integer) + vehicle_id = db.Column(db.Integer, db.ForeignKey('vehicle.id')) + costs = db.Column(db.Numeric(10, 2), default=0) + description = db.Column(db.String(4096)) + + def __init__(self, date, odometer, vehicle_id, costs, description): + self.description = description + self.costs = costs + self.date = date + self.odometer = odometer + self.vehicle_id = vehicle_id + + def __repr__(self): + return '' % \ + (self.odometer, self.date, self.vehicle_id, self.costs, self.description)