Skip to content

MrAllenA/vendor-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vendor and Purchase Order Management API

This API provides functionality for managing vendors and purchase orders. It supports operations such as creating, updating, and deleting vendors, as well as creating, updating, and acknowledging purchase orders.

Table of Contents

Authentication

  • Some endpoints require authentication.
  • Include the authentication token in the request headers.
  • http://127.0.0.1:8000/swagger/ you will get all the endpoints
  • Test All endpoints by clicking "Try Out"
  • alt text
  • You can Put token here on top left you have authorize, you will get the token after creating a vendor
  • alt text
  • input token like this
  • alt text

Setup

  • setup a postgress database
  • put the required info about the database inside .env inside vendor_base folder
  • all dependencies are avaialable in req.text , for setting up environment

Endpoints

1. Create Vendor (POST api/vendors/) - Authentication not required , POST request to this will create vendor

Create a new vendor.

Request:

{
  "vendor": "testor1",
  "contact_details": "95352343324 road no",
  "address": "near 2nd lane road"
}

Response:

{
  "token": "token 0880fe6847cd56bc8aba750a270c8ebdf25aa4fb",
  "vendor_code": "ven5db0e212-3f5e-4e00-8d3f-9485b3e99035",
  "vendor_id": 21
}

Note

Add token keyword before token like this - token 0880fe6847cd56bc8aba750a270c8ebdf25aa4fb

2. List Vendors (GET api/vendors/) - Authentication required , POST request to this will return list of all vendors

Response

[
  {
    "id": 21,
    "vendor_code": "ven5db0e212-3f5e-4e00-8d3f-9485b3e99035",
    "name": "testor1",
    "contact_details": "95352343324 road no ",
    "address": "near 2nd lane road",
    "on_time_delivery_rate": 0,
    "quality_rating_avg": 0,
    "average_response_time": 0,
    "fullfillment_rate": 0,
    "user": 22
  }
]

Note

The id here and the vendor id got when you created the vendor is same, so please note the vendor id.

3. Retrieve Details of Specific Vendor (GET api/vendors/id/) - Authentication required , GET request to this will return list of all vendors

parameter value
id vendors id(eg. 21)

Response

[
  {
    "id": 21,
    "vendor_code": "ven5db0e212-3f5e-4e00-8d3f-9485b3e99035",
    "name": "testor1",
    "contact_details": "95352343324 road no ",
    "address": "near 2nd lane road",
    "on_time_delivery_rate": 0,
    "quality_rating_avg": 0,
    "average_response_time": 0,
    "fullfillment_rate": 0,
    "user": 22
  },
  {
    "id": 22,
    "vendor_code": "ven7dbg0e232-325e-4100-8d3s-94d5bde9d035",
    "name": "testor1",
    "contact_details": "95352343324 road no ",
    "address": "near 2nd lane road",
    "on_time_delivery_rate": 0,
    "quality_rating_avg": 0,
    "average_response_time": 0,
    "fullfillment_rate": 0,
    "user": 22
  }
]

4. Update Vendor (PUT api/vendors/id/) - Authentication required , PUT request to this will update vendor details, for the vendor id you have provided

parameter value
id vendors id(eg. 21)

Request

{
  "name": "tester",
  "contact_details": "new contact",
  "address": "new address"
}

Response

{
  "id": 21,
  "vendor_code": "ven5db0e212-3f5e-4e00-8d3f-9485b3e99035",
  "name": "tester",
  "contact_details": "new contact",
  "address": "new address",
  "on_time_delivery_rate": 0,
  "quality_rating_avg": 0,
  "average_response_time": 0,
  "fullfillment_rate": 0,
  "user": 22
}

Note

id : 21 - or the id of the vendor you want to update

5. Delete Vendor (DELETE api/vendors/id/) - Authentication required , DELETE request to this will delete vendor, for the id you have provided

parameter value
id vendors id(eg. 21)

Response

{"Vendor deleted successfully"}

6. Create Purchase Order (POST api/purchase_orders/) - Authentication not required , POST to this will create purchase order, this purchase order will be assigned to the vendor with the least orders

Request

{
  "delivery_date": "2023-12-31T15:20:16.481960Z",
  "items": [{"item_name": "item1"}, {"item_name": "item2"}],
  "quantity": 15,
   "quality_Rating":3
}

Response

{
  "id": 34,
  "po_number": "poa4fe783c-551c-48db-8876-381590063bd7",
  "order_date": "2023-12-15T22:15:15.423349+05:30",
  "delivery_date": "2023-12-31T20:50:16.481960+05:30",
  "items": [
    {
      "item_name": "item1"
    },
    {
      "item_name": "item2"
    }
  ],
  "quantity": 15,
  "status": "pending",
  "quality_rating": null,
  "issue_date": "2023-12-15T22:15:15.408343+05:30",
  "acknowledgment_date": null,
  "vendor": 21
}

Note

id : purchase order id is 34

7. List All Purchase Orders (GET api/purchase_orders/) - Authentication not required , GET to this will list all the purchase orders

Response

[
  {
    "id": 34,
    "po_number": "poa4fe783c-551c-48db-8876-381590063bd7",
    "order_date": "2023-12-15T22:15:15.423349+05:30",
    "delivery_date": "2023-12-31T20:50:16.481960+05:30",
    "items": [
      {
        "item_name": "item1"
      },
      {
        "item_name": "item2"
      }
    ],
    "quantity": 15,
    "status": "pending",
    "quality_rating": null,
    "issue_date": "2023-12-15T22:15:15.408343+05:30",
    "acknowledgment_date": null,
    "vendor": 21
  },
   { "id": 35,
    "po_number": "poadfe783c-f51c-48d4-7674-dsg81590gs63bd7",
    "order_date": "2023-12-15T22:15:15.423349+05:30",
    "delivery_date": "2023-12-17T20:50:16.481960+05:30",
    "items": [
      {
        "item_name": "item1"
      },
      {
        "item_name": "item2"
      }
    ],
    "quantity": 15,
    "status": "pending",
    "quality_rating": null,
    "issue_date": "2023-12-15T22:15:15.408343+05:30",
    "acknowledgment_date": null,
    "vendor": 22
  }

]

8. List Vendor Purchase Orders (GET api/purchase_orders/id) - Authentication not required , GET to this will list all the purchase orders of the vendor, for the id given

parameter value
id vendors id(eg. 21)

Response

[
  {
    "id": 34,
    "po_number": "poa4fe783c-551c-48db-8876-381590063bd7",
    "order_date": "2023-12-15T22:15:15.423349+05:30",
    "delivery_date": "2023-12-31T20:50:16.481960+05:30",
    "items": [
      {
        "item_name": "item1"
      },
      {
        "item_name": "item2"
      }
    ],
    "quantity": 15,
    "status": "pending",
    "quality_rating": null,
    "issue_date": "2023-12-15T22:15:15.408343+05:30",
    "acknowledgment_date": null,
    "vendor": 21
  }
]

9. Get Purchase Order Details (GET /purchase_orders/id/) - Authentication required , GET to this will retrieve details of specific purchase order, for id given

parameter value
id purchase order id (eg. 34)

Response

{
  "id": 34,
  "po_number": "poa4fe783c-551c-48db-8876-381590063bd7",
  "order_date": "2023-12-15T22:15:15.423349+05:30",
  "delivery_date": "2023-12-31T20:50:16.481960+05:30",
  "items": [
    {
      "item_name": "item1"
    },
    {
      "item_name": "item2"
    }
  ],
  "quantity": 15,
  "status": "pending",
  "quality_rating": null,
  "issue_date": "2023-12-15T22:15:15.408343+05:30",
  "acknowledgment_date": null,
  "vendor": 21
}

10. Update Purchase Order (PUT api/purchase_orders/id/) - Authentication required , PUT to this will update details of the purchase order, for id you given

parameter value
id purchase order id (eg. 34)

Request

{
  "delivery_date": "2023-12-31T15:20:16.481960Z",
  "items": [{"item_name": "item1"}, {"item_name": "item2"},{"item_name": "item3"}],
  "quantity": 15,
   "quality_Rating":3
}

Response

{
  "id": 34,
  "po_number": "poa4fe783c-551c-48db-8876-381590063bd7",
  "order_date": "2023-12-15T22:15:15.423349+05:30",
  "delivery_date": "2023-12-31T20:50:16.481960+05:30",
  "items": [
    {
      "item_name": "item1"
    },
    {
      "item_name": "item2"
    },
    {
      "item_name": "item3"
    }
  ],
  "quantity": 15,
  "status": "pending",
  "quality_rating": null,
  "issue_date": "2023-12-15T22:15:15.408343+05:30",
  "acknowledgment_date": null,
  "vendor": 21
}

11. Delete Purchase Order (DELETE api/purchase_orders/id/) - Authentication required , DELETE will delete the purchase order of specific purchase order, for the id given

parameter value
id purchase order id (eg. 34)

Response

{"Purchase Order deleted successfully"}

12. Acknowledge Purchase Order (POST api/purchase_orders/id/acknowledge) - Authentication required, POST to this will acknowledge, and change the status of the purchase order to completed from pending , i.e the purchase order id which have been provided, and this will only be changed to completed, if the purchase order is assigned to the vendor which your logged in as, and metrics will be calculated.

parameter value
id purchase order id (eg. 34)

Response

{
  "id": 34,
  "po_number": "poa4fe783c-551c-48db-8876-381590063bd7",
  "order_date": "2023-12-15T22:42:08.457905+05:30",
  "delivery_date": "2023-12-31T20:50:16.481960+05:30",
  "items": [
    {
      "item_name": "item1"
    },
    {
      "item_name": "item2"
    },
    {
      "item_name": "item2"
    }
  ],
  "quantity": 15,
  "status": "completed",
  "quality_rating": null,
  "issue_date": "2023-12-15T22:15:15.408343+05:30",
  "acknowledgment_date": "2023-12-15T22:42:08.457905+05:30",
  "vendor": 21
}

Note

An already acknowledged PO cant be acknowledged again

13. Get Vendor Performance Metrics (GET api/vendors/id/performance) - authentication required, GET request will fetch the current metrics of vendor and all the historical metrics.

parameter value
id vendors id(eg. 21)

Response

{
  "current_metrics": {
    "id": 21,
    "vendor_code": "ven5db0e212-3f5e-4e00-8d3f-9485b3e99035",
    "name": "tester",
    "contact_details": "new contact",
    "address": "new address",
    "on_time_delivery_rate": 1,
    "quality_rating_avg": null,
    "average_response_time": 1613.049562,
    "fullfillment_rate": 1,
    "user": 22
  },
  "historical metrics": [
    {
      "id": 18,
      "date": "2023-12-15T22:42:08.457905+05:30",
      "on_time_delivery_rate": 0,
      "quality_rating_avg": 0,
      "average_response_time": 0,
      "fullfillment_rate": 0,
      "vendor": 21
    }
  ]
}

About

Vendor Management System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages