Updated claude big changes

This commit is contained in:
2026-01-29 08:43:56 -05:00
parent 2dbd3ea53f
commit eb4740c553
24 changed files with 388 additions and 429 deletions

View File

@@ -150,42 +150,42 @@ def teardown_appcontext(error):
@app.errorhandler(500)
def internal_error500(error):
return jsonify({"error": "Internal Error 500"}), 500
return jsonify({"ok": False, "error": "Internal Error 500"}), 500
@app.errorhandler(502)
def internal_error502(error):
return jsonify({"error": "Internal Error 502"}), 502
return jsonify({"ok": False, "error": "Internal Error 502"}), 502
@app.errorhandler(404)
def internal_error404(error):
return jsonify({"error": "Internal Error 400"}), 400
return jsonify({"ok": False, "error": "Not Found"}), 404
@app.errorhandler(401)
def internal_error401(error):
return jsonify({"error": "Internal Error 401"}), 401
return jsonify({"ok": False, "error": "Unauthorized"}), 401
@app.errorhandler(400)
def internal_error400(error):
return jsonify({"error": "Internal Error 400"}), 400
return jsonify({"ok": False, "error": "Bad Request"}), 400
@app.errorhandler(413)
def to_large_file(error):
return jsonify({"error": "File is too large. Use a smaller image/file."}), 413
return jsonify({"ok": False, "error": "File is too large. Use a smaller image/file."}), 413
@app.errorhandler(403)
def internal_error403(error):
return jsonify({"error": "Internal Error 403"}), 403
return jsonify({"ok": False, "error": "Forbidden"}), 403
@app.errorhandler(405)
def internal_error(error):
return jsonify({"error": "Internal Error 405"}), 405
return jsonify({"ok": False, "error": "Method Not Allowed"}), 405
# link locations
@@ -268,7 +268,11 @@ with app.app_context():
logger.info("🤖🤖🤖🤖🤖 Mode: Development 🤖🤖🤖🤖🤖")
elif mode in ['PRODUCTION', 'PROD']:
logger.info("💀💀💀💀💀💀💀💀💀💀 ⚠️ WARNING PRODUCTION 💀💀💀💀💀💀💀💀💀💀")
logger.info(f"DB: {ApplicationConfig.SQLALCHEMY_DATABASE_URI[:30]}...")
# Sanitize DB URI to avoid logging credentials
db_uri = ApplicationConfig.SQLALCHEMY_DATABASE_URI
if '@' in db_uri:
db_uri = db_uri.split('@')[-1]
logger.info(f"DB: ...@{db_uri[:50]}")
logger.info(f"CORS: {len(ApplicationConfig.CORS_ALLOWED_ORIGINS)} origins configured")
# Test database connection

View File

@@ -1,8 +1,9 @@
import logging
from flask import request, jsonify
from flask import request
from flask_login import current_user, logout_user, login_user, login_required
from app.admin import admin
from app import db
from app.common.responses import error_response, success_response
from datetime import datetime
from app.classes.pricing import (
Pricing_Oil_Oil,
@@ -48,10 +49,7 @@ def create_oil_price():
db.session.add(new_admin_oil_price)
db.session.commit()
return jsonify({
"ok": True,
'price': new_admin_oil_price.id,
}), 200
return success_response({'price': new_admin_oil_price.id})
@@ -67,7 +65,7 @@ def get_oil_price():
.order_by(Pricing_Oil_Oil.date.desc())
.first())
price_schema = Pricing_Oil_Oil_schema(many=False)
return jsonify(price_schema.dump(get_oil_prices))
return success_response({"price": price_schema.dump(get_oil_prices)})
@admin.route("/company/<int:company_id>", methods=["GET"])
@@ -79,7 +77,7 @@ def get_company(company_id):
.first())
company_schema = Admin_Company_schema(many=False)
return jsonify(company_schema.dump(get_data_company))
return success_response({"company": company_schema.dump(get_data_company)})
@admin.route("/voip_routing", methods=["GET"])
@admin_required
@@ -93,6 +91,6 @@ def get_voip_routing():
.order_by(Call.created_at.desc())
.first())
if latest_call:
return jsonify({"current_phone": latest_call.current_phone})
return success_response({"current_phone": latest_call.current_phone})
else:
return jsonify({"current_phone": None}), 404
return error_response("No VoIP routing found", 404)

View File

@@ -1,10 +1,12 @@
import logging
from flask import request, jsonify
from flask import request
from flask_login import current_user, logout_user, login_required
from app.auth import auth
from app import db, bcrypt
from app.common.responses import error_response, success_response
from datetime import datetime
from uuid import uuid4
import secrets
from app.classes.auth import Auth_User
from app.classes.employee import Employee_Employee
from app.schemas import LoginSchema, RegisterSchema, ChangePasswordSchema, validate_request
@@ -19,7 +21,7 @@ def check_session():
"""
auth_header = request.headers.get('Authorization')
if not auth_header:
return jsonify({"ok": False, "error": "Authorization header missing"}), 401
return error_response("Authorization header missing", 401)
# --- THIS IS THE FIX ---
# Use a case-insensitive regular expression to remove "bearer "
@@ -30,11 +32,10 @@ def check_session():
if not user:
logger.warning("Authentication failed: no user found with provided API key")
return jsonify({"ok": False, "error": "Invalid token"}), 401
return error_response("Invalid token", 401)
# Now, build the complete response with both user and employee data.
return jsonify({
"ok": True,
return success_response({
'user': {
'user_name': user.username,
'user_id': user.id,
@@ -43,7 +44,7 @@ def check_session():
'token': user.api_key,
'confirmed': user.confirmed
},
}), 200
})
@auth.route("/amiconfirmed", methods=["GET"])
@@ -61,7 +62,7 @@ def check_confirmed():
else:
confirmed = True
return jsonify({"status": confirmed}), 200
return success_response({"status": confirmed})
@auth.route("/logout", methods=["POST"])
@@ -71,9 +72,9 @@ def logout():
"""
try:
logout_user()
return jsonify({'status': 'logged out'}), 200
return success_response({'status': 'logged out'})
except Exception as e:
return jsonify({"error", 'error'}), 400
return error_response("Logout failed", 400)
@auth.route("/login", methods=["POST"])
@@ -87,18 +88,17 @@ def login():
# Important checks!
if not user:
return jsonify({"error": "User not found"}), 401 # Use a more descriptive error and status code
return error_response("User not found", 401)
if not bcrypt.check_password_hash(user.password_hash, password):
return jsonify({"error": "Invalid password"}), 401 # Use a more descriptive error and status code
return error_response("Invalid password", 401)
# Check if user is active
if user.active != 1:
return jsonify({"error": "Please contact a manager. Login rejected"}), 401
return error_response("Please contact a manager. Login rejected", 401)
# If login is successful, return the correct structure
return jsonify({
"ok": True,
return success_response({
'user': {
'user_name': user.username,
'user_id': user.id,
@@ -106,7 +106,7 @@ def login():
'admin_role': user.admin_role,
},
'token': user.api_key
}), 200
})
@auth.route("/register", methods=["POST"])
@validate_request(RegisterSchema)
@@ -121,10 +121,8 @@ def register_user():
email = data["email"]
password = data["password"]
part_one_code = uuid4().hex
part_two_code = uuid4().hex
part_three_code = uuid4().hex
key = part_one_code + part_two_code + part_three_code
# Generate a cryptographically secure 64-byte (128 hex chars) API key
key = secrets.token_hex(64)
# check if email exists
user_exists_email = db.session\
@@ -132,7 +130,7 @@ def register_user():
.filter_by(email=email)\
.first() is not None
if user_exists_email:
return jsonify({"error": "Email already exists"}), 200
return error_response("Email already exists")
# check if username exists
user_exists_username = db.session\
@@ -140,7 +138,7 @@ def register_user():
.filter_by(username=username)\
.first() is not None
if user_exists_username:
return jsonify({"error": "User already exists"}), 200
return error_response("User already exists")
# hash password for database
hashed_password = bcrypt.generate_password_hash(password).decode('utf-8')
@@ -167,8 +165,7 @@ def register_user():
# current_user.is_authenticated()
# current_user.is_active()
return jsonify({
"ok": True,
return success_response({
'user': {
'user_email': new_user.email,
'admin_role': new_user.admin_role,
@@ -176,7 +173,7 @@ def register_user():
'confirmed': new_user.confirmed,
},
'token': new_user.api_key
}), 200
})
@auth.route('/change-password', methods=['POST'])
@@ -184,21 +181,21 @@ def register_user():
def change_password():
auth_header = request.headers.get('Authorization')
if not auth_header:
return jsonify({"error": "Authorization header missing"}), 401
return error_response("Authorization header missing", 401)
api_key = re.sub(r'^bearer\s+', '', auth_header, flags=re.IGNORECASE).strip('"')
user = db.session.query(Auth_User).filter(Auth_User.api_key == api_key).first()
if not user:
return jsonify({"error": "Invalid token"}), 401
return error_response("Invalid token", 401)
data = request.validated_data
new_password = data["new_password"]
new_password_confirm = data["password_confirm"]
if str(new_password) != str(new_password_confirm):
return jsonify({"error": "Error: Incorrect Passwords"}), 200
return error_response("Error: Incorrect Passwords")
hashed_password = bcrypt.generate_password_hash(
new_password).decode('utf8')
@@ -208,43 +205,43 @@ def change_password():
db.session.add(user)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@auth.route('/admin-change-password', methods=['POST'])
def admin_change_password():
auth_header = request.headers.get('Authorization')
if not auth_header:
return jsonify({"error": "Authorization header missing"}), 401
return error_response("Authorization header missing", 401)
api_key = re.sub(r'^bearer\s+', '', auth_header, flags=re.IGNORECASE).strip('"')
user = db.session.query(Auth_User).filter(Auth_User.api_key == api_key).first()
if not user:
return jsonify({"error": "Invalid token"}), 401
return error_response("Invalid token", 401)
if user.admin_role == 0:
return jsonify({"error": "Admin access required"}), 403
return error_response("Admin access required", 403)
employee_id = request.json.get("employee_id")
new_password = request.json.get("new_password")
new_password_confirm = request.json.get("password_confirm")
if not employee_id or not new_password or not new_password_confirm:
return jsonify({"error": "Missing required fields"}), 400
return error_response("Missing required fields", 400)
if str(new_password) != str(new_password_confirm):
return jsonify({"error": "Passwords do not match"}), 400
return error_response("Passwords do not match", 400)
from app.classes.employee import Employee_Employee
employee = db.session.query(Employee_Employee).filter(Employee_Employee.id == employee_id).first()
if not employee:
return jsonify({"error": "Employee not found"}), 404
return error_response("Employee not found", 404)
target_user = db.session.query(Auth_User).filter(Auth_User.id == employee.user_id).first()
if not target_user:
return jsonify({"error": "User not found"}), 404
return error_response("User not found", 404)
hashed_password = bcrypt.generate_password_hash(new_password).decode('utf-8')
@@ -253,4 +250,4 @@ def admin_change_password():
db.session.add(target_user)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()

View File

@@ -1,7 +1,8 @@
from flask_login import current_user
from flask import abort, jsonify
from flask import abort
from functools import wraps
from app.common.responses import error_response
def login_required(f):
@wraps(f)
@@ -20,6 +21,6 @@ def admin_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if not current_user.is_authenticated or not current_user.admin_role:
return jsonify({"error": "Admin access required"}), 403
return error_response("Admin access required", 403)
return f(*args, **kwargs)
return decorated_function

54
app/common/responses.py Normal file
View File

@@ -0,0 +1,54 @@
"""
Standardized API response utilities for consistent error and success responses.
Usage:
from app.common.responses import error_response, success_response
# Error responses
return error_response("User not found", 404)
return error_response("Invalid credentials", 401)
return error_response("Server error", 500, details=str(e))
# Success responses
return success_response({"user": user_data})
return success_response({"message": "Created"}, 201)
"""
from flask import jsonify
def error_response(message: str, status_code: int = 400, details: str = None):
"""
Create a standardized error response.
Args:
message: Human-readable error message
status_code: HTTP status code (default 400)
details: Optional additional details (e.g., exception info)
Returns:
Tuple of (JSON response, status code)
"""
response = {
"ok": False,
"error": message
}
if details:
response["details"] = details
return jsonify(response), status_code
def success_response(data: dict = None, status_code: int = 200):
"""
Create a standardized success response.
Args:
data: Response data dictionary
status_code: HTTP status code (default 200)
Returns:
Tuple of (JSON response, status code)
"""
response = {"ok": True}
if data:
response.update(data)
return jsonify(response), status_code

View File

@@ -42,5 +42,8 @@ class CustomerAutomaticStatus:
WILL_CALL = 0
AUTOMATIC = 1
# Additional constants can be added here as needed
# For example: ServiceStatus, UserRoles, etc.
# Tank configuration
DEFAULT_TANK_SIZE_GALLONS = 275
# Pagination
DEFAULT_PAGE_SIZE = 100

View File

@@ -1,10 +1,11 @@
import logging
from flask import request, jsonify
from flask import request
from flask_login import login_required
from geopy.geocoders import Nominatim
from app.customer import customer
from app import db
from app.common.decorators import login_required as common_login_required
from app.common.responses import error_response, success_response
logger = logging.getLogger(__name__)
from datetime import datetime
@@ -21,8 +22,9 @@ from app.classes.admin import Admin_Company
from app.classes.auto import Auto_Delivery,Auto_Delivery_schema
from app.classes.stats_customer import Stats_Customer
from app.schemas import CreateCustomerSchema, UpdateCustomerSchema, validate_request
from app.constants import DEFAULT_TANK_SIZE_GALLONS, DEFAULT_PAGE_SIZE
import string
import random
import secrets
def generate_random_number_string(length):
@@ -30,8 +32,8 @@ def generate_random_number_string(length):
if length < 1:
raise ValueError("Length must be at least 1")
# Generate a random number with the specified length
random_number = ''.join(random.choices(string.digits, k=length))
# Generate a cryptographically secure random number string
random_number = ''.join(secrets.choice(string.digits) for _ in range(length))
return random_number
@@ -45,7 +47,7 @@ def all_customers_around():
.query(Customer_Customer) \
.all()
customer_schema = Customer_Customer_schema(many=True)
return jsonify(customer_schema.dump(customer_list))
return success_response({"customers": customer_schema.dump(customer_list)})
@customer.route("/all/<int:page>", methods=["GET"])
@@ -55,7 +57,7 @@ def all_customers(page):
pagination all customers
"""
logger.info(f"GET /customer/all/{page} - Fetching customers page {page}")
per_page_amount = 100
per_page_amount = DEFAULT_PAGE_SIZE
if page is None:
offset_limit = 0
elif page == 1:
@@ -69,7 +71,7 @@ def all_customers(page):
.limit(per_page_amount).offset(offset_limit)
customer_schema = Customer_Customer_schema(many=True)
return jsonify(customer_schema.dump(customer_list))
return success_response({"customers": customer_schema.dump(customer_list)})
@customer.route("/<int:customer_id>", methods=["GET"])
@@ -83,7 +85,7 @@ def get_a_customer(customer_id):
.filter(Customer_Customer.id == customer_id)
.first())
customer_schema = Customer_Customer_schema(many=False)
return jsonify(customer_schema.dump(get_customer))
return success_response({"customer": customer_schema.dump(get_customer)})
@customer.route("/description/<int:customer_id>", methods=["GET"])
@@ -117,8 +119,7 @@ def get_a_customer_description(customer_id):
.filter(Customer_Description.customer_id == customer_id)
.first())
customer_schema = Customer_Description_schema(many=False)
return jsonify(customer_schema.dump(get_customer_description))
return success_response({"description": customer_schema.dump(get_customer_description)})
@customer.route("/tank/<int:customer_id>", methods=["GET"])
@@ -139,7 +140,7 @@ def get_a_customer_tank(customer_id):
last_tank_inspection = None,
tank_status = False,
outside_or_inside = True,
tank_size = 275,
tank_size = DEFAULT_TANK_SIZE_GALLONS,
)
db.session.add(new_tank)
db.session.commit()
@@ -148,9 +149,7 @@ def get_a_customer_tank(customer_id):
.filter(Customer_Tank_Inspection.customer_id == customer_id)
.first())
customer_schema = Customer_Tank_Inspection_schema(many=False)
return jsonify(customer_schema.dump(get_customer_tank))
return success_response({"tank": customer_schema.dump(get_customer_tank)})
@customer.route("/create", methods=["POST"])
@@ -276,22 +275,20 @@ def create_customer():
last_tank_inspection=None,
tank_status = False,
outside_or_inside = True,
tank_size=275,
tank_size=DEFAULT_TANK_SIZE_GALLONS,
)
db.session.add(new_tank)
db.session.commit()
return jsonify({
"ok": True,
return success_response({
'user': {
'user_id': new_customer.id,
'user_name': new_customer.customer_last_name,
'user_email': new_customer.customer_email,
},
}), 200
})
@customer.route("/edit/<int:customer_id>", methods=["PUT"])
@@ -307,7 +304,7 @@ def edit_customer(customer_id):
.first())
if not get_customer:
return jsonify({"error": "Customer not found"}), 404
return error_response("Customer not found", 404)
get_customer_description = (db.session
.query(Customer_Description)
@@ -390,14 +387,12 @@ def edit_customer(customer_id):
db.session.add(get_customer)
db.session.commit()
return jsonify({
"ok": True,
return success_response({
'user': {
'user_name': get_customer.customer_last_name,
'user_email': get_customer.customer_email,
},
}), 200
})
@customer.route("/delete/<int:customer_id>", methods=["DELETE"])
@@ -421,13 +416,12 @@ def delete_customer(customer_id):
db.session.delete(get_customer)
db.session.commit()
return jsonify({
"ok": True,
return success_response({
'user': {
'user_name': get_customer.customer_last_name,
'user_email': get_customer.customer_email,
},
}), 200
})
@customer.route("/count", methods=["GET"])
@@ -440,10 +434,7 @@ def customer_count():
.query(Customer_Customer)
.count())
return jsonify({
"ok": True,
'count': get_customer
}), 200
return success_response({'count': get_customer})
@customer.route("/automatic/status/<int:customer_id>", methods=["GET"])
@@ -464,10 +455,7 @@ def customer_automatic_status(customer_id):
status = 0
return jsonify({
"ok": True,
'status': status
}), 200
return success_response({'status': status})
@customer.route("/automatic/deliveries", methods=["GET"])
@@ -480,9 +468,9 @@ def get_all_automatic_deliveries():
try:
deliveries = Auto_Delivery.query.all()
schema = Auto_Delivery_schema(many=True)
return jsonify(schema.dump(deliveries)), 200
return success_response({"deliveries": schema.dump(deliveries)})
except Exception as e:
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@@ -531,10 +519,7 @@ def customer_automatic_assignment(customer_id):
if get_main_credit_card is None:
status = 2
return jsonify({
"ok": True,
'status': status
}), 200
return success_response({'status': status})
# customer becomes an automatic
if get_auto is None:
@@ -568,10 +553,7 @@ def customer_automatic_assignment(customer_id):
db.session.commit()
return jsonify({
"ok": True,
'status': status
}), 200
return success_response({'status': status})
@customer.route("/edit/tank/<int:customer_id>", methods=["PUT"])
@@ -583,7 +565,7 @@ def edit_customer_tank(customer_id):
logger.info(f"PUT /customer/edit/tank/{customer_id} - Editing customer tank info")
get_customer = db.session.query(Customer_Customer).filter(Customer_Customer.id == customer_id).one_or_none()
if not get_customer:
return jsonify({"ok": False, "error": "Customer not found"}), 404
return error_response("Customer not found", 404)
get_customer_description = db.session.query(Customer_Description).filter(Customer_Description.customer_id == customer_id).first()
if not get_customer_description:
@@ -626,4 +608,4 @@ def edit_customer_tank(customer_id):
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()

View File

@@ -1,10 +1,11 @@
import logging
from flask import request, jsonify
from flask import request
from flask_login import current_user
from datetime import date, datetime, timedelta
from app.delivery import delivery
from app import db
from app.common.decorators import login_required as common_login_required
from app.common.responses import error_response, success_response
logger = logging.getLogger(__name__)
from sqlalchemy import or_
@@ -84,9 +85,9 @@ def move_deliveries():
if counter > 0:
db.session.commit()
return jsonify({"ok": True, 'update': True}), 200
return success_response({'update': True})
return jsonify({"ok": True, 'update': False}), 200
return success_response({'update': False})
@delivery.route("/<int:delivery_id>", methods=["GET"])
@@ -98,11 +99,11 @@ def get_a_delivery(delivery_id):
logger.info(f"GET /delivery/{delivery_id} - Fetching delivery")
get_delivery = db.session.query(Delivery_Delivery).filter(Delivery_Delivery.id == delivery_id).first()
if not get_delivery:
return jsonify({"ok": False, "error": "Delivery not found"}), 404
return error_response("Delivery not found", 404)
# Using the schema is cleaner and less error-prone than building a manual dictionary.
delivery_schema = Delivery_Delivery_schema(many=False)
return jsonify({"ok": True, "delivery": delivery_schema.dump(get_delivery)}), 200
return success_response({"delivery": delivery_schema.dump(get_delivery)})
@@ -119,7 +120,7 @@ def get_customer_past_delivery1(customer_id):
.limit(5))
delivery_schema = Delivery_Delivery_schema(many=True)
return jsonify(delivery_schema.dump(get_customer_past_delivery))
return success_response({"deliveries": delivery_schema.dump(get_customer_past_delivery)})
@delivery.route("/past2/<int:customer_id>", methods=["GET"])
@@ -134,7 +135,7 @@ def get_customer_past_delivery2(customer_id):
.limit(5))
delivery_schema = Delivery_Delivery_schema(many=True)
return jsonify(delivery_schema.dump(get_customer_past_delivery))
return success_response({"deliveries": delivery_schema.dump(get_customer_past_delivery)})
@delivery.route("/auto/<int:customer_id>", methods=["GET"])
@common_login_required
@@ -148,7 +149,7 @@ def get_customer_auto_delivery(customer_id):
.limit(5))
delivery_schema = Tickets_Auto_Delivery_schema(many=True)
return jsonify(delivery_schema.dump(get_customer_past_delivery))
return success_response({"deliveries": delivery_schema.dump(get_customer_past_delivery)})
@delivery.route("/order/<int:delivery_id>", methods=["GET"])
@@ -159,12 +160,10 @@ def get_a_specific_delivery(delivery_id):
"""
get_delivery = db.session.query(Delivery_Delivery).filter(Delivery_Delivery.id == delivery_id).first()
if not get_delivery:
return jsonify({"ok": False, "error": "Delivery not found"}), 404
return error_response("Delivery not found", 404)
delivery_schema = Delivery_Delivery_schema(many=False)
return jsonify({"ok": True, "delivery": delivery_schema.dump(get_delivery)}), 200
return success_response({"delivery": delivery_schema.dump(get_delivery)})
@delivery.route("/cash/<int:delivery_id>/<int:type_of_payment>", methods=["PUT"])
@@ -184,8 +183,7 @@ def update_a_delivery_payment(delivery_id, type_of_payment):
db.session.add(get_delivery)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@delivery.route("/all/<int:page>", methods=["GET"])
@@ -210,8 +208,7 @@ def get_deliveries_all(page):
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/customer/<int:customer_id>/<int:page>", methods=["GET"])
@@ -236,8 +233,7 @@ def get_deliveries_from_customer(customer_id, page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/all/order/<int:page>", methods=["GET"])
@@ -262,8 +258,7 @@ def get_deliveries_not_delivered(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/waiting/<int:page>", methods=["GET"])
@@ -290,9 +285,7 @@ def get_deliveries_waiting(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/pending/<int:page>", methods=["GET"])
@@ -315,7 +308,7 @@ def get_deliveries_pending(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/outfordelivery/<int:page>", methods=["GET"])
@common_login_required
@@ -337,8 +330,7 @@ def get_deliveries_outfordelivery(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/tommorrow/<int:page>", methods=["GET"])
@@ -364,8 +356,7 @@ def get_deliveries_tommorrow(page):
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/finalized/<int:page>", methods=["GET"])
@@ -389,8 +380,7 @@ def get_deliveries_finalized(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/cancelled/<int:page>", methods=["GET"])
@@ -414,8 +404,7 @@ def get_deliveries_cancelled(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/partialdelivery/<int:page>", methods=["GET"])
@@ -439,8 +428,7 @@ def get_deliveries_partial(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/issue/<int:page>", methods=["GET"])
@@ -464,8 +452,7 @@ def get_deliveries_issue(page):
.limit(per_page_amount).offset(offset_limit))
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/time/today", methods=["GET"])
@@ -481,8 +468,7 @@ def get_deliveries_today():
.all())
customer_schema = Delivery_Delivery_schema(many=True)
return jsonify(customer_schema.dump(deliveries))
return success_response({"deliveries": customer_schema.dump(deliveries)})
@delivery.route("/edit/<int:delivery_id>", methods=["POST"])
@@ -496,16 +482,16 @@ def edit_a_delivery(delivery_id):
get_delivery = db.session.query(Delivery_Delivery).filter(Delivery_Delivery.id == delivery_id).first()
if not get_delivery:
return jsonify({"ok": False, "error": "Delivery not found"}), 404
return error_response("Delivery not found", 404)
# --- Fetch related data ---
get_customer = db.session.query(Customer_Customer).filter(Customer_Customer.id == get_delivery.customer_id).first()
if not get_customer:
return jsonify({"ok": False, "error": "Associated customer not found"}), 404
return error_response("Associated customer not found", 404)
get_today_price = db.session.query(Pricing_Oil_Oil).order_by(Pricing_Oil_Oil.id.desc()).first()
if not get_today_price:
return jsonify({"ok": False, "error": "Pricing information not available"}), 500
return error_response("Pricing information not available", 500)
# --- Process Form Input (using .get() for safety) ---
get_delivery.gallons_ordered = data.get("gallons_ordered", get_delivery.gallons_ordered)
@@ -581,11 +567,10 @@ def edit_a_delivery(delivery_id):
db.session.add(get_delivery)
db.session.commit()
return jsonify({
"ok": True,
return success_response({
'message': f"Delivery {delivery_id} updated successfully.",
'customer_id': get_customer.id # Keep this if the frontend uses it for navigation
}), 200
'customer_id': get_customer.id
})
@delivery.route("/create/<int:user_id>", methods=["POST"])
@@ -607,7 +592,7 @@ def create_a_delivery(user_id):
if not get_customer:
return jsonify({"ok": False}), 200
return error_response("Customer not found")
else:
gallons_ordered = request.json["gallons_ordered"]
@@ -799,11 +784,7 @@ def create_a_delivery(user_id):
db.session.add(new_delivery)
db.session.commit()
return jsonify({
"ok": True,
'delivery_id': new_delivery.id,
}), 200
return success_response({'delivery_id': new_delivery.id})
@delivery.route("/cancel/<int:delivery_id>", methods=["POST"])
@@ -822,7 +803,7 @@ def cancel_a_delivery(delivery_id):
db.session.add(get_delivery)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@delivery.route("/delivered/<int:delivery_id>", methods=["POST"])
@@ -849,7 +830,7 @@ def mark_as_delivered(delivery_id):
db.session.add(get_delivery)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@delivery.route("/partial/<int:delivery_id>", methods=["POST"])
@@ -873,7 +854,7 @@ def partial_delivery(delivery_id):
db.session.add(get_delivery)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@delivery.route("/note/technician/<int:delivery_id>", methods=["PUT"])
@@ -908,7 +889,7 @@ def delivery_note_driver(delivery_id):
db.session.add(create_new_note)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@delivery.route("/delete/<int:delivery_id>", methods=["DELETE"])
@@ -925,9 +906,7 @@ def delete_call(delivery_id):
db.session.delete(get_call_to_delete)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@delivery.route("/total/<int:delivery_id>", methods=["GET"])
@@ -991,12 +970,11 @@ def calculate_total(delivery_id):
discount = round(discount, 2)
total = round(total, 2)
return jsonify({
"ok": True,
return success_response({
'priceprime': priceprime,
'pricesameday': pricesameday,
'priceemergency': priceemergency,
'total_amount':total,
'total_amount': total,
'discount': discount,
'total_amount_after_discount':total_amount_after_discount,
}), 200
'total_amount_after_discount': total_amount_after_discount,
})

View File

@@ -1,9 +1,10 @@
import logging
from flask import request, jsonify
from flask import request
from datetime import datetime
from decimal import Decimal
from app.delivery_data import delivery_data
from app import db
from app.common.responses import success_response
from app.classes.customer import Customer_Customer, Customer_Description
from app.classes.delivery import Delivery_Delivery
from app.classes.employee import Employee_Employee
@@ -54,12 +55,9 @@ def office_finalize_delivery(delivery_id):
.filter(Customer_Description.customer_id == get_delivery.customer_id) \
.first()
#TODO hardcode for now
delivery_driver_id = 2
get_driver = (db.session
.query(Employee_Employee)
.filter(Employee_Employee.id == delivery_driver_id)
.filter(Employee_Employee.id == get_delivery.driver_employee_id)
.first())
get_stats_employee = (db.session
@@ -156,9 +154,8 @@ def office_finalize_delivery(delivery_id):
db.session.commit()
return jsonify({
"ok": True,
return success_response({
'delivery': {
'id': get_delivery.id,
},
}), 200
})

View File

@@ -1,8 +1,8 @@
import logging
from flask import jsonify
from datetime import date, timedelta
from app.delivery_status import deliverystatus
from app import db
from app.common.responses import error_response, success_response
from sqlalchemy import func, case
from app.classes.delivery import (Delivery_Delivery,
@@ -53,8 +53,7 @@ def get_sidebar_counts():
transaction_count = db.session.query(Transaction).filter(Transaction.transaction_type == 0).count()
return jsonify({
"ok": True,
return success_response({
"counts": {
"today": today_count,
"tomorrow": tomorrow_count,
@@ -65,11 +64,10 @@ def get_sidebar_counts():
"today_service": today_service_count,
"transaction": transaction_count,
}
}), 200
})
except Exception as e:
# Basic error handling
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)
@deliverystatus.route("/tomorrow-totals", methods=["GET"])
@@ -91,14 +89,13 @@ def get_tomorrow_totals():
totals = [{'town': d.customer_town, 'gallons': int(d.total_gallons)} for d in deliveries]
grand_total = sum(d.total_gallons for d in deliveries)
result = {
return success_response({
'totals': totals,
'grand_total': int(grand_total)
}
return jsonify(result), 200
})
except Exception as e:
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)
@deliverystatus.route("/today-totals", methods=["GET"])
@@ -120,14 +117,13 @@ def get_today_totals():
totals = [{'town': d.customer_town, 'gallons': int(d.total_gallons)} for d in deliveries]
grand_total = sum(d.total_gallons for d in deliveries)
result = {
return success_response({
'totals': totals,
'grand_total': int(grand_total)
}
return jsonify(result), 200
})
except Exception as e:
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)
@deliverystatus.route("/waiting-totals", methods=["GET"])
@@ -149,11 +145,10 @@ def get_waiting_totals():
totals = [{'town': d.customer_town, 'gallons': int(d.total_gallons)} for d in deliveries]
grand_total = sum(d.total_gallons for d in deliveries)
result = {
return success_response({
'totals': totals,
'grand_total': int(grand_total)
}
return jsonify(result), 200
})
except Exception as e:
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)

View File

@@ -1,11 +1,12 @@
import logging
from flask import request, jsonify
from flask import request
from sqlalchemy import or_
from flask_login import login_required
from app.employees import employees
from app import db
from app.common.responses import success_response
from app.classes.employee import Employee_Employee, Employee_Employee_schema
from app.classes.auth import Auth_User
from app.classes.stats_employee import Stats_Employee_Oil, Stats_Employee_Office
@@ -29,7 +30,7 @@ def get_specific_employee(userid):
employee_data = employee_schema.dump(employee)
employee_data['active'] = active_status
return jsonify(employee_data)
return success_response({"employee": employee_data})
@employees.route("/byid/<int:employee_id>", methods=["GET"])
@@ -41,7 +42,7 @@ def get_employee_by_id(employee_id):
.filter(Employee_Employee.id == employee_id) \
.first()
employee_schema = Employee_Employee_schema(many=False)
return jsonify(employee_schema.dump(employee))
return success_response({"employee": employee_schema.dump(employee)})
@employees.route("/userid/<int:userid>", methods=["GET"])
@@ -53,7 +54,7 @@ def get_specific_employee_user_id(userid):
.filter(Employee_Employee.user_id == userid) \
.first()
employee_schema = Employee_Employee_schema(many=False)
return jsonify(employee_schema.dump(employee))
return success_response({"employee": employee_schema.dump(employee)})
@employees.route("/all/<int:page>", methods=["GET"])
@@ -76,7 +77,7 @@ def all_employees_paginated(page):
.limit(per_page_amount).offset(offset_limit))
employee_schema = Employee_Employee_schema(many=True)
return jsonify(employee_schema.dump(employee_list))
return success_response({"employees": employee_schema.dump(employee_list)})
@employees.route("/all", methods=["GET"])
@@ -87,7 +88,7 @@ def all_employees():
.query(Employee_Employee) \
.all()
customer_schema = Employee_Employee_schema(many=True)
return jsonify(customer_schema.dump(employee_list))
return success_response({"employees": customer_schema.dump(employee_list)})
@employees.route("/drivers", methods=["GET"])
@@ -101,7 +102,7 @@ def all_employees_drivers():
.all()
customer_schema = Employee_Employee_schema(many=True)
return jsonify(customer_schema.dump(employee_list))
return success_response({"drivers": customer_schema.dump(employee_list)})
@employees.route("/techs", methods=["GET"])
@@ -117,7 +118,7 @@ def all_employees_techs():
)) \
.all()
customer_schema = Employee_Employee_schema(many=True)
return jsonify(customer_schema.dump(employee_list))
return success_response({"techs": customer_schema.dump(employee_list)})
@employees.route("/create", methods=["POST"])
@@ -181,9 +182,7 @@ def employee_create():
)
db.session.add(new_stats_oil)
return jsonify({"ok": True,
'user_id': new_employee.id,
}), 200
return success_response({'user_id': new_employee.id})
@employees.route("/edit/<int:employee_id>", methods=["POST"])
@@ -228,4 +227,4 @@ def employee_edit(employee_id):
db.session.add(get_employee)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()

View File

@@ -1,8 +1,8 @@
import logging
from flask import jsonify
from decimal import Decimal
from app.info import info
from app import db
from app.common.responses import error_response, success_response
from app.classes.pricing import Pricing_Oil_Oil, Pricing_Oil_Oil_schema
from app.classes.admin import Admin_Company
from app.classes.delivery import Delivery_Delivery
@@ -22,7 +22,7 @@ def get_pricing_tiers():
.first())
if not get_price_query:
return jsonify({"error": "No pricing data available"}), 404
return error_response("No pricing data available", 404)
# Get the single price per gallon from the database, e.g., Decimal('2.92')
price_per_gallon = get_price_query.price_for_customer
@@ -37,7 +37,7 @@ def get_pricing_tiers():
}
# Return the dictionary of totals
return jsonify(pricing_totals)
return success_response({"pricing_tiers": pricing_totals})
@info.route("/price/oil", methods=["GET"])
@login_required
@@ -47,14 +47,14 @@ def get_oil_price_today():
.query(Pricing_Oil_Oil)
.order_by(Pricing_Oil_Oil.date.desc())
.first())
return jsonify({"ok": True,
return success_response({
'price_from_supplier': get_price_query.price_from_supplier,
'price_for_customer': get_price_query.price_for_customer,
'price_for_employee': get_price_query.price_for_employee,
'price_same_day': get_price_query.price_same_day,
'price_prime': get_price_query.price_prime,
'price_emergency': get_price_query.price_emergency,
}), 200
})
@info.route("/price/oil/table", methods=["GET"])
@@ -66,7 +66,7 @@ def get_pricing():
.order_by(Pricing_Oil_Oil.date.desc())
.first())
delivery_schema = Pricing_Oil_Oil_schema(many=False)
return jsonify(delivery_schema.dump(get_price_query))
return success_response({"pricing": delivery_schema.dump(get_price_query)})
@@ -80,7 +80,7 @@ def get_company():
.query(Admin_Company)
.first())
return jsonify({"ok": True,
return success_response({
'name': get_data_company.company_name,
'telephone': get_data_company.company_phone_number,
}), 200
})

View File

@@ -1,6 +1,7 @@
import logging
from flask import jsonify, Response, url_for
from flask import Response, url_for
from app import app
from app.common.responses import success_response
logger = logging.getLogger(__name__)
@@ -25,4 +26,4 @@ def static_from_root():
@app.route('/', methods=['GET'])
def index():
logger.info("GET / or /index - API health check")
return jsonify({"success": "Api is online"}), 200
return success_response({"success": "Api is online"})

View File

@@ -1,7 +1,7 @@
import logging
from flask import jsonify
from app.money import money
from app import db
from app.common.responses import success_response
import datetime
from datetime import date
from app.classes.money import Money_delivery, Money_delivery_schema
@@ -47,10 +47,10 @@ def total_profit_week():
total_deliveries = total_deliveries + 1
return jsonify({"ok": True,
return success_response({
'total_profit': total_profit,
'total_deliveries': total_deliveries
}), 200
})
@@ -70,9 +70,7 @@ def total_profit_year():
.all())
for f in get_total:
total_profit = total_profit + f.total_profit
return jsonify({"ok": True,
'total': total_profit
}), 200
return success_response({'total': total_profit})
@money.route("/<int:delivery_id>", methods=["GET"])
@@ -86,4 +84,4 @@ def get_money_delivery(delivery_id):
.first())
money_schema = Money_delivery_schema(many=False)
return jsonify(money_schema.dump(profit))
return success_response({"profit": money_schema.dump(profit)})

View File

@@ -1,7 +1,8 @@
import logging
from flask import jsonify, request
from flask import request
from app.payment import payment
from app import db
from app.common.responses import error_response, success_response
from app.classes.customer import Customer_Customer
from app.classes.cards import Card_Card, Card_Card_schema
from app.classes.transactions import Transaction
@@ -68,7 +69,7 @@ def get_user_cards(user_id):
.all())
card_schema = Card_Card_schema(many=True)
return jsonify(card_schema.dump(get_u_cards))
return success_response({"cards": card_schema.dump(get_u_cards)})
@payment.route("/cards/onfile/<int:user_id>", methods=["GET"])
@@ -83,10 +84,7 @@ def get_user_cards_count(user_id):
.filter(Card_Card.user_id == user_id)
.count())
return jsonify({
"ok": True,
'cards': get_u_cards,
}), 200
return success_response({'cards': get_u_cards})
@payment.route("/card/<int:card_id>", methods=["GET"])
@@ -102,8 +100,7 @@ def get_user_specific_card(card_id):
.first())
card_schema = Card_Card_schema(many=False)
return jsonify(card_schema.dump(get_user_card))
return success_response({"card": card_schema.dump(get_user_card)})
@payment.route("/card/main/<int:card_id>/<int:user_id>", methods=["PUT"])
@@ -133,9 +130,7 @@ def set_main_card(user_id, card_id):
db.session.add(get_new_main_card)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@payment.route("/card/remove/<int:card_id>", methods=["DELETE"])
@@ -153,7 +148,7 @@ def remove_user_card(card_id):
db.session.delete(get_card)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
# In your Flask payment routes file (e.g., app/routes/payment.py)
@@ -172,7 +167,7 @@ def create_user_card(user_id):
.first())
if not get_customer:
return jsonify({"ok": False, "error": "Customer not found"}), 404
return error_response("Customer not found", 404)
data = request.get_json()
name_on_card = data.get("name_on_card")
@@ -212,10 +207,10 @@ def create_user_card(user_id):
except Exception as e:
db.session.rollback()
logger.error(f"Database error saving card for user {user_id}: {e}")
return jsonify({"ok": False, "error": "Failed to save card information."}), 500
return error_response("Failed to save card information.", 500)
# Return a success response with the card_id
return jsonify({"ok": True, "card_id": create_new_card.id}), 200
return success_response({"card_id": create_new_card.id})
@payment.route("/card/update_payment_profile/<int:card_id>", methods=["PUT"])
@login_required
@@ -228,7 +223,7 @@ def update_card_payment_profile(card_id):
.filter(Card_Card.id == card_id)
.first())
if not get_card:
return jsonify({"ok": False, "error": "Card not found"}), 404
return error_response("Card not found", 404)
data = request.get_json()
auth_net_payment_profile_id = data.get("auth_net_payment_profile_id")
@@ -238,7 +233,7 @@ def update_card_payment_profile(card_id):
db.session.add(get_card)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@payment.route("/card/edit/<int:card_id>", methods=["PUT"])
@@ -252,7 +247,7 @@ def update_user_card(card_id):
.filter(Card_Card.id == card_id)
.first())
if not get_card:
return jsonify({"ok": False, "error": "Card not found"}), 404
return error_response("Card not found", 404)
data = request.get_json()
# FIX: Use .get() for safety and get the correct key 'name_on_card'
@@ -286,7 +281,7 @@ def update_user_card(card_id):
db.session.add(get_card)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@payment.route("/transactions/authorize/<int:page>", methods=["GET"])
@@ -327,10 +322,10 @@ def get_authorize_transactions(page):
"auto_id": transaction.auto_id,
})
return jsonify(transactions_data), 200
return success_response({"transactions": transactions_data})
except Exception as e:
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)
@payment.route("/authorize/cleanup/<int:customer_id>", methods=["POST"])
@@ -344,7 +339,7 @@ def cleanup_authorize_profile(customer_id):
# Get customer and set auth_net_profile_id to null
customer = db.session.query(Customer_Customer).filter(Customer_Customer.id == customer_id).first()
if not customer:
return jsonify({"ok": False, "error": "Customer not found"}), 404
return error_response("Customer not found", 404)
customer.auth_net_profile_id = None
@@ -356,11 +351,11 @@ def cleanup_authorize_profile(customer_id):
# Commit all changes
db.session.commit()
return jsonify({"ok": True, "message": f"Cleaned up Authorize.Net data for customer {customer_id}"}), 200
return success_response({"message": f"Cleaned up Authorize.Net data for customer {customer_id}"})
except Exception as e:
db.session.rollback()
return jsonify({"ok": False, "error": f"Failed to cleanup profile: {str(e)}"}), 500
return error_response(f"Failed to cleanup profile: {str(e)}", 500)
@payment.route("/authorize/<int:delivery_id>", methods=["PUT"])
@@ -375,14 +370,14 @@ def update_delivery_payment_authorize(delivery_id):
.first())
if not get_delivery:
return jsonify({"ok": False, "error": "Delivery not found"}), 404
return error_response("Delivery not found", 404)
get_delivery.payment_type = 11
db.session.add(get_delivery)
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
@payment.route("/transaction/delivery/<int:delivery_id>", methods=["GET"])
@@ -397,11 +392,10 @@ def get_transaction_by_delivery(delivery_id):
.first())
if not transaction:
return jsonify({"ok": False, "error": "Transaction not found"}), 404
return error_response("Transaction not found", 404)
# Convert to dict-like format for frontend
return jsonify({
"ok": True,
return success_response({
"transaction": {
"id": transaction.id,
"preauthorize_amount": float(transaction.preauthorize_amount or 0),
@@ -456,10 +450,10 @@ def get_customer_transactions(customer_id, page):
"auto_id": transaction.auto_id,
})
return jsonify(transactions_data), 200
return success_response({"transactions": transactions_data})
except Exception as e:
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)
@payment.route("/service/payment/<int:service_id>/<int:payment_type>", methods=["PUT"])
@@ -467,7 +461,7 @@ def get_customer_transactions(customer_id, page):
def process_service_payment_tiger(service_id, payment_type):
service = db.session.query(Service_Service).filter(Service_Service.id == service_id).first()
if not service:
return jsonify({"ok": False, "error": "Service not found"}), 404
return error_response("Service not found", 404)
# Set payment columns as specified
service.payment_type = payment_type # 1 for Tiger
@@ -476,10 +470,10 @@ def process_service_payment_tiger(service_id, payment_type):
try:
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@payment.route("/authorize/service/<int:service_id>", methods=["PUT"])
@@ -487,7 +481,7 @@ def process_service_payment_tiger(service_id, payment_type):
def update_service_payment_authorize(service_id):
service = db.session.query(Service_Service).filter(Service_Service.id == service_id).first()
if not service:
return jsonify({"error": "Service not found"}), 404
return error_response("Service not found", 404)
data = request.get_json()
card_id = data.get('card_id')
@@ -500,10 +494,10 @@ def update_service_payment_authorize(service_id):
try:
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@payment.route("/capture/service/<int:service_id>", methods=["PUT"])
@@ -511,7 +505,7 @@ def update_service_payment_authorize(service_id):
def update_service_payment_capture(service_id):
service = db.session.query(Service_Service).filter(Service_Service.id == service_id).first()
if not service:
return jsonify({"error": "Service not found"}), 404
return error_response("Service not found", 404)
data = request.get_json()
card_id = data.get('card_id')
@@ -525,10 +519,10 @@ def update_service_payment_capture(service_id):
try:
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@payment.route("/transactions/service/<int:service_id>", methods=["GET"])
@@ -563,8 +557,8 @@ def get_service_transactions(service_id):
"card_id": transaction.card_id,
})
return jsonify(transactions_data), 200
return success_response({"transactions": transactions_data})
except Exception as e:
logger.error(f"Error fetching transactions for service {service_id}: {e}")
return jsonify({"ok": False, "error": str(e)}), 500
return error_response(str(e), 500)

View File

@@ -1,9 +1,10 @@
import logging
from flask import request, jsonify
from flask import request
import decimal
from datetime import datetime
from app.promo import promo
from app import db
from app.common.responses import success_response
from app.classes.promo import (
Promo_Promo,
Promo_Promo_schema)
@@ -32,7 +33,7 @@ def get_promo(promo_id):
.filter(Promo_Promo.id == promo_id)
.first())
query_schema = Promo_Promo_schema(many=False)
return jsonify(query_schema.dump(get_promo_data))
return success_response({"promo": query_schema.dump(get_promo_data)})
@promo.route("/promoprice/<int:delivery_id>", methods=["GET"])
@@ -47,10 +48,7 @@ def get_promo_price(delivery_id):
price = get_delivery.customer_price - get_delivery.promo_money_discount
price = convert_to_decimal(price)
return jsonify({
"ok": True,
"price": price,
}), 200
return success_response({"price": price})
@@ -63,7 +61,7 @@ def get_all_promo():
.query(Promo_Promo)
.all())
query_schema = Promo_Promo_schema(many=True)
return jsonify(query_schema.dump(get_promo_data))
return success_response({"promos": query_schema.dump(get_promo_data)})
@promo.route("/delete/<int:promo_id>", methods=["DELETE"])
@@ -79,10 +77,7 @@ def delete_a_promo(promo_id):
db.session.delete(get_promo_data)
db.session.commit()
return jsonify({
"ok": True,
}), 200
return success_response()
@promo.route("/create", methods=["POST"])
def create_promo():
@@ -108,11 +103,7 @@ def create_promo():
db.session.add(new_promo)
db.session.commit()
return jsonify({
"ok": True,
'promo_id':new_promo.id,
}), 200
return success_response({'promo_id': new_promo.id})
@promo.route("/edit/<int:promo_id>", methods=["PUT"])
@@ -141,11 +132,7 @@ def edit_promo(promo_id):
db.session.add(get_promo_data)
db.session.commit()
return jsonify({
"ok": True,
'promo_id':get_promo_data.id,
}), 200
return success_response({'promo_id': get_promo_data.id})
@promo.route("/on/<int:promo_id>", methods=["PATCH"])
@@ -161,14 +148,10 @@ def turn_on_promo(promo_id):
get_promo_data.active = True
db.session.add(get_promo_data)
db.session.commit()
return jsonify({
"ok": True,
'promo_id':get_promo_data.id,
}), 200
return success_response({'promo_id': get_promo_data.id})
@promo.route("/off/<int:promo_id>", methods=["PATCH"])
def turn_off_promo(promo_id):
@@ -183,11 +166,7 @@ def turn_off_promo(promo_id):
get_promo_data.active = False
db.session.add(get_promo_data)
db.session.commit()
return jsonify({
"ok": True,
'promo_id':get_promo_data.id,
}), 200
return success_response({'promo_id': get_promo_data.id})

View File

@@ -1,7 +1,7 @@
import logging
from flask import jsonify
from app.query import query
from app import db
from app.common.responses import success_response
from app.classes.admin import Admin_Company
from app.classes.query import (Query_StateList,
Query_DeliveryStatusList,
@@ -28,7 +28,7 @@ def get_company(company_id):
.filter(Admin_Company.id == company_id)
.first())
delivery_schema = Query_DeliveryStatusList_Schema(many=False)
return jsonify(delivery_schema.dump(query_data))
return success_response({"company": delivery_schema.dump(query_data)})
@query.route("/states", methods=["GET"])
@login_required
@@ -43,7 +43,7 @@ def get_state_list():
.all()
customer_schema = Query_StateList_Schema(many=True)
return jsonify(customer_schema.dump(query_data))
return success_response({"states": customer_schema.dump(query_data)})
@query.route("/customertype", methods=["GET"])
@@ -58,7 +58,7 @@ def get_customer_type_list():
.query(Query_CustomerTypeList) \
.all()
customer_schema = Query_CustomerTypeList_Schema(many=True)
return jsonify(customer_schema.dump(query_data))
return success_response({"customer_types": customer_schema.dump(query_data)})
@@ -75,7 +75,7 @@ def get_employee_type_list():
.query(Query_EmployeeTypeList) \
.all()
customer_schema = Query_EmployeeTypeList_Schema(many=True)
return jsonify(customer_schema.dump(query_data))
return success_response({"employee_types": customer_schema.dump(query_data)})
@query.route("/deliverystatus", methods=["GET"])
@@ -90,4 +90,4 @@ def get_delivery_status_list():
.query(Query_DeliveryStatusList) \
.all()
delivery_schema = Query_DeliveryStatusList_Schema(many=True)
return jsonify(delivery_schema.dump(query_data))
return success_response({"delivery_statuses": delivery_schema.dump(query_data)})

View File

@@ -1,8 +1,8 @@
import logging
from flask import jsonify
from sqlalchemy.sql import func
from app.reports import reports
from app import db
from app.common.responses import success_response
from app.classes.customer import Customer_Customer
@@ -19,7 +19,7 @@ def oil_total_gallons():
.group_by(Delivery_Delivery.id)\
.all()
return jsonify({"ok": True, "oil": total_oil }), 200
return success_response({"oil": total_oil})
@reports.route("/customers/list", methods=["GET"])
def customer_list():
@@ -42,6 +42,4 @@ def customer_list():
}
for customer in customers
]
response = jsonify({"ok": True, "customers": customer_data})
return response, 200
return success_response({"customers": customer_data})

View File

@@ -1,6 +1,7 @@
from flask import jsonify, request
from flask import request
from functools import wraps
from marshmallow import ValidationError
from app.common.responses import error_response
def validate_request(schema_class):
@@ -19,11 +20,11 @@ def validate_request(schema_class):
def decorated_function(*args, **kwargs):
# Check if request has JSON data
if not request.is_json:
return jsonify({"error": "Request must be JSON"}), 400
return error_response("Request must be JSON", 400)
json_data = request.get_json()
if json_data is None:
return jsonify({"error": "Invalid JSON data"}), 400
return error_response("Invalid JSON data", 400)
# Validate the data
schema = schema_class()
@@ -32,7 +33,7 @@ def validate_request(schema_class):
# Attach validated data to request object for easy access
request.validated_data = validated_data
except ValidationError as err:
return jsonify({"error": "Validation failed", "details": err.messages}), 400
return error_response("Validation failed", 400, details=str(err.messages))
return f(*args, **kwargs)
return decorated_function

