Defines a kind of voucher an organisation issues, and acts as the template every individual Voucher of that kind is created from. It holds the display title, the printed content and its template, the optional cash value, the custom fields collected against each voucher, and the rules that decide when an issued voucher expires. The issuing organisation and the redeeming organisation can differ, so one organisation can issue vouchers that another accepts. Voucher types are soft deleted rather than removed: the deleted flag is set and the name is given a timestamp suffix, so the original name can be used again.

Group: Database Entities

Implements: Serializable


Properties

PropertyReturnsDescription
autoCreateVoucherBooleanWhether allocating from this type creates a new voucher on demand, instead of handing out one from a pool of vouchers created in advance. Null is treated as false.
cashValueBigDecimalThe monetary value a voucher of this type is worth when it is used against an order, in the store's currency. Null means the voucher carries no cash value and cannot be discounted against a checkout total.
contentStringThe HTML body shown on the voucher itself, edited by administrators and rendered into the voucher page and its PDF. Null when no content has been written.
createdByProfileThe profile of the administrator who created this voucher type.
createdDateDateWhen this voucher type was created. Stored to day precision only.
deletedbooleanWhether this voucher type has been soft deleted. Deleted types are excluded from the finders by default and keep their vouchers, so the history of anything already issued survives.
deletedByProfileThe profile of the administrator who soft deleted this voucher type, or null if it has not been deleted.
deletedDateDateWhen this voucher type was soft deleted, or null if it has not been.
effectiveExpiryModeStringThe expiry mode actually applied: the configured mode when one is set, otherwise one inferred from whichever of the calculator, validity period or fixed date fields is populated. This keeps voucher types created before the mode field existed behaving exactly as they did, with no data migration.
expirationCalculatorConfigStringThe settings the selected expiry rule type needs to do its work. Its content depends entirely on that rule type, so read it through the rule rather than parsing it by hand.
expirationCalculatorIdStringIdentifies the voucher expiry rule type used to work out a voucher's expiry date when it is allocated, which takes precedence over the validity period and the fixed expiry date. Null when no calculator is chosen.
expiryModeStringWhich of the validity period, the fixed expiry date or the expiry calculator is the active source of a voucher's expiry date, as one of the EXPIRY_MODE constants on this class. It is explicit so that no expiry can be a deliberate choice rather than simply the result of leaving every field blank. Null on voucher types created before the field existed, so read getEffectiveExpiryMode instead.
fieldsetNvSetOptional set of custom field definitions collected against each voucher of this type, in display order. Null when the type has no custom fields.
idlongPrimary key of this voucher type, assigned when it is first saved.
modifiedByProfileThe profile of the administrator who last changed this voucher type.
modifiedDateDateWhen this voucher type was last changed. Stored to day precision only.
nameStringPath-safe identifier for this voucher type, unique within the issuing or redeeming organisation among types that have not been deleted. Soft deleting a type renames it with a timestamp suffix so the name becomes free again.
notesStringFree-text notes for administrators about this voucher type. Null when none have been entered.
productSkuProductSkuThe specific product variant this voucher type applies to, when the voucher is tied to one product rather than to an order total. Null for a general purpose voucher.
redeemingOrgOrganisationThe organisation whose administrators can see and redeem vouchers of this type. It is set to the issuing organisation by default, but can be a different one so that vouchers are issued by one organisation and accepted by another.
staticExpiryDateDateFixed calendar date on which every voucher of this type expires, no matter when it was allocated. Only used when the effective expiry mode is date.
templateStringPath of the theme template used to render a printable voucher of this type. Blank or null falls back to the built-in vouchers/printVoucher template.
titleStringFree-text display label for this voucher type, shown to administrators and participants. It is not unique and is not safe to use as a lookup key or path segment.
validForDaysIntegerNumber of days after allocation that a voucher of this type stays valid. Only used when the effective expiry mode is days, and null when expiry is set some other way.
voucherIdTemplateStringMVEL template expression evaluated to produce the identifier printed on each new voucher, letting an organisation use its own code format. Null or blank means a random hexadecimal value is generated instead. Generation retries until the identifier is unused within this type.

Methods

