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 KVRouterStore
- Merged: 2024-03-19T10:18:15Z
- Files changed: 30 files
- Commits: 24 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
This PR includes below changes
- implement KVRouterStore for storing payout data in either redis + postgres or postgres only
- moving required columns for dashboard analytics to a single table
- usage and consumption of `payouts` feature throughout crates

Explained in issue - #3
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(payouts): implement KVRouterStore (#3889)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyper
Files to modify:


**crates/api_models/src/admin.rs**
  Remove:
    - enum: pub::PayoutRoutingAlgorithm

**crates/api_models/src/payment_methods.rs**
  Modify existing code

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

**crates/data_models/src/lib.rs**
  Add:
    - trait: pub::PayoutAttemptInterface
    - trait: pub::PayoutsInterface
    - mod: pub::payouts

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

**crates/data_models/src/payouts/payout_attempt.rs**
  Add:
    - function: private::default
    - function: private::from
    - struct: pub::PayoutAttempt
    - struct: pub::PayoutAttemptNew
    - struct: pub::PayoutAttemptUpdateInternal
    - enum: pub::PayoutAttemptUpdate
    - trait: pub::PayoutAttemptInterface
    - impl: impl Default for PayoutAttemptNew
    - impl: impl From<PayoutAttemptUpdate> for PayoutAttemptUpdateInternal

**crates/data_models/src/payouts/payouts.rs**
  Add:
    - function: private::default
    - function: private::from
    - struct: pub::Payouts
    - struct: pub::PayoutsNew
    - struct: pub::PayoutsUpdateInternal
    - enum: pub::PayoutsUpdate
    - trait: pub::PayoutsInterface
    - impl: impl Default for PayoutsNew
    - impl: impl From<PayoutsUpdate> for PayoutsUpdateInternal

**crates/diesel_models/src/kv.rs**
  Modify existing code

**crates/diesel_models/src/lib.rs**
  Modify existing code

**crates/diesel_models/src/payout_attempt.rs**
  Remove:
    - function: private::default
    - impl: impl Default for PayoutAttempt
  Add:
    - function: private::default
    - function: pub::apply_changeset
    - impl: impl Default for PayoutAttemptUpdateInternal
    - impl: impl PayoutAttemptUpdate

**crates/diesel_models/src/payouts.rs**
  Remove:
    - function: private::default
    - impl: impl Default for Payouts
  Add:
    - function: private::default
    - impl: impl Default for PayoutsUpdateInternal

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

**crates/diesel_models/src/query/payouts.rs**
  Add:
    - function: pub::update
    - function: pub::find_optional_by_merchant_id_payout_id

**crates/diesel_models/src/schema.rs**
  Modify existing code

**crates/router/src/core/admin.rs**
  Modify existing code

**crates/router/src/core/locker_migration.rs**
  Modify existing code

**crates/router/src/core/payment_methods.rs**
  Modify existing code

**crates/router/src/core/payment_methods/cards.rs**
  Modify existing code

**crates/router/src/core/payment_methods/transformers.rs**
  Modify existing code

**crates/router/src/core/payments/helpers.rs**
  Modify existing code

**crates/router/src/core/payments/tokenization.rs**
  Modify existing code

**crates/router/src/core/payouts.rs**
  Modify existing code

**crates/router/src/core/payouts/helpers.rs**
  Modify existing code

**crates/router/src/core/payouts/retry.rs**
  Modify existing code

**crates/router/src/core/payouts/validator.rs**
  Modify existing code

**crates/router/src/db.rs**
  Remove:
    - mod: pub::payout_attempt
    - mod: pub::payouts

**crates/router/src/db/kafka_store.rs**
  Remove:
    - function: private::find_payout_attempt_by_merchant_id_payout_id
    - function: private::insert_payout_attempt
  Add:
    - impl: impl PayoutAttemptInterface for KafkaStore
    - impl: impl PayoutsInterface for KafkaStore

**crates/router/src/db/payout_attempt.rs**
  Remove:
    - function: private::find_payout_attempt_by_merchant_id_payout_id
    - function: private::find_payout_attempt_by_merchant_id_payout_attempt_id
    - function: private::update_payout_attempt_by_merchant_id_payout_id
    - function: private::update_payout_attempt_by_merchant_id_payout_attempt_id
    - function: private::insert_payout_attempt
    - function: private::find_payout_attempt_by_merchant_id_payout_id
    - function: private::find_payout_attempt_by_merchant_id_payout_attempt_id
    - function: private::update_payout_attempt_by_merchant_id_payout_id
    - function: private::update_payout_attempt_by_merchant_id_payout_attempt_id
    - function: private::insert_payout_attempt
    - trait: pub::PayoutAttemptInterface
    - impl: impl PayoutAttemptInterface for Store
    - impl: impl PayoutAttemptInterface for MockDb

**crates/router/src/db/payouts.rs**
  Remove:
    - function: private::find_payout_by_merchant_id_payout_id
    - function: private::update_payout_by_merchant_id_payout_id
    - function: private::insert_payout
    - function: private::find_payout_by_merchant_id_payout_id
    - function: private::update_payout_by_merchant_id_payout_id
    - function: private::insert_payout
    - trait: pub::PayoutsInterface
    - impl: impl PayoutsInterface for Store
    - impl: impl PayoutsInterface for MockDb

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

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

**crates/router/src/types/api.rs**
  Add:
    - trait: pub::Payouts
    - trait: pub::Payouts

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

**crates/router/src/types/api/payouts.rs**
  Remove:
    - trait: pub::Payouts
    - trait: pub::Payouts

**crates/router/src/types/domain/user.rs**
  Modify existing code

**crates/router/src/types/storage.rs**
  Modify existing code

**crates/router/src/types/storage/payment_method.rs**
  Add:
    - struct: pub::PaymentMethodListContext

**crates/router/src/types/transformers.rs**
  Modify existing code

**crates/router/tests/connectors/payme.rs**
  Modify existing code

**crates/router/tests/connectors/square.rs**
  Modify existing code

**crates/router/tests/connectors/stax.rs**
  Modify existing code

**crates/router/tests/connectors/utils.rs**
  Modify existing code

**crates/storage_impl/src/lib.rs**
  Add:
    - function: private::unique_constraints
    - function: private::table_name
    - function: private::unique_constraints
    - function: private::table_name
    - impl: impl UniqueConstraints for diesel_models::Payouts
    - impl: impl UniqueConstraints for diesel_models::PayoutAttempt
    - impl: impl PayoutAttemptInterface for KVRouterStore<T>
    - impl: impl PayoutAttemptInterface for RouterStore<T>
    - impl: impl PayoutsInterface for KVRouterStore<T>
    - impl: impl PayoutsInterface for RouterStore<T>
    - mod: pub::payouts

**crates/storage_impl/src/mock_db.rs**
  Add:
    - impl: impl PayoutsInterface for MockDb
    - impl: impl PayoutAttemptInterface for MockDb
    - mod: pub::payout_attempt
    - mod: pub::payouts

**crates/storage_impl/src/mock_db/payout_attempt.rs**
  Add:
    - function: private::update_payout_attempt
    - function: private::insert_payout_attempt
    - function: private::find_payout_attempt_by_merchant_id_payout_attempt_id
    - impl: impl PayoutAttemptInterface for MockDb

**crates/storage_impl/src/mock_db/payouts.rs**
  Add:
    - function: private::find_payout_by_merchant_id_payout_id
    - function: private::update_payout
    - function: private::insert_payout
    - function: private::find_optional_payout_by_merchant_id_payout_id
    - impl: impl PayoutsInterface for MockDb

**crates/storage_impl/src/payouts.rs**
  Add:
    - impl: impl KvStorePartition for Payouts
    - impl: impl KvStorePartition for PayoutAttempt
    - mod: pub::payout_attempt
    - mod: pub::payouts

**crates/storage_impl/src/payouts/payout_attempt.rs**
  Add:
    - function: private::insert_payout_attempt
    - function: private::update_payout_attempt
    - function: private::find_payout_attempt_by_merchant_id_payout_attempt_id
    - function: private::insert_payout_attempt
    - function: private::update_payout_attempt
    - function: private::find_payout_attempt_by_merchant_id_payout_attempt_id
    - function: private::to_storage_model
    - function: private::from_storage_model
    - function: private::to_storage_model
    - function: private::from_storage_model
    - function: private::to_storage_model
    - function: private::from_storage_model
    - impl: impl PayoutAttemptInterface for KVRouterStore<T>
    - impl: impl PayoutAttemptInterface for crate::RouterStore<T>
    - impl: impl DataModelExt for PayoutAttempt
    - impl: impl DataModelExt for PayoutAttemptNew
    - impl: impl DataModelExt for PayoutAttemptUpdate

**crates/storage_impl/src/payouts/payouts.rs**
  Add:
    - function: private::insert_payout
    - function: private::update_payout
    - function: private::find_payout_by_merchant_id_payout_id
    - function: private::find_optional_payout_by_merchant_id_payout_id
    - function: private::insert_payout
    - function: private::update_payout
    - function: private::find_payout_by_merchant_id_payout_id
    - function: private::find_optional_payout_by_merchant_id_payout_id
    - function: private::to_storage_model
    - function: private::from_storage_model
    - function: private::to_storage_model
    - function: private::from_storage_model
    - function: private::to_storage_model
    - function: private::from_storage_model
    - impl: impl PayoutsInterface for KVRouterStore<T>
    - impl: impl PayoutsInterface for crate::RouterStore<T>
    - impl: impl DataModelExt for Payouts
    - impl: impl DataModelExt for PayoutsNew
    - impl: impl DataModelExt for PayoutsUpdate