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
| Property | Returns | Description |
|---|---|---|
| autoCreateVoucher | 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. |
| cashValue | 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. |
| content | 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. |
| createdBy | Profile | The profile of the administrator who created this voucher type. |
| createdDate | Date | When this voucher type was created. Stored to day precision only. |
| deleted | 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. |
| deletedBy | Profile | The profile of the administrator who soft deleted this voucher type, or null if it has not been deleted. |
| deletedDate | Date | When this voucher type was soft deleted, or null if it has not been. |
| effectiveExpiryMode | 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. |
| expirationCalculatorConfig | 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. |
| expirationCalculatorId | 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. |
| expiryMode | 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. |
| fieldset | 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. |
| id | long | Primary key of this voucher type, assigned when it is first saved. |
| modifiedBy | Profile | The profile of the administrator who last changed this voucher type. |
| modifiedDate | Date | When this voucher type was last changed. Stored to day precision only. |
| name | 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. |
| notes | String | Free-text notes for administrators about this voucher type. Null when none have been entered. |
| productSku | 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. |
| redeemingOrg | 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. |
| staticExpiryDate | 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. |
| template | 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. |
| title | 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. |
| validForDays | 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. |
| voucherIdTemplate | 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. |
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.
| Parameter | Description |
|---|---|
title | the voucher type's display title |
setOrganisation(Organisation organisation)
Returns: void
Sets the organisation that issues vouchers of this type.
| Parameter | Description |
|---|---|
organisation | the 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.
| Parameter | Description |
|---|---|
name | the 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.
| Parameter | Description |
|---|---|
notes | the 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.
| Parameter | Description |
|---|---|
redeemingOrg | the 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.
| Parameter | Description |
|---|---|
template | the 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.
| Parameter | Description |
|---|---|
createdDate | the 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.
| Parameter | Description |
|---|---|
createdBy | the 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.
| Parameter | Description |
|---|---|
modifiedDate | the 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.
| Parameter | Description |
|---|---|
modifiedBy | the 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.
| Parameter | Description |
|---|---|
deleted | true 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.
| Parameter | Description |
|---|---|
deletedDate | the 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.
| Parameter | Description |
|---|---|
deletedBy | the 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.
| Parameter | Description |
|---|---|
voucherIdTemplate | the 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.
| Parameter | Description |
|---|---|
validForDays | the 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.
| Parameter | Description |
|---|---|
staticExpiryDate | the 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.
| Parameter | Description |
|---|---|
expirationCalculatorId | the 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.
| Parameter | Description |
|---|---|
expirationCalculatorConfig | the 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.
| Parameter | Description |
|---|---|
expiryMode | the 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.
| Parameter | Description |
|---|---|
cashValue | the 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.
| Parameter | Description |
|---|---|
fieldset | the 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.
| Parameter | Description |
|---|---|
content | the 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.
| Parameter | Description |
|---|---|
productSku | the 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.
| Parameter | Description |
|---|---|
autoCreateVoucher | true to create a voucher on allocation, false or null to allocate from vouchers created in advance |