A single issued voucher, such as a gift card, discount code or entitlement, belonging to one voucher type. The voucher type holds the template, cash value and expiry rules, and this row is one instance of it identified by its voucherId. Its lifecycle is a single letter status code, see VOUCHER_STATUS_CODE, and every change to that code is copied to a VoucherStatusChange for auditing. A voucher may be allocated either to a Kademi profile or to an external identifier, may carry a cash value and an expiry date that override the ones on the type, and is linked to a Cart when it is redeemed through a checkout. Deletion is soft: a deleted voucher keeps its row and records who deleted it and when.

Group: Database Entities

Implements: Serializable, Relational


Properties

PropertyReturnsDescription
allocatedToProfileThe Kademi profile currently holding this voucher, if it was allocated to a known user. Null when the voucher is unallocated or was allocated to an external recipient, in which case see getAllocatedToId. Cleared by a soft delete. Loaded lazily.
allocatedToIdStringExternal identifier of the recipient holding this voucher, for recipients who are not Kademi profiles. Null when the voucher is unallocated or is allocated to a profile. Cleared by a soft delete.
cancelledbooleanWhether the voucher has been cancelled, meaning its status code is C. Cancelled vouchers can never be redeemed again.
cartCartThe shopping cart this voucher was applied to, set when it is redeemed through a checkout. Null for vouchers redeemed outside a checkout or not yet redeemed. Loaded lazily.
cashValueBigDecimalCash value for this individual voucher, overriding the value on the voucher type. Null means use the type's value, so read getFinalCashValue rather than this when you want the amount actually in force.
createdByProfileThe profile that generated the voucher, normally the administrator who ran the voucher creation. Loaded lazily.
createdDateDateWhen the voucher was generated. This is not the date it was allocated or redeemed, which are tracked by the status date.
deletedByProfileThe profile that soft deleted this voucher. Non-null means the voucher is deleted and should be excluded from listings. Loaded lazily.
deletedDateDateWhen the voucher was soft deleted. The row is kept so the voucher code cannot be reissued and the audit trail survives.
expiryDateDateThe date past which the voucher can no longer be redeemed. It is calculated from the voucher type's expiry rules when the voucher is allocated, is null when there is no expiry, and is cleared by a soft delete.
fieldsNvSetCustom name and value pairs captured against this voucher, matching the field set defined on the voucher type. Use the field method to read a single value safely. Loaded lazily.
finalCashValueBigDecimalThe cash value actually in force for this voucher: the per voucher override if one is set, otherwise the value from the voucher type. This is the amount to use when applying the voucher to an order.
idlongDatabase identifier for this voucher, assigned when the row is first saved.
redeemingOrgOrganisationThe organisation that may redeem this voucher, taken from the voucher type. This is usually different from the organisation that issued the type, and it is one of the two orgs that grant an administrator access to the voucher.
reqDayintDay of the month of the last status change, denormalised from the status date for reporting. Zero until the status is first set.
reqMonthintCalendar month of the last status change, denormalised from the status date for reporting. It is taken straight from java.util.Calendar, so it is zero based: January is 0 and December is 11. Zero also means the status has never been set, so test the status date if you need to tell those apart.
reqYearintCalendar year of the last status change, denormalised from the status date so reports can group by period without a date function. Zero until the status is first set.
statusStringThe single letter lifecycle code: A allocated, I idle, R redeemed, P pending, C cancelled, E expired. Blank or null means the voucher has been generated but not yet put into any state, which is treated as not redeemable.
statusChangedByProfileThe operator who made the most recent status change, for example the staff member who processed the redemption. Loaded lazily.
statusChangedForOrgOrganisationThe branch or store the most recent status change was made on behalf of, which is what redemption reporting groups by. Loaded lazily.
statusDateDateWhen the status was last changed, so for a redeemed voucher this is the redemption date.
voucherIdStringThe voucher code as the recipient sees it, generated from the type's voucher ID template. It is unique within the voucher type, not globally, so always look a voucher up by code and type together.
voucherStatusChangesList<VoucherStatusChange>The audit trail of status changes, one entry per change, each recording the new status, who made it, when, the client IP and any operator notes. Notes added without a status change also appear here.
voucherTypeVoucherTypeThe voucher type this voucher was issued from, which holds the title, template, cash value, expiry rules and the owning and redeeming organisations.
voucherTypeTitleStringDisplay title of the voucher type, as a convenience for listings and templates. This is the free text display label, not the type's portable name, so do not use it as an identifier.

Methods

getId() · getVoucherType() · getVoucherId() · getVoucherStatusChanges() · getCreatedDate() · getCreatedBy() · getAllocatedTo() · getAllocatedToId() · getStatus() · getStatusDate() · getStatusChangedBy() · getStatusChangedForOrg() · getExpiryDate() · getReqYear() · getReqMonth() · getReqDay() · getFields() · getDeletedBy() · getDeletedDate() · getCart() · getCashValue() · isCancelled() · field(String s) · getFinalCashValue() · getVoucherTypeTitle() · getRedeemingOrg() · isAvailableForRedemption(Date now)