View File

@@ -1,8 +1,9 @@
import logging
from flask import request, jsonify
from flask import request
from app.search import search
from app import db
from app.common.responses import success_response
from sqlalchemy import or_
from app.classes.customer import Customer_Customer, Customer_Customer_schema
from app.classes.delivery import Delivery_Delivery, Delivery_Delivery_schema
@@ -74,7 +75,7 @@ def search_customers():
customer_schema = Customer_Customer_schema(many=True)
return jsonify(customer_schema.dump(customer_list))
return success_response({"customers": customer_schema.dump(customer_list)})
@search.route("/delivery", methods=["GET"])
@@ -95,4 +96,4 @@ def search_delivery():
delivery_schema = Delivery_Delivery_schema(many=True)
return jsonify(delivery_schema.dump(delivery_ticket))
return success_response({"deliveries": delivery_schema.dump(delivery_ticket)})

View File

@@ -1,7 +1,8 @@
import logging
from flask import request, jsonify
from flask import request
from app.service import service
from app import db
from app.common.responses import error_response, success_response
from datetime import datetime, date, timedelta
from app.classes.customer import (Customer_Customer)
from app.classes.service import (Service_Service,
@@ -10,6 +11,7 @@ from app.classes.service import (Service_Service,
)
from app.classes.auto import Auto_Delivery
from flask_login import login_required
from app.constants import DEFAULT_PAGE_SIZE
logger = logging.getLogger(__name__)
@@ -53,10 +55,10 @@ def get_all_service_calls():
}
calendar_events.append(event_data)
return jsonify(calendar_events), 200
return success_response({"events": calendar_events})
except Exception as e:
logger.error(f"Error in /service/all: {e}")
return jsonify(error=str(e)), 500
return error_response(str(e), 500)
# --- THIS IS THE FIX ---
@@ -73,15 +75,14 @@ def get_upcoming_service_calls():
Service_Service.query
.filter(Service_Service.scheduled_date >= now)
.order_by(Service_Service.scheduled_date.asc())
.limit(100)
.limit(DEFAULT_PAGE_SIZE)
.all()
)
service_schema = Service_Service_schema(many=True)
result = service_schema.dump(upcoming_services)
return jsonify(result), 200
return success_response({"services": result})
@service.route("/past", methods=["GET"])
@@ -94,14 +95,14 @@ def get_past_service_calls():
Service_Service.query
.filter(Service_Service.scheduled_date < datetime.combine(date.today(), datetime.min.time()))
.order_by(Service_Service.scheduled_date.asc())
.limit(100)
.limit(DEFAULT_PAGE_SIZE)
.all()
)
service_schema = Service_Service_schema(many=True)
result = service_schema.dump(past_services)
return jsonify(result), 200
return success_response({"services": result})
@service.route("/today", methods=["GET"])
@@ -117,14 +118,14 @@ def get_today_service_calls():
.filter(Service_Service.scheduled_date >= start_of_today)
.filter(Service_Service.scheduled_date < start_of_tomorrow)
.order_by(Service_Service.scheduled_date.asc())
.limit(100)
.limit(DEFAULT_PAGE_SIZE)
.all()
)
service_schema = Service_Service_schema(many=True)
result = service_schema.dump(today_services)
return jsonify(result), 200
return success_response({"services": result})
@service.route("/upcoming/count", methods=["GET"])
@@ -133,9 +134,9 @@ def get_upcoming_service_calls_count():
now = datetime.now()
try:
count = (db.session.query(Service_Service).filter(Service_Service.scheduled_date >= now).count())
return jsonify({"count": count}), 200
return success_response({"count": count})
except Exception as e:
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/for-customer/<int:customer_id>", methods=["GET"])
@login_required
@@ -143,16 +144,16 @@ def get_service_calls_for_customer(customer_id):
service_records = (Service_Service.query.filter_by(customer_id=customer_id).order_by(Service_Service.scheduled_date.desc()).all())
service_schema = Service_Service_schema(many=True)
result = service_schema.dump(service_records)
return jsonify(result), 200
return success_response({"services": result})
@service.route("/create", methods=["POST"])
@login_required
def create_service_call():
data = request.get_json()
if not data: return jsonify({"error": "No data provided"}), 400
if not data: return error_response("No data provided", 400)
cus_id=data.get('customer_id')
get_customer = (db.session.query(Customer_Customer).filter(Customer_Customer.id == cus_id).first())
if not get_customer: return jsonify({"error": f"Customer with id {cus_id} not found."}), 404
if not get_customer: return error_response(f"Customer with id {cus_id} not found.", 404)
scheduled_datetime_str = data.get('expected_delivery_date')
scheduled_datetime_obj = datetime.fromisoformat(scheduled_datetime_str)
new_service_call = Service_Service(
@@ -164,7 +165,7 @@ def create_service_call():
)
db.session.add(new_service_call)
db.session.commit()
return jsonify({ "ok": True, "id": new_service_call.id }), 201
return success_response({"id": new_service_call.id}, 201)
@service.route("/update-cost/<int:id>", methods=["PUT"])
@login_required
@@ -180,18 +181,18 @@ def update_service_cost(id):
# Get request data - only service_cost
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
return error_response("No data provided", 400)
# Extract and validate the service_cost
new_cost = data.get('service_cost')
if new_cost is None:
return jsonify({"error": "service_cost is required"}), 400
return error_response("service_cost is required", 400)
# Convert to float for validation
try:
new_cost_float = float(new_cost)
except (ValueError, TypeError):
return jsonify({"error": "service_cost must be a valid number"}), 400
return error_response("service_cost must be a valid number", 400)
# Update the service_cost
service_record.service_cost = new_cost_float
@@ -200,24 +201,23 @@ def update_service_cost(id):
db.session.commit()
# Return success response
return jsonify({
"ok": True,
return success_response({
"service_id": id,
"service_cost_updated": new_cost_float,
"message": f"Service {id} cost updated to ${new_cost_float}"
}), 200
})
except Exception as e:
db.session.rollback()
logger.error(f"Error updating service cost for service {id}: {e}")
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/update/<int:id>", methods=["PUT"])
@login_required
def update_service_call(id):
service_record = Service_Service.query.get_or_404(id)
data = request.get_json()
if not data: return jsonify({"error": "No data provided"}), 400
if not data: return error_response("No data provided", 400)
scheduled_datetime_str = data.get('scheduled_date')
if scheduled_datetime_str:
service_record.scheduled_date = datetime.fromisoformat(scheduled_datetime_str)
@@ -228,10 +228,10 @@ def update_service_call(id):
try:
db.session.commit()
service_schema = Service_Service_schema(many=False)
return jsonify({"ok": True, "service": service_schema.dump(service_record)}), 200
return success_response({"service": service_schema.dump(service_record)})
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
# Service Plans CRUD endpoints
@@ -254,9 +254,9 @@ def get_active_service_plans():
plan['customer_address'] = customer.customer_address
plan['customer_town'] = customer.customer_town
return jsonify(result), 200
return success_response({"plans": result})
except Exception as e:
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/plans/customer/<int:customer_id>", methods=["GET"])
@@ -269,11 +269,11 @@ def get_customer_service_plan(customer_id):
plan = Service_Plans.query.filter_by(customer_id=customer_id).first()
if plan:
plan_schema = Service_Plans_schema()
return jsonify(plan_schema.dump(plan)), 200
return success_response({"plan": plan_schema.dump(plan)})
else:
return jsonify(None), 200
return success_response({"plan": None})
except Exception as e:
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/plans/create", methods=["POST"])
@@ -284,7 +284,7 @@ def create_service_plan():
"""
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
return error_response("No data provided", 400)
try:
new_plan = Service_Plans(
@@ -297,10 +297,10 @@ def create_service_plan():
db.session.commit()
plan_schema = Service_Plans_schema()
return jsonify({"ok": True, "plan": plan_schema.dump(new_plan)}), 201
return success_response({"plan": plan_schema.dump(new_plan)}, 201)
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/plans/update/<int:customer_id>", methods=["PUT"])
@@ -311,7 +311,7 @@ def update_service_plan(customer_id):
"""
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
return error_response("No data provided", 400)
try:
plan = Service_Plans.query.filter_by(customer_id=customer_id).first()
@@ -328,10 +328,10 @@ def update_service_plan(customer_id):
db.session.commit()
plan_schema = Service_Plans_schema()
return jsonify({"ok": True, "plan": plan_schema.dump(plan)}), 200
return success_response({"plan": plan_schema.dump(plan)})
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/plans/delete/<int:customer_id>", methods=["DELETE"])
@@ -343,21 +343,21 @@ def delete_service_plan(customer_id):
try:
plan = Service_Plans.query.filter_by(customer_id=customer_id).first()
if not plan:
return jsonify({"error": "Service plan not found"}), 404
return error_response("Service plan not found", 404)
db.session.delete(plan)
db.session.commit()
return jsonify({"ok": True, "message": "Service plan deleted successfully"}), 200
return success_response({"message": "Service plan deleted successfully"})
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/<int:id>", methods=["GET"])
@login_required
def get_service_by_id(id):
service_record = Service_Service.query.get_or_404(id)
service_schema = Service_Service_schema()
return jsonify({"ok": True, "service": service_schema.dump(service_record)}), 200
return success_response({"service": service_schema.dump(service_record)})
@service.route("/delete/<int:id>", methods=["DELETE"])
@login_required
@@ -366,10 +366,10 @@ def delete_service_call(id):
try:
db.session.delete(service_record)
db.session.commit()
return jsonify({"ok": True, "message": "Service deleted successfully"}), 200
return success_response({"message": "Service deleted successfully"})
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/parts/customer/<int:customer_id>", methods=["GET"])
@login_required
@@ -377,12 +377,12 @@ def get_service_parts(customer_id):
parts = Service_Parts.query.filter_by(customer_id=customer_id).first()
if parts:
parts_schema = Service_Parts_schema()
return jsonify(parts_schema.dump(parts)), 200
return success_response({"parts": parts_schema.dump(parts)})
else:
return jsonify({
return success_response({"parts": {
"customer_id": customer_id, "oil_filter": "", "oil_filter_2": "",
"oil_nozzle": "", "oil_nozzle_2": "", "hot_water_tank": 0
}), 200
}})
@service.route("/parts/update/<int:customer_id>", methods=["POST"])
@login_required
@@ -391,7 +391,7 @@ def update_service_parts(customer_id):
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
return error_response("No data provided", 400)
get_customer = db.session.query(Customer_Customer).filter(Customer_Customer.id == customer_id).first()
parts = Service_Parts.query.filter_by(customer_id=customer_id).first()
@@ -412,11 +412,10 @@ def update_service_parts(customer_id):
db.session.add(get_auto)
db.session.commit()
return jsonify({"ok": True, "message": "Service parts updated successfully"}), 200
return success_response({"message": "Service parts updated successfully"})
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)
@service.route("/payment/<int:service_id>/<int:payment_type>", methods=["PUT"])
@@ -424,7 +423,7 @@ def update_service_parts(customer_id):
def process_service_payment(service_id, payment_type):
service = db.session.query(Service_Service).filter(Service_Service.id == service_id).first()
if not service:
return jsonify({"ok": False, "error": "Service not found"}), 404
return error_response("Service not found", 404)
# Set payment columns as specified
service.payment_type = payment_type # e.g., 1 for Tiger
@@ -433,7 +432,7 @@ def process_service_payment(service_id, payment_type):
try:
db.session.commit()
return jsonify({"ok": True}), 200
return success_response()
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
return error_response(str(e), 500)

