Skip to content

Commit

Permalink
feat: create a GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
kamajus committed Jan 12, 2025
1 parent 4a5bb69 commit 92ce866
Show file tree
Hide file tree
Showing 9 changed files with 565 additions and 28 deletions.
60 changes: 42 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,57 @@
# Invoice generation system for e-commerce
# Invoice Generator

## Main technologies
## Main Technologies

- Python
- Fast Api
- Weasyprint
- FastAPI
- WeasyPrint
- Jinja2
- Firebase Admin
- PyQt5
- SQLite3
- Docker

## Getting Started

1. Install poetry
1. **Install Poetry**

You can see how to install poetry in your computer accessing [this link](https://python-poetry.org/docs/main#installation)
You can learn how to install Poetry on your computer by visiting [this link](https://python-poetry.org/docs/main#installation).

2. Active the virtual environment
2. **Activate the virtual environment**

```bash
poetry shell
```
```bash
poetry shell
```

3. Create a .env.local file in the root directory following the
env.example file.
3. **Create a `.env.local` file** in the root directory based on the `env.example` file.

4. Run the the server.
4. **Install PyQt5 using pip through Poetry**

```bash
uvicorn main:app --reload
```
```bash
poetry run pip install pyqt5-qt5
```

5. Still Working
5. **Install all dependencies**

```bash
poetry install
```

6. **Populate the database**

```bash
task seed
```

7. **Run the server**

```bash
task run
```

8. **Run the GUI in another tab**

```bash
task gui
```

9. **Still Working 😊**
58 changes: 58 additions & 0 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,64 @@
templates = Jinja2Templates(directory="/tmp/")


@app.get("/data/{order_id}")
async def invoice_data(order_id: str):
# Query the Invoice table for the specific order_id
order = execute("SELECT * FROM Invoice WHERE invoice_id = ?", (order_id,))

if order is None:
raise HTTPException(status_code=404, detail="Invoice not found")

order = dict(order)

client = dict(
execute("SELECT * FROM Client WHERE client_id = ?", (order["client_id"],))
)

invoice_products = execute(
"SELECT * from InvoiceProduct WHERE invoice_id = ?",
(order["invoice_id"],),
fetchall=True,
)

products = []

for product in list(invoice_products):
product = dict(product)

product_data = dict(
execute(
"SELECT * FROM Product WHERE product_id = ?",
(product["product_id"],),
)
)

products.append(
{
"name": product_data["name"],
"unit_price": product_data["unit_price"],
"quantity": product["quantity"],
"total_price": product["total_price"],
}
)

tt = datetime.datetime.strptime(order["created_at"], "%Y-%m-%dT%H:%M:%S.%fZ")
order["created_at"] = tt.strftime("%Y-%m-%d %H:%M")

# Prepare template context data
context_data = {
"name": client["name"],
"phone": client["phone"],
"address": client["address"],
"reference": order["reference"],
"created_at": order["created_at"],
"products": products,
"total_price": order["total_price"],
}

return context_data


@app.get("/invoice/{order_id}")
async def invoice(order_id: str):
# Query the Invoice table for the specific order_id
Expand Down
5 changes: 0 additions & 5 deletions api/utils/secure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ def get_api_key(
Raises:
HTTPException: If the API key is invalid or missing.
"""
print(api_key_query in API_KEYS)
print(api_key_query in API_KEYS)

print(API_KEYS)

if api_key_query in API_KEYS:
return api_key_query
if api_key_header in API_KEYS:
Expand Down
Empty file added gui/__init__.py
Empty file.
Loading

0 comments on commit 92ce866

Please sign in to comment.