This project is a Factura Management System built with Django for the backend and React with Material-UI for the frontend.
- Requirements
- Installation
- Backend Setup
- Frontend Setup
- SQL Server Setup
- Running the Project
- API Endpoints
- Usage
- License
- Python 3.8+
- Node.js 14+
- npm or yarn
- SQL Server
-
Clone the repository:
git clone https://github.com/sahinmeric/django_project.git ** cd django_project
-
Create and activate a virtual environment:
python -m venv env source env/bin/activate # On Windows use env\Scripts\activate
-
Install the dependencies:
-
Configure the database:
Update the
DATABASES
setting insettings.py
to match your SQL Server configuration. -
Apply the database migrations:
python manage.py makemigrations python manage.py migrate`
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
-
Navigate to the frontend directory:
cd frontend
-
Install the dependencies:
npm install # or yarn install
-
Start the development server:
npm start # or yarn start
-
Download SQL Server:
You can download SQL Server from the official Microsoft website. Choose the version that suits your needs (e.g., SQL Server Express for development purposes). Download SQL Server
-
Install SQL Server:
Follow the installation instructions provided by Microsoft. During installation, you will be asked to configure the server name and authentication mode. It's recommended to use mixed mode authentication (SQL Server and Windows Authentication).
-
Install SQL Server Management Studio (SSMS):
SSMS is a free tool provided by Microsoft for managing SQL Server. You can download it from the link below: Download SSMS
-
Create a Database:
After installing SSMS, open it and connect to your SQL Server instance. Create a new database named
SIMBA_PRUEBA
(or any other name you prefer).sql
CREATE DATABASE SIMBA_PRUEBA;
-
Create Tables:
Use the following SQL script to create the necessary tables in your database. Adjust the script according to your data model if necessary.
sql
-- Example table creation script CREATE TABLE dbo.CLIENTES ( EMPRESA INT NOT NULL, ID_CLIENTE INT PRIMARY KEY, CLIENTE VARCHAR(255), TIPO CHAR(1), NOMBRE VARCHAR(255), TELEFONO VARCHAR(50), CORREO VARCHAR(255), DIRECCION VARCHAR(255), PAGINAWEB VARCHAR(255), FECHA_CREACION DATETIME, ESTADO CHAR(1) ); CREATE TABLE dbo.MAE_FACTURA ( EMPRESA INT NOT NULL, ID_FACTURA INT PRIMARY KEY, FECHA_FACTURA DATE, ID_CLIENTE INT, OBSERVACIONES TEXT, TOTAL DECIMAL(18, 2), FECHA_AUDITORIA DATETIME, NUMERO INT ); CREATE TABLE dbo.DET_FACTURA ( EMPRESA INT NOT NULL, ID_FACTURA INT NOT NULL, CONSECUTIVO INT PRIMARY KEY, ID_PRODUCTO INT, CANTIDAD DECIMAL(20, 2), PRECIO DECIMAL(20, 2), SUB_TOTAL DECIMAL(20, 2) );`
-
Start the backend server:
python manage.py runserver
-
Start the frontend server:
`cd frontend
npm start # or yarn start`
-
Access the application:
Open your web browser and go to
http://localhost:3000
.
- GET /api/empresas/ - List all empresas
- GET /api/clientes/ - List all clientes
- GET /api/clientes/empresa/:id/ - List clientes by empresa
- GET /api/productos/ - List all productos
- GET /api/facturas/ - List all facturas
- GET /api/facturas/:id/ - Retrieve a single factura by ID
- POST /api/facturas/ - Create a new factura
- PUT /api/facturas/:id/ - Update a factura by ID
- The backend server is configured to run on
http://127.0.0.1:8000
. - Use Django admin to manage data:
http://127.0.0.1:8000/admin
.
- The frontend server runs on
http://localhost:3000
. - Navigate through the app to manage
empresas
,clientes
,productos
,facturas
and Crear nueva factura
-
Ensure CORS is configured correctly for local development by adding
http://localhost:3000
to theCORS_ALLOWED_ORIGINS
insettings.py
.python
`CORS_ALLOWED_ORIGINS = [ 'http://localhost:3000', 'http://127.0.0.1:8000' # If needed for backend API access ]` `INSTALLED_APPS = [ 'corsheaders', ... ]` `MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', ... ]`
This project is licensed under the MIT License. See the LICENSE file for details.