getId()

Returns: long

Database identifier for this voucher, assigned when the row is first saved.

getVoucherType()

Returns: VoucherType

The voucher type this voucher was issued from, which holds the title, template, cash value, expiry rules and the owning and redeeming organisations.

getVoucherId()

Returns: String

The voucher code as the recipient sees it, generated from the type's voucher ID template. It is unique within the voucher type, not globally, so always look a voucher up by code and type together.

getVoucherStatusChanges()

Returns: List<VoucherStatusChange>

The audit trail of status changes, one entry per change, each recording the new status, who made it, when, the client IP and any operator notes. Notes added without a status change also appear here.

getCreatedDate()

Returns: Date

When the voucher was generated. This is not the date it was allocated or redeemed, which are tracked by the status date.

getCreatedBy()

Returns: Profile

The profile that generated the voucher, normally the administrator who ran the voucher creation. Loaded lazily.

getAllocatedTo()

Returns: Profile

The Kademi profile currently holding this voucher, if it was allocated to a known user. Null when the voucher is unallocated or was allocated to an external recipient, in which case see getAllocatedToId. Cleared by a soft delete. Loaded lazily.

getAllocatedToId()

Returns: String

External identifier of the recipient holding this voucher, for recipients who are not Kademi profiles. Null when the voucher is unallocated or is allocated to a profile. Cleared by a soft delete.

getStatus()

Returns: String

The single letter lifecycle code: A allocated, I idle, R redeemed, P pending, C cancelled, E expired. Blank or null means the voucher has been generated but not yet put into any state, which is treated as not redeemable.

getStatusDate()

Returns: Date

When the status was last changed, so for a redeemed voucher this is the redemption date.

getStatusChangedBy()

Returns: Profile

The operator who made the most recent status change, for example the staff member who processed the redemption. Loaded lazily.

getStatusChangedForOrg()

Returns: Organisation

The branch or store the most recent status change was made on behalf of, which is what redemption reporting groups by. Loaded lazily.

getExpiryDate()

Returns: Date

The date past which the voucher can no longer be redeemed. It is calculated from the voucher type's expiry rules when the voucher is allocated, is null when there is no expiry, and is cleared by a soft delete.

getReqYear()

Returns: int

Calendar year of the last status change, denormalised from the status date so reports can group by period without a date function. Zero until the status is first set.

getReqMonth()

Returns: int

Calendar month of the last status change, denormalised from the status date for reporting. It is taken straight from java.util.Calendar, so it is zero based: January is 0 and December is 11. Zero also means the status has never been set, so test the status date if you need to tell those apart.

getReqDay()

Returns: int

Day of the month of the last status change, denormalised from the status date for reporting. Zero until the status is first set.

getFields()

Returns: NvSet

Custom name and value pairs captured against this voucher, matching the field set defined on the voucher type. Use the field method to read a single value safely. Loaded lazily.

getDeletedBy()

Returns: Profile

The profile that soft deleted this voucher. Non-null means the voucher is deleted and should be excluded from listings. Loaded lazily.

getDeletedDate()

Returns: Date

When the voucher was soft deleted. The row is kept so the voucher code cannot be reissued and the audit trail survives.

getCart()

Returns: Cart

The shopping cart this voucher was applied to, set when it is redeemed through a checkout. Null for vouchers redeemed outside a checkout or not yet redeemed. Loaded lazily.

getCashValue()

Returns: BigDecimal

Cash value for this individual voucher, overriding the value on the voucher type. Null means use the type's value, so read getFinalCashValue rather than this when you want the amount actually in force.

isCancelled()

Returns: boolean

Whether the voucher has been cancelled, meaning its status code is C. Cancelled vouchers can never be redeemed again.

field(String s)

Returns: String

Reads one custom field value by name, returning null rather than failing when the voucher has no field set at all or has no value for that name.

ParameterDescription
sthe field name, as defined in the voucher type's field set

getFinalCashValue()

Returns: BigDecimal

The cash value actually in force for this voucher: the per voucher override if one is set, otherwise the value from the voucher type. This is the amount to use when applying the voucher to an order.

getVoucherTypeTitle()

Returns: String

Display title of the voucher type, as a convenience for listings and templates. This is the free text display label, not the type's portable name, so do not use it as an identifier.

getRedeemingOrg()

Returns: Organisation

The organisation that may redeem this voucher, taken from the voucher type. This is usually different from the organisation that issued the type, and it is one of the two orgs that grant an administrator access to the voucher.

isAvailableForRedemption(Date now)

Returns: boolean

Tests whether the voucher can be redeemed at the given moment. It must have a status, that status must not be cancelled, redeemed, idle, pending or expired, and its expiry date must not have passed, so in practice only an allocated voucher qualifies. Rejections are logged.

ParameterDescription
nowthe date and time to test against, normally the current time
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.