R-CMD-check / check (push) Successful in 3m5s
Rewrites expenditure/revenue classification off item-code first-letter
prefixes and onto summary_categories membership (F-018: prefix Y spans
revenue, expenditure, and balance codes), and exposes
expenditure_concept = c("primary", "direct", "total") with primary as
the new default:
primary = operations + capital + assistance
direct = primary + interest + insurance_benefits (Census Direct)
total = direct + intergovernmental (M/L/Q via ig views)
- inst/sql: flow views (20-25) select by crosswalk membership;
summary_categories moves to 11- so it registers before them (DuckDB
binds view sources eagerly). The IG leg gains Q11/Q12/Q18 state
school-system payments (F-017).
- R: one subtype scope per verb call drives the verb SQL, the
harmonization exclusion count, and the complete = TRUE grid;
flow_prefixes survives only to scope recipe suggestions.
cog_geographic_rollup/cog_peer_compare accept primary|direct, still
refuse total, and now actually pass the concept through.
- Balance codes can never reach a spending or revenue result
(uscogdata#25), asserted at both view and verb level.
- Deletes the #11 skip; per the 2026-07-30 owner ruling the F-018 Y01
proof is asserted against the crosswalk, not the default
cog_revenue() call (which stays General Revenue pending #12).
Suite: 696 pass / 0 fail / 1 skip (#12, expected).
Closes #11
41 lines
1.7 KiB
R
41 lines
1.7 KiB
R
# R/revenue.R
|
|
|
|
#' Summarized revenue by category
|
|
#'
|
|
#' Mirror of [cog_spending()] for revenue categories. One row per
|
|
#' `(year, canonical_govid, revenue_subtype, category)`. Amounts are returned
|
|
#' in **full U.S. dollars** (raw Census values are in $1,000s; this verb
|
|
#' multiplies by 1000 and records the conversion in `provenance`).
|
|
#'
|
|
#' @inheritParams cog_spending
|
|
#' @return Tibble with columns `year`, `canonical_govid`, `gov_name`,
|
|
#' `revenue_subtype`, `category`, `amt_nominal`, optional `amt_real`,
|
|
#' optional `amt_per_capita_nominal`, optional `amt_per_capita_real`,
|
|
#' optional `pop_source`, `codes_included`, `aggregate_fallback`, `notes`,
|
|
#' and `value_source` when `complete = TRUE`.
|
|
#' @export
|
|
cog_revenue <- function(govid, years, category = NULL,
|
|
per_capita = FALSE, adjust_to_year = NULL,
|
|
basis = c("harmonized", "raw"), recipe = NULL,
|
|
complete = FALSE) {
|
|
# flow_prefixes no longer classifies rows (crosswalk revenue_subtype
|
|
# membership does -- General Revenue, i.e. everything except
|
|
# insurance_trust) -- it only scopes the recipe-suggestion machinery to
|
|
# this verb's recipe families (see R/suggestions.R).
|
|
.verb_spendrev(
|
|
verb = "cog_revenue",
|
|
view_base = "revenue_annotated",
|
|
subtype_col = "revenue_subtype",
|
|
flow_prefixes = c("T", "A", "U", "B", "C", "D"),
|
|
call = match.call(),
|
|
govid = govid,
|
|
years = years,
|
|
category = category,
|
|
per_capita = per_capita,
|
|
adjust_to_year = adjust_to_year,
|
|
basis = basis,
|
|
recipe = recipe,
|
|
complete = complete
|
|
)
|
|
}
|