> ## Documentation Index
> Fetch the complete documentation index at: https://developer.tryfinch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate Year-To-Date (YTD) Wages

> Learn how to calculate year-to-date (YTD) gross wages for individual employees using data returned from Finch Organization endpoints.

A common use case for Finch APIs is to calculate YTD gross wages for individual employees. This useful and powerful information can be calculated easily by using the right approach.

### Logic Flow

The general flow for calculating individual YTD wages works like this:

1. Call the `/payment` endpoint and pass a `start_date` of the first day of the year (January 01) and an `end_date` of the current date.
2. Loop over the array of returned payment objects and collect all of the payment `id`s.
3. Call the `/pay-statement` endpoint and pass all of the `payment_id`s as a batched request.
4. Loop over the array of returned pay statements and aggregate each individual's gross pay amounts.

### Sequence Diagram

<img src="https://mintcdn.com/finch/nj9ms34wTOuvZws1/images/ytd-gross-wages.png?fit=max&auto=format&n=nj9ms34wTOuvZws1&q=85&s=b871277bc48f2d7536879805fcd52633" alt="ytd-gross-wages.png" width="1759" height="1769" data-path="images/ytd-gross-wages.png" />
