|
|
|
@@ -15,6 +15,7 @@ out_receipts_payer <- function( |
|
|
|
|
|
|
|
receipts_payer <- |
|
|
|
receipts |> |
|
|
|
receipts_replace_na() |> |
|
|
|
distinct( |
|
|
|
org_name, |
|
|
|
is_org, |
|
|
|
@@ -35,6 +36,20 @@ out_receipts_payer <- function( |
|
|
|
dirname(out) |
|
|
|
} |
|
|
|
|
|
|
|
receipts_replace_na <- function(receipts) { |
|
|
|
receipts |> |
|
|
|
tidyr::replace_na(list( |
|
|
|
org_name = "", |
|
|
|
profession = "", |
|
|
|
employers_name = "", |
|
|
|
street_1 = "", |
|
|
|
city = "", |
|
|
|
state = "", |
|
|
|
full_zip = "", |
|
|
|
country_name = "" |
|
|
|
)) |
|
|
|
} |
|
|
|
|
|
|
|
out_receipts <- function( |
|
|
|
path_data_prep_receipts, |
|
|
|
path_out_receipts_payer, |
|
|
|
@@ -59,14 +74,16 @@ out_receipts <- function( |
|
|
|
|
|
|
|
receipts <- |
|
|
|
receipts |> |
|
|
|
receipts_replace_na() |> |
|
|
|
left_join(receipts_payer, by = cols_payer_common) |> |
|
|
|
select(-any_of(cols_payer_common)) |> |
|
|
|
select(-any_of(cols_payer_common), -name_sort) |> |
|
|
|
mutate( |
|
|
|
is_donation = receipt_type_code %in% c("IND", "CPCM", "GEN", "PPTY", "OUTS", "NFPC"), |
|
|
|
.after = receipt_type_code |
|
|
|
) |> |
|
|
|
relocate(payer_id, .after = report_id) |> |
|
|
|
collect() |
|
|
|
collect() |> |
|
|
|
mutate(across(occur_date, lubridate::mdy)) |
|
|
|
|
|
|
|
arrow::write_parquet(receipts, out) |
|
|
|
|