> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-management/capital/remittance-invoices/sample-flows.md

## Article Content:

# Remittance Invoices: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation.

## Show a merchant their remittance history

A merchant wants to review how much of their sales has gone towards repaying their cash advance, day by day, and how much of each remittance was applied to the advanced amount rather than to the fee.

To show a merchant their remittance history:

1. Call [Query Remittance Invoices](https://dev.wix.com/docs/api-reference/business-management/capital/remittance-invoices/query-remittance-invoices.md) with a filter on the merchant's `cashAdvanceAgreementId`, sorted by `salesDay` in descending order. For example:

    ```json
    {
      "query": {
        "filter": {
          "cashAdvanceAgreementId": "<cash-advance-agreement-id>"
        },
        "sort": [
          { "fieldName": "salesDay", "order": "DESC" }
        ],
        "cursorPaging": { "limit": 30 }
      }
    }
    ```

1. Display each returned invoice's `salesDay`, `amount`, and `salesAmount`.
1. Split each `amount` into `cashAdvanceAmountPortion` and `cashAdvanceFeePortion`, so the merchant can see how much of each remittance was applied to the principal and how much to the fee.
1. Retrieve the rest of the history by passing `pagingMetadata.cursors.next` from the response as `query.cursorPaging.cursor` in the next request.

## Reconcile a collection with the remittances it covers

A merchant sees a single collection on their statement and wants to know which sales days it accounts for. A financial operation can cover several remittance invoices, so reconciling means retrieving every invoice linked to it.

To reconcile a collection with the remittances it covers:

1. Call [Get Remittance Invoice](https://dev.wix.com/docs/api-reference/business-management/capital/remittance-invoices/get-remittance-invoice.md) for an invoice you already know is part of the collection, and read its `financialOperationId`. An invoice with no `financialOperationId` hasn't been collected yet.
1. Call [Query Remittance Invoices](https://dev.wix.com/docs/api-reference/business-management/capital/remittance-invoices/query-remittance-invoices.md) filtered by that `financialOperationId`. For example:

    ```json
    {
      "query": {
        "filter": {
          "financialOperationId": "<financial-operation-id>"
        },
        "sort": [
          { "fieldName": "salesDay", "order": "ASC" }
        ],
        "cursorPaging": { "limit": 50 }
      }
    }
    ```

1. Display each returned invoice's `salesDay` and `amount`. Together they account for the full amount collected.
1. Retrieve any remaining invoices by passing `pagingMetadata.cursors.next` from the response as `query.cursorPaging.cursor` in the next request.