getId() · getTitle() · setTitle(String title) · setOrganisation(Organisation organisation) · getName() · setName(String name) · getNotes() · setNotes(String notes) · getRedeemingOrg() · setRedeemingOrg(Organisation redeemingOrg) · getTemplate() · setTemplate(String template) · getCreatedDate() · setCreatedDate(Date createdDate) · getCreatedBy() · setCreatedBy(Profile createdBy) · getModifiedDate() · setModifiedDate(Date modifiedDate) · getModifiedBy() · setModifiedBy(Profile modifiedBy) · isDeleted() · setDeleted(boolean deleted) · getDeletedDate() · setDeletedDate(Date deletedDate) · getDeletedBy() · setDeletedBy(Profile deletedBy) · getVoucherIdTemplate() · setVoucherIdTemplate(String voucherIdTemplate) · getValidForDays() · setValidForDays(Integer validForDays) · getStaticExpiryDate() · setStaticExpiryDate(Date staticExpiryDate) · getExpirationCalculatorId() · setExpirationCalculatorId(String expirationCalculatorId) · getExpirationCalculatorConfig() · setExpirationCalculatorConfig(String expirationCalculatorConfig) · getExpiryMode() · setExpiryMode(String expiryMode) · getEffectiveExpiryMode() · getCashValue() · setCashValue(BigDecimal cashValue) · getFieldset() · setFieldset(NvSet fieldset) · getContent() · setContent(String content) · getProductSku() · setProductSku(ProductSku productSku) · isAutoCreateVoucher() · setAutoCreateVoucher(Boolean autoCreateVoucher)

getId()

Returns: long

Primary key of this voucher type, assigned when it is first saved.

getTitle()

Returns: String

Free-text display label for this voucher type, shown to administrators and participants. It is not unique and is not safe to use as a lookup key or path segment.

setTitle(String title)

Returns: void

Sets the display title of this voucher type.

ParameterDescription
titlethe voucher type's display title

setOrganisation(Organisation organisation)

Returns: void

Sets the organisation that issues vouchers of this type.

ParameterDescription
organisationthe issuing organisation

getName()

Returns: String

Path-safe identifier for this voucher type, unique within the issuing or redeeming organisation among types that have not been deleted. Soft deleting a type renames it with a timestamp suffix so the name becomes free again.

setName(String name)

Returns: void

Sets the path-safe unique name of this voucher type.

ParameterDescription
namethe voucher type's unique name

getNotes()

Returns: String

Free-text notes for administrators about this voucher type. Null when none have been entered.

setNotes(String notes)

Returns: void

Sets the administrator notes for this voucher type.

ParameterDescription
notesthe notes to record, or null

getRedeemingOrg()

Returns: Organisation

The organisation whose administrators can see and redeem vouchers of this type. It is set to the issuing organisation by default, but can be a different one so that vouchers are issued by one organisation and accepted by another.

setRedeemingOrg(Organisation redeemingOrg)

Returns: void

Sets the organisation whose administrators can see and redeem vouchers of this type.

ParameterDescription
redeemingOrgthe redeeming organisation

getTemplate()

Returns: String

Path of the theme template used to render a printable voucher of this type. Blank or null falls back to the built-in vouchers/printVoucher template.

setTemplate(String template)

Returns: void

Sets the theme template used to render a printable voucher of this type.

ParameterDescription
templatethe print template path, or null for the default

getCreatedDate()

Returns: Date

When this voucher type was created. Stored to day precision only.

setCreatedDate(Date createdDate)

Returns: void

Sets when this voucher type was created.

ParameterDescription
createdDatethe creation date

getCreatedBy()

Returns: Profile

The profile of the administrator who created this voucher type.

setCreatedBy(Profile createdBy)

Returns: void

Sets the profile of the administrator who created this voucher type.

ParameterDescription
createdBythe creating profile

getModifiedDate()

Returns: Date

When this voucher type was last changed. Stored to day precision only.

setModifiedDate(Date modifiedDate)

Returns: void

Sets when this voucher type was last changed.

ParameterDescription
modifiedDatethe last modified date

getModifiedBy()

Returns: Profile

The profile of the administrator who last changed this voucher type.

setModifiedBy(Profile modifiedBy)

Returns: void

Sets the profile of the administrator who last changed this voucher type.

ParameterDescription
modifiedBythe last modifying profile

isDeleted()

Returns: boolean

Whether this voucher type has been soft deleted. Deleted types are excluded from the finders by default and keep their vouchers, so the history of anything already issued survives.

setDeleted(boolean deleted)

Returns: void

Sets the soft deleted flag. Prefer deleteSoft, which also renames the type and records who deleted it.

ParameterDescription
deletedtrue to mark the voucher type as deleted

getDeletedDate()

Returns: Date

When this voucher type was soft deleted, or null if it has not been.

setDeletedDate(Date deletedDate)

Returns: void

Sets when this voucher type was soft deleted.

ParameterDescription
deletedDatethe deletion timestamp, or null

getDeletedBy()

Returns: Profile

The profile of the administrator who soft deleted this voucher type, or null if it has not been deleted.

setDeletedBy(Profile deletedBy)

Returns: void

Sets the profile of the administrator who soft deleted this voucher type.

