Closed saipavan10-git closed 3 months ago
I forgot we also needed to update the service_instance table with entries for every new service request. That required a lot fo resequencing.
I tested this in an in memory database with copies of the 8 tables it needs. It was able to run to completion and send the XLSX t me and Taryn. Taryn reviewed my work and she likes it.
This is the code I used to make the in memory test DB:
library(redcapcustodian)
library(RMariaDB)
library(DBI)
library(tidyverse)
library(dotenv)
library(rcc.billing)
load_dot_env("prod_with_local_log.env")
rc_conn_prod <- connect_to_redcap_db()
rcc_billing_conn_prod <- connect_to_rcc_billing_db()
mem_conn <- DBI::dbConnect(duckdb::duckdb(), dbdir = ":memory:")
tables_to_copy <- tribble(
~source, ~table,
rc_conn_prod, "redcap_projects",
rc_conn_prod, "redcap_user_information",
rc_conn_prod, "redcap_entity_project_ownership",
rc_conn_prod, "redcap_config",
rcc_billing_conn_prod, "service_type",
rcc_billing_conn_prod, "service_instance",
rcc_billing_conn_prod, "invoice_line_item",
rcc_billing_conn_prod, "invoice_line_item_communications",
)
purrr::walk2(tables_to_copy$source, tables_to_copy$table, redcapcustodian::copy_entire_table_to_db, mem_conn)
DBI::dbListTables(mem_conn)
rc_conn <- mem_conn
rcc_billing_conn <- mem_conn
Added required setup to call service_request_line_items() and bind its output to all new invoice line items.
Addresses #229