@Override
public PaymentEntity convertTo(Payment source, PaymentEntity destination) {
PaymentEntity result = null;
if (source instanceof IncomingPayment) {
IncomingPaymentEntity incomingPaymentEntity = new IncomingPaymentEntity();
incomingPaymentEntity.setCompleted(source.isCompleted());
incomingPaymentEntity.setCreationDate(source.getCreationDate());
incomingPaymentEntity.setId(source.getId());
Customer customer = ((IncomingPayment) source).getPayer();
CustomerEntity customerEntity = null;
if (customer instanceof PersonalCustomer) {
customerEntity = DozerHelper
.map(customer, PersonalCustomerEntity.class);
}
if (customer instanceof CorporateCustomer) {
customerEntity = DozerHelper.map(customer,
CorporateCustomerEntity.class);
}
incomingPaymentEntity.setPayer(customerEntity);
incomingPaymentEntity.setPaymentDate(source.getPaymentDate());
incomingPaymentEntity.setSubject(source.getSubject());
SubsidiaryEntity subsidiaryEntity = DozerHelper.map(
source.getSubsidiary(), SubsidiaryEntity.class);
incomingPaymentEntity.setSubsidiary(subsidiaryEntity);
incomingPaymentEntity.setTotal(source.getTotal());
incomingPaymentEntity.setType(source.getType());
result = incomingPaymentEntity;
}
if (source instanceof OutgoingPayment) {