Class ReconciliationUtils
- java.lang.Object
-
- com.avoka.fc.core.service.payment.reconciliation.ReconciliationUtils
-
public class ReconciliationUtils extends Object
Provides utility methods to support the reconciliation process.- Since:
- 4.0.0
-
-
Constructor Summary
Constructors Constructor Description ReconciliationUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Date
adjustDateByDays(Date date, int incrementDays)
Add a number of days to the specified date.static Date
calculateSettlementDate(Client client, Date requestTimestamp)
This method calculate the settlement date for a timestamp.static String
formatDate(Date date, String format)
Format a date to a string using the supplied format string.static Date
getFileDateForLastReconciliationFile(Client client, Date nowDate)
Work out the date for the last reconcilaiton file that should have been received.static Date
getNowDate(IFileBasedReconciliation paymentGateway)
This method will return the now date to use for the reconciliation processing.static Map<String,ReconciliationFile>
importReconciliationFile(Client client, String fileName, Date settlementDate, byte[] fileContent, Map<String,Object> config)
Load the specified reconciliation file into the cache.static ReconciliationFile
loadReconciliatonFile(Map<String,ReconciliationFile> reconciliationFiles, Client client, Date dateStamp, Map<String,Object> csvConfig)
Load the specified reconciliation file into the cache.static Date
moveDateToNextBusinessDay(Date date)
Move to the next business day if the date falls on a weekend.static Date
moveDateToPreviousBusinessDay(Date date)
Move date to the previous business day if the day falls on a weekend.static Date
parseDate(String dateString, String format)
Parse a date time string.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.static void
purgeOldReconciliationFiles(IFileBasedReconciliation paymentGateway, Client client)
Purge old reconciliation files from the database.static void
reconcilePaymentLog(PaymentLog paymentLog, IFileBasedReconciliation paymentGateway, Map<String,ReconciliationFile> reconciliationFiles)
Attempt to reconcile a individual payment log.static Date
setTimeToBatchCutOff(Client client, Date date)
Set the time part of the specified date to the time stamp of the batch cut off for that day.
-
-
-
Method Detail
-
purgeOldReconciliationFiles
public static void purgeOldReconciliationFiles(IFileBasedReconciliation paymentGateway, Client client) throws ParseException
Purge old reconciliation files from the database.- Parameters:
paymentGateway
- the payment gatewayclient
- 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 formatformat
- 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 dateformat
- 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 timerequestTimestamp
- 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 dateincrementDays
- 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 offdate
- 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 offnowDate
- 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 cacheclient
- the client the file is fordateStamp
- the file date stampcsvConfig
- 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 forfileName
- the file namesettlementDate
- the settlement date the file representsfileContent
- the contents of the fileconfig
- 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 tofileName
- the file namesettlementDate
- the settlementDate datefileContent
- the file contentpaymentGateway
- 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 reconcilepaymentGateway
- the payment gatewayreconciliationFiles
- 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
-
-