Registers the sales data application, which lets an organisation record recurring or one-off amounts, such as sales figures, against profiles or other entities and group them into named data series. It provides the website and admin folders used to view, edit and upload series and records, drives points allocation and reward calculation from recorded sales, raises funnel trigger events, feeds sales records into search indexing and omni-search, and contributes profile tabs, portlets and menu items for the feature. Registered under the instance id "salesData".

Implements: ChildPageApplication, MenuApplication, BackupableApplication, SearchableApplication, ManageProfileApplication, PortletApplication, ComponentApplication, TemplatingApplication, DependentApplication, JourneyBuilderApplication, QueryApplication, TableUploadApplication, FieldProviderApplication, PromotionMechanicApplication, OmniSearchApplication


Properties

PropertyReturnsDescription
allSalesDataSeriesList<SalesDataSeries>All sales data series defined for the current organisation, resolved from the current root folder.
configAppConfigConfiguration this application instance was initialised with, including its manifest and repository metadata.
dataSeriesAppIndexerDataSeriesAppIndexerThe search indexer used to index sales data records, one indexer instance per application.
instanceIdStringIdentifier this application is registered under with the application manager.
legacyboolean
metricTypesList<MetricType>The reporting metric types this application contributes, currently just the sum-of-sales-data metric.
promotionTypesList<PromotionMechanicType>The promotion mechanic types this application contributes, made available only when the installed version of the sales data app is an earlier, legacy version.
rolesList<Role>The roles this application contributes to the platform's permission system: the sales data viewer and sales data editor roles.

Methods

getInstanceId() · getConfig() · getAllSalesDataSeries() · getAllSalesDataRecords(SalesDataSeries series) · getSalesDataSeries(String name) · getDataSeriesExtraFields(String name) · insertDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Profile enteredBy, Date entered) · insertDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Profile enteredBy, Date entered, String productSku) · insertDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Date entered) · insertOrUpdateDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Date entered, Map<String,String> fields) · updateDataPoint(SalesDataRecord r, BigDecimal amount, Date entered) · deleteDataPoint(SalesDataRecord r) · findExistingBySkuAndSalesBy(SalesDataRecord rec) · findExistingBySkuAndSalesBy(SalesDataRecord rec, Date from, Date to) · findDataPoint(SalesDataSeries series, BaseEntity attributedTo, Date from, Date to, Map<String,String> fields) · findDataPoint(SalesDataSeries series, Date from, Date to, Map<String,String> fields) · getRoles() · getPointsAllocationForRecord(long salesDataRecordId) · processPointsAllocation(SalesDataSeries series, Consumer<String> progressCallback) · calculateAllocationPoints(PointsAllocationSource pas, SalesDataRecord r, Formatter f) · getDataSeriesAppIndexer() · dataSeriesHistogram(SalesDataSeries series, Date startDate, Date endDate, String groupBy, String aggregation, Profile forUser) · createSeries(String name, String title, Group salesByGroup) · getPromotionTypes() · getMetricTypes()

getInstanceId()

Returns: String

Identifier this application is registered under with the application manager.

getConfig()

Returns: AppConfig

Configuration this application instance was initialised with, including its manifest and repository metadata.

getAllSalesDataSeries()

Returns: List<SalesDataSeries>

All sales data series defined for the current organisation, resolved from the current root folder.

getAllSalesDataRecords(SalesDataSeries series)

Returns: List<SalesDataRecord>

Loads every record that has been recorded in the given series, regardless of period.

ParameterDescription
seriesthe series to load records for

getSalesDataSeries(String name)

Returns: SalesDataSeries

Looks up a sales data series belonging to the current organisation by its unique name.

ParameterDescription
namethe series' unique name

getDataSeriesExtraFields(String name)

Returns: List<ExtraField>

The extra, series-specific fields configured for the named sales data series, used to render custom field inputs when entering or editing a record.

ParameterDescription
namethe series' unique name

insertDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Profile enteredBy, Date entered)

Returns: SalesDataRecord

Records a new sales data point in the given series, using a session obtained from the current thread. The record is saved immediately and a sales-data-updated funnel event is fired.

ParameterDescription
seriesthe series to add the record to
amountthe amount recorded for this data point
periodFromthe start of the period the amount applies to
periodTothe end of the period the amount applies to
attributedTothe entity the sale is attributed to, such as a profile
enteredBythe profile who entered the record
enteredthe date and time the record was entered

insertDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Profile enteredBy, Date entered, String productSku)

Returns: SalesDataRecord

Records a new sales data point against a specific product SKU, using a session obtained from the current thread. The record is saved immediately and a sales-data-updated funnel event is fired.

ParameterDescription
seriesthe series to add the record to, must not be null
amountthe amount recorded for this data point
periodFromthe start of the period the amount applies to
periodTothe end of the period the amount applies to
attributedTothe entity the sale is attributed to, such as a profile
enteredBythe profile who entered the record
enteredthe date and time the record was entered
productSkuthe SKU of the product the sale relates to

insertDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Date entered)

Returns: SalesDataRecord

Records a new sales data point using a session obtained from the current thread, with the entered-by profile defaulting to the currently logged in user. Delegates to the session-taking overload.

ParameterDescription
seriesthe series to add the record to
amountthe amount recorded for this data point
periodFromthe start of the period the amount applies to
periodTothe end of the period the amount applies to
attributedTothe entity the sale is attributed to, such as a profile
enteredthe date and time the record was entered

insertOrUpdateDataPoint(SalesDataSeries series, BigDecimal amount, Date periodFrom, Date periodTo, BaseEntity attributedTo, Date entered, Map<String,String> fields)

Returns: SalesDataRecord

Finds an existing record for the given series, entity and period and updates it, or inserts a new one if none exists. Any custom field values supplied are also applied to the record and the change is flushed immediately.

ParameterDescription
seriesthe series the record belongs to
amountthe amount to set on the record
periodFromthe start of the period the amount applies to
periodTothe end of the period the amount applies to
attributedTothe entity the sale is attributed to, used to find an existing record
enteredthe date and time the record was entered
fieldscustom field name to value pairs to apply to the record; blank values are skipped

updateDataPoint(SalesDataRecord r, BigDecimal amount, Date entered)

Returns: void

Updates the amount and entered date of an existing sales data record, using a session obtained from the current thread, and fires the sales-data-updated funnel event.

ParameterDescription
rthe record to update
amountthe new amount for the record
enteredthe new entered date for the record

deleteDataPoint(SalesDataRecord r)

Returns: void

Deletes a sales data record, using a session obtained from the current thread, and fires the sales-data-deleted funnel event.

ParameterDescription
rthe record to delete

findExistingBySkuAndSalesBy(SalesDataRecord rec)

Returns: List<SalesDataRecord>

Finds other records that share the given record's product SKU and sales-attributed entity, regardless of period. Delegates to the period-bounded overload with no date restriction.

ParameterDescription
recthe record whose SKU and sales-attributed entity to match on

findExistingBySkuAndSalesBy(SalesDataRecord rec, Date from, Date to)

Returns: List<SalesDataRecord>

Finds other records that share the given record's product SKU and sales-attributed entity, within an optional period range.

ParameterDescription
recthe record whose SKU and sales-attributed entity to match on
fromthe earliest period start to match, or null for no lower bound
tothe latest period end to match, or null for no upper bound

findDataPoint(SalesDataSeries series, BaseEntity attributedTo, Date from, Date to, Map<String,String> fields)

Returns: SalesDataRecord

Finds the first existing record for a series, entity and period that also matches the given custom field values, using a session obtained from the current thread.

ParameterDescription
seriesthe series to search in
attributedTothe entity the record must be attributed to
fromthe start of the period to search within
tothe end of the period to search within
fieldscustom field name to value pairs the record must match

findDataPoint(SalesDataSeries series, Date from, Date to, Map<String,String> fields)

Returns: SalesDataRecord

Finds the first existing record for a series and period, not restricted to any particular attributed entity, that matches the given custom field values, using a session obtained from the current thread.

ParameterDescription
seriesthe series to search in
fromthe start of the period to search within
tothe end of the period to search within
fieldscustom field name to value pairs the record must match

getRoles()

Returns: List<Role>

The roles this application contributes to the platform's permission system: the sales data viewer and sales data editor roles.

getPointsAllocationForRecord(long salesDataRecordId)

Returns: List<PointsAllocation>

Looks up the points allocations that were generated from a sales data record, using a session obtained from the current thread.

ParameterDescription
salesDataRecordIdthe database id of the sales data record

processPointsAllocation(SalesDataSeries series, Consumer<String> progressCallback)

Returns: void

Runs points allocation processing for every points allocation source configured on the series, delegating to DataSeriesManager. This is an expensive, potentially long-running operation over the series' records.

ParameterDescription
seriesthe series to process points allocation for
progressCallbackcallback invoked with progress messages as processing proceeds, may be null

calculateAllocationPoints(PointsAllocationSource pas, SalesDataRecord r, Formatter f)

Returns: BigDecimal

Calculates how many points a single sales data record earns under a points allocation source, delegating to DataSeriesManager.

ParameterDescription
pasthe points allocation source defining the calculation rule
rthe sales data record to calculate points for
fthe formatter used to evaluate the allocation source's calculation

getDataSeriesAppIndexer()

Returns: DataSeriesAppIndexer

The search indexer used to index sales data records, one indexer instance per application.

dataSeriesHistogram(SalesDataSeries series, Date startDate, Date endDate, String groupBy, String aggregation, Profile forUser)

Returns: KSearchResponse

Runs a date-histogram search over a series' records for the given period, aggregating the amount field by the requested aggregation type and optionally bucketed by a grouping field. Defaults the period to the current year to date when either bound is omitted, and restricts results to the organisations the given user has reporting access to, falling back to just their own records if they have none. This performs an Elasticsearch query and is relatively expensive.

ParameterDescription
seriesthe series to build the histogram over
startDatethe start of the period to search, defaults to the start of the current year if null
endDatethe end of the period to search, defaults to now if null
groupBythe field to sub-aggregate each histogram bucket by, or null for no grouping
aggregationthe metric aggregation to apply to the amount field: sum, average, min, max, or a count if null or unrecognised
forUserthe user to restrict results for, or null to search without a user-based restriction

createSeries(String name, String title, Group salesByGroup)

Returns: SalesDataSeries

Creates and persists a new, enabled sales data series for the current organisation, attributed to profiles within a group, with dollar units and the sales-by-profile sales type.

ParameterDescription
namethe series' unique name
titlethe series' display title
salesByGroupthe group whose profile members sales can be attributed to

getPromotionTypes()

Returns: List<PromotionMechanicType>

The promotion mechanic types this application contributes, made available only when the installed version of the sales data app is an earlier, legacy version.

getMetricTypes()

Returns: List<MetricType>

The reporting metric types this application contributes, currently just the sum-of-sales-data metric.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.