Refine search
@Override public int hashCode() { int result = id != null ? id.hashCode() : 0; result = 31 * result + (externalKey != null ? externalKey.hashCode() : 0); result = 31 * result + (currency != null ? currency.hashCode() : 0); result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0); result = 31 * result + (fixedOffsetTimeZone != null ? fixedOffsetTimeZone.hashCode() : 0); result = 31 * result + (referenceTime != null ? referenceTime.hashCode() : 0); return result; }
@Test(groups = "slow") public void testGetOverriddenPlanPhases() throws Exception { final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarAdvanced.xml").toExternalForm(), StandaloneCatalog.class); final Plan plan = catalog.findCurrentPlan("discount-standard-monthly"); final PlanPhasePriceOverride[] resolvedOverrides = new PlanPhasePriceOverride[plan.getAllPhases().length]; resolvedOverrides[0] = new DefaultPlanPhasePriceOverride(plan.getAllPhases()[0].getName(), Currency.USD, BigDecimal.TEN, BigDecimal.ONE, null); resolvedOverrides[1] = new DefaultPlanPhasePriceOverride(plan.getAllPhases()[1].getName(), Currency.USD, BigDecimal.ONE, BigDecimal.TEN, null); resolvedOverrides[2] = new DefaultPlanPhasePriceOverride(plan.getFinalPhase().getName(), Currency.USD, BigDecimal.ZERO, new BigDecimal("348.64"), null); final CatalogOverridePlanDefinitionModelDao newPlan = catalogOverrideDao.getOrCreateOverridePlanDefinition(plan, new DateTime(catalog.getEffectiveDate()), resolvedOverrides, internalCallContext); final List<CatalogOverridePhaseDefinitionModelDao> phases = catalogOverrideDao.getOverriddenPlanPhases(newPlan.getRecordId(), internalCallContext); assertEquals(phases.size(), 3); for (int i = 0; i < 3; i++) { final CatalogOverridePhaseDefinitionModelDao curPhase = phases.get(i); assertEquals(curPhase.getCurrency(), resolvedOverrides[i].getCurrency().name()); assertEquals(curPhase.getFixedPrice().compareTo(resolvedOverrides[i].getFixedPrice()), 0); assertEquals(curPhase.getRecurringPrice().compareTo(resolvedOverrides[i].getRecurringPrice()), 0); assertEquals(curPhase.getParentPhaseName(), resolvedOverrides[i].getPhaseName()); } }
@Test(groups = "slow") public void testInsertPaymentResult() throws SQLException, IOException { final DateTime utcNow = DateTime.now(); final UUID kbAccountId = UUID.randomUUID(); final UUID kbPaymentId = UUID.randomUUID(); final UUID kbTransactionId = UUID.randomUUID(); final TransactionType transactionType = TransactionType.AUTHORIZE; final BigDecimal amount = new BigDecimal("123.456"); final Currency currency = Currency.JPY; final Map<String, String> additionalData = new HashMap<String, String>(); final DateTime timestamp = utcNow.minus(utcNow.getMillisOfSecond()); final UUID kbTenantId = UUID.randomUUID(); Assert.assertEquals(record.getKbPaymentTransactionId(), kbTransactionId.toString(), "Wrong kbPaymentTransactionId"); Assert.assertEquals(record.getTransactionType(), transactionType.name(), "Wrong transactionType"); Assert.assertEquals(record.getAmount().doubleValue(), amount.doubleValue(), "Wrong amount"); Assert.assertEquals(record.getCurrency(), currency.name(), "Wrong currency"); Assert.assertEquals(TestUtils.buildPluginPropertiesMap(record.getAdditionalData()), additionalData, "Wrong additionalData");
private List<ChangedField> calculateChangedFields(final AccountModelDao oldData, final AccountModelDao newData, final DateTime changeDate) { final List<ChangedField> tmpChangedFields = new ArrayList<ChangedField>(); addIfValueChanged(tmpChangedFields, "externalKey", oldData.getExternalKey(), newData.getExternalKey(), changeDate); addIfValueChanged(tmpChangedFields, "email", oldData.getEmail(), newData.getEmail(), changeDate); addIfValueChanged(tmpChangedFields, "firstName", oldData.getName(), newData.getName(), changeDate); addIfValueChanged(tmpChangedFields, "currency", (oldData.getCurrency() != null) ? oldData.getCurrency().toString() : null, (newData.getCurrency() != null) ? newData.getCurrency().toString() : null, changeDate); addIfValueChanged(tmpChangedFields, "billCycleDayLocal", String.valueOf(oldData.getBillingCycleDayLocal()), String.valueOf(newData.getBillingCycleDayLocal()), changeDate); addIfValueChanged(tmpChangedFields, "paymentMethodId", (oldData.getPaymentMethodId() != null) ? oldData.getPaymentMethodId().toString() : null, (newData.getPaymentMethodId() != null) ? newData.getPaymentMethodId().toString() : null, changeDate); addIfValueChanged(tmpChangedFields, "locale", oldData.getLocale(), newData.getLocale(), changeDate); addIfValueChanged(tmpChangedFields, "timeZone", (oldData.getTimeZone() == null) ? null : oldData.getTimeZone().toString(), (newData.getTimeZone() == null) ? null : newData.getTimeZone().toString(), changeDate); addIfValueChanged(tmpChangedFields, "address1", oldData.getAddress1(), newData.getAddress1(), changeDate); addIfValueChanged(tmpChangedFields, "address2", oldData.getAddress2(), newData.getAddress2(), changeDate); addIfValueChanged(tmpChangedFields, "city", oldData.getCity(), newData.getCity(), changeDate); addIfValueChanged(tmpChangedFields, "stateOrProvince", oldData.getStateOrProvince(), newData.getStateOrProvince(), changeDate); addIfValueChanged(tmpChangedFields, "country", oldData.getCountry(), newData.getCountry(), changeDate); addIfValueChanged(tmpChangedFields, "postalCode", oldData.getPostalCode(), newData.getPostalCode(), changeDate); addIfValueChanged(tmpChangedFields, "phone", oldData.getPhone(), newData.getPhone(), changeDate); return tmpChangedFields; }
@Override public Void withConnection(final Connection conn) throws SQLException { DSL.using(conn, dialect, settings) .insertInto(responsesTable, DSL.field(KB_ACCOUNT_ID), DSL.field(KB_PAYMENT_ID), DSL.field(KB_PAYMENT_TRANSACTION_ID), DSL.field(TRANSACTION_TYPE), DSL.field(AMOUNT), DSL.field(CURRENCY), DSL.field(ADDITIONAL_DATA), DSL.field(CREATED_DATE), DSL.field(KB_TENANT_ID)) .values(kbAccountId.toString(), kbPaymentId.toString(), kbPaymentTransactionId.toString(), transactionType.toString(), amount, currency == null ? null : currency.name(), asString(additionalData), toTimestamp(utcNow), kbTenantId.toString()) .execute(); return null; } });
if (creditId != null ? !creditId.equals(that.creditId) : that.creditId != null) { return false; (creditAmount != null && that.creditAmount != null && creditAmount.compareTo(that.creditAmount) == 0))) { return false; if (currency != null ? !currency.equals(that.currency) : that.currency != null) { return false; if (invoiceId != null ? !invoiceId.equals(that.invoiceId) : that.invoiceId != null) { return false;
if (accountId != null ? !accountId.equals(that.accountId) : that.accountId != null) { return false; if (paymentMethodId != null ? !paymentMethodId.equals(that.paymentMethodId) : that.paymentMethodId != null) { return false; return false; if (transactionId != null ? !transactionId.equals(that.transactionId) : that.transactionId != null) { return false; return false; if (effectiveDate != null ? effectiveDate.compareTo(that.effectiveDate) != 0 : that.effectiveDate != null) { return false; return false; if (amount != null ? amount.compareTo(that.amount) != 0 : that.amount != null) { return false; if (currency != null ? !currency.equals(that.currency) : that.currency != null) { return false;
@Override public void readExternal(final ObjectInput in) throws IOException { this.id = new UUID(in.readLong(), in.readLong()); this.externalKey = in.readUTF(); this.currency = in.readBoolean() ? Currency.valueOf(in.readUTF()) : null; this.timeZone = DateTimeZone.forID(in.readUTF()); this.fixedOffsetTimeZone = DateTimeZone.forID(in.readUTF()); this.referenceTime = new DateTime(in.readUTF()); }
@Override protected PaymentTransactionInfoPlugin buildPaymentTransactionInfoPlugin(final TestResponsesRecord record) { final DateTime createdDate = new DateTime(record.getCreatedDate(), DateTimeZone.UTC); final List<PluginProperty> properties = TestUtils.buildPluginProperties(record.getAdditionalData()); return new PluginPaymentTransactionInfoPlugin(UUID.fromString(record.getKbPaymentId()), UUID.fromString(record.getKbPaymentTransactionId()), TransactionType.valueOf(record.getTransactionType()), record.getAmount(), Strings.isNullOrEmpty(record.getCurrency()) ? null : Currency.valueOf(record.getCurrency()), PaymentPluginStatus.UNDEFINED, null, // String gatewayError null, // String gatewayErrorCode null, // String firstPaymentReferenceId null, // String secondPaymentReferenceId createdDate, createdDate, properties); }
@Override public void writeExternal(final ObjectOutput oo) throws IOException { oo.writeLong(id.getMostSignificantBits()); oo.writeLong(id.getLeastSignificantBits()); oo.writeUTF(externalKey); oo.writeBoolean(currency != null); if (currency != null) { oo.writeUTF(currency.name()); } oo.writeUTF(timeZone.getID()); oo.writeUTF(fixedOffsetTimeZone.getID()); oo.writeUTF(referenceTime.toString()); } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (targetDate != null ? targetDate.hashCode() : 0); result = 31 * result + (accountId != null ? accountId.hashCode() : 0); result = 31 * result + (amountOwed != null ? amountOwed.hashCode() : 0); result = 31 * result + (currency != null ? currency.hashCode() : 0); return result; } }
@Override public int hashCode() { int result = invoiceId != null ? invoiceId.hashCode() : 0; result = 31 * result + (accountId != null ? accountId.hashCode() : 0); result = 31 * result + (amountOwed != null ? amountOwed.hashCode() : 0); result = 31 * result + (currency != null ? currency.hashCode() : 0); return result; } }
for (final InvoiceItem inputItem : inputItems) { if (inputItem.getAmount() == null || inputItem.getAmount().compareTo(BigDecimal.ZERO) < 0) { if (itemType == InvoiceItemType.EXTERNAL_CHARGE) { throw new InvoiceApiException(ErrorCode.EXTERNAL_CHARGE_AMOUNT_INVALID, inputItem.getAmount()); if (inputItem.getCurrency() != null && !inputItem.getCurrency().equals(accountCurrency)) { throw new InvoiceApiException(ErrorCode.CURRENCY_INVALID, inputItem.getCurrency(), accountCurrency); inputItem.getDescription(), inputItem.getAmount().negate(), accountCurrency, inputItem.getItemDetails());
@Override public String getFormattedAmount() { final NumberFormat number = NumberFormat.getCurrencyInstance(locale); number.setCurrency(java.util.Currency.getInstance(item.getCurrency().toString())); return number.format(getAmount().doubleValue()); }
private InvoiceItem mergeCBAItem(final List<InvoiceItem> invoiceItems, InvoiceItem mergedCBAItem, final InvoiceItem item) { if (mergedCBAItem == null) { mergedCBAItem = item; } else { // This is really just to be safe - they should always have the same currency if (!mergedCBAItem.getCurrency().equals(item.getCurrency())) { invoiceItems.add(item); } else { mergedCBAItem = new CreditBalanceAdjInvoiceItem(invoice.getId(), invoice.getAccountId(), invoice.getInvoiceDate(), mergedCBAItem.getAmount().add(item.getAmount()), mergedCBAItem.getCurrency()); } } return mergedCBAItem; }
private String getFormattedAmountByLocaleAndInvoiceCurrency(final BigDecimal amount) { final String invoiceCurrencyCode = invoice.getCurrency().toString(); final CurrencyUnit currencyUnit = CurrencyUnit.of(invoiceCurrencyCode); final DecimalFormat numberFormatter = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale); final DecimalFormatSymbols dfs = numberFormatter.getDecimalFormatSymbols(); dfs.setInternationalCurrencySymbol(currencyUnit.getCurrencyCode()); try { Currency currency = Currency.fromCode(invoiceCurrencyCode); dfs.setCurrencySymbol(currency.getSymbol()); } catch (final IllegalArgumentException e) { dfs.setCurrencySymbol(currencyUnit.getSymbol(locale)); } numberFormatter.setDecimalFormatSymbols(dfs); numberFormatter.setMinimumFractionDigits(currencyUnit.getDefaultFractionDigits()); numberFormatter.setMaximumFractionDigits(currencyUnit.getDefaultFractionDigits()); return numberFormatter.format(amount.doubleValue()); }
public DefaultAccountData(final AccountModelDao d) { this(d.getExternalKey(), d.getName(), d.getFirstNameLength(), d.getEmail(), d.getBillingCycleDayLocal(), d.getCurrency() != null ? d.getCurrency().name() : null, d.getParentAccountId(), d.getIsPaymentDelegatedToParent(), d.getPaymentMethodId(), d.getReferenceTime() != null ? d.getReferenceTime().toString() : null, d.getTimeZone() != null ? d.getTimeZone().getID() : null, d.getLocale(), d.getAddress1(), d.getAddress2(), d.getCompanyName(), d.getCity(), d.getStateOrProvince(), d.getPostalCode(), d.getCountry(), d.getPhone(), d.getNotes(), d.getMigrated()); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final PriceJson priceJson = (PriceJson) o; if (currency != null ? !currency.equals(priceJson.currency) : priceJson.currency != null) { return false; } if (value != null ? !value.equals(priceJson.value) : priceJson.value != null) { return false; } return true; }