Skip to content

rangegowdaym/sr-trading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SR Trading Management System

A comprehensive Desktop and Web UI-based Trading Management System built using Java Spring Boot, MySQL, HTML, CSS, and AngularJS.

Features

Purchase Management

  • Add/Update purchase records with date, shop, item, bags, amount, and discount
  • Search purchases by date range and shop name
  • Display total bags and total amount
  • Edit and delete purchase records

Sales Management

  • Add/Update sales records with date, item, customer, bags, and amount
  • Search sales by date range and customer name
  • Automatic customer balance update when sales are added
  • Display total bags and total amount
  • Edit and delete sales records

Payment Management

  • View all customer balances in real-time
  • Make payments against customer balances
  • Automatic balance deduction when payment is made
  • Add payment notes for record-keeping
  • View payment history
  • Delete payment records

Master Data Management

  • Add, list, and delete Items
  • Add, list, and delete Shops with address and contact information
  • Add, list, and delete Customers with address and contact information
  • View customer balance information

Technology Stack

Backend

  • Java 11
  • Spring Boot 2.7.14
  • Spring Data JPA
  • MySQL 8
  • Maven

Frontend

  • HTML5
  • CSS3
  • AngularJS 1.8.2

Database

  • MySQL 8.0

Project Structure

sr-trading/
├── src/
│   ├── main/
│   │   ├── java/com/trading/srtrading/
│   │   │   ├── controller/          # REST Controllers
│   │   │   │   ├── CustomerController.java
│   │   │   │   ├── ItemController.java
│   │   │   │   ├── PaymentController.java
│   │   │   │   ├── PurchaseController.java
│   │   │   │   ├── SalesController.java
│   │   │   │   └── ShopController.java
│   │   │   ├── entity/              # JPA Entities
│   │   │   │   ├── Customer.java
│   │   │   │   ├── Item.java
│   │   │   │   ├── Payment.java
│   │   │   │   ├── Purchase.java
│   │   │   │   ├── Sales.java
│   │   │   │   └── Shop.java
│   │   │   ├── repository/          # JPA Repositories
│   │   │   │   ├── CustomerRepository.java
│   │   │   │   ├── ItemRepository.java
│   │   │   │   ├── PaymentRepository.java
│   │   │   │   ├── PurchaseRepository.java
│   │   │   │   ├── SalesRepository.java
│   │   │   │   └── ShopRepository.java
│   │   │   ├── service/             # Business Logic Services
│   │   │   │   ├── CustomerService.java
│   │   │   │   ├── ItemService.java
│   │   │   │   ├── PaymentService.java
│   │   │   │   ├── PurchaseService.java
│   │   │   │   ├── SalesService.java
│   │   │   │   └── ShopService.java
│   │   │   └── SrTradingApplication.java  # Main Application
│   │   └── resources/
│   │       ├── static/              # Frontend Files
│   │       │   ├── css/
│   │       │   │   └── styles.css
│   │       │   ├── js/
│   │       │   │   └── app.js
│   │       │   └── index.html
│   │       ├── application.properties
│   │       └── schema.sql
│   └── test/
├── pom.xml
└── README.md

Prerequisites

Before running this application, ensure you have the following installed:

  1. Java Development Kit (JDK) 11 or higher

  2. Apache Maven 3.6+

  3. MySQL 8.0+

  4. Git (for cloning the repository)

Installation and Setup

1. Clone the Repository

git clone https://github.com/rangegowdaym/sr-trading.git
cd sr-trading

2. Setup MySQL Database

  1. Start MySQL server

  2. Login to MySQL:

    mysql -u root -p
  3. Create the database:

    CREATE DATABASE sr_trading;
  4. (Optional) Create a dedicated user:

    CREATE USER 'trading_user'@'localhost' IDENTIFIED BY 'trading_password';
    GRANT ALL PRIVILEGES ON sr_trading.* TO 'trading_user'@'localhost';
    FLUSH PRIVILEGES;

3. Configure Database Connection

Edit src/main/resources/application.properties if needed:

spring.datasource.url=jdbc:mysql://localhost:3306/sr_trading?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root

Note: Update the username and password to match your MySQL credentials.

4. Build the Application

mvn clean install

5. Run the Application

mvn spring-boot:run

Alternatively, you can run the JAR file:

java -jar target/sr-trading-1.0.0.jar

6. Access the Application

Once the application starts successfully:

API Endpoints

Items

  • GET /api/items - Get all items
  • GET /api/items/{id} - Get item by ID
  • POST /api/items - Create new item
  • PUT /api/items/{id} - Update item
  • DELETE /api/items/{id} - Delete item

Shops

  • GET /api/shops - Get all shops
  • GET /api/shops/{id} - Get shop by ID
  • POST /api/shops - Create new shop
  • PUT /api/shops/{id} - Update shop
  • DELETE /api/shops/{id} - Delete shop

Customers

  • GET /api/customers - Get all customers
  • GET /api/customers/{id} - Get customer by ID
  • POST /api/customers - Create new customer
  • PUT /api/customers/{id} - Update customer
  • DELETE /api/customers/{id} - Delete customer

Purchases

  • GET /api/purchases - Get all purchases
  • GET /api/purchases/{id} - Get purchase by ID
  • GET /api/purchases/search?startDate={date}&endDate={date}&shopId={id} - Search purchases
  • POST /api/purchases - Create new purchase
  • PUT /api/purchases/{id} - Update purchase
  • DELETE /api/purchases/{id} - Delete purchase

Sales

  • GET /api/sales - Get all sales
  • GET /api/sales/{id} - Get sales by ID
  • GET /api/sales/search?startDate={date}&endDate={date}&customerId={id} - Search sales
  • POST /api/sales - Create new sales (automatically updates customer balance)
  • PUT /api/sales/{id} - Update sales
  • DELETE /api/sales/{id} - Delete sales

Payments

  • GET /api/payments - Get all payments
  • GET /api/payments/{id} - Get payment by ID
  • GET /api/payments/customer/{customerId} - Get payments by customer
  • POST /api/payments - Create new payment (automatically deducts from customer balance)
  • PUT /api/payments/{id} - Update payment
  • DELETE /api/payments/{id} - Delete payment

Usage Guide

First-Time Setup

  1. Add Master Data First: Navigate to the "Master Data" tab and add:

    • Items (e.g., Rice, Wheat, Sugar)
    • Shops (with addresses and contact information)
    • Customers (with addresses and contact information)
  2. Record Purchases: Go to the "Purchase" tab to record:

    • Purchase date
    • Shop name
    • Items purchased
    • Number of bags
    • Amount and discount
  3. Record Sales: Go to the "Sales" tab to record:

    • Sales date
    • Item sold
    • Customer name
    • Number of bags
    • Amount (automatically updates customer balance)
  4. Manage Payments: Go to the "Payment" tab to:

    • View all customer balances
    • Record payments made by customers
    • View payment history

Key Features

Transaction Management

  • All sales and payment operations are transactional
  • Customer balance automatically updates when:
    • New sales are added (balance increases)
    • Payments are made (balance decreases)
    • Sales or payments are deleted (balance is adjusted accordingly)

Search and Reporting

  • Date range filtering for purchases and sales
  • Filter by shop name for purchases
  • Filter by customer name for sales
  • Automatic calculation of totals (bags and amounts)

Data Validation

  • All forms have required field validation
  • Proper foreign key constraints in the database
  • Error handling for all operations

Troubleshooting

Application won't start

  • Verify MySQL is running
  • Check database credentials in application.properties
  • Ensure port 8080 is not in use

Database connection errors

  • Verify MySQL service is running
  • Check if the database sr_trading exists
  • Verify username and password in application.properties

Frontend not loading

  • Clear browser cache
  • Check browser console for JavaScript errors
  • Verify the backend is running on port 8080

CORS errors

  • The application is configured to accept requests from all origins
  • If issues persist, check browser console and network tab

Development

Running in Development Mode

mvn spring-boot:run -Dspring-boot.run.profiles=dev

Building for Production

mvn clean package -DskipTests

Database Schema

The application creates the following tables:

  • item - Stores item information
  • shop - Stores shop information
  • customer - Stores customer information with balance
  • purchase - Stores purchase records
  • sales - Stores sales records
  • payment - Stores payment records

All tables have proper foreign key relationships and indexes for optimal performance.

License

This project is licensed under the MIT License.

Support

For issues and questions, please create an issue in the GitHub repository.

Author

SR Trading Management System Development Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors