Bookings

Filed under following categories:

Sales

Most commonly used with the following data sources:

Pipedrive

"Bookings" measures the total amount of deals in progress in your sales pipeline.

Sample Gtmhub algorithm for Pipedrive CRM


# Get the reference to pipedrive deals entity
deals <- entity("pipedrive_deals")
# Take only deals that have been won
if (exists("settings.date_range") && settings.date_range != "") {
    date_range <- as.Date(
        strsplit(settings.date_range, "[|]")[[1]],
        "%F"
    )
    date_start <- head(date_range, 1)
    date_end <- tail(date_range, 1)
    deals <- filter(deals,
        close_time >= date_start,
        close_time < date_end
    )
}
wonDeals <- filter(deals, lower(status) == "won")
# Calculate the amount of won deals
summary <- summarise(wonDeals,
    count = n(),
    total_value = sum(value)
)
# Retrieve findings from DB
summary <- collect(summary)
# Output findings
if (summary$count > 0 ){
    bookings <- summary$total_value
} else {
    bookings <- 0
}
out(bookings = bookings)