# Get Results of Approved Invoices Using Date Filter

Endpoint Name: `getapproveinvoices`

Endpoint Details:This API is used to get the results of approved invoices which are approved by the approver of a company using date range filter, QBE status filter and username list.

Note: This API works only for Admin and Approver users.

Authorization: Bearer token as header

### Request Type

<table data-header-hidden><thead><tr><th width="118"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td><code>URL/access/klearstack/getapproveinvoices</code></td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="90"></th><th width="185"></th><th width="99"></th><th></th></tr></thead><tbody><tr><td>Type</td><td>Params</td><td>Values</td><td>Description</td></tr><tr><td>POST</td><td>company_name</td><td>string</td><td><p>Name of the company</p><p><br></p></td></tr><tr><td>POST</td><td>username</td><td>string</td><td><p>Username for a particular user of a company</p><p><br></p></td></tr><tr><td>POST</td><td>password</td><td>string</td><td>Password for a particular user of a company</td></tr><tr><td>POST</td><td>document_type</td><td>string</td><td><p>Type of document to be processed - “Invoices”,  “Receipts”, “PurchaseOrders”,“NACH”,“LoanAgreement” </p><p>or “Insurances”</p><p>By default “Invoices” will be set if this parameter is not passed</p><p>Note: Optional Parameter</p><p><br></p></td></tr><tr><td>POST</td><td>from_date</td><td>string</td><td><p>Date from which the user wants approved invoices. </p><p>Format : “DD/MM/YYYY”</p></td></tr><tr><td>POST</td><td>to_date</td><td>string</td><td><p>Date till which user wants approved invoices. </p><p>Format : “DD/MM/YYYY”</p></td></tr><tr><td>POST</td><td>user_list</td><td>string</td><td><p>Name of users whose invoices are required.(comma separated)</p><p>Ex. “Creator,Creator1”</p><p>By default all users are considered.</p><p>Note: Optional Parameter</p></td></tr><tr><td>POST</td><td>QBE_status</td><td>string</td><td><p>Status of QBE integration.</p><p>Only two values are considered</p><p>“successful” or “failed”<br>Note: Optional Parameter</p></td></tr></tbody></table>

### Shell

* Request Body

```sh
curl --location POST "URL/access/klearstack/getapproveinvoices" \
  --header "Authorization: Bearer your_token_here" \
  --form "company_name=Replace_Company_Name_Here" \
  --form "username=Replace_User_Name_Here" \
  --form "password=Replace_Password_Here" \
  --form "document_type=Invoices" \
  --form "from_date=01/01/2024" \
  --form "to_date=01/03/2024" \
  --form "user_list=Creator,Creator1" \
  --form "QBE_status=successful"
```

### Python

* Request Body

```python
import requests

# API URL
url = "URL/access/klearstack/getapproveinvoices"

# Request payload
data = {
    "company_name": "Replace_Company_Name_Here",
    "username": "Replace_User_Name_Here",
    "password": "Replace_Password_Here",
    "document_type": "Invoices",  # Optional parameter
    "from_date": "01/01/2024",
    "to_date": "01/03/2024",
    "user_list": "Creator,Creator1",  # Optional parameter
    "QBE_status": "successful"
}

# Headers
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer your_token_here"
}

# Make the POST request
response = requests.post(url, json=data, headers=headers)

# Print the response
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.text)
```

### Java

* Request Body

```java
import okhttp3.*;

import java.io.IOException;

public class GetApproveInvoicesAPI {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        // JSON payload
        String jsonPayload = "{ \"company_name\": \"Replace_Company_Name_Here\", " +
                "\"username\": \"Replace_User_Name_Here\", " +
                "\"password\": \"Replace_Password_Here\", " +
                "\"document_type\": \"Invoices\", " + 
                "\"from_date\": \"01/01/2024\", " +
                "\"to_date\": \"01/03/2024\", " +
                "\"user_list\": \"Creator,Creator1\", " + 
                "\"QBE_status\": \"successful\" }";

        RequestBody body = RequestBody.create(
            jsonPayload, MediaType.parse("application/json"));

        Request request = new Request.Builder()
            .url("URL/access/klearstack/getapproveinvoices")
            .post(body)
            .addHeader("Content-Type", "application/json")
            .addHeader("Authorization", "Bearer your_token_here")
            .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response: " + response.body().string());
            } else {
                System.out.println("Error: " + response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

### Node Js

* Request Body

```javascript
var request = require('request');

const form_data = {
  'company_name': 'Replace_Company_Name_Here',
  'username': 'Replace_User_Name_Here',
  'password': 'Replace_Password_Here',
  'document_type': 'Invoices',  // Optional parameter
  'from_date': '01/01/2024',
  'to_date': '01/03/2024',
  'user_list': 'Creator,Creator1',  // Optional parameter
  'QBE_status': 'successful'
};

const options = {
  url: 'URL/access/klearstack/getapproveinvoices',
  json: form_data,
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_token_here'
  }
};

request.post(options, function(err, httpResponse, body) {
  if (err) {
    console.error('Request failed:', err);
    return;
  }

  console.log('Response:', body);
});
```

### JavaScript

* Request Body

```javascript
var payload = JSON.stringify({
    company_name: "Replace_Company_Name_Here",
    username: "Replace_User_Name_Here",
    password: "Replace_Password_Here",
    document_type: "Invoices", // Optional parameter
    from_date: "01/01/2024",
    to_date: "01/03/2024",
    user_list: "Creator,Creator1", // Optional parameter
    QBE_status: "successful"
});

var xhr = new XMLHttpRequest();
xhr.open("POST", "URL/access/klearstack/getapproveinvoices", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

// Handle response
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE) {
        if (xhr.status === 200) {
            console.log("Response:", xhr.responseText);
        } else {
            console.error("Error:", xhr.responseText);
        }
    }
};

// Send request
xhr.send(payload);
```

### API Response

<table data-header-hidden><thead><tr><th width="102"></th><th></th></tr></thead><tbody><tr><td>Status</td><td>Example Response</td></tr><tr><td>200</td><td><p>{</p><p>    "result": [</p><p>        {</p><p>            "Document_id": "5e9ebf7c1ed959c4bb4dc214",</p><p>            "is_approved": 0,</p><p>           "approved_date": "Wed Apr 14 2021",</p><p>            "file_name": "tata capital west bengal 5712.pdf",</p><p>            "overall_confidence": 0.917829326729445,</p><p>           "AccountsData": {</p><p>                "Supplier GL Account #": "1200021",</p><p>                "Supplier ID": 1001,</p><p>                "Supplier name": "Tatiana Henderson LLP",</p><p>                "CGST": "450002, Central Input GST",</p><p>                "SGST": "450001, State Input GST",</p><p>                "IGST": "420003, Inter State Input GST",</p><p>                "PurchaseAc": "980001, Printing &#x26; Stationery",</p><p>                "SplitFlag": "false",</p><p>                "LineItemAccounts": [</p><p>                    "LineItem1, 980001, Printing &#x26; Stationery, 49,357.00"</p><p>                ],</p><p>                "SplitAccounts": [],</p><p>                "individualQuickBookAc": [],</p><p>                "individualQbItemType": [],</p><p>                "sgstv": "",</p><p>                "cgstv": "",</p><p>                "igstv": "8,884.26",</p><p>                "qbItemName": "",</p><p>                "qbItemType": ""</p><p>            },</p><p>            "Inv_Date": {</p><p>                "value": "23 February, 2020",</p><p>                "confidence": 0.566981644843936,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Number": {</p><p>                "value": "MATTB-2331",</p><p>                "confidence": 0.946715178008698,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1283,</p><p>                    383,</p><p>                    1409,</p><p>                    409</p><p>                ]</p><p>            },</p><p>            "Inv_PO": {</p><p>                "value": "P6060",</p><p>                "confidence": 0.998517162654257,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    1287,</p><p>                    443,</p><p>                    1349,</p><p>                    468</p><p>                ]</p><p>            },</p><p>            "Inv_Total": {</p><p>                "value": "30199",</p><p>                "confidence": 0.970878755401809,</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    0,</p><p>                    0,</p><p>                    0,</p><p>                    0</p><p>                ]</p><p>            },</p><p>            "Inv_CGST_Value": {</p><p>                "value": "1661",</p><p>                "confidence": 0.822383355941637,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_SGST_Value": {</p><p>                "value": "1661",</p><p>                "confidence": 0.881396053757078,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_CGST_Percent": {</p><p>                "value": "5",</p><p>                "confidence": 0.827240639155472,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_SGST_Percent": {</p><p>                "value": "5",</p><p>                "confidence": 0.823984961348311,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Supplier": {</p><p>                "value": "Pai International Electronics Ltd",</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    0,</p><p>                    0,</p><p>                    0,</p><p>                    0</p><p>                ],</p><p>                "confidence": 0.805663607700772</p><p>            },</p><p>            "Inv_Customer": {</p><p>                "value": "Pai, INTERNATIONAL,",</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    406,</p><p>                    58,</p><p>                    795,</p><p>                    105</p><p>                ],</p><p>                "confidence": 0.954218689055312</p><p>            },</p><p>            "Inv_Type": {</p><p>                "value": "Tax Invoice",</p><p>                "confidence": 0.981186005027941,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Currency": {</p><p>                "value": "INR",</p><p>                "confidence": 0.978,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Origin": {</p><p>                "value": "India",</p><p>                "confidence": 0.978,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Supplier_Address": {</p><p>                "value": "GST INVOICE , PAI INTERNATIONAL ELECTRONICS LTD. , Corporate Office: # 28/1A, 100 Feet Road, Indiranagar, Bangalore-560 - 560038.",</p><p>                "page_index": 1,</p><p>                "coordinate": [</p><p>                    406,</p><p>                    3,</p><p>                    1179,</p><p>                    157</p><p>                ],</p><p>                "confidence": 0.962132237592736</p><p>            },</p><p>            "Inv_Supplier_State": {</p><p>                "value": "Karnataka",</p><p>                "confidence": 0.95,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Supplier_City": {</p><p>                "value": "Bengaluru",</p><p>                "confidence": 0.981349645091967,</p><p>                "page_index": 1</p><p>            },</p><p>            "Inv_Supplier_Pincode": {</p><p>                "value": "560038",</p><p>                "confidence": 0.981349645091967,</p><p>                "page_index": 1</p><p>            },</p><p>           "line_items": [</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "Dell Latitude 3400 C15 Intel Core I5 8265 U 8 Gb Ddr4 /512 Gb Ssd 14'' Screen(1366x768) Intel Uhd Graphic 620 10/100/1000 Ehernate Port Window 10 Pro With Bag Pack",</p><p>                        "of Goods": "",</p><p>                        "HSN Code": "8471",</p><p>                        "Quantity": "1 NOS",</p><p>                        "Rate": "49,357.00",</p><p>                        "per": "NOS",</p><p>                        "Line_Item_Total": "49,357.00"</p><p>                    },</p><p>                    "page_index": 1,</p><p>                    "coordinate": [</p><p>                        95,</p><p>                        776,</p><p>                        1343,</p><p>                        892</p><p>                    ]</p><p>                },</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "3 year warranty Output IGST 18%",</p><p>                        "HSN Code": "",</p><p>                        "Quantity": "",</p><p>                        "Rate": "18",</p><p>                        "per": "%",</p><p>                        "Line_Item_Total": "8,884.26"</p><p>                    },</p><p>                    "page_index": 2,</p><p>                    "coordinate": [</p><p>                        92,</p><p>                        777,</p><p>                        1325,</p><p>                        812</p><p>                    ]</p><p>                }</p><p>            ],</p><p>            "data_items": [</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "APPLE IPHONE732GB 7 BLACK",</p><p>                        "serial_number": "MOBIP63",</p><p>                        "imei_number": "356642080262057",</p><p>                        "Line_Item_Total": "29900"</p><p>                    },</p><p>                    "page_index": 1,</p><p>                    "coordinate": [</p><p>                        153,</p><p>                        593,</p><p>                        342,</p><p>                        657</p><p>                    ],</p><p>                    "confidence": 0.973677977720621</p><p>                },</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "2 2 BOAT NECKLACE STYLE IN EAR SPORTS BT HEADSET ROCKERZ 255RBL",</p><p>                        "serial_number": "8904130843761/5314",</p><p>                        "imei_number": "",</p><p>                        "Line_Item_Total": "1899"</p><p>                    },</p><p>                    "page_index": 1,</p><p>                    "coordinate": [</p><p>                        152,</p><p>                        754,</p><p>                        374,</p><p>                        781</p><p>                    ],</p><p>                    "confidence": 0.973677977720621</p><p>                },</p><p>                {</p><p>                    "row": {</p><p>                        "Description": "3 3 MOBILE CARRY BAG (PAPER)",</p><p>                        "serial_number": "BAG04",</p><p>                        "imei_number": "",</p><p>                        "Line_Item_Total": ""</p><p>                    },</p><p>                    "page_index": 1,</p><p>                    "coordinate": [</p><p>                        152,</p><p>                        835,</p><p>                        224,</p><p>                        859</p><p>                    ],</p><p>                    "confidence": 0.973677977720621</p><p>                }</p><p>            ]</p><p>        }</p><p>    ],</p><p>    "status": "complete",</p><p>    “release_version”:”7.8.9”</p><p>}</p></td></tr><tr><td>400</td><td>{"error":"Please provide username."}</td></tr><tr><td>400</td><td>{"error":"Please provide password."}</td></tr><tr><td>401</td><td>{"error":"Incorrect username or password."}</td></tr><tr><td>500</td><td>{"error":"Something went wrong. Please try again later."}</td></tr></tbody></table>
