@Override public String value(WrappedBooking input) { return Attribute.normalize(input.getPurpose()); } },
@Override public void modify(WrappedBooking booking) { if (StringUtils.startsWithIgnoreCase(booking.getReferenceName(), "PayPal") && booking.getPurpose() != null) { Matcher matcher = PAYPAL_PURPOSE_PATTERN.matcher(booking.getPurpose()); if (matcher.matches() && matcher.groupCount() == 4) { booking.setOtherAccount("PayPal Zahlung an " + matcher.group(3)); } } }
@Override public boolean match(WrappedBooking wrappedBooking) { switch (rule.getSimilarityMatchType()) { case IBAN: return StringUtils.equalsIgnoreCase(rule.getExpression(), wrappedBooking.getBankConnection()); case REFERENCE_NAME: if (wrappedBooking.getReferenceName() != null) { Double result = JARO_WINKLER.apply(rule.getExpression(), wrappedBooking.getReferenceName().toLowerCase()); if (result >= MIN_DISTANCE) { log.debug("similarity expression {} compared with {} resulted in score {}", rule.getExpression(), wrappedBooking.getReferenceName().toLowerCase(), result); } return result >= MIN_DISTANCE; } return false; case PURPOSE: Double result = JARO_WINKLER.apply(rule.getExpression(), normalize(wrappedBooking.getPurpose())); if (result >= MIN_DISTANCE) { log.debug("similarity expression {} compared with {} resulted in score {}", rule.getExpression(), normalize(wrappedBooking.getPurpose()), result); } return result >= MIN_DISTANCE; } throw new IllegalArgumentException("missing match type"); }
/** * Assert if the given booking is a recurrent non sepa booking. * <p> * If a blacklist is defined each entry will be matched with the given input. * If all non null attribute values of the blacklist entry matches the booking will be refused. * * @param booking the booking to be asserted * @param blacklist booking templates to be false * @return true if the booking is a recurrent non sepa booking otherwise false. */ public static boolean isRecurrent(WrappedBooking booking, List<Matcher> blacklist) { // should only have negative amount if (booking.getAmount() == null || booking.getAmount().compareTo(BigDecimal.ZERO) >= 0) { return false; } // should have a purpose if (booking.getPurpose() == null) { return false; } // should not have a valid creditorId if (booking.getCreditorId() != null) { return false; } for (Matcher backlistEntry : blacklist) { if (backlistEntry.match(booking)) { return false; } } return true; }
if (booking.getPurpose() == null) { return false;
/** * Assert if the given booking is a recurrent income booking. * * @param booking the booking to be asserted * @return true if the booking is a recurrent income booking otherwise false. */ public static boolean isRecurrent(WrappedBooking booking) { // should only have positive amount if (booking.getAmount() == null || booking.getAmount().compareTo(BigDecimal.ZERO) < 0) { return false; } // should have a purpose if (booking.getPurpose() == null) { return false; } // should not have a valid bank connection return booking.getIban() != null || (booking.getBankCode() != null && booking.getAccountNumber() != null) || booking.getReferenceName() != null; }
@Override public BookingGroup createGroup(WrappedBooking booking) { if (booking == null || booking.getPurpose() == null || booking.getMandateReference() == null || booking.getCreditorId() == null || booking.getRuleIds() == null) { return null; } log.trace("create group for {}, {}", booking.getCreditorId(), booking.getMandateReference()); return new BookingGroup(booking.getCreditorId()+"|"+booking.getMandateReference(), booking.getRuleIds().toString(), getGroupName(), getGroupType()); }
@Override public BookingGroup createGroup(WrappedBooking booking) { if (booking == null) { return null; } if (booking.getRuleIds() != null) { return new BookingGroup(booking.getBankConnection(), booking.getRuleIds().toString(), getGroupName(), getGroupType()); } return new BookingGroup(booking.getBankConnection(), booking.getPurpose(), getGroupName(), getGroupType()); }