ParameterDescription
deletedBythe deleting profile, or null

getVoucherIdTemplate()

Returns: String

MVEL template expression evaluated to produce the identifier printed on each new voucher, letting an organisation use its own code format. Null or blank means a random hexadecimal value is generated instead. Generation retries until the identifier is unused within this type.

setVoucherIdTemplate(String voucherIdTemplate)

Returns: void

Sets the MVEL template expression used to generate the identifier printed on each new voucher.

ParameterDescription
voucherIdTemplatethe template expression, or null for random identifiers

getValidForDays()

Returns: Integer

Number of days after allocation that a voucher of this type stays valid. Only used when the effective expiry mode is days, and null when expiry is set some other way.

setValidForDays(Integer validForDays)

Returns: void

Sets how many days after allocation a voucher of this type stays valid.

ParameterDescription
validForDaysthe validity period in days, or null

getStaticExpiryDate()

Returns: Date

Fixed calendar date on which every voucher of this type expires, no matter when it was allocated. Only used when the effective expiry mode is date.

setStaticExpiryDate(Date staticExpiryDate)

Returns: void

Sets the fixed calendar date on which every voucher of this type expires.

ParameterDescription
staticExpiryDatethe fixed expiry date, or null

getExpirationCalculatorId()

Returns: String

Identifies the voucher expiry rule type used to work out a voucher's expiry date when it is allocated, which takes precedence over the validity period and the fixed expiry date. Null when no calculator is chosen.

setExpirationCalculatorId(String expirationCalculatorId)

Returns: void

Sets the voucher expiry rule type used to work out a voucher's expiry date on allocation.

ParameterDescription
expirationCalculatorIdthe expiry rule type identifier, or null

getExpirationCalculatorConfig()

Returns: String

The settings the selected expiry rule type needs to do its work. Its content depends entirely on that rule type, so read it through the rule rather than parsing it by hand.

setExpirationCalculatorConfig(String expirationCalculatorConfig)

Returns: void

Sets the configuration passed to the selected expiry rule type.

ParameterDescription
expirationCalculatorConfigthe expiry calculator configuration, or null

getExpiryMode()

Returns: String

Which of the validity period, the fixed expiry date or the expiry calculator is the active source of a voucher's expiry date, as one of the EXPIRY_MODE constants on this class. It is explicit so that no expiry can be a deliberate choice rather than simply the result of leaving every field blank. Null on voucher types created before the field existed, so read getEffectiveExpiryMode instead.

setExpiryMode(String expiryMode)

Returns: void

Sets which source decides a voucher's expiry date, using one of the EXPIRY_MODE constants on this class.

ParameterDescription
expiryModethe expiry mode to use

getEffectiveExpiryMode()

Returns: String

The expiry mode actually applied: the configured mode when one is set, otherwise one inferred from whichever of the calculator, validity period or fixed date fields is populated. This keeps voucher types created before the mode field existed behaving exactly as they did, with no data migration.

getCashValue()

Returns: BigDecimal

The monetary value a voucher of this type is worth when it is used against an order, in the store's currency. Null means the voucher carries no cash value and cannot be discounted against a checkout total.

setCashValue(BigDecimal cashValue)

Returns: void

Sets the monetary value a voucher of this type is worth.

ParameterDescription
cashValuethe cash value of one voucher, or null

getFieldset()

Returns: NvSet

Optional set of custom field definitions collected against each voucher of this type, in display order. Null when the type has no custom fields.

setFieldset(NvSet fieldset)

Returns: void

Sets the custom field definitions collected against each voucher of this type.

ParameterDescription
fieldsetthe custom field definitions, or null for none

getContent()

Returns: String

The HTML body shown on the voucher itself, edited by administrators and rendered into the voucher page and its PDF. Null when no content has been written.

setContent(String content)

Returns: void

Sets the HTML body shown on the voucher.

ParameterDescription
contentthe voucher content HTML

getProductSku()

Returns: ProductSku

The specific product variant this voucher type applies to, when the voucher is tied to one product rather than to an order total. Null for a general purpose voucher.

setProductSku(ProductSku productSku)

Returns: void

Sets the product variant this voucher type applies to.

ParameterDescription
productSkuthe product variant, or null for a general voucher

isAutoCreateVoucher()

Returns: Boolean

Whether allocating from this type creates a new voucher on demand, instead of handing out one from a pool of vouchers created in advance. Null is treated as false.

setAutoCreateVoucher(Boolean autoCreateVoucher)

Returns: void

Sets whether allocating from this type creates a new voucher on demand.

ParameterDescription
autoCreateVouchertrue to create a voucher on allocation, false or null to allocate from vouchers created in advance
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.