@Override public String getFormattedAmount() { final NumberFormat number = NumberFormat.getCurrencyInstance(locale); number.setCurrency(java.util.Currency.getInstance(item.getCurrency().toString())); return number.format(getAmount().doubleValue()); }
public PriceJson(final Price price) throws CurrencyValueNull { this(price.getCurrency().toString(), price.getValue()); }
public ChargebackJson(final UUID accountId, final InvoicePayment chargeback, @Nullable final List<AuditLog> auditLogs) { this(chargeback.getId().toString(), accountId.toString(), chargeback.getPaymentDate(), chargeback.getPaymentDate(), chargeback.getAmount().negate(), chargeback.getPaymentId().toString(), chargeback.getCurrency().toString(), toAuditLogJson(auditLogs)); }
@Override public PriceJson apply(final Price price) { try { return new PriceJson(price); } catch (CurrencyValueNull e) { return new PriceJson(price.getCurrency().toString(), BigDecimal.ZERO); } } });
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)); }
private InvoiceJson createInvoice() { final UUID accountId = UUID.randomUUID(); final UUID invoiceId = UUID.randomUUID(); final BigDecimal invoiceAmount = BigDecimal.TEN; final BigDecimal creditAdj = BigDecimal.ONE; final BigDecimal refundAdj = BigDecimal.ONE; final LocalDate invoiceDate = clock.getUTCToday(); final LocalDate targetDate = clock.getUTCToday(); final String invoiceNumber = UUID.randomUUID().toString(); final BigDecimal balance = BigDecimal.ZERO; return new InvoiceJson(invoiceAmount, Currency.USD.toString(), creditAdj, refundAdj, invoiceId.toString(), invoiceDate, targetDate, invoiceNumber, balance, accountId.toString(), null, null, null, null); }
public PaymentJson(final Payment payment, final String bundleExternalKey, final List<RefundJson> refunds, final List<ChargebackJson> chargebacks, @Nullable final List<AuditLog> auditLogs) { this(payment.getAmount(), payment.getPaidAmount(), payment.getAccountId().toString(), payment.getInvoiceId().toString(), payment.getId().toString(), payment.getPaymentNumber().toString(), payment.getPaymentMethodId().toString(), payment.getEffectiveDate(), payment.getEffectiveDate(), payment.getAttempts().size(), payment.getCurrency().toString(), payment.getPaymentStatus().toString(), payment.getAttempts().get(payment.getAttempts().size() - 1).getGatewayErrorCode(), payment.getAttempts().get(payment.getAttempts().size() - 1).getGatewayErrorMsg(), bundleExternalKey, refunds, chargebacks, toAuditLogJson(auditLogs)); }
public InvoiceJson(final Invoice input, final String bundleKeys, final List<CreditJson> credits, final List<AuditLog> auditLogs) { this(input.getChargedAmount(), input.getCurrency().toString(), input.getCreditedAmount(), input.getRefundedAmount(), input.getId().toString(), input.getInvoiceDate(), input.getTargetDate(), String.valueOf(input.getInvoiceNumber()), input.getBalance(), input.getAccountId().toString(), bundleKeys, credits, null, toAuditLogJson(auditLogs)); }
@Override public Pagination<InvoiceModelDao> searchInvoices(final String searchKey, final Long offset, final Long limit, final InternalTenantContext context) { final List<InvoiceModelDao> results = new LinkedList<InvoiceModelDao>(); for (final InvoiceModelDao invoice : getAll(context)) { if (invoice.getId().toString().equals(searchKey) || invoice.getAccountId().toString().equals(searchKey) || invoice.getInvoiceNumber().toString().equals(searchKey) || invoice.getCurrency().toString().equals(searchKey)) { results.add(invoice); } } return DefaultPagination.<InvoiceModelDao>build(offset, limit, results); }
public InvoiceJson(final Invoice input, final boolean withItems, @Nullable final AccountAuditLogs accountAuditLogs) { super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForInvoice(input.getId()))); this.items = new ArrayList<InvoiceItemJson>(input.getInvoiceItems().size()); if (withItems) { for (final InvoiceItem item : input.getInvoiceItems()) { this.items.add(new InvoiceItemJson(item, accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForInvoiceItem(item.getId()))); } } this.amount = input.getChargedAmount(); this.currency = input.getCurrency().toString(); this.creditAdj = input.getCreditedAmount(); this.refundAdj = input.getRefundedAmount(); this.invoiceId = input.getId().toString(); this.invoiceDate = input.getInvoiceDate(); this.targetDate = input.getTargetDate(); this.invoiceNumber = input.getInvoiceNumber() == null ? null : String.valueOf(input.getInvoiceNumber()); this.balance = input.getBalance(); this.accountId = input.getAccountId().toString(); this.bundleKeys = null; this.credits = null; }
public BusinessAccountModelDao(final Account account) { super(account.getId(), account.getCreatedDate(), account.getUpdatedDate()); this.accountId = account.getId(); this.name = account.getName(); this.key = account.getExternalKey(); if (account.getCurrency() != null) { this.currency = account.getCurrency().toString(); } }
final List<CreditJson> credits = ImmutableList.<CreditJson>of(creditJson); final List<AuditLogJson> auditLogs = createAuditLogsJson(clock.getUTCNow()); final InvoiceJson invoiceJsonSimple = new InvoiceJson(amount, Currency.USD.toString(), creditAdj, refundAdj, invoiceId, invoiceDate, targetDate, invoiceNumber, balance, accountId, bundleKeys, credits, null, auditLogs);
Assert.assertEquals(accountJson.getCompany(), account.getCompanyName()); Assert.assertEquals(accountJson.getCity(), account.getCity()); Assert.assertEquals(accountJson.getCurrency(), account.getCurrency().toString()); Assert.assertEquals(accountJson.getEmail(), account.getEmail()); Assert.assertEquals(accountJson.getExternalKey(), account.getExternalKey());
this.currency = currency.toString(); } else { this.currency = null;
public AccountJson(final Account account, final BigDecimal accountBalance, final BigDecimal accountCBA, @Nullable final AccountAuditLogs accountAuditLogs) { super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForAccount())); this.accountCBA = accountCBA; this.accountBalance = accountBalance; this.accountId = account.getId().toString(); this.externalKey = account.getExternalKey(); this.name = account.getName(); this.firstNameLength = account.getFirstNameLength(); this.email = account.getEmail(); this.billCycleDayLocal = account.getBillCycleDayLocal(); this.currency = account.getCurrency() != null ? account.getCurrency().toString() : null; this.paymentMethodId = account.getPaymentMethodId() != null ? account.getPaymentMethodId().toString() : null; this.timeZone = account.getTimeZone().toString(); this.address1 = account.getAddress1(); this.address2 = account.getAddress2(); this.postalCode = account.getPostalCode(); this.company = account.getCompanyName(); this.city = account.getCity(); this.state = account.getStateOrProvince(); this.country = account.getCountry(); this.locale = account.getLocale(); this.phone = account.getPhone(); this.isMigrated = account.isMigrated(); this.isNotifiedForInvoices = account.isNotifiedForInvoices(); }
q.bind("currency", invoicePayment.getCurrency().toString()); q.bind("payment_error", invoicePayment.getPaymentError()); q.bind("processing_status", invoicePayment.getProcessingStatus());
q.bind("currency", invoice.getCurrency().toString()); q.bind("balance", Rounder.round(invoice.getBalance())); q.bind("amount_paid", Rounder.round(invoice.getAmountPaid()));
q.bind("currency", invoiceItem.getCurrency().toString());
this.currency = currency.toString(); } else { this.currency = null;