@Override public RefundJson apply(final Refund refund) { UUID kbAccountId = null; if (!AuditLevel.NONE.equals(auditMode.getLevel()) && paymentIdAccountIdMappings.get(refund.getPaymentId()) == null) { try { kbAccountId = paymentApi.getPayment(refund.getPaymentId(), false, tenantContext).getAccountId(); paymentIdAccountIdMappings.put(refund.getPaymentId(), kbAccountId); } catch (final PaymentApiException e) { log.warn("Unable to retrieve payment for id " + refund.getPaymentId()); } } // Cache audit logs per account if (accountsAuditLogs.get().get(kbAccountId) == null) { accountsAuditLogs.get().put(kbAccountId, auditUserApi.getAccountAuditLogs(kbAccountId, auditMode.getLevel(), tenantContext)); } final List<AuditLog> auditLogs = accountsAuditLogs.get().get(kbAccountId) == null ? null : accountsAuditLogs.get().get(kbAccountId).getAuditLogsForRefund(refund.getId()); return new RefundJson(refund, null, auditLogs); } },
@Override public RefundJson apply(final Refund refund) { UUID kbAccountId = null; if (!AuditLevel.NONE.equals(auditMode.getLevel()) && paymentIdAccountIdMappings.get(refund.getPaymentId()) == null) { try { kbAccountId = paymentApi.getPayment(refund.getPaymentId(), false, tenantContext).getAccountId(); paymentIdAccountIdMappings.put(refund.getPaymentId(), kbAccountId); } catch (final PaymentApiException e) { log.warn("Unable to retrieve payment for id " + refund.getPaymentId()); } } // Cache audit logs per account if (accountsAuditLogs.get().get(kbAccountId) == null) { accountsAuditLogs.get().put(kbAccountId, auditUserApi.getAccountAuditLogs(kbAccountId, auditMode.getLevel(), tenantContext)); } final List<AuditLog> auditLogs = accountsAuditLogs.get().get(kbAccountId) == null ? null : accountsAuditLogs.get().get(kbAccountId).getAuditLogsForRefund(refund.getId()); return new RefundJson(refund, null, auditLogs); } },
public RefundJson(final Refund refund, @Nullable final List<InvoiceItem> adjustments, @Nullable final List<AuditLog> auditLogs) { this(refund.getId().toString(), refund.getPaymentId().toString(), refund.getRefundAmount(), refund.getCurrency().toString(), refund.getRefundStatus().toString(), refund.isAdjusted(), refund.getEffectiveDate(), refund.getEffectiveDate(), adjustments == null ? null : ImmutableList.<InvoiceItemJson>copyOf(Collections2.transform(adjustments, new Function<InvoiceItem, InvoiceItemJson>() { @Override public InvoiceItemJson apply(@Nullable final InvoiceItem input) { return new InvoiceItemJson(input); } })), toAuditLogJson(auditLogs)); }
final Multimap<UUID, Refund> refundsByPayment = ArrayListMultimap.<UUID, Refund>create(); for (final Refund refund : refunds) { refundsByPayment.put(refund.getPaymentId(), refund);