# Income

## CREATE

<mark style="color:green;">`POST`</mark> `https://api.pesatime.com/v1/income`

Record a new sale

#### Request Body

| Name        | Type   | Description                                            |
| ----------- | ------ | ------------------------------------------------------ |
| category    | string | Category ID                                            |
| amount      | number | Amount                                                 |
| date        | string | The date this sale was made YYYY-MM-DD e.g. 2019-11-03 |
| description | string | Add any notes                                          |

{% tabs %}
{% tab title="200 Success" %}

```
{
  "status": 1,
  "message": "Saved",
  "data": {
    "_id": "5dce4b8a4d44af36f693cd2b"
  }
}
```

{% endtab %}

{% tab title="302 Error" %}

```
{
  "status": 0,
  "message": "Error message here"
}
```

{% endtab %}
{% endtabs %}

## UPDATE

<mark style="color:orange;">`PUT`</mark> `https://api.pesatime.com/v1/income/:incomeId`

Update an income

#### Path Parameters

| Name     | Type   | Description          |
| -------- | ------ | -------------------- |
| incomeId | string | The ID of the income |

#### Request Body

| Name        | Type   | Description               |
| ----------- | ------ | ------------------------- |
| date        | string | Date in format YYYY-MM-DD |
| description | string | The new description       |
| amount      | number | The new amount            |
| category    | number | New category ID           |

{% tabs %}
{% tab title="200 SUCCESS" %}

```
{
  "status": 1,
  "message": "Expense updated successfully"
}
```

{% endtab %}

{% tab title="302 Error" %}

```
{
  "status": 0,
  "message": "Error description here"
}
```

{% endtab %}
{% endtabs %}

## DELETE

<mark style="color:red;">`DELETE`</mark> `https://api.pesatime.com/v1/income/:incomeId`

Delete a sale

#### Path Parameters

| Name     | Type   | Description              |
| -------- | ------ | ------------------------ |
| incomeId | string | ID of the sale to delete |

{% tabs %}
{% tab title="200 Success" %}

```
{
  "status": 1,
  "message": "Expense deleted successfully"
}
```

{% endtab %}

{% tab title="302 Error" %}

```
{
  "status": 0,
  "message": "Error description here"
}
```

{% endtab %}
{% endtabs %}

## RETRIEVE - All

<mark style="color:blue;">`GET`</mark> `https://api.pesatime.com/v1/income`

Retrieve all sales made

#### Query Parameters

| Name        | Type   | Description                      |
| ----------- | ------ | -------------------------------- |
| category    | string | Category ID                      |
| description | string | Contains any of what is put here |
| date\_from  | string | The date this sale was made      |
| date\_from  | string | The date this sale was made      |

{% tabs %}
{% tab title="200 " %}

```
{
  "status": 1,
  "data": [
    {
      "amount": 10001,
      "active": true,
      "_id": "5dce51d0bf6c524c59a75c96",
      "organization": "5db5a64a6cb3e2060a7b864c",
      "user": "5cded7f553ea376e8bba6bfd",
      "category": {
        "_id": "5cdfb75bb8f2b84e5fb55ce6",
        "name": "Marketing"
      },
      "description": "New marketing deal",
      "date": "2019-01-23T00:00:00.000Z",
      "attachments": [],
      "dateCreated": "2019-11-15T07:20:48.818Z",
      "__v": 0
    },
    
    .......
  
  ]
}
```

{% endtab %}
{% endtabs %}

## RETRIEVE - single item

<mark style="color:blue;">`GET`</mark> `https://api.pesatime.com/v1/income/:incomeId`

Retrieve contents of one sale item

#### Query Parameters

| Name     | Type   | Description                |
| -------- | ------ | -------------------------- |
| incomeId | string | The ID of the item to pull |

{% tabs %}
{% tab title="200 " %}

```
{
  "status": 1,
  "data": {
    "amount": 10001,
    "active": true,
    "_id": "5dce51d0bf6c524c59a75c96",
    "organization": "5db5a64a6cb3e2060a7b864c",
    "user": "5cded7f553ea376e8bba6bfd",
    "category": {
      "_id": "5cdfb75bb8f2b84e5fb55ce6",
      "name": "Marketing"
    },
    "description": "Description here",
    "date": "2019-01-23T00:00:00.000Z",
    "attachments": [],
    "dateCreated": "2019-11-15T07:20:48.818Z",
    "__v": 0
  }
}
```

{% endtab %}
{% endtabs %}
