Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Created October 21, 2023 02:49
Show Gist options
  • Select an option

  • Save dharmatech/06cc7e2cfbf3084039e0d775cd653f6e to your computer and use it in GitHub Desktop.

Select an option

Save dharmatech/06cc7e2cfbf3084039e0d775cd653f6e to your computer and use it in GitHub Desktop.
$base = 'https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v1/accounting/dts'
$fields = @(
'record_date',
'account_type',
'transaction_type',
'transaction_catg',
# 'transaction_catg_desc',
# 'transaction_today_amt',
@{ L = 'transaction_today_amt'; E = { [decimal] $_.'transaction_today_amt' }; F = 'N0' }
'transaction_mtd_amt ',
# 'transaction_fytd_amt',
@{ L = 'transaction_fytd_amt'; E = { [decimal] $_.'transaction_fytd_amt' }; F = 'N0' }
'table_nbr',
# 'table_nm',
# 'src_line_nbr',
'record_fiscal_year',
'record_fiscal_quarter'
# 'record_calendar_year',
# 'record_calendar_quarter'
# 'record_calendar_month'
# 'record_calendar_day'
)
# ----------------------------------------------------------------------
# last day of fiscal year
$record_date = '2023-09-29'
$rest_url = "/dts_table_2?filter=record_date:eq:$record_date&page[number]=1&page[size]=1000"
$result = Invoke-RestMethod -Method Get -Uri ($base + $rest_url)
$result.data | Where-Object transaction_catg -Match 'tax' | Sort-Object -Property transaction_type, @{ Expression = { [decimal] $_.transaction_fytd_amt }; Descending = $true } | ft $fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment