当前位置: 首页>>代码示例>>Java>>正文


Java CurrencyUnit类代码示例

本文整理汇总了Java中org.joda.money.CurrencyUnit的典型用法代码示例。如果您正苦于以下问题:Java CurrencyUnit类的具体用法?Java CurrencyUnit怎么用?Java CurrencyUnit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CurrencyUnit类属于org.joda.money包,在下文中一共展示了CurrencyUnit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUpdatePrice

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
/** Returns a new update price for the pricer. */
public FeesAndCredits getUpdatePrice(Registry registry, String domainName, DateTime date)
    throws EppException {
  CurrencyUnit currency = registry.getCurrency();
  BaseFee feeOrCredit =
      Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE);
  return customLogic.customizeUpdatePrice(
      UpdatePriceParameters.newBuilder()
          .setFeesAndCredits(
              new FeesAndCredits.Builder()
                  .setCurrency(currency)
                  .addFeeOrCredit(feeOrCredit)
                  .build())
          .setRegistry(registry)
          .setDomainName(InternetDomainName.from(domainName))
          .setAsOfDate(date)
          .build());
}
 
开发者ID:google,项目名称:nomulus,代码行数:19,代码来源:DomainPricingLogic.java

示例2: handleSuccessResponse

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
/**
 * Handles a transaction success response.
 *
 * @see <a href="https://developers.braintreepayments.com/reference/response/transaction/java#success">
 *     Braintree - Transaction - Success</a>
 * @see <a href="https://developers.braintreepayments.com/reference/general/statuses#transaction">
 *     Braintree - Statuses - Transaction</a>
 */
private Map<String, Object> handleSuccessResponse(Transaction transaction) {
  // XXX: Currency scaling: https://github.com/braintree/braintree_java/issues/33
  Money amount =
      Money.of(CurrencyUnit.of(transaction.getCurrencyIsoCode()),
          transaction.getAmount().stripTrailingZeros());
  logger.infofmt("Transaction for %s via %s %s with ID: %s",
      amount,
      transaction.getPaymentInstrumentType(),  // e.g. credit_card, paypal_account
      transaction.getStatus(),                 // e.g. SUBMITTED_FOR_SETTLEMENT
      transaction.getId());
  return JsonResponseHelper
      .create(SUCCESS, "Payment processed successfully", asList(
          ImmutableMap.of(
              "id", transaction.getId(),
              "formattedAmount", formatMoney(amount))));
}
 
开发者ID:google,项目名称:nomulus,代码行数:25,代码来源:RegistrarPaymentAction.java

示例3: setCommandSpecificProperties

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Override
void setCommandSpecificProperties(Registry.Builder builder) {
  // Pick up the currency from the create cost. Since all costs must be in one currency, and that
  // condition is enforced by the builder, it doesn't matter which cost we choose it from.
  CurrencyUnit currency = createBillingCost != null
      ? createBillingCost.getCurrencyUnit()
      : Registry.DEFAULT_CURRENCY;

  builder.setCurrency(currency);

  // If this is a non-default currency and the user hasn't specified an EAP fee schedule, set the
  // EAP fee schedule to a matching currency.
  if (!currency.equals(Registry.DEFAULT_CURRENCY) && eapFeeSchedule.isEmpty()) {
    builder.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(currency)));
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:17,代码来源:CreateTldCommand.java

示例4: setUp

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  createTld("tld");
  Registrar theRegistrar = ofy().load()
      .type(Registrar.class)
      .parent(getCrossTldKey())
      .id("TheRegistrar").now();
  auctionCredit = persistResource(
      new RegistrarCredit.Builder()
          .setParent(theRegistrar)
          .setType(CreditType.AUCTION)
          .setCurrency(CurrencyUnit.USD)
          .setTld("tld")
          .setCreationTime(clock.nowUtc())
          .build());
  promoCredit = persistResource(
      new RegistrarCredit.Builder()
          .setParent(theRegistrar)
          .setType(CreditType.PROMOTION)
          .setCurrency(CurrencyUnit.USD)
          .setTld("tld")
          .setCreationTime(clock.nowUtc())
          .build());
}
 
开发者ID:google,项目名称:nomulus,代码行数:25,代码来源:RegistrarCreditTest.java

示例5: testLoadBalance_oneCurrency_hasTwoEntriesWithSumAndZero

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testLoadBalance_oneCurrency_hasTwoEntriesWithSumAndZero() {
  RegistrarBillingEntry entry1 = new RegistrarBillingEntry.Builder()
      .setPrevious(null)
      .setParent(registrar)
      .setCreated(clock.nowUtc())
      .setDescription("USD Invoice for July")
      .setAmount(Money.parse("USD 10.00"))
      .build();
  clock.advanceBy(Duration.standardDays(30));
  RegistrarBillingEntry entry2 = new RegistrarBillingEntry.Builder()
      .setPrevious(entry1)
      .setParent(registrar)
      .setCreated(clock.nowUtc())
      .setDescription("USD Invoice for August")
      .setAmount(Money.parse("USD 23.00"))
      .build();
  persistSimpleResources(asList(entry1, entry2));
  Map<CurrencyUnit, Money> balance = RegistrarBillingUtils.loadBalance(registrar);
  assertThat(balance).hasSize(2);
  assertThat(balance).containsEntry(USD, Money.parse("USD 33.00"));
  assertThat(balance).containsEntry(JPY, Money.parse("JPY 0"));
}
 
开发者ID:google,项目名称:nomulus,代码行数:24,代码来源:RegistrarBillingUtilsTest.java

示例6: testFailure_wrongCurrency_v06

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v06() throws Exception {
  setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainCreateFlowTest.java

示例7: testFailure_wrongCurrency_v11

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v11() throws Exception {
  setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainCreateFlowTest.java

示例8: testFailure_wrongCurrency_v12

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v12() throws Exception {
  setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainCreateFlowTest.java

示例9: testFailure_wrongCurrency_v06

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v06() throws Exception {
  createTld("tld", TldState.LANDRUSH);
  setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  clock.advanceOneMilli();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:DomainApplicationCreateFlowTest.java

示例10: testFailure_wrongCurrency_v11

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v11() throws Exception {
  createTld("tld", TldState.LANDRUSH);
  setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  clock.advanceOneMilli();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:DomainApplicationCreateFlowTest.java

示例11: testFailure_wrongCurrency_v12

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v12() throws Exception {
  createTld("tld", TldState.LANDRUSH);
  setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  clock.advanceOneMilli();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:DomainApplicationCreateFlowTest.java

示例12: testTokenGeneration

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testTokenGeneration() throws Exception {
  action.brainframe = "/doodle";
  action.accountIds =
      ImmutableMap.of(
          CurrencyUnit.USD, "sorrow",
          CurrencyUnit.JPY, "torment");
  String blanketsOfSadness = "our hearts are beating, but no one is breathing";
  when(clientTokenGateway.generate()).thenReturn(blanketsOfSadness);
  assertThat(action.handleJsonRequest(ImmutableMap.of()))
      .containsExactly(
          "status", "SUCCESS",
          "message", "Success",
          "results", asList(
              ImmutableMap.of(
                  "token", blanketsOfSadness,
                  "currencies", asList("USD", "JPY"),
                  "brainframe", "/doodle")));
  verify(customerSyncer).sync(eq(loadRegistrar("TheRegistrar")));
}
 
开发者ID:google,项目名称:nomulus,代码行数:21,代码来源:RegistrarPaymentSetupActionTest.java

示例13: testSuccess_billingAccountMap

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testSuccess_billingAccountMap() throws Exception {
  runCommandForced(
      "--name=blobio",
      "--password=some_password",
      "--registrar_type=REAL",
      "--iana_id=8",
      "--billing_account_map=USD=abc123,JPY=789xyz",
      "--passcode=01234",
      "[email protected]",
      "--street=\"123 Fake St\"",
      "--city Fakington",
      "--state MA",
      "--zip 00351",
      "--cc US",
      "clientz");

  Optional<Registrar> registrar = Registrar.loadByClientId("clientz");
  assertThat(registrar).isPresent();
  assertThat(registrar.get().getBillingAccountMap())
      .containsExactly(CurrencyUnit.USD, "abc123", CurrencyUnit.JPY, "789xyz");
}
 
开发者ID:google,项目名称:nomulus,代码行数:23,代码来源:CreateRegistrarCommandTest.java

示例14: testSuccess_billingAccountMap_onlyAppliesToRealRegistrar

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
@Test
public void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception {
  createTlds("foo");

  runCommandForced(
      "--name=blobio",
      "--password=some_password",
      "--registrar_type=TEST",
      "--billing_account_map=JPY=789xyz",
      "--allowed_tlds=foo",
      "--passcode=01234",
      "[email protected]",
      "--street=\"123 Fake St\"",
      "--city Fakington",
      "--state MA",
      "--zip 00351",
      "--cc US",
      "clientz");

  Optional<Registrar> registrar = Registrar.loadByClientId("clientz");
  assertThat(registrar).isPresent();
  assertThat(registrar.get().getBillingAccountMap()).containsExactly(CurrencyUnit.JPY, "789xyz");
}
 
开发者ID:google,项目名称:nomulus,代码行数:24,代码来源:CreateRegistrarCommandTest.java

示例15: buildExpenseItem

import org.joda.money.CurrencyUnit; //导入依赖的package包/类
/**
 * Creates a new expense item based on the contents of the data fields in
 * the user interface.
 * 
 * @return The new expense item.
 */
private ExpenseItem buildExpenseItem() {
	Money amount = Money.of(
			CurrencyUnit.of(currencySpinner.getSelectedItem().toString()),
			Float.parseFloat(amountField.getText().toString()),
			RoundingMode.HALF_UP);
	ExpenseItem item = new ExpenseItem(nameField.getText().toString(),
			descriptionField.getText().toString(), categorySpinner
					.getSelectedItem().toString(), amount,
			dateField.getDate());
	if (receiptFileUri != null) {
		item.setReceiptUri(receiptFileUri);
	}
	item.setIncomplete(incomplete);
	item.setLocation(expenseLocation);
	return item;
}
 
开发者ID:CMPUT301W15T09,项目名称:Team9Project,代码行数:23,代码来源:ExpenseItemAddActivity.java


注:本文中的org.joda.money.CurrencyUnit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。