Class Bill
- java.lang.Object
-
- net.codecrete.qrbill.generator.Bill
-
- All Implemented Interfaces:
java.io.Serializable
public class Bill extends java.lang.Object implements java.io.SerializableQR bill data- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBill.VersionQR bill version
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREFERENCE_TYPE_CRED_REFReference type: creditor reference (ISO 11649)static java.lang.StringREFERENCE_TYPE_NO_REFReference type: without reference.static java.lang.StringREFERENCE_TYPE_QR_REFReference type: QR reference.
-
Constructor Summary
Constructors Constructor Description Bill()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateAndSetCreditorReference(java.lang.String rawReference)Creates and sets a ISO11649 creditor reference from a raw string by prefixing the String with "RF" and the modulo 97 checksum.voidcreateAndSetQRReference(java.lang.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.booleanequals(java.lang.Object o)java.lang.StringgetAccount()Gets the creditor's account number.AlternativeScheme[]getAlternativeSchemes()Get the alternative schemes.java.math.BigDecimalgetAmount()Gets the payment amountjava.lang.DoublegetAmountAsDouble()Gets the payment amount as aDoubleinstancejava.lang.StringgetBillInformation()Gets the additional bill information.AddressgetCreditor()Gets the creditor address.java.lang.StringgetCurrency()Gets the payment currency.AddressgetDebtor()Gets the debtor's address.BillFormatgetFormat()Gets the bill format.java.lang.StringgetReference()Gets the payment referencejava.lang.StringgetReferenceType()Gets the type of payment reference.java.lang.StringgetUnstructuredMessage()Gets the additional unstructured message.Bill.VersiongetVersion()Gets the version of the QR bill standard.inthashCode()voidsetAccount(java.lang.String account)Sets the creditor's account number.voidsetAlternativeSchemes(AlternativeScheme[] alternativeSchemes)Sets the alternative scheme parameters.voidsetAmount(java.math.BigDecimal amount)Sets the payment amount.voidsetAmountFromDouble(java.lang.Double amount)Sets the payment amount from aDoublesolid-line-with_scissorsvoidsetBillInformation(java.lang.String billInformation)Sets the additional bill informationvoidsetCreditor(Address creditor)Sets the creditor address.voidsetCurrency(java.lang.String currency)Sets the payment currency.voidsetDebtor(Address debtor)Sets the debtor's address.voidsetFormat(BillFormat format)Sets the bill format.voidsetReference(java.lang.String reference)Sets the payment reference.voidsetReferenceType(java.lang.String referenceType)Sets the type of payment reference.voidsetUnstructuredMessage(java.lang.String unstructuredMessage)Sets the additional unstructured message.voidsetVersion(Bill.Version version)Sets the version of the QR bill standard.java.lang.StringtoString()voidupdateReferenceType()Updates the reference type by deriving it from the payment reference.
-
-
-
Field Detail
-
REFERENCE_TYPE_NO_REF
public static final java.lang.String REFERENCE_TYPE_NO_REF
Reference type: without reference.- See Also:
- Constant Field Values
-
REFERENCE_TYPE_QR_REF
public static final java.lang.String REFERENCE_TYPE_QR_REF
Reference type: QR reference.- See Also:
- Constant Field Values
-
REFERENCE_TYPE_CRED_REF
public static final java.lang.String REFERENCE_TYPE_CRED_REF
Reference type: creditor reference (ISO 11649)- See Also:
- Constant Field Values
-
-
Method Detail
-
getVersion
public Bill.Version getVersion()
Gets the version of the QR bill standard.- Returns:
- the version
-
setVersion
public void setVersion(Bill.Version version)
Sets the version of the QR bill standard.- Parameters:
version- the version
-
getAmount
public java.math.BigDecimal getAmount()
Gets the payment amount- Returns:
- the amount
-
getAmountAsDouble
public java.lang.Double getAmountAsDouble()
Gets the payment amount as aDoubleinstance- Returns:
- the amount
-
setAmount
public void setAmount(java.math.BigDecimal amount)
Sets the payment amount.Valid values are between 0.01 and 999,999,999.99
- Parameters:
amount- the amount
-
setAmountFromDouble
public void setAmountFromDouble(java.lang.Double amount)
Sets the payment amount from aDoublesolid-line-with_scissorsThe value is saved with a scale of 2.
- Parameters:
amount- the amount
-
getCurrency
public java.lang.String getCurrency()
Gets the payment currency.- Returns:
- the currency
-
setCurrency
public void setCurrency(java.lang.String currency)
Sets the payment currency.Valid values are "CHF" and "EUR".
- Parameters:
currency- the currency
-
getAccount
public java.lang.String getAccount()
Gets the creditor's account number.- Returns:
- the account number
-
setAccount
public void setAccount(java.lang.String account)
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
public Address getCreditor()
Gets the creditor address.- Returns:
- the creditor address
-
setCreditor
public void setCreditor(Address creditor)
Sets the creditor address.- Parameters:
creditor- the creditor address.
-
getReferenceType
public java.lang.String 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:
REFERENCE_TYPE_QR_REF,REFERENCE_TYPE_CRED_REF,REFERENCE_TYPE_NO_REF
-
setReferenceType
public void setReferenceType(java.lang.String referenceType)
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:
REFERENCE_TYPE_QR_REF,REFERENCE_TYPE_CRED_REF,REFERENCE_TYPE_NO_REF
-
updateReferenceType
public void updateReferenceType()
Updates the reference type by deriving it from the payment reference.
-
getReference
public java.lang.String getReference()
Gets the payment reference- Returns:
- the reference
-
setReference
public void setReference(java.lang.String reference)
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(String),createAndSetQRReference(String)
-
createAndSetCreditorReference
public void createAndSetCreditorReference(java.lang.String rawReference)
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:
java.lang.IllegalArgumentException- ifrawReferencecontains invalid characters
-
createAndSetQRReference
public void createAndSetQRReference(java.lang.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.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:
java.lang.IllegalArgumentException- ifrawReferencecontains invalid characters
-
getDebtor
public Address getDebtor()
Gets the debtor's address.- Returns:
- the debtor address
-
setDebtor
public void setDebtor(Address debtor)
Sets the debtor's address.The debtor is optional. If it is omitted, both setting this field to
nullor setting an address with allnullor empty values is ok.- Parameters:
debtor- the debtor address
-
getUnstructuredMessage
public java.lang.String getUnstructuredMessage()
Gets the additional unstructured message.- Returns:
- the unstructured message
-
setUnstructuredMessage
public void setUnstructuredMessage(java.lang.String unstructuredMessage)
Sets the additional unstructured message.- Parameters:
unstructuredMessage- the unstructured message
-
getBillInformation
public java.lang.String getBillInformation()
Gets the additional bill information.- Returns:
- bill information
-
setBillInformation
public void setBillInformation(java.lang.String billInformation)
Sets the additional bill information- Parameters:
billInformation- bill information
-
getAlternativeSchemes
public AlternativeScheme[] getAlternativeSchemes()
Get the alternative schemes.A maximum of two schemes are allowed.
- Returns:
- alternative schemes
-
setAlternativeSchemes
public void setAlternativeSchemes(AlternativeScheme[] alternativeSchemes)
Sets the alternative scheme parameters.A maximum of two schemes with parameters are allowed.
- Parameters:
alternativeSchemes- alternative payment scheme information
-
getFormat
public BillFormat getFormat()
Gets the bill format.- Returns:
- bill format
-
setFormat
public void setFormat(BillFormat format)
Sets the bill format.- Parameters:
format- bill format
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-