updated page amount

This commit is contained in:
2025-07-28 12:05:14 -04:00
parent 09fafa59d4
commit b97d729ef1
9 changed files with 211 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
FROM python:3.12-bullseye
FROM python:3.13.3-bullseye
ENV PYTHONFAULTHANDLER=1

View File

@@ -217,6 +217,10 @@ app.register_blueprint(promo_blueprint, url_prefix='/promo')
from .social import social as social_blueprint
app.register_blueprint(social_blueprint, url_prefix='/social')
from .service import service as service_blueprint
app.register_blueprint(service_blueprint, url_prefix='/service')
with app.app_context():
db.configure_mappers()

View File

@@ -1,5 +1,5 @@
from flask import request, jsonify
from flask_login import current_user, logout_user, login_user, login_required
from flask_login import current_user, logout_user, login_required
from app.auth import auth
from app import db, bcrypt
from datetime import datetime

68
app/classes/service.py Normal file
View File

@@ -0,0 +1,68 @@
from app import db, ma
from datetime import datetime
class Service_Service(db.Model):
__tablename__ = 'service_service'
__table_args__ = {"schema": "public"}
id = db.Column(db.Integer,
primary_key=True,
autoincrement=True,
unique=False)
customer_id = db.Column(db.INTEGER)
customer_name = db.Column(db.VARCHAR(1000))
customer_address = db.Column(db.VARCHAR(1000))
customer_town = db.Column(db.VARCHAR(140))
customer_state = db.Column(db.VARCHAR(140))
customer_zip = db.Column(db.INTEGER)
# tune-up = 0
# no heat = 1
# fix = 2
# tank = 3
# other = 4
type_service_call = db.Column(db.INTEGER)
status = db.Column(db.INTEGER)
# complete = 0
# incomplete = 1
when_ordered = db.Column(db.DATE())
scheduled_date = db.Column(db.DATE())
time = db.Column(db.INTEGER())
description = db.Column(db.TEXT())
prime = db.Column(db.INTEGER)
same_day = db.Column(db.INTEGER)
emergency = db.Column(db.INTEGER)
service_employee_id = db.Column(db.INTEGER)
service_first_name = db.Column(db.VARCHAR(140))
service_last_name = db.Column(db.VARCHAR(140))
# cash = 0
# credit = 1
# credit/cash = 2
# check = 3
# other = 4
payment_type = db.Column(db.INTEGER)
payment_card_id = db.Column(db.INTEGER)
cash_recieved = db.Column(db.DECIMAL(6, 2))
check_number = db.Column(db.VARCHAR(20))
pre_charge_amount = db.Column(db.DECIMAL(6, 2))
total_price = db.Column(db.DECIMAL(6, 2))
final_price = db.Column(db.DECIMAL(6, 2))
promo_id = db.Column(db.INTEGER)
promo_money_discount = db.Column(db.DECIMAL(6, 2))
class Service_Service_schema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Service_Service

View File

