Shop management system#3324
Open
Sny4m wants to merge 8 commits into
Open
Conversation
Reviewer's GuideIntroduces a new Python-based CLI shop management application that uses pandas and CSV files for persistent storage, along with accompanying documentation and dependency specification. Sequence diagram for CLI session and CSV loggingsequenceDiagram
actor User
participant CLI as buybye_main
participant FS as CSV_files
User->>CLI: run buybye.py
CLI->>FS: setup
FS-->>CLI: create_missing_csv
loop main_menu
User->>CLI: select option
alt Sales
CLI->>FS: read_csv sales.csv
CLI->>FS: to_csv sales.csv
else Stock
CLI->>FS: read_csv stock.csv
CLI->>FS: to_csv stock.csv
else Products
CLI->>FS: read_csv products.csv
CLI->>FS: to_csv products.csv
else Employees
CLI->>FS: read_csv employees.csv
CLI->>FS: to_csv employees.csv
else Liabilities
CLI->>FS: read_csv liabilities.csv
CLI->>FS: to_csv liabilities.csv
end
end
User->>CLI: choose Exit
CLI->>FS: read_csv log.csv
CLI->>FS: to_csv log.csv
CLI-->>User: show logout_animation
Entity relationship diagram for CSV-based shop data modelerDiagram
sales {
string Item
int Qty
float Total
}
stock {
string Product
int Qty
}
products {
string Product
float Price
}
employees {
string Name
string Role
}
liabilities {
string Name
float Amount
string Due
}
log {
datetime LoginTime
datetime LogoutTime
}
products ||--o{ stock : tracks_quantity
products ||--o{ sales : sold_as
employees ||--o{ sales : recorded_by_optional
employees ||--o{ liabilities : responsible_optional
log ||--o{ employees : session_for_optional
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Several menu handlers repeat the same
clear()/header()/input("Enter...")pattern; consider extracting a small helper to reduce duplication and make future UI tweaks easier. - CSV file operations currently assume the working directory is the script location; using
__file__to build paths relative to the script would make the app more robust when run from other directories. - User input (e.g., numeric quantities, prices, dates) is parsed without error handling, so invalid input will raise exceptions; adding simple validation and friendly error messages would improve resilience of the CLI.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Several menu handlers repeat the same `clear()`/`header()`/`input("Enter...")` pattern; consider extracting a small helper to reduce duplication and make future UI tweaks easier.
- CSV file operations currently assume the working directory is the script location; using `__file__` to build paths relative to the script would make the app more robust when run from other directories.
- User input (e.g., numeric quantities, prices, dates) is parsed without error handling, so invalid input will raise exceptions; adding simple validation and friendly error messages would improve resilience of the CLI.
## Individual Comments
### Comment 1
<location path="Shop-Management-System/buybye.py" line_range="98" />
<code_context>
+
+ elif choice == "2":
+ item = input("Item: ")
+ qty = int(input("Qty: "))
+ price = float(input("Price (₹): "))
+ total = qty * price
</code_context>
<issue_to_address>
**issue:** Validate numeric input to avoid unhandled `ValueError` on invalid user input.
Casting `input()` directly to `int`/`float` (here for `qty` and `price`) will raise `ValueError` and terminate the program if the user enters non-numeric data. Consider a small helper that repeatedly prompts until valid numeric input (or cancellation) is provided so the CLI doesn’t crash on invalid input.
</issue_to_address>
### Comment 2
<location path="Shop-Management-System/buybye.py" line_range="127-138" />
<code_context>
+ name = input("Product: ")
+ qty = int(input("Qty: "))
+
+ if name in df["Product"].values:
+ df.loc[df["Product"] == name, "Qty"] = qty
+ else:
+ df.loc[len(df)] = [name, qty]
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use consistent matching semantics (e.g. case-insensitive) for product updates and searches.
In the stock menu, search uses `str.contains(..., case=False)` but updates use exact, case-sensitive match (`df['Product'] == name`). This lets users find a product with one casing but fail to update it with the same input. Consider normalizing casing for both storage and comparison, or using a case-insensitive equality check for updates to align the behavior.
```suggestion
elif choice == "2":
name = input("Product: ")
qty = int(input("Qty: "))
# use case-insensitive matching to keep behavior consistent with search
name_lower = name.lower()
product_match = df["Product"].str.lower() == name_lower
if product_match.any():
df.loc[product_match, "Qty"] = qty
else:
df.loc[len(df)] = [name, qty]
df.to_csv("stock.csv", index=False)
print("Stock updated.")
input("Enter...")
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Author
i hzve added input validation and fixed the issues |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary
Added a Shop Management System written in Python that stores data using CSV files and pandas. The application provides a simple command-line interface for managing a small shop's day-to-day operations.
Features
Fixes #N/A
Type of change
Checklist
README.mdTemplate for README.mdrequirements.txtfile if needed.Project Metadata
Category:
Title: Shop Management System
Folder: Shop-Management-System
Requirements: requirements.txt
Script: buybye.py
Arguments: None
Contributor: Sny4m
Description: A command-line Shop Management System built with Python and pandas. It allows users to manage sales, inventory, products, employees, liabilities, and session logs using CSV files for persistent data storage.
Summary by Sourcery
Add a new Python-based CLI shop management system that persists data to CSV files and provides menus for core store operations.
New Features:
Documentation: