Class ReconciliationUtils


  • public class ReconciliationUtils
    extends Object
    Provides utility methods to support the reconciliation process.
    Since:
    4.0.0
    • Constructor Detail

      • ReconciliationUtils

        public ReconciliationUtils()
    • Method Detail

      • purgeOldReconciliationFiles

        public static void purgeOldReconciliationFiles​(IFileBasedReconciliation paymentGateway,
                                                       Client client)
                                                throws ParseException
        Purge old reconciliation files from the database.
        Parameters:
        paymentGateway - the payment gateway
        client - the client to delete files for
        Throws:
        ParseException - the parse exception
      • formatDate

        public static String formatDate​(Date date,
                                        String format)
        Format a date to a string using the supplied format string.
        Parameters:
        date - the date to format
        format - the format string
        Returns:
        the string
      • parseDate

        public static Date parseDate​(String dateString,
                                     String format)
                              throws ParseException
        Parse a date time string.
        Parameters:
        dateString - the string representation of the date
        format - the format of the date
        Returns:
        the date
        Throws:
        ParseException - the parse exception
      • calculateSettlementDate

        public static Date calculateSettlementDate​(Client client,
                                                   Date requestTimestamp)
                                            throws ParseException
        This method calculate the settlement date for a timestamp.
        Parameters:
        client - the client object which hold the batch cut off time
        requestTimestamp - the transaction time stamp
        Returns:
        the settlement date
        Throws:
        ParseException - the parse exception
      • moveDateToNextBusinessDay

        public static Date moveDateToNextBusinessDay​(Date date)
        Move to the next business day if the date falls on a weekend.
        Parameters:
        date - the date
        Returns:
        the next business date
      • adjustDateByDays

        public static Date adjustDateByDays​(Date date,
                                            int incrementDays)
        Add a number of days to the specified date.
        Parameters:
        date - the date
        incrementDays - the number of dates to add
        Returns:
        the new date
      • moveDateToPreviousBusinessDay

        public static Date moveDateToPreviousBusinessDay​(Date date)
        Move date to the previous business day if the day falls on a weekend.
        Parameters:
        date - the date
        Returns:
        the new date
      • setTimeToBatchCutOff

        public static Date setTimeToBatchCutOff​(Client client,
                                                Date date)
                                         throws ParseException
        Set the time part of the specified date to the time stamp of the batch cut off for that day.
        Parameters:
        client - the client to that defines the batch cut off
        date - the date
        Returns:
        the new date
        Throws:
        ParseException - the parse exception
      • getFileDateForLastReconciliationFile

        public static Date getFileDateForLastReconciliationFile​(Client client,
                                                                Date nowDate)
                                                         throws ParseException
        Work out the date for the last reconcilaiton file that should have been received.
        Parameters:
        client - the client to that defines the batch cut off
        nowDate - the now date
        Returns:
        the new date
        Throws:
        ParseException - the parse exception
      • loadReconciliatonFile

        public static ReconciliationFile loadReconciliatonFile​(Map<String,​ReconciliationFile> reconciliationFiles,
                                                               Client client,
                                                               Date dateStamp,
                                                               Map<String,​Object> csvConfig)
                                                        throws IOException,
                                                               ParseException
        Load the specified reconciliation file into the cache.
        Parameters:
        reconciliationFiles - the cache
        client - the client the file is for
        dateStamp - the file date stamp
        csvConfig - the file format configuration
        Returns:
        the reconciliation file, null if the file was not found
        Throws:
        IOException - Signals that an I/O exception has occurred.
        ParseException - the parse exception
      • importReconciliationFile

        public static Map<String,​ReconciliationFile> importReconciliationFile​(Client client,
                                                                                    String fileName,
                                                                                    Date settlementDate,
                                                                                    byte[] fileContent,
                                                                                    Map<String,​Object> config)
                                                                             throws IOException,
                                                                                    ParseException
        Load the specified reconciliation file into the cache.
        Parameters:
        client - the client the file is for
        fileName - the file name
        settlementDate - the settlement date the file represents
        fileContent - the contents of the file
        config - the reconciliation configuration
        Returns:
        the reconciliation file map, This may contain multiple files if the reconciliation file represents multiple dates
        Throws:
        IOException - Signals that an I/O exception has occurred.
        ParseException - the parse exception
      • processReconciliationFile

        public static void processReconciliationFile​(Client client,
                                                     String fileName,
                                                     Date settlementDate,
                                                     byte[] fileContent,
                                                     IFileBasedReconciliation paymentGateway)
        Resolve any payment transactions within the reconciliation file for the specified date. The file will also be stored in the client reconciliation file table.
        Parameters:
        client - the file relates to
        fileName - the file name
        settlementDate - the settlementDate date
        fileContent - the file content
        paymentGateway - payment gateway
      • reconcilePaymentLog

        public static void reconcilePaymentLog​(PaymentLog paymentLog,
                                               IFileBasedReconciliation paymentGateway,
                                               Map<String,​ReconciliationFile> reconciliationFiles)
        Attempt to reconcile a individual payment log.
        Parameters:
        paymentLog - the payment log to reconcile
        paymentGateway - the payment gateway
        reconciliationFiles - the reconciliation file cache to file additional files
      • getNowDate

        public static Date getNowDate​(IFileBasedReconciliation paymentGateway)
        This method will return the now date to use for the reconciliation processing.
        Parameters:
        paymentGateway - the payment gateway
        Returns:
        the now date