Code Monkey home page Code Monkey logo

cashcollector's Introduction

Cash Collector Application

Overview

This project is a Cash Collection application with a RESTful backend and mobile and web frontends. It manages tasks for Cash Collectors who collect cash from customers and deliver it to Managers. The project includes features to ensure that Cash Collectors do not abuse the system.

Features

  1. Database Models:

    • User: Custom user model extending AbstractUser with roles for Cash Collectors and Managers.
    • Customer: Model to store customer details.
    • Task: Model to store tasks related to cash collection, including customer, amount due, collection status, and timestamps.
  2. Admin Interface:

    • Manage users, customers, and tasks.
    • View status of tasks and Cash Collectors' freeze status.
  3. RESTful API:

    • Endpoints to manage tasks, including creation, collection, delivery, and status checks.
    • JWT authentication for secure access.
    • API to generate CSV reports for tasks.
  4. CSV Output:

    • Generate CSV reports for tasks with filters for completed, assigned, and delivered tasks.

Installation

  1. Clone the repository:

    git clone https://github.com/amremaish/CashCollector
    cd cash-collector
  2. Create and activate a virtual environment:

     python -m venv venv
     source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements.txt
  4. Run migrations:

    python manage.py migrate
  5. Create a superuser:

     python manage.py createsuperuser
  6. Run the development server:

     python manage.py runserver

Postman Collection

You can view it from here.

Database Models

alt text

Authentication Endpoints

Login

Description: Authenticate a user and obtain a token.
Method: POST
Endpoint: /api/users/login

curl -X POST http://localhost:8000/api/users/login \
-H "Content-Type: application/json" \
-d '{
  "username": "cash_collector",
  "password": "123456"
}'

Current User

Description: Retrieve the current authenticated user’s details.
Method: GET
Endpoint: /api/users/me

curl -X GET http://localhost:8000/api/users/me \
-H "Authorization: Bearer <TOKEN>"

Cash Collector status

Description: Retrieve Cash Collector status whether frozen or not Method: GET
Endpoint: /api/users/status

curl -X GET 'http://localhost:8000/api/users/status' \
-H "Authorization: Bearer <TOKEN>"

Add Cash Collector

Description: Add a new cash collector user.
Method: PUT
Endpoint: /api/users/add/cash-collector

curl -X PUT http://localhost:8000/api/users/add/cash-collector \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
  "username": "cash_collector",
  "email": "[email protected]",
  "first_name": "Amr",
  "last_name": "Emaish",
  "password": "123456"
}'

Sign Up Manager

Description: Sign up a new manager user.
Method: PUT
Endpoint: /api/users/manager/signup

curl -X PUT http://localhost:8000/api/users/manager/signup \
-H "Content-Type: application/json" \
-d '{
  "username": "manager",
  "email": "[email protected]",
  "first_name": "Amr",
  "last_name": "Emaish",
  "password": "123456"
}'

Customer Endpoints

Add Customer

Description: Add a new customer.
Method: PUT
Endpoint: /api/users/add/customer

curl -X PUT http://localhost:8000/api/users/add/customer \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
  "name": "test customer",
  "address": "Cairo / Egypt"
}'

Get Customers

Description: Retrieve a list of customers with pagination.
Method: GET
Endpoint: /api/users/customers?page=2&page_size=5

curl -X GET http://localhost:8000/api/users/customers?page=2&page_size=5 \
-H "Authorization: Bearer <TOKEN>"

Task Endpoints

Add Task

Description: Add a new task for a customer.
Method: PUT
Endpoint: /api/tasks/create

curl -X PUT http://localhost:8000/api/tasks/create \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
  "customer": 4
}'

Get Tasks

Description: Retrieve a list of tasks with pagination.
Method: GET
Endpoint: /api/tasks?page=1&page_size=5

curl -X GET http://localhost:8000/api/tasks?page=1&page_size=5 \
-H "Authorization: Bearer <TOKEN>"

Next Task

Description: Retrieve the next task.
Method: GET
Endpoint: /api/tasks/next_task

curl -X GET http://localhost:8000/api/tasks/next_task \
-H "Authorization: Bearer <TOKEN>"

Collect Task

Description: Collect payment for a task.
Method: POST
Endpoint: /api/tasks/19/collect

curl -X POST http://localhost:8000/api/tasks/19/collect \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
  "amount_due": 3000
}'

Deliver Task

Description: Mark a task as delivered.
Method: POST
Endpoint: /api/tasks/16/deliver

curl -X POST http://localhost:8000/api/tasks/16/deliver \
-H "Authorization: Bearer <TOKEN>"

Generate Tasks CSV

Description: Generate a CSV file for tasks.
Method: GET
Endpoint: /api/tasks/generate_csv?assigned=1&delivered=1

curl -X GET http://localhost:8000/api/tasks/generate_csv?assigned=1&delivered=1 \
-H "Authorization: Bearer <TOKEN>"

Admin screenshots

alt text alt text alt text

cashcollector's People

Contributors

amrmtsn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.