Skip to content
Merged
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: activityinfo
Type: Package
Title: R interface to ActivityInfo.org, an information management software for
humanitarian and development operations
Version: 4.38
Date: 2024-12-17
Version: 4.39
Date: 2025-04-02
Authors@R: c(
person("Alex", "Bertram", email = "alex@bedatadriven.com",
role = c("aut", "cre")),
Expand Down
23 changes: 18 additions & 5 deletions R/billingInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ getBillingAccount <- function(billingAccountId, asDataFrame = TRUE) {

billingInfo <- getResource(paste0("/billingAccounts/", billingAccountId), task = "Getting billing account info")
billingInfo$id <- as.character(billingInfo$id)
billingInfo$addons <- list(billingInfo$addons)
if (is.null(billingInfo$parentBillingAccountId)) {
billingInfo$parentBillingAccountId <- NA
} else {
billingInfo$parentBillingAccountId <- as.character(billingInfo$parentBillingAccountId)
}

if (asDataFrame == TRUE) {
billingInfo <- tibble::as_tibble(billingInfo)
return(billingInfo)
Expand Down Expand Up @@ -131,13 +138,19 @@ getDatabaseBillingAccount <- function(databaseId, asDataFrame = TRUE) {
if(missing(databaseId)) stop("A databaseId must be provided")
stopifnot("A single databaseId must be provided" = (length(databaseId)==1))

databaseOwner <- getResource(paste0("/databases/", databaseId, "/billingAccount"), task = "Getting database owner")
databaseOwner$id <- as.character(databaseOwner$id)

billingInfo <- getResource(paste0("/databases/", databaseId, "/billingAccount"), task = "Getting database billing account")
billingInfo$id <- as.character(billingInfo$id)
billingInfo$addons <- list(billingInfo$addons)
if (is.null(billingInfo$parentBillingAccountId)) {
billingInfo$parentBillingAccountId <- NA
} else {
billingInfo$parentBillingAccountId <- as.character(billingInfo$parentBillingAccountId)
}

if (asDataFrame) {
databaseOwner <- as_tibble(databaseOwner)
billingInfo <- as_tibble(billingInfo)
}
return(databaseOwner)
return(billingInfo)
}


Expand Down