Files
eamco_office_api/app/info/views.py

46 lines
1.6 KiB
Python

from flask import jsonify
from app.info import info
from app import db
from app.classes.pricing import Pricing_Oil_Oil, Pricing_Service_General
from app.classes.admin import Admin_Company
@info.route("/price/oil", methods=["GET"])
def get_oil_price():
get_price_query = (db.session
.query(Pricing_Oil_Oil)
.order_by(Pricing_Oil_Oil.date.desc())
.first())
return jsonify({"ok": True,
'price': get_price_query.price_for_customer,
}), 200
@info.route("/price/service", methods=["GET"])
def get_service_price():
get_price_query = (db.session
.query(Pricing_Service_General)
.order_by(Pricing_Service_General.date.desc())
.first())
return jsonify({"ok": True,
'price_hourly': get_price_query.price_service_hour,
'emergency_fee': get_price_query.price_emergency_call,
'emergency_rate': get_price_query.price_emergency_service_hour,
'prime': get_price_query.price_prime,
'cleaning': get_price_query.price_cleaning,
'out_of_oil': get_price_query.price_out_of_oil,
}), 200
@info.route("/company", methods=["GET"])
def get_company():
get_data_company = (db.session
.query(Admin_Company)
.first())
return jsonify({"ok": True,
'name': get_data_company.company_name,
'telephone': get_data_company.company_phone_number,
}), 200