Skip to content

Shop management system#3324

Open
Sny4m wants to merge 8 commits into
avinashkranjan:mainfrom
Sny4m:shop-mnagement-system
Open

Shop management system#3324
Sny4m wants to merge 8 commits into
avinashkranjan:mainfrom
Sny4m:shop-mnagement-system

Conversation

@Sny4m

@Sny4m Sny4m commented Jul 20, 2026

Copy link
Copy Markdown

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

  • Manage sales records
  • Manage stock and inventory
  • Add and update products with prices
  • Manage employee records
  • Track liabilities with due dates
  • Store login and logout session logs
  • Automatically create required CSV files on first run

Fixes #N/A

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation Update

Checklist

  • My code follows the style guidelines (Clean Code) of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have created a helpful and easy to understand README.md
  • My documentation follows the Template for README.md
  • I have added the project metadata in the PR template.
  • I have created the requirements.txt file if needed.

Project Metadata

Category:

  • Calculators
  • AI/ML
  • Scrappers
  • Social_Media
  • PDF
  • Image_Processing
  • Video_Processing
  • Games
  • Networking
  • OS_Utilities
  • Automation
  • Cryptography
  • Computer_Vision
  • Fun
  • Others

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:

  • Introduce a command-line shop management script for managing sales, stock, products, employees, and liabilities with CSV-backed storage.
  • Automatically initialize required CSV data files for application state on first run.
  • Log user sessions by recording login and logout timestamps to a CSV log file.
  • Provide a user-facing README documenting installation, usage, features, and workflow for the shop management tool.

Documentation:

  • Add a README describing installation, usage, interface, features, and workflow for the shop management system.

@sourcery-ai

sourcery-ai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces 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 logging

sequenceDiagram
    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
Loading

Entity relationship diagram for CSV-based shop data model

erDiagram
    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
Loading

File-Level Changes

Change Details Files
Add a CLI-based shop management application that manages sales, stock, products, employees, liabilities, and session logs using CSV files and pandas.
  • Initialize login timestamp and implement session logging to a CSV file on exit
  • Implement a cross-platform terminal clear function and ASCII art header for the UI
  • Add setup routine that auto-creates required CSV files with appropriate schemas on first run
  • Implement menu handlers for sales, stock, products, employees, and liabilities with view/add/update/search/filter operations backed by pandas DataFrames
  • Implement a reusable list-display helper for printing different record types in a formatted manner
  • Implement main loop with text-based navigation that wires top-level menu options to corresponding handlers
Shop-Management-System/buybye.py
Add project documentation and dependency declaration for the shop management system.
  • Create README describing installation, usage, features, auto-created files, and licensing for the BuyBye shop manager
  • Declare pandas as the sole dependency in requirements.txt
Shop-Management-System/README.md
Shop-Management-System/requirements.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread Shop-Management-System/buybye.py Outdated
Comment thread Shop-Management-System/buybye.py Outdated
Sny4m and others added 2 commits July 20, 2026 17:40
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@Sny4m

Sny4m commented Jul 20, 2026

Copy link
Copy Markdown
Author

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>


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
* [X](https://twitter.com/intent/tweet?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3Dbot_review_share)
* [Mastodon](https://mastodon.social/share?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai/%3Futm_source%3Dmastodon%26utm_medium%3Dsocial%26utm_campaign%3Dbot_review_share)
* [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A//sourcery.ai/%3Futm_source%3Dlinkedin%26utm_medium%3Dsocial%26utm_campaign%3Dbot_review_share)
* [Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A//sourcery.ai/%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3Dbot_review_share)

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

i hzve added input validation and fixed the issues

@Sny4m Sny4m mentioned this pull request Jul 20, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant