> 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

# QueryRemittanceInvoices

# Package: capital

# Namespace: RemittanceInvoiceService

# Method link: https://dev.wix.com/docs/api-reference/business-management/capital/remittance-invoices/query-remittance-invoices.md

## Permission Scopes:
Request and view Merchant Cash Advance: SCOPE.PAYMENTS.WIX-PAYMENTS-CAPITAL-MCA

## Introduction

Retrieves a list of up to 100 remittance invoices, given the provided paging, filtering, and sorting.

Query Remittance Invoices runs with these defaults, which you can override:

- `createdDate` is sorted in `DESC` order
- `cursorPaging.limit` is `50`

To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-field-projection.md).

---

## REST API

### Schema

```
 Method: queryRemittanceInvoices
 Description: Retrieves a list of up to 100 remittance invoices, given the provided paging, filtering, and sorting.  Query Remittance Invoices runs with these defaults, which you can override:  - `createdDate` is sorted in `DESC` order - `cursorPaging.limit` is `50`  To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-field-projection.md).
 URL: https://www.wixapis.com/capital/v1/remittance-invoices/query
 Method: POST
 Method parameters:
   param name: accountId | type: accountId | description: Wix Payments account GUID.  | validation: format GUID
   param name: query | type: CursorQuery    
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
   param name: siteId | type: siteId | description: GUID of the site the cash advance agreement belongs to.  | validation: format GUID
 Query fields:
   - field: id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: amount.value | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: amount.currency | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: accountId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: siteId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: cashAdvanceAgreementId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: financialOperationId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: salesStartDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: none | aggregatable: undefined | searchable: undefined
   - field: salesEndDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: none | aggregatable: undefined | searchable: undefined
   - field: createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: salesDay | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryRemittanceInvoicesResponse
  - name: remittanceInvoices | type: array<RemittanceInvoice> | description: Retrieved remittance invoices.  
     - name: id | type: string | description: Remittance invoice GUID.  | validation: format GUID, immutable
     - name: amount | type: Money | description: Amount due to be collected as a remittance for the sales day.  Never negative. Equal to the sum of `cashAdvanceAmountPortion` and `cashAdvanceFeePortion`.  | validation: immutable
        - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE, decimalValue {"maxScale":8}
        - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
     - name: last | type: boolean | description: Whether this is the last remittance invoice for the cash advance agreement.  This indicates that no further invoices are issued for the agreement. It doesn't indicate whether the remittance has been collected.  | validation: immutable
     - name: cashAdvanceAmountPortion | type: Money | description: Portion of `amount` applied to the principal advanced under the agreement.  For example, a 100 USD remittance may cover 80 USD of the advanced amount and 20 USD of the fee.  | validation: immutable
     - name: cashAdvanceFeePortion | type: Money | description: Portion of `amount` applied to the agreement's fee.  | validation: immutable
     - name: salesAmount | type: Money | description: Total sales for the sales day that the remittance was calculated from.  | validation: immutable
     - name: salesStartDate | type: string | description: Date and time the sales day started.  | validation: format date-time, immutable
     - name: salesEndDate | type: string | description: Date and time the sales day ended.  | validation: format date-time, immutable
     - name: salesDay | type: string | description: Sales day the remittance covers, in the cash advance agreement's timezone.  Date in `YYYY-MM-DD` format.  | validation: format LOCAL_DATE, immutable
     - name: salesCount | type: integer | description: Number of sales included in the remittance.  | validation: format int32
     - name: accountId | type: string | description: Wix Payments account GUID.  | validation: format GUID, immutable
     - name: tenantId | type: string | description: Internal identifier. Not required for third-party integrations.  | read-only: true | validation: format GUID, immutable
     - name: siteId | type: string | description: GUID of the site the cash advance agreement belongs to.  | validation: format GUID, immutable
     - name: sandbox | type: boolean | description: Whether the remittance invoice was created in a test environment.  | read-only: true | validation: immutable
     - name: cashAdvanceAgreementId | type: string | description: GUID of the cash advance agreement the remittance invoice belongs to.  | validation: format GUID, immutable
     - name: financialOperationId | type: string | description: GUID of the financial operation that collected the remittance.  Populated when the remittance is collected. A remittance invoice with no `financialOperationId` has been calculated but not yet collected.  | validation: format GUID
     - name: createdDate | type: string | description: Date and time the remittance invoice was created.  | read-only: true | validation: format date-time, immutable
     - name: updatedDate | type: string | description: Date and time the remittance invoice was updated.  | read-only: true | validation: format date-time
     - name: revision | type: string | description: Revision number, which increments by 1 each time the remittance invoice is updated.  | read-only: true | validation: format int64
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query remittance invoices for a cash advance agreement
Retrieves a merchant's remittance history, most recent sales day first.

```curl
curl -X POST \
'https://www.wixapis.com/capital/v1/remittance-invoices/query' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "query": {
    "filter": {
      "cashAdvanceAgreementId": "6e4d3c2b-1a09-4f8e-7d6c-5b4a39281706"
    },
    "sort": [
      {
        "fieldName": "salesDay",
        "order": "DESC"
      }
    ],
    "cursorPaging": {
      "limit": 2
    }
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.capital.remittanceInvoices.queryRemittanceInvoices(query, options)
 Description: Retrieves a list of up to 100 remittance invoices, given the provided paging, filtering, and sorting.  Query Remittance Invoices runs with these defaults, which you can override:  - `createdDate` is sorted in `DESC` order - `cursorPaging.limit` is `50`  To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-field-projection.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: options | type: QueryRemittanceInvoicesOptions  none  
        - name: accountId | type: string | description: Wix Payments account GUID.  | validation: format GUID
        - name: siteId | type: string | description: GUID of the site the cash advance agreement belongs to.  | validation: format GUID
   param name: query | type: RemittanceInvoiceQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: _id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: amount.value | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: amount.currency | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: accountId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: siteId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: cashAdvanceAgreementId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: financialOperationId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: salesStartDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: none | aggregatable: undefined | searchable: undefined
   - field: salesEndDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: none | aggregatable: undefined | searchable: undefined
   - field: _createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: salesDay | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryRemittanceInvoicesResponse>
  - name: remittanceInvoices | type: array<RemittanceInvoice> | description: Retrieved remittance invoices.  
     - name: _id | type: string | description: Remittance invoice GUID.  | validation: format GUID, immutable
     - name: amount | type: Money | description: Amount due to be collected as a remittance for the sales day.  Never negative. Equal to the sum of `cashAdvanceAmountPortion` and `cashAdvanceFeePortion`.  | validation: immutable
        - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE, decimalValue {"maxScale":8}
        - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
     - name: last | type: boolean | description: Whether this is the last remittance invoice for the cash advance agreement.  This indicates that no further invoices are issued for the agreement. It doesn't indicate whether the remittance has been collected.  | validation: immutable
     - name: cashAdvanceAmountPortion | type: Money | description: Portion of `amount` applied to the principal advanced under the agreement.  For example, a 100 USD remittance may cover 80 USD of the advanced amount and 20 USD of the fee.  | validation: immutable
     - name: cashAdvanceFeePortion | type: Money | description: Portion of `amount` applied to the agreement's fee.  | validation: immutable
     - name: salesAmount | type: Money | description: Total sales for the sales day that the remittance was calculated from.  | validation: immutable
     - name: salesStartDate | type: Date | description: Date and time the sales day started.  | validation: immutable
     - name: salesEndDate | type: Date | description: Date and time the sales day ended.  | validation: immutable
     - name: salesDay | type: string | description: Sales day the remittance covers, in the cash advance agreement's timezone.  Date in `YYYY-MM-DD` format.  | validation: format LOCAL_DATE, immutable
     - name: salesCount | type: integer | description: Number of sales included in the remittance.  | validation: format int32
     - name: accountId | type: string | description: Wix Payments account GUID.  | validation: format GUID, immutable
     - name: tenantId | type: string | description: Internal identifier. Not required for third-party integrations.  | read-only: true | validation: format GUID, immutable
     - name: siteId | type: string | description: GUID of the site the cash advance agreement belongs to.  | validation: format GUID, immutable
     - name: sandbox | type: boolean | description: Whether the remittance invoice was created in a test environment.  | read-only: true | validation: immutable
     - name: cashAdvanceAgreementId | type: string | description: GUID of the cash advance agreement the remittance invoice belongs to.  | validation: format GUID, immutable
     - name: financialOperationId | type: string | description: GUID of the financial operation that collected the remittance.  Populated when the remittance is collected. A remittance invoice with no `financialOperationId` has been calculated but not yet collected.  | validation: format GUID
     - name: _createdDate | type: Date | description: Date and time the remittance invoice was created.  | read-only: true | validation: immutable
     - name: _updatedDate | type: Date | description: Date and time the remittance invoice was updated.  | read-only: true 
     - name: revision | type: string | description: Revision number, which increments by 1 each time the remittance invoice is updated.  | read-only: true | validation: format int64
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query remittance invoices for a cash advance agreement
Retrieves a merchant's remittance history, most recent sales day first.

```javascript
import { remittanceInvoices } from "@wix/capital";

async function queryRemittanceInvoices() {
  const response = await remittanceInvoices.queryRemittanceInvoices({
    filter: {
      cashAdvanceAgreementId: "6e4d3c2b-1a09-4f8e-7d6c-5b4a39281706",
    },
    sort: [
      {
        fieldName: "salesDay",
        order: "DESC",
      },
    ],
    cursorPaging: {
      limit: 2,
    },
  });
}

/* Promise resolves to:
 * {
 *   "remittanceInvoices": [
 *     {
 *       "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *       "amount": {
 *         "value": "124.50",
 *         "currency": "USD"
 *       },
 *       "last": false,
 *       "cashAdvanceAmountPortion": {
 *         "value": "99.60",
 *         "currency": "USD"
 *       },
 *       "cashAdvanceFeePortion": {
 *         "value": "24.90",
 *         "currency": "USD"
 *       },
 *       "salesAmount": {
 *         "value": "830.00",
 *         "currency": "USD"
 *       },
 *       "salesStartDate": "2024-01-15T00:00:00.000Z",
 *       "salesEndDate": "2024-01-15T23:59:59.999Z",
 *       "salesDay": "2024-01-15",
 *       "salesCount": 17,
 *       "accountId": "5f2c1a83-6b4e-4d19-9c87-1e0a2f3b4c5d",
 *       "tenantId": "8a1b2c3d-4e5f-4a6b-8c9d-0e1f2a3b4c5d",
 *       "siteId": "b3f9e2d1-7c48-4a35-9e6f-2d8c1a4b7e90",
 *       "sandbox": false,
 *       "cashAdvanceAgreementId": "6e4d3c2b-1a09-4f8e-7d6c-5b4a39281706",
 *       "financialOperationId": "9c8b7a65-4321-4fed-cba9-876543210fed",
 *       "_createdDate": "2024-01-16T00:12:44.318Z",
 *       "_updatedDate": "2024-01-16T04:30:12.905Z",
 *       "revision": "2"
 *     },
 *     {
 *       "_id": "3b8f0c47-5e21-4d96-a0b3-7c4e5f6a8d92",
 *       "amount": {
 *         "value": "87.30",
 *         "currency": "USD"
 *       },
 *       "last": false,
 *       "cashAdvanceAmountPortion": {
 *         "value": "69.84",
 *         "currency": "USD"
 *       },
 *       "cashAdvanceFeePortion": {
 *         "value": "17.46",
 *         "currency": "USD"
 *       },
 *       "salesAmount": {
 *         "value": "582.00",
 *         "currency": "USD"
 *       },
 *       "salesStartDate": "2024-01-14T00:00:00.000Z",
 *       "salesEndDate": "2024-01-14T23:59:59.999Z",
 *       "salesDay": "2024-01-14",
 *       "salesCount": 11,
 *       "accountId": "5f2c1a83-6b4e-4d19-9c87-1e0a2f3b4c5d",
 *       "tenantId": "8a1b2c3d-4e5f-4a6b-8c9d-0e1f2a3b4c5d",
 *       "siteId": "b3f9e2d1-7c48-4a35-9e6f-2d8c1a4b7e90",
 *       "sandbox": false,
 *       "cashAdvanceAgreementId": "6e4d3c2b-1a09-4f8e-7d6c-5b4a39281706",
 *       "financialOperationId": "9c8b7a65-4321-4fed-cba9-876543210fed",
 *       "_createdDate": "2024-01-15T00:11:02.774Z",
 *       "_updatedDate": "2024-01-15T04:28:55.140Z",
 *       "revision": "2"
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "count": 2,
 *     "cursors": {
 *       "next": "c2FsZXNEYXk9MjAyNC0wMS0xNA"
 *     },
 *     "hasNext": true
 *   }
 * }
 */

```

### queryRemittanceInvoices (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { remittanceInvoices } from '@wix/capital';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { remittanceInvoices },
  // Include the auth strategy and host as relevant
});


async function queryRemittanceInvoices(query,options) {
  const response = await myWixClient.remittanceInvoices.queryRemittanceInvoices(query,options);
};
```

---