nesh170 / asap-inventory-system

This is a concept inventory system for ECE458. It is built by ASAPsolutions
1 stars 0 forks source link

created loans with create loans, delete loans and return loans #179

Closed nesh170 closed 7 years ago

nesh170 commented 7 years ago

Created loans:-

CHANGED API FOR CREATE DISBURSEMENT to /api/request/disbursement/

  1. Get all loans GET /api/request/loan/ HTTP/1.1 Can filter by 'cartstatus', 'itemname', 'cartownerusername','returned' returned is either true or false Response:

    {
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
    {
      "id": 4,
      "item": {
        "id": 5,
        "name": "iPhone 7",
        "quantity": 18
      },
      "quantity": 3,
      "cart_id": 12,
      "loaned_timestamp": "2017-03-18T20:26:47.451709Z",
      "returned_timestamp": "2017-03-18T20:28:03.874267Z"
    },
    {
      "id": 2,
      "item": {
        "id": 5,
        "name": "iPhone 7",
        "quantity": 18
      },
      "quantity": 3,
      "cart_id": 11,
      "loaned_timestamp": "2017-03-17T06:13:08.205724Z",
      "returned_timestamp": "2017-03-17T06:14:43.952348Z"
    }
    ]
    }
  2. Create a loan POST /api/request/loan/addItem/ HTTP/1.1 Request:

    {
    "item_id": 5,
    "quantity": 3
    }

    Response:

    {
    "id": 5,
    "item": {
        "id": 5,
        "name": "iPhone 7",
        "quantity": 18
    },
    "quantity": 3,
    "cart_id": 13,
    "loaned_timestamp": null,
    "returned_timestamp": null
    }
  3. Delete a loan DELETE /api/request/loan/deleteItem/5 HTTP/1.1

Returns HTTP_204_NO_CONTENT on success

  1. Return Loan PATCH /api/request/loan/returnItem/6/ HTTP/1.1 Cart must be fulfilled already Response:

    {
    "id": 6,
    "item": {
        "id": 5,
        "name": "iPhone 7",
        "quantity": 15
    },
    "quantity": 3,
    "cart_id": 13,
    "loaned_timestamp": "2017-03-18T20:43:13.042918Z",
    "returned_timestamp": "2017-03-18T16:43:32.183303"
    }
  2. Return All Loans PATCH /api/request/returnAllLoans/16/ HTTP/1.1 This returns the entire cart Response:

    {
    "id": 16,
    "owner": "plebian",
    "status": "fulfilled",
    "reason": "we put in random reason",
    "cart_disbursements": [],
    "cart_loans": [
        {
            "id": 9,
            "item": {
                "id": 5,
                "name": "iPhone 7",
                "quantity": 15
            },
            "quantity": 3,
            "cart_id": 16,
            "loaned_timestamp": "2017-03-19T17:53:40.329680Z",
            "returned_timestamp": "2017-03-19T17:53:56.556661Z"
        }
    ],
    "timestamp": "2017-03-19T17:53:01.914821Z",
    "staff_timestamp": "2017-03-19T17:53:40.283118Z",
    "staff_comment": "lit",
    "staff": "staff"
    }
  3. Modify Quantity of Disbursement/Loan PATCH /api/request/modifyQuantityRequested/7/ HTTP/1.1 Type can be ['loan','disbursement'] Request:

    {
    "type": "loan",
    "quantity": 1
    }

    Response:

    {
    "id": 7,
    "item": {
        "id": 5,
        "name": "iPhone 7",
        "quantity": 18
    },
    "quantity": 1,
    "cart_id": 14,
    "loaned_timestamp": null,
    "returned_timestamp": null
    }
  4. Convert Request Type POST /api/request/convertRequestType/ HTTP/1.1 Request:

    {
    "current_type": "disbursement",
    "pk": 10
    }

    Response:

    {
    "id": 11,
    "item": {
    "id": 7,
    "name": "Samsung Galaxy Note",
    "quantity": 9000
    },
    "quantity": 3,
    "cart_id": 7,
    "cart_owner": "panda",
    "loaned_timestamp": "2017-03-16T19:11:49.825038Z",
    "returned_timestamp": null
    }

    current_type = ['loan','disbursement'] pk = pk of the current_type They are response are both the same (except if current_type is loan, then there is no loaned_timestamp or returned_timestamp).