Issue:
[FEATURE] Analytics for payouts

### Feature Description

**APIs**
There is no provision for listing / filtering payout transactions processed via HyperSwitch. This needs to be implemented for analytical processing for payouts.

- List API helps in listing payouts based on generic constraints

- Filter API helps in filtering payouts based on payout specific filters

**Dashboard Analytics**
There are two tables for core payout operations
- payouts
- payout_attempt

The information regarding payouts and the attempts are stored in respective tables. For fetching all the information, there needs to be 2 DB calls for gathering entire context. As of writing this issue, Hyperswitch's dashboard can read data only from a single table in CKH.

As a temporary measure, all the required fields are to be moved to a single table.

### Possible Implementation

List API to include below constraints (similar to payments)
- customer_id
- starting_after
- ending_before
- limit
- created
- created_lt
- created_gt
- created_lte
- created_gte

Filter API to include below filters
- payout_id
- profile_id
- customer_id
- limit
- offset
- time_range
- connector
- currency
- status
- payout_method
- entity_type

Below columns are to be added in `payout_attempt`
 - payout_type
 - amount
- destination_currency
- source_currency
- recurring
- entity_type

### Have you spent some time checking if this feature request has been raised before?

- [X] I checked and didn't find a similar issue

### Have you read the Contributing Guidelines?

- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!

Resolution:
<think>
PR Context:
- Title: feat(payouts): implement list and filter APIs
- Merged: 2024-03-21T09:11:03Z
- Files changed: 26 files
- Commits: 30 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Explained in issue - #3652 


### Additional Changes

- [x] This PR modifies the API contract
- [x] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Fol
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(payouts): implement list and filter APIs (#3651)
Co-authored-by: hyperswitch-bot[bot] <14852550
Files to modify:


**crates/api_models/src/events/payouts.rs**
  Add:
    - function: private::get_api_event_type
    - function: private::get_api_event_type
    - function: private::get_api_event_type
    - function: private::get_api_event_type
    - impl: impl ApiEventMetric for PayoutListConstraints
    - impl: impl ApiEventMetric for PayoutListFilterConstraints
    - impl: impl ApiEventMetric for PayoutListResponse
    - impl: impl ApiEventMetric for PayoutListFilters

**crates/api_models/src/payments.rs**
  Remove:
    - function: private::default_limit

**crates/api_models/src/payouts.rs**
  Add:
    - struct: pub::PayoutAttemptResponse
    - struct: pub::PayoutListFilterConstraints
    - struct: pub::PayoutListResponse
    - struct: pub::PayoutListFilters

**crates/common_enums/src/enums.rs**
  Modify existing code

**crates/common_utils/src/consts.rs**
  Add:
    - function: pub::default_payments_list_limit
    - function: pub::default_payouts_list_limit

**crates/data_models/src/payouts.rs**
  Add:
    - function: private::from
    - function: private::from
    - function: private::from
    - struct: pub::PayoutListParams
    - enum: pub::PayoutFetchConstraints
    - impl: impl From<api_models::payouts::PayoutListConstraints> for PayoutFetchConstraints
    - impl: impl From<api_models::payments::TimeRange> for PayoutFetchConstraints
    - impl: impl From<api_models::payouts::PayoutListFilterConstraints> for PayoutFetchConstraints

**crates/data_models/src/payouts/payout_attempt.rs**
  Add:
    - struct: pub::PayoutListFilters

**crates/data_models/src/payouts/payouts.rs**
  Modify existing code

**crates/diesel_models/src/query/payout_attempt.rs**
  Add:
    - function: pub::get_filters_for_payouts

**crates/openapi/src/openapi.rs**
  Modify existing code

**crates/openapi/src/routes/payouts.rs**
  Add:
    - function: pub::payouts_list
    - function: pub::payouts_filter

**crates/router/src/core/payments/transformers.rs**
  Add:
    - function: private::foreign_from
    - impl: impl ForeignFrom<(storage::Payouts, storage::PayoutAttempt)> for api::PayoutCreateResponse

**crates/router/src/core/payouts.rs**
  Add:
    - function: pub::payouts_list_core
    - function: pub::payouts_filtered_list_core
    - function: pub::payouts_list_available_filters_core

**crates/router/src/core/payouts/helpers.rs**
  Add:
    - function: pub::filter_by_constraints

**crates/router/src/core/payouts/validator.rs**
  Add:
    - function: pub::validate_payout_list_request
    - function: pub::validate_payout_list_request_for_joins

**crates/router/src/db/kafka_store.rs**
  Add:
    - function: private::get_filters_for_payouts
    - function: private::filter_payouts_by_constraints
    - function: private::filter_payouts_and_attempts
    - function: private::filter_payouts_by_time_range_constraints

**crates/router/src/routes/app.rs**
  Modify existing code

**crates/router/src/routes/lock_utils.rs**
  Modify existing code

**crates/router/src/routes/payouts.rs**
  Add:
    - function: pub::payouts_list
    - function: pub::payouts_list_by_filter
    - function: pub::payouts_list_available_filters

**crates/router/src/types/api/payouts.rs**
  Modify existing code

**crates/router_env/src/logger/types.rs**
  Modify existing code

**crates/storage_impl/src/mock_db/payout_attempt.rs**
  Add:
    - function: private::get_filters_for_payouts

**crates/storage_impl/src/mock_db/payouts.rs**
  Add:
    - function: private::filter_payouts_by_constraints
    - function: private::filter_payouts_and_attempts
    - function: private::filter_payouts_by_time_range_constraints

**crates/storage_impl/src/payouts/payout_attempt.rs**
  Add:
    - function: private::get_filters_for_payouts
    - function: private::get_filters_for_payouts

**crates/storage_impl/src/payouts/payouts.rs**
  Add:
    - function: private::filter_payouts_by_constraints
    - function: private::filter_payouts_and_attempts
    - function: private::filter_payouts_by_time_range_constraints
    - function: private::filter_payouts_by_constraints
    - function: private::filter_payouts_and_attempts
    - function: private::filter_payouts_by_time_range_constraints