Skip to content

Commit

Permalink
Bug repaires and additional features
Browse files Browse the repository at this point in the history
  • Loading branch information
Mouradost committed Oct 31, 2021
1 parent 1f07507 commit f65bfff
Show file tree
Hide file tree
Showing 523 changed files with 28,009 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/resource/
# /resource/
*.pyc
**/__pycach__/
.idea
*.db
# *.db
52 changes: 35 additions & 17 deletions DB/DBHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
from dataclasses import astuple
from DB.DbTables import *
import datetime
import os


class DBHelper(object):
DATABASE_NAME = "Shop.db"
DATABASE_VERSION = 1

def __init__(self):
self.conn = sql.connect(DBHelper.DATABASE_NAME, check_same_thread=True)
self.conn = sql.connect(os.path.join(
os.getcwd(), "DB", DBHelper.DATABASE_NAME), check_same_thread=True)
self.c = self.conn.cursor()

def createTables(self):
Expand Down Expand Up @@ -187,35 +189,43 @@ def deleteFinishProduct(self, _id: int):

def deleteRawProduct(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {RawProductTable.TABLE_NAME} WHERE {RawProductTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {RawProductTable.TABLE_NAME} WHERE {RawProductTable.COLUMN_ID}=?", (_id,))

def deleteCustomer(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {CustomerTable.TABLE_NAME} WHERE {CustomerTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {CustomerTable.TABLE_NAME} WHERE {CustomerTable.COLUMN_ID}=?", (_id,))

def deleteWorker(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {WorkerTable.TABLE_NAME} WHERE {WorkerTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {WorkerTable.TABLE_NAME} WHERE {WorkerTable.COLUMN_ID}=?", (_id,))

def deleteSell(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {SellTable.TABLE_NAME} WHERE {SellTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {SellTable.TABLE_NAME} WHERE {SellTable.COLUMN_ID}=?", (_id,))

def deleteSellItem(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {SellItemTable.TABLE_NAME} WHERE {SellItemTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {SellItemTable.TABLE_NAME} WHERE {SellItemTable.COLUMN_ID}=?", (_id,))

def deleteTable(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {TableTable.TABLE_NAME} WHERE {TableTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {TableTable.TABLE_NAME} WHERE {TableTable.COLUMN_ID}=?", (_id,))

def deleteCategory(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {CategoryTable.TABLE_NAME} WHERE {CategoryTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {CategoryTable.TABLE_NAME} WHERE {CategoryTable.COLUMN_ID}=?", (_id,))

def deletePointer(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {PointerTable.TABLE_NAME} WHERE {PointerTable.COLUMN_ID}=?", (_id,))
self.c.execute(
f"DELETE FROM {PointerTable.TABLE_NAME} WHERE {PointerTable.COLUMN_ID}=?", (_id,))

# Delete all
def deleteAllFinishProducts(self):
Expand Down Expand Up @@ -262,7 +272,8 @@ def getAllFinishProducts(self):
results = []
if all_x is not None:
for x in all_x:
results.append(FinishProduct(x[1], x[2], x[3], x[4], x[5], x[0]))
results.append(FinishProduct(
x[1], x[2], x[3], x[4], x[5], x[0]))
return results

def getAllRawProducts(self):
Expand All @@ -282,7 +293,8 @@ def getAllCustomers(self):
results = []
if all_x is not None:
for x in all_x:
results.append(Customer(x[1], x[2], x[3], x[4], x[5], x[6], x[0]))
results.append(
Customer(x[1], x[2], x[3], x[4], x[5], x[6], x[0]))
return results

def getAllWorkers(self):
Expand All @@ -292,7 +304,8 @@ def getAllWorkers(self):
results = []
if all_x is not None:
for x in all_x:
results.append(Worker(x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[0]))
results.append(
Worker(x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[0]))
return results

def getAllSells(self):
Expand Down Expand Up @@ -528,7 +541,8 @@ def getTableContent(self, _id: int):
if all_x is not None:
for x in all_x:
total = x[6]
results.append(OrderItem(x[0], x[1], x[2], x[3], x[4], x[5]))
results.append(
OrderItem(x[0], x[1], x[2], x[3], x[4], x[5]))
return results, total

def getWorkerByUsername(self, username):
Expand All @@ -543,7 +557,8 @@ def getWorkerByUsername(self, username):

def deleteAllRelatedSellItems(self, _id: int):
with self.conn:
self.c.execute(f"DELETE FROM {SellItemTable.TABLE_NAME} WHERE {SellItemTable.COLUMN_ID_SELL}=?", (_id,))
self.c.execute(
f"DELETE FROM {SellItemTable.TABLE_NAME} WHERE {SellItemTable.COLUMN_ID_SELL}=?", (_id,))

def getAllUncompletedSells(self):
with self.conn:
Expand Down Expand Up @@ -580,7 +595,8 @@ def insertOrder(self, order_items: list, total: float, id_worker: int, id_custom
table.id_sell = sell_id
self.updateTable(table)
for item in order_items:
self.insertSellItem(SellItem(item.productId, sell_id, item.orderItemQuantity, item.orderItemTotal))
self.insertSellItem(
SellItem(item.productId, sell_id, item.orderItemQuantity, item.orderItemTotal))

def getUncompletedOrdersBySellId(self, _id):
sql_command = f"""SELECT NULL,
Expand All @@ -603,7 +619,8 @@ def getUncompletedOrdersBySellId(self, _id):
total = 0
if all_x is not None:
for x in all_x:
results.append(OrderItem(x[0], x[1], x[2], x[3], x[4], x[5]))
results.append(
OrderItem(x[0], x[1], x[2], x[3], x[4], x[5]))
total = x[6]
return results, total

Expand All @@ -626,7 +643,8 @@ def getUncompletedOrders(self):
results = []
if all_x is not None:
for x in all_x:
results.append(OrderItem(x[0], x[1], x[2], x[3], x[4], x[5]))
results.append(
OrderItem(x[0], x[1], x[2], x[3], x[4], x[5]))
return results

def getHomeScreenInfo(self, month_date: str, day_date: str):
Expand Down
Binary file renamed Shop.db → DB/Shop.db
Binary file not shown.
Binary file added Documentation/All_tickets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions PatusUi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from DB.DBHandler import DBHelper
from DB.DbTables import *
from Threads import *
from Utilities.Threads import *

from Utilities.UiUtilities import *
from resource import resource_rc
from Utilities import Threads

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
Expand All @@ -14,7 +15,6 @@
import threading
import datetime
import hashlib
import Threads
import time
import copy
import sys
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Patus PC application

![Patus](patus_logo.jpg)
![Patus](resource/patus_logo.jpg)
This is the application for the restaurant patus.

![App](App.png)
![App](Documentation/App.png)

## Progress

Expand Down Expand Up @@ -50,9 +50,13 @@ git pull origin/master
- Change and save your setting by following the pictures bellow
- Congratulation ! You can use the app now

![Access Setting](MobileAPP/setting_0.png)
![Access Setting](Documentation/setting_0.png)

![Access Setting](MobileAPP/setting1.png)
![Access Setting](Documentation/setting1.png)

## Ticket printing

![All tickets](Documentation/All_tickets.png)

## Issues

Expand Down
19 changes: 0 additions & 19 deletions Receipt.txt

This file was deleted.

7 changes: 1 addition & 6 deletions Setting/Setting.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"IP": "198.168.1.6",
"PORT": 7800,
"MAX_CLIENTS": 10,
"PATH": "d:\\Code\\Python_projects\\PatusNewShop\\Setting\\Setting.json"
}
{"IP": "198.168.1.3", "PORT": 7800, "MAX_CLIENTS": 10, "PATH": "D:\\Code\\Python_projects\\PatusNewShop\\Setting\\Setting.json"}
1 change: 1 addition & 0 deletions Threads.py → Utilities/Threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def run(self):

def stop(self):
self.server.stop()
self.terminate()


class InfoThread(QtCore.QThread):
Expand Down
64 changes: 34 additions & 30 deletions Utilities/UiUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ def calculator(self):

def validate_print(self):
try:
file = open('Receipt.txt', 'a')
file.writelines('{0:25}{1:15}\n'.format(
'RECEIVED', float(self.le_givenAmount.text())))
file.writelines('{0:25}{1:15}\n'.format('RETURNED', float(self.le_givenAmount.text()) -
self.lcdN_total.value()))
file.writelines('-' * 42 + ' \n')
file.writelines('PATUS vous remercie pour votre visite')
file = open(os.path.join(os.getcwd(), 'tmp', 'Receipt.txt'), 'a')
file.writelines(
f"{'RECEIVED':<30}{self.le_givenAmount.text():^20}\n")
file.writelines(
f"{'RETURNED':<30}{round(float(self.le_givenAmount.text()) - self.lcdN_total.value(), 2):^20}\n")
file.writelines('=' * 50 + ' \n')
file.writelines(f"{'PATUS vous remercie pour votre visite':^50}\n")
file.writelines('=' * 50 + ' \n')
file.close()
self.accept()
except Exception as e:
Expand Down Expand Up @@ -130,28 +131,28 @@ def displayDbData(table_widget: QTableWidget, data):
def printTicket(worker_name: str, order_items: list, tax: float):
try:
total = 0
file = open('Receipt.txt', 'wt')
file = open(os.path.join(os.getcwd(), 'tmp', 'Receipt.txt'), 'wt')
file.writelines('=' * 50 + ' \n')
file.writelines(f'Worker Name: {worker_name:^50}\n')
file.writelines(f'Worker Name: {worker_name:>37}\n')
file.writelines(
f'Date and time : {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"):^50}\n')
f'Date and time : {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"):>33}\n')
file.writelines('-' * 50 + ' \n')
if order_items[0].tableId is not None:
file.writelines(f'Table {order_items[0].tableId:^50}\n')
file.writelines(f'Table {order_items[0].tableId:>44}\n')
else:
file.writelines('Take away \n')
file.writelines('-' * 50 + ' \n')
file.writelines(f"{'ITEM':^20}{'QUANTITY':^10}{'PRICE':^20}\n")
file.writelines(f"{'ITEM':<20}{'QUANTITY':^10}{'PRICE':^20}\n")
file.writelines('-' * 50 + ' \n')
for order_item in order_items:
total += order_item.orderItemTotal * order_item.orderItemQuantity
file.writelines(
f"{order_item.productName:^20}{order_item.orderItemQuantity:^10}{round(order_item.orderItemTotal * order_item.orderItemQuantity, 2):^20}\n")
f"{order_item.productName:<20}{order_item.orderItemQuantity:^10}{round(order_item.orderItemTotal * order_item.orderItemQuantity, 2):^20}\n")
file.writelines('-' * 50 + ' \n')
file.writelines(f"{'TOTAL':^25}{round(total, 2):^25}\n")
file.writelines(f"{'TOTAL TAX':^25}{round(total * tax, 2):^25}\n")
file.writelines(f"{'TOTAL':<30}{round(total, 2):^20}\n")
file.writelines(f"{'TOTAL TAX':<30}{round(total * tax, 2):^20}\n")
file.writelines(
f"{'TOTAL TO PAY':^25}{round(total + (total * tax), 2):^25}\n")
f"{'TOTAL TO PAY':<30}{round(total + (total * tax), 2):^20}\n")
file.writelines('=' * 50 + ' \n')
file.close()
except Exception as e:
Expand All @@ -167,41 +168,43 @@ def printTicket(worker_name: str, order_items: list, tax: float):
def kitchenTicket(worker_name: str, order_items: list):
try:
pizza_count = 0
file = open('chef.txt', 'wt')
file_ = open('pizzaYolo.txt', 'wt')
file = open(os.path.join(os.getcwd(), 'tmp', 'chef.txt'), 'wt')
file_ = open(os.path.join(os.getcwd(), 'tmp', 'pizzaYolo.txt'), 'wt')
now = datetime.datetime.now()
# chef
file.writelines('=' * 50 + ' \n')
file.writelines(f'Worker Name: {worker_name:^50}\n')
file.writelines(f'Worker Name: {worker_name:>37}\n')
file.writelines(
f'Date and time : {now.strftime("%Y-%m-%d %H:%M:%S"):^50}\n')
f'Date and time : {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"):>33}\n')
file.writelines('-' * 50 + ' \n')
if order_items[0].tableId is not None:
file.writelines(f'Table {order_items[0].tableId:>44}\n')
else:
file.writelines('Take away \n')
# pizza yolo
file_.writelines('=' * 50 + ' \n')
file_.writelines(f'Worker Name: {worker_name:^50}\n')
file_.writelines(f'Worker Name: {worker_name:>37}\n')
file_.writelines(
f'Date and time : {now.strftime("%Y-%m-%d %H:%M:%S"):^50}\n')
f'Date and time : {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"):>33}\n')
file_.writelines('-' * 50 + ' \n')
if order_items[0].tableId is not None:
file.writelines(f'Table {order_items[0].tableId:^50} \n')
file_.writelines(f'Table {order_items[0].tableId:^50} \n')
file_.writelines(f'Table {order_items[0].tableId:>44}\n')
else:
file.writelines('Take away \n')
file_.writelines('Take away \n')
# chef
file.writelines('-' * 50 + ' \n')
file.writelines(f"{'ITEM':^25}{'QUANTITY':^25}\n")
file.writelines(f"{'ITEM':<25}{'QUANTITY':^25}\n")
file.writelines('-' * 50 + ' \n')
# pizza yolo
file_.writelines('-' * 50 + ' \n')
file_.writelines(f"{'ITEM':^25}{'QUANTITY':^25}\n")
file_.writelines(f"{'ITEM':<25}{'QUANTITY':^25}\n")
file_.writelines('-' * 50 + ' \n')
for order_item in order_items:
file.writelines(
f"{order_item.productName:^25} {order_item.orderItemQuantity:^25}\n")
f"{order_item.productName:<25} {order_item.orderItemQuantity:^25}\n")
if order_item.productCategory == "Pizza":
file_.writelines(
f"{order_item.productName:^25} {order_item.orderItemQuantity:^25}\n")
f"{order_item.productName:<25} {order_item.orderItemQuantity:^25}\n")
pizza_count += 1
file.writelines('=' * 50 + ' \n')
file.close()
Expand All @@ -227,7 +230,8 @@ def createProductContainer(parent, product, table_id, fc):
frame.setMaximumSize(200, 300)
# Picture or name
label = QLabel()
label.setPixmap(QPixmap("patus_logo.jpg"))
label.setPixmap(QPixmap(os.path.join(
os.getcwd(), "resource", "patus_logo.jpg")))
label.setScaledContents(True)
label.setAlignment(Qt.AlignHCenter)
label.setMaximumSize(200, 200)
Expand Down
15 changes: 0 additions & 15 deletions chef.txt

This file was deleted.

10 changes: 0 additions & 10 deletions pizzaYolo.txt

This file was deleted.

File renamed without changes
Loading

0 comments on commit f65bfff

Please sign in to comment.