Class Bill
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createAndSetCreditorReference
(String rawReference) Creates and sets a ISO11649 creditor reference from a raw string by prefixing the String with "RF" and the modulo 97 checksum.void
createAndSetQRReference
(String rawReference) Creates and sets a QR reference from a raw string by appending the checksum digit and prepending zeros to make it the correct length.boolean
Gets the creditor's account number.Get the alternative schemes.Gets the payment amountGets the payment amount as aDouble
instanceGets the additional bill information.Gets the character set used for the QR bill data.Gets the creditor address.Gets the payment currency.Gets the debtor's address.Gets the bill format.Gets the payment referenceGets the type of payment reference.Gets the line separator for the QR code data fields.Gets the additional unstructured message.Gets the version of the QR bill standard.int
hashCode()
void
setAccount
(String account) Sets the creditor's account number.void
setAlternativeSchemes
(AlternativeScheme[] alternativeSchemes) Sets the alternative scheme parameters.void
setAmount
(BigDecimal amount) Sets the payment amount.void
setAmountFromDouble
(Double amount) Sets the payment amount from aDouble
solid-line-with_scissorsvoid
setBillInformation
(String billInformation) Sets the additional bill informationvoid
setCharacterSet
(SPSCharacterSet characterSet) Sets the character set used for the QR bill data.void
setCreditor
(Address creditor) Sets the creditor address.void
setCurrency
(String currency) Sets the payment currency.void
Sets the debtor's address.void
setFormat
(BillFormat format) Sets the bill format.void
setReference
(String reference) Sets the payment reference.void
setReferenceType
(String referenceType) Sets the type of payment reference.void
setSeparator
(QrDataSeparator separator) Sets the line separator for the QR code data fields.void
setUnstructuredMessage
(String unstructuredMessage) Sets the additional unstructured message.void
setVersion
(Bill.Version version) Sets the version of the QR bill standard.toString()
void
Updates the reference type by deriving it from the payment reference.
-
Field Details
-
REFERENCE_TYPE_NO_REF
Reference type: without reference.- See Also:
-
REFERENCE_TYPE_QR_REF
Reference type: QR reference.- See Also:
-
REFERENCE_TYPE_CRED_REF
Reference type: creditor reference (ISO 11649)- See Also:
-
-
Constructor Details
-
Bill
public Bill()Creates a new instance with default values for the format.
-
-
Method Details
-
getVersion
Gets the version of the QR bill standard.- Returns:
- the version
-
setVersion
Sets the version of the QR bill standard.- Parameters:
version
- the version
-
getAmount
Gets the payment amount- Returns:
- the amount
-
getAmountAsDouble
Gets the payment amount as aDouble
instance- Returns:
- the amount
-
setAmount
Sets the payment amount.Valid values are between 0.01 and 999,999,999.99
- Parameters:
amount
- the amount
-
setAmountFromDouble
Sets the payment amount from aDouble
solid-line-with_scissorsThe value is saved with a scale of 2.
- Parameters:
amount
- the amount
-
getCurrency
Gets the payment currency.- Returns:
- the currency
-
setCurrency
Sets the payment currency.Valid values are "CHF" and "EUR".
- Parameters:
currency
- the currency
-
getAccount
Gets the creditor's account number.- Returns:
- the account number
-
setAccount
Sets the creditor's account number.Account numbers must be valid IBANs of a bank of Switzerland or Liechtenstein. Spaces are allowed in the account number.
- Parameters:
account
- the account number
-
getCreditor
Gets the creditor address.- Returns:
- the creditor address
-
setCreditor
Sets the creditor address.- Parameters:
creditor
- the creditor address.
-
getReferenceType
Gets the type of payment reference.The reference type is automatically set when a payment reference is set.
- Returns:
- one of the constants REFERENCE_TYPE_xxx.
- See Also:
-
setReferenceType
Sets the type of payment reference.Usually there is no need to set the reference type as it is automatically set when a payment reference is set..
- Parameters:
referenceType
- one of the constantsREFERENCE_TYPE_xx
- See Also:
-
updateReferenceType
public void updateReferenceType()Updates the reference type by deriving it from the payment reference. -
getReference
Gets the payment reference- Returns:
- the reference
-
setReference
Sets the payment reference.The reference is mandatory for QR IBANs, i.e. IBANs in the range CHxx30000xxxxxx through CHxx31999xxxxx. QR IBANs require a valid QR reference (numeric reference corresponding to the ISR reference format).
For non-QR IBANs, the reference is optional. If it is provided, it must be valid creditor reference according to ISO 11649 ("RFxxxx").
Both types of references may contain spaces for formatting.
- Parameters:
reference
- the payment reference number- See Also:
-
createAndSetCreditorReference
Creates and sets a ISO11649 creditor reference from a raw string by prefixing the String with "RF" and the modulo 97 checksum.Whitespace is removed from the reference
- Parameters:
rawReference
- The raw string- Throws:
IllegalArgumentException
- ifrawReference
contains invalid characters
-
createAndSetQRReference
Creates and sets a QR reference from a raw string by appending the checksum digit and prepending zeros to make it the correct length.As the QR reference is numeric, the raw string must consist of digits and whitespace only. Whitespace is removed from the reference.
- Parameters:
rawReference
- The raw string- Throws:
IllegalArgumentException
- ifrawReference
contains invalid characters
-
getDebtor
Gets the debtor's address.- Returns:
- the debtor address
-
setDebtor
Sets the debtor's address.The debtor is optional. If it is omitted, both setting this field to
null
or setting an address with allnull
or empty values is ok.- Parameters:
debtor
- the debtor address
-
getUnstructuredMessage
Gets the additional unstructured message.- Returns:
- the unstructured message
-
setUnstructuredMessage
Sets the additional unstructured message.- Parameters:
unstructuredMessage
- the unstructured message
-
getBillInformation
Gets the additional bill information.- Returns:
- bill information
-
setBillInformation
Sets the additional bill information- Parameters:
billInformation
- bill information
-
getAlternativeSchemes
Get the alternative schemes.A maximum of two schemes are allowed.
- Returns:
- alternative schemes
-
setAlternativeSchemes
Sets the alternative scheme parameters.A maximum of two schemes with parameters are allowed.
- Parameters:
alternativeSchemes
- alternative payment scheme information
-
getFormat
Gets the bill format.- Returns:
- bill format
-
setFormat
Sets the bill format.- Parameters:
format
- bill format
-
getSeparator
Gets the line separator for the QR code data fields.The default is
QrDataSeparator.LF
. There is no need to change it except for improving compatibility with a non-compliant software processing the QR code data.- Returns:
- the line separator for the QR code data fields.
-
setSeparator
Sets the line separator for the QR code data fields.The default is
QrDataSeparator.LF
. There is no need to change it except for improving compatibility with a non-compliant software processing the QR code data.- Parameters:
separator
- the line separator for the QR code data fields.
-
getCharacterSet
Gets the character set used for the QR bill data.Defaults to
SPSCharacterSet.LATIN_1_SUBSET
.Until November 21, 2025,
SPSCharacterSet.LATIN_1_SUBSET
is the only value that will generate QR bills accepted by all banks. This will change by November 21, 2025.- Returns:
- the character set used for the QR bill data.
-
setCharacterSet
Sets the character set used for the QR bill data.Defaults to
SPSCharacterSet.LATIN_1_SUBSET
.Until November 21, 2025,
SPSCharacterSet.LATIN_1_SUBSET
is the only value that will generate QR bills accepted by all banks. This will change by November 21, 2025.- Parameters:
characterSet
- the character set used for the QR bill data.
-
equals
-
hashCode
public int hashCode() -
toString
-