@@ -48,7 +48,7 @@ def all_customers(page):
pagination all customers
"""
per_page_amount = 10
per_page_amount = 100
if page is None:
offset_limit = 0
elif page == 1:

View File

@@ -21,3 +21,27 @@ def oil_total_gallons():
.all()
return jsonify({"ok": True }), 200
@reports.route("/customers/list", methods=["GET"])
def customer_list():
"""
Retrieve a list of customers with selected fields for printing.
Returns account number, first name, last name, address, town, and phone number.
Ordered by last name from A to Z.
"""
customers = db.session.query(Customer_Customer).order_by(Customer_Customer.customer_last_name.asc()).all()
customer_data = [
{
"account_number": customer.account_number,
"first_name": customer.customer_first_name,
"last_name": customer.customer_last_name,
"address": customer.customer_address,
"town": customer.customer_town,
"phone_number": customer.customer_phone_number
}
for customer in customers
]
response = jsonify({"ok": True, "customers": customer_data})
return response, 200

7
app/service/__init__.py Normal file
View File

@@ -0,0 +1,7 @@
# coding=utf-8
from flask import Blueprint
service = Blueprint('service', __name__)
from . import views

103
app/service/views.py Normal file
View File

@@ -0,0 +1,103 @@
from flask import request, jsonify
from flask_login import current_user
from datetime import date, timedelta
from app.service import service
from app import db
from sqlalchemy import or_
from app.classes.customer import (Customer_Customer)
from app.classes.service import (Service_Service,
Service_Service_schema
)
from app.classes.employee import Employee_Employee
from app.classes.cards import Card_Card
from app.classes.pricing import Pricing_Oil_Oil
from app.classes.auth import Auth_User
from app.classes.promo import Promo_Promo
@service.route("/<int:id>", methods=["GET"])
def get_service_call(id):
services = Service_Service.query.filter(Service_Service.id==id).first()
service_schema = Service_Service_schema(many=False)
return jsonify(service_schema.dump(services)), 200
@service.route("/create", methods=["POST"])
def create_service_call():
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
new_service = Service_Service(
customer_id=data.get('customer_id'),
customer_name=data.get('customer_name'),
customer_address=data.get('customer_address'),
customer_town=data.get('customer_town'),
customer_state=data.get('customer_state'),
customer_zip=data.get('customer_zip'),
type_service_call=data.get('type_service_call'),
status=data.get('status', 1), # Default to incomplete
when_ordered=data.get('when_ordered', str(date.today())),
scheduled_date=data.get('scheduled_date'),
time=data.get('time'),
description=data.get('description'),
prime=data.get('prime', 0),
same_day=data.get('same_day', 0),
emergency=data.get('emergency', 0),
service_employee_id=data.get('service_employee_id'),
service_first_name=data.get('service_first_name'),
service_last_name=data.get('service_last_name'),
payment_type=data.get('payment_type'),
payment_card_id=data.get('payment_card_id'),
cash_recieved=data.get('cash_recieved', 0.0),
check_number=data.get('check_number'),
pre_charge_amount=data.get('pre_charge_amount', 0.0),
total_price=data.get('total_price', 0.0),
final_price=data.get('final_price', 0.0),
promo_id=data.get('promo_id'),
promo_money_discount=data.get('promo_money_discount', 0.0)
)
try:
db.session.add(new_service)
db.session.commit()
return jsonify({"message": "Service created successfully", "id": new_service.id}), 201
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
@service.route("/edit/<int:id>", methods=["PUT"])
def update_service_call(id):
service = Service_Service.query.get_or_404(id)
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
for key, value in data.items():
if hasattr(service, key):
setattr(service, key, value)
try:
db.session.commit()
return jsonify({"message": "Service updated successfully"}), 200
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
@service.route("/<int:id>", methods=["DELETE"])
def delete_service_call(id):
service = Service_Service.query.get_or_404(id)
try:
db.session.delete(service)
db.session.commit()
return jsonify({"message": "Service deleted successfully"}), 200
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
@service.route("/list/all", methods=["GET"])
def list_service_calls():
services = Service_Service.query.all()
service_schema = Service_Service_schema(many=True)
return jsonify(service_schema.dump(services)), 200

View File

@@ -32,6 +32,7 @@ class ApplicationConfig:
SECRET_KEY = "34dsfkjh43123cxzfvqwer23432dsf233214efdasf2134321"
# sessions
SESSION_TYPE = "sqlalchemy"
SESSION_COOKIE_NAME = "eamco_session"
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_HTTPONLY = True
@@ -49,5 +50,3 @@ class ApplicationConfig:
CORS_ALLOW_HEADERS = "*"
CORS_ORIGIN_WHITELIST = ['http://192.168.1.204','http://localhost', 'http://192.168.1.204:9511', "*"]
WHITE= ['http://192.168.1.204','http://localhost', "*"]