View File

@@ -1,8 +1,9 @@
import logging
from flask import jsonify, request
from flask import request
import datetime
from app.social import social
from app import db
from app.common.responses import success_response
from app.classes.customer_social import (Customer_Customer_Social_schema,
Customer_Customer_Social)
@@ -29,7 +30,7 @@ def get_customer_posts(customer_id, page):
.order_by(Customer_Customer_Social.id.desc())
.limit(per_page_amount).offset(offset_limit))
customer_social_schema = Customer_Customer_Social_schema(many=True)
return jsonify(customer_social_schema.dump(customer_posts))
return success_response({"posts": customer_social_schema.dump(customer_posts)})
@@ -50,7 +51,7 @@ def create_post(customer_id):
db.session.add(create_post)
db.session.commit()
return jsonify({ "ok": True,}), 200
return success_response()
@@ -69,7 +70,7 @@ def edit_post(post_id):
db.session.add(customer_post)
db.session.commit()
return jsonify({ "ok": True,}), 200
return success_response()
@@ -86,4 +87,4 @@ def delete_post(post_id):
db.session.delete(customer_post)
db.session.commit()
return jsonify({ "ok": True,}), 200
return success_response()

View File

@@ -1,9 +1,9 @@
import logging
from flask import jsonify
from datetime import date
from app.stats import stats
import datetime
from app import db
from app.common.responses import success_response
from app.classes.delivery import Delivery_Delivery
from app.classes.stats_company import Stats_Company, Stats_Company_schema
from app.classes.stats_customer import Stats_Customer, Stats_Customer_schema
@@ -42,8 +42,7 @@ def total_calls_post():
db.session.add(total_calls_today)
db.session.commit()
return jsonify({"ok": True,}), 200
return success_response()
@stats.route("/calls/count/today", methods=["GET"])
@@ -54,9 +53,7 @@ def total_calls_today():
.filter(Stats_Company.expected_delivery_date == date.today())
.count())
return jsonify({"ok": True,
'data': total_calls_today,
}), 200
return success_response({'data': total_calls_today})
@stats.route("/gallons/total/<int:driver_id>", methods=["GET"])
@@ -73,9 +70,7 @@ def total_gallons_delivered_driver(driver_id):
gallons_list.append(f.gallons_delivered)
sum_of_gallons = (sum(gallons_list))
return jsonify({"ok": True,
'data': sum_of_gallons,
}), 200
return success_response({'data': sum_of_gallons})
@stats.route("/delivery/total/<int:driver_id>", methods=["GET"])
@@ -85,9 +80,7 @@ def total_deliveries_driver(driver_id):
.query(Delivery_Delivery)
.filter(Delivery_Delivery.driver_employee_id == driver_id)
.count())
return jsonify({"ok": True,
'data': total_stops,
}), 200
return success_response({'data': total_stops})
@stats.route("/primes/total/<int:driver_id>", methods=["GET"])
@@ -99,10 +92,7 @@ def total_primes_driver(driver_id):
.filter(Delivery_Delivery.prime == 1)
.count())
return jsonify({"ok": True,
'data': total_stops,
}), 200
return success_response({'data': total_stops})
@stats.route("/delivery/count/today", methods=["GET"])
def total_deliveries_today():
@@ -111,9 +101,7 @@ def total_deliveries_today():
.query(Delivery_Delivery)
.filter(Delivery_Delivery.expected_delivery_date == date.today())
.count())
return jsonify({"ok": True,
'data': total_stops,
}), 200
return success_response({'data': total_stops})
@stats.route("/delivery/count/delivered/today", methods=["GET"])
@@ -125,9 +113,7 @@ def total_deliveries_today_finished():
.filter((Delivery_Delivery.delivery_status == 10))
.count())
return jsonify({"ok": True,
'data': total_stops,
}), 200
return success_response({'data': total_stops})
@stats.route("/user/<int:user_id>", methods=["GET"])
@@ -160,7 +146,7 @@ def get_user_stats(user_id):
.first()
user_schema = Stats_Customer_schema(many=False)
return jsonify(user_schema.dump(get_user))
return success_response({"user_stats": user_schema.dump(get_user)})
@stats.route("/user/lastdelivery/<int:user_id>", methods=["GET"])
@@ -179,9 +165,7 @@ def get_user_last_delivery(user_id):
date_delivered = get_delivery.when_delivered
else:
date_delivered = "no deliveries on record"
return jsonify({"ok": True,
'date': str(date_delivered),
}), 200
return success_response({'date': str(date_delivered)})
@stats.route("/gallons/week", methods=["GET"])
@@ -201,9 +185,7 @@ def total_gallons_delivered_this_week():
.all())
for f in get_total:
total_gallons = total_gallons + f.gallons_delivered
return jsonify({"ok": True,
'total': total_gallons,
}), 200
return success_response({'total': total_gallons})
@stats.route("/gallons/check/total/<int:user_id>", methods=["GET"])
def calculate_gallons_user(user_id):
@@ -227,5 +209,4 @@ def calculate_gallons_user(user_id):
get_user.oil_total_gallons = total_gallons
db.session.add(get_user)
db.session.commit()
return jsonify({"ok": True,
}), 200
return success_response()

View File

@@ -1,8 +1,8 @@
import logging
from flask import jsonify
from app.ticket import ticket
from app import db
from app.classes.delivery import Delivery_Delivery
from app.common.responses import success_response
logger = logging.getLogger(__name__)
@@ -11,6 +11,4 @@ logger = logging.getLogger(__name__)
def get_ticket_printer_letter(ticket_id):
logger.info(f"GET /ticket/{ticket_id} - Generating ticket printer letter")
return jsonify({"ok": True,
}), 200
return success_response()