Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Created December 17, 2022 23:37
Show Gist options
  • Select an option

  • Save dharmatech/11617441289243fb90abdff5bf95e323 to your computer and use it in GitHub Desktop.

Select an option

Save dharmatech/11617441289243fb90abdff5bf95e323 to your computer and use it in GitHub Desktop.
$date = '2022-12-15'
$result = Invoke-RestMethod -Method Get -Uri ('https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v1/accounting/dts/dts_table_2?filter=record_date:gte:{0}' -f $date)
foreach ($row in $result.data)
{
$row.transaction_today_amt = [decimal]$row.transaction_today_amt
}
$fields =
'record_date',
'account_type',
'transaction_type',
'transaction_catg',
# 'transaction_catg_desc',
@{ Label = 'today'; Expression = { $_.'transaction_today_amt' } },
@{ Label = 'mtd'; Expression = { $_.'transaction_mtd_amt' } },
@{ Label = 'fytd'; Expression = { $_.'transaction_fytd_amt' } },
# 'table_nbr',
# 'table_name',
'src_line_nbr',
@{ Label = 'fis year'; Expression = { $_.'record_fiscal_year' } },
@{ Label = 'fis qtr'; Expression = { $_.'record_fiscal_quarter' } },
@{ Label = 'cal year'; Expression = { $_.'record_calendar_year' } },
@{ Label = 'cal qtr'; Expression = { $_.'record_calendar_quarter' } },
@{ Label = 'cal mth'; Expression = { $_.'record_calendar_month' } },
@{ Label = 'day'; Expression = { $_.'record_calendar_day' } }
$result.data | Where-Object transaction_type -EQ 'Deposits' | Sort-Object transaction_today_amt -Descending | Select-Object -First 10 | Format-Table $fields -AutoSize
$result.data | Where-Object transaction_type -EQ 'Withdrawals' | Sort-Object transaction_today_amt -Descending | Select-Object -First 10 | Format-Table $fields -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment