java.lang.Object
ch.tocco.nice2.optional.finance.api.service.referencecode.ReferenceCodeHelper

@Component public class ReferenceCodeHelper extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Generates the validation digit at the end of the qrr reference code it is based on modulo10 recursive and the VALIDATION_LINE
    static String
    addScorChecksum(String scorReference)
    Generates the mod 97-10 checksum of the scor reference and adds it to the reference Uses the CHARACTER_TRANSLATION_MAP to translate non-numeric characters
    static String
    Gets the string value of "the" counter field of the given entity throws an exception if the entity does not have a singular counter field
    static String
    getScorPrintFormat(String scorReference)
    Shortens a SCOR reference by removing all leading zeros after the checksum
    static String
    Extends a SCOR reference to its maximum length of 25 characters this is done by adding 0 after the checksum e.g.
    static String
    padLeft(String number, int length)
    pads a string with zeros to the left throws an exception if the counterNr is longer than the given maximum length

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getCounter

      public static String getCounter(Entity entity)
      Gets the string value of "the" counter field of the given entity throws an exception if the entity does not have a singular counter field
    • padLeft

      public static String padLeft(String number, int length)
      pads a string with zeros to the left throws an exception if the counterNr is longer than the given maximum length
    • addQrrValidationNumber

      public static String addQrrValidationNumber(String referenceCode)
      Generates the validation digit at the end of the qrr reference code it is based on modulo10 recursive and the VALIDATION_LINE
      Parameters:
      referenceCode - the 26-length reference code without a validation digit
      Returns:
      the 27-length reference code including the validation digit
    • addScorChecksum

      public static String addScorChecksum(String scorReference)
      Generates the mod 97-10 checksum of the scor reference and adds it to the reference Uses the CHARACTER_TRANSLATION_MAP to translate non-numeric characters
      Parameters:
      scorReference - the content of the scor reference (max 21 chars, alphanumeric, e.g. 93T9608)
      Returns:
      the finalized scor reference number (e.g. RF839309608)
    • getScorTechnicalFormat

      public static String getScorTechnicalFormat(String scorReference)
      Extends a SCOR reference to its maximum length of 25 characters this is done by adding 0 after the checksum e.g. RF839309608 -> RF83000000000000009309608
      Parameters:
      scorReference - a print format scor reference (e.g. RF839309608)
      Returns:
      a technical format scor reference (e.g. RF83000000000000009309608)
    • getScorPrintFormat

      public static String getScorPrintFormat(String scorReference)
      Shortens a SCOR reference by removing all leading zeros after the checksum
      Parameters:
      scorReference - a technical-format scor reference (e.g. RF83000000000000009309608)
      Returns:
      a print-format scor reference (e.g. RF839309608)