List of usage examples for java.util Currency getInstance
public static Currency getInstance(Locale locale)
Currency
instance for the country of the given locale. From source file:com.pluscubed.velociraptor.SettingsActivity.java
private void showSupportDialog() { if (!billingProcessor.isInitialized()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT) .show();//from ww w . j a v a 2 s . c o m return; } final List<SkuDetails> purchaseListingDetails = billingProcessor .getPurchaseListingDetails(new ArrayList<>(Arrays.asList(PURCHASES))); final List<SkuDetails> subscriptionListingDetails = billingProcessor .getSubscriptionListingDetails(new ArrayList<>(Arrays.asList(SUBSCRIPTIONS))); if (purchaseListingDetails == null || purchaseListingDetails.isEmpty()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT) .show(); return; } purchaseListingDetails.addAll(0, subscriptionListingDetails); List<String> purchaseDisplay = new ArrayList<>(); for (SkuDetails details : purchaseListingDetails) { NumberFormat format = NumberFormat.getCurrencyInstance(); format.setCurrency(Currency.getInstance(details.currency)); String amount = format.format(details.priceValue); if (details.isSubscription) amount = String.format(getString(R.string.per_month), amount); else { amount = String.format(getString(R.string.one_time), amount); } purchaseDisplay.add(amount); } String content = getString(R.string.support_dev_dialog); if (PrefUtils.hasSupported(this) || !billingProcessor.listOwnedSubscriptions().isEmpty()) { content += "\n\n\uD83C\uDF89 " + getString(R.string.support_dev_dialog_badge) + " \uD83C\uDF89"; } new MaterialDialog.Builder(this) .icon(Utils.getVectorDrawableCompat(this, R.drawable.ic_favorite_black_24dp)) .title(R.string.support_development).content(content).items(purchaseDisplay) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { SkuDetails skuDetails = purchaseListingDetails.get(which); if (skuDetails.isSubscription) { billingProcessor.subscribe(SettingsActivity.this, skuDetails.productId); } else { billingProcessor.purchase(SettingsActivity.this, skuDetails.productId); } } }).show(); }
From source file:org.broadleafcommerce.vendor.paypal.service.payment.PayPalResponseGeneratorImpl.java
protected void addCapturePaymentInfoData(String rawResponse, PayPalPaymentResponse response) { PayPalPaymentInfo paymentInfo = new PayPalPaymentInfo(); response.setPaymentInfo(paymentInfo); String currencyCode = getResponseValue(rawResponse, MessageConstants.CURRENCYCODE); paymentInfo.setCurrencyCode(currencyCode); paymentInfo.setTransactionId(getResponseValue(rawResponse, MessageConstants.TRANSACTIONID)); paymentInfo.setParentTransactionId(getResponseValue(rawResponse, MessageConstants.PARENTTRANSACTIONID)); paymentInfo.setReceiptId(getResponseValue(rawResponse, MessageConstants.RECEIPTID)); String paymentType = getResponseValue(rawResponse, MessageConstants.PAYMENTTYPE); if (!StringUtils.isEmpty(paymentType)) { paymentInfo.setPaymentType(PayPalPaymentType.getInstance(paymentType)); }//from www . j ava 2 s. c o m String orderTime = getResponseValue(rawResponse, MessageConstants.ORDERITEM); if (!StringUtils.isEmpty(orderTime)) { try { paymentInfo.setOrderTime(dateFormat.parse(orderTime)); } catch (ParseException e) { throw new RuntimeException("Unable to parse the date string (" + orderTime + ")"); } } String amount = getResponseValue(rawResponse, MessageConstants.AMOUNT); if (!StringUtils.isEmpty(amount)) { paymentInfo.setTotalAmount(new Money(amount, Currency.getInstance(currencyCode))); } String feeAmount = getResponseValue(rawResponse, MessageConstants.FEEAMOUNT); if (!StringUtils.isEmpty(feeAmount)) { paymentInfo.setFeeAmount(new Money(feeAmount, Currency.getInstance(currencyCode))); } String settleAmount = getResponseValue(rawResponse, MessageConstants.SETTLEAMOUNT); if (!StringUtils.isEmpty(settleAmount)) { paymentInfo.setSettleAmount(new Money(settleAmount, Currency.getInstance(currencyCode))); } String taxAmount = getResponseValue(rawResponse, MessageConstants.TAXAMOUNT); if (!StringUtils.isEmpty(taxAmount)) { paymentInfo.setTaxAmount(new Money(taxAmount, Currency.getInstance(currencyCode))); } String exchangeRate = getResponseValue(rawResponse, MessageConstants.EXCHANGERATE); if (!StringUtils.isEmpty(exchangeRate)) { paymentInfo.setExchangeRate(new BigDecimal(exchangeRate)); } String paymentStatusType = getResponseValue(rawResponse, MessageConstants.PAYMENTSTATUSTYPE); if (!StringUtils.isEmpty(paymentStatusType)) { paymentInfo.setPaymentStatusType(PayPalPaymentStatusType.getInstance(paymentStatusType)); } String pendingReasonType = getResponseValue(rawResponse, MessageConstants.PENDINGREASONTYPE); if (!StringUtils.isEmpty(pendingReasonType)) { paymentInfo.setPendingReasonType(PayPalPendingReasonType.getInstance(pendingReasonType)); } }
From source file:org.gnucash.android.ui.transaction.TransactionFormFragment.java
/** * Callback when the account in the navigation bar is changed by the user * @param newAccountId Database record ID of the newly selected account *//*from w w w. ja v a2s.c om*/ public void onAccountChanged(long newAccountId) { AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(getActivity()); String currencyCode = accountsDbAdapter.getCurrencyCode(newAccountId); Currency currency = Currency.getInstance(currencyCode); mCurrencyTextView.setText(currency.getSymbol(Locale.getDefault())); Account.AccountType previousAccountType = mAccountType; mAccountType = accountsDbAdapter.getAccountType(newAccountId); toggleTransactionTypeState(); //if the new account has a different credit/debit philosophy as the previous one, then toggle the button if (mAccountType.hasDebitNormalBalance() != previousAccountType.hasDebitNormalBalance()) { mTransactionTypeButton.toggle(); } updateTransferAccountsList(); accountsDbAdapter.close(); }
From source file:fragment.web.RegistrationControllerTest.java
@Test public void testRegisterTrial() throws Exception { MockHttpServletRequest mockRequest = getRequestTemplate(HttpMethod.GET, "/portal/signup?pc=TESTPROMOCODE"); UserRegistration registration = new UserRegistration(); registration.setCountryList(countryService.getCountries(null, null, null, null, null, null, null)); registration.setAcceptedTerms(true); AccountType disposition = accountTypeDAO.getTrialAccountType(); BindingResult result = setupRegistration(disposition, registration); PromotionSignup promotionSignup = new PromotionSignup("test" + random.nextInt(), "Citrix", "PromotionSignUp@citrix.com"); promotionSignup.setCreateBy(getRootUser()); promotionSignup.setCurrency(Currency.getInstance("USD")); promotionSignup.setPhone("9999999999"); CampaignPromotion campaignPromotion = new CampaignPromotion(); campaignPromotion.setCode("USD" + random.nextInt()); campaignPromotion.setCreateBy(getRootUser()); campaignPromotion.setTrial(true);//w w w. j a va2s. c o m campaignPromotion.setUpdateBy(getRootUser()); CampaignPromotionsInChannels cpic = new CampaignPromotionsInChannels(campaignPromotion, channelService.getDefaultServiceProviderChannel()); campaignPromotion.getCampaignPromotionsInChannels().add(cpic); cmpdao.save(campaignPromotion); PromotionToken promotionToken = new PromotionToken(campaignPromotion, "TESTPROMOCODE"); promotionToken.setCreateBy(getRootUser()); tokendao.save(promotionToken); promotionSignup.setPromotionToken(promotionToken); registration.setTrialCode("TESTPROMOCODE"); DispatcherServletWebRequest webRequest = new DispatcherServletWebRequest(mockRequest); RequestContextHolder.setRequestAttributes(webRequest); mockRequest.getSession().setAttribute("phoneVerificationPin", "12345"); mockRequest.getSession().setAttribute("phoneNumber", "919591241025"); registration.setUserEnteredPhoneVerificationPin("12345"); String view = controller.register(registration, result, "abc", "abc", map, null, status, mockRequest); Assert.assertEquals("register.registration_success", view); Assert.assertTrue(status.isComplete()); verifyRegistration(disposition, registration.getUser(), registration.getTenant()); Assert.assertEquals(registration.getTenant().getAccountId(), ((com.citrix.cpbm.access.Tenant) map.get("tenant")).getAccountId()); }
From source file:no.abmu.lise.service.hibernate3.LiseImportServiceH3Impl.java
private void processSheetThree(Session session, LiseImportExcelParser excelParser) { List<Entity> entityStorList = new ArrayList<Entity>(); int noProductCustomerRelation = 0; excelParser.setSheetName("Sheet3"); excelParser.load();//from w ww . ja va 2 s . c o m Date creationTime = new Date(); StopWatch stopWatch = new StopWatch(); stopWatch.start("processSheetThree"); for (; excelParser.hasNext(); excelParser.next()) { ProductCustomerRelation productCustomerFromDb = findProductCustomerRelInDb(excelParser); if (productCustomerFromDb != null) { ProductCustomerRelation productCustomerRelInSession = (ProductCustomerRelation) session .get(ProductCustomerRelation.class, productCustomerFromDb.getId()); InvoiceToCustomer invoiceToCustomer = createInvoiceToCustomer(excelParser); // Make sure we have currency on all invoices to customer if (invoiceToCustomer.getCurrency() == null) { Product product = productCustomerRelInSession.getProduct(); Consortium consortium = product.getConsortium(); invoiceToCustomer.setCurrency(consortium.getCurrency()); } // Setting up percentage currency buffer if (invoiceToCustomer.getCurrency().equals(Currency.getInstance("NOK"))) { invoiceToCustomer.setPercentageCurrencyBuffer(BigDecimal.valueOf(0)); } else { invoiceToCustomer.setPercentageCurrencyBuffer(BigDecimal.valueOf(1.75)); } // Be sure there are original amount if (invoiceToCustomer.getOriginalAmount() == null) { invoiceToCustomer.setOriginalAmount(BigDecimal.valueOf(0)); } if (invoiceToCustomer.getLiseComment() != null) { invoiceToCustomer.getLiseComment().setCreated(creationTime); invoiceToCustomer.getLiseComment().setLastUpdated(creationTime); } productCustomerRelInSession.addInvoicesToCustomer(invoiceToCustomer); entityStorList.add(productCustomerRelInSession); } else { noProductCustomerRelation++; } } creationTime = new Date(); // // Save // Hibernate3Util.saveEntities(session, entityStorList); stopWatch.stop(); logger.info(" ============================================================================= "); logger.info("Saving [" + entityStorList.size() + "] product customer relations with invoice information."); logger.info( "Missing [" + noProductCustomerRelation + "] product customer relations with invoice information."); logger.info("TransactionTime [" + stopWatch.getLastTaskTimeMillis() + "] in ms."); logger.info(" ============================================================================= "); }
From source file:com.pluscubed.velociraptor.settings.SettingsActivity.java
private void showSupportDialog() { String content = getString(BuildConfig.FLAVOR.equals("play") ? R.string.support_dev_dialog : R.string.support_dev_dialog_notplay); if (PrefUtils.hasSupported(this) || !billingProcessor.listOwnedSubscriptions().isEmpty()) { content += "\n\n\uD83C\uDF89 " + getString(R.string.support_dev_dialog_badge) + " \uD83C\uDF89"; }/* w w w . j a v a 2 s. c o m*/ MaterialDialog.Builder builder = new MaterialDialog.Builder(this) .icon(Utils.getVectorDrawableCompat(this, R.drawable.ic_favorite_black_24dp)) .title(R.string.support_development).content(Html.fromHtml(content)); if (BuildConfig.FLAVOR.equals("play")) { if (!billingProcessor.isInitialized()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT).show(); return; } final List<SkuDetails> purchaseListingDetails = billingProcessor .getPurchaseListingDetails(new ArrayList<>(Arrays.asList(PURCHASES))); final List<SkuDetails> subscriptionListingDetails = billingProcessor .getSubscriptionListingDetails(new ArrayList<>(Arrays.asList(SUBSCRIPTIONS))); if (purchaseListingDetails == null || purchaseListingDetails.isEmpty()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT).show(); return; } purchaseListingDetails.addAll(0, subscriptionListingDetails); List<String> purchaseDisplay = new ArrayList<>(); for (SkuDetails details : purchaseListingDetails) { NumberFormat format = NumberFormat.getCurrencyInstance(); format.setCurrency(Currency.getInstance(details.currency)); String amount = format.format(details.priceValue); if (details.isSubscription) amount = String.format(getString(R.string.per_month), amount); else { amount = String.format(getString(R.string.one_time), amount); } purchaseDisplay.add(amount); } builder.items(purchaseDisplay).itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { SkuDetails skuDetails = purchaseListingDetails.get(which); if (skuDetails.isSubscription) { billingProcessor.subscribe(SettingsActivity.this, skuDetails.productId); } else { billingProcessor.purchase(SettingsActivity.this, skuDetails.productId); } } }); } if (BuildConfig.FLAVOR.equals("full")) { builder.positiveText(R.string.dismiss); } builder.show(); }
From source file:org.gnucash.android.ui.transaction.TransactionFormFragment.java
/** * Collects information from the fragment views and uses it to create * and save a transaction//from w w w .j a v a2 s .co m */ private void saveNewTransaction() { Calendar cal = new GregorianCalendar(mDate.get(Calendar.YEAR), mDate.get(Calendar.MONTH), mDate.get(Calendar.DAY_OF_MONTH), mTime.get(Calendar.HOUR_OF_DAY), mTime.get(Calendar.MINUTE), mTime.get(Calendar.SECOND)); String name = mNameEditText.getText().toString(); String description = mDescriptionEditText.getText().toString(); BigDecimal amountBigd = parseInputToDecimal(mAmountEditText.getText().toString()); long accountID = ((TransactionsActivity) getSherlockActivity()).getCurrentAccountID(); Currency currency = Currency.getInstance(mTransactionsDbAdapter.getCurrencyCode(accountID)); Money amount = new Money(amountBigd, currency); TransactionType type; if (mAccountType.hasDebitNormalBalance()) { type = amount.isNegative() ? TransactionType.CREDIT : TransactionType.DEBIT; } else type = amount.isNegative() ? TransactionType.DEBIT : TransactionType.CREDIT; if (mTransaction != null) { mTransaction.setAmount(amount); mTransaction.setName(name); mTransaction.setTransactionType(type); } else { mTransaction = new Transaction(amount, name, type); } mTransaction.setAccountUID(mTransactionsDbAdapter.getAccountUID(accountID)); mTransaction.setTime(cal.getTimeInMillis()); mTransaction.setDescription(description); //set the double account if (mUseDoubleEntry) { long doubleAccountId = mDoubleAccountSpinner.getSelectedItemId(); //negate the transaction before saving if we are in the double account if (isInDoubleAccount()) { mTransaction.setAmount(amount.negate()); mTransaction.setAccountUID(mTransactionsDbAdapter.getAccountUID(doubleAccountId)); mTransaction.setDoubleEntryAccountUID(mTransactionsDbAdapter.getAccountUID(accountID)); } else { mTransaction.setAccountUID(mTransactionsDbAdapter.getAccountUID(accountID)); mTransaction.setDoubleEntryAccountUID(mTransactionsDbAdapter.getAccountUID(doubleAccountId)); } } //save the normal transaction first mTransactionsDbAdapter.addTransaction(mTransaction); //set up recurring transaction if requested int recurrenceIndex = mRecurringTransactionSpinner.getSelectedItemPosition(); if (recurrenceIndex != 0) { String[] recurrenceOptions = getResources().getStringArray(R.array.recurrence_period_millis); long recurrencePeriodMillis = Long.parseLong(recurrenceOptions[recurrenceIndex]); long firstRunMillis = System.currentTimeMillis() + recurrencePeriodMillis; Transaction recurringTransaction = new Transaction(mTransaction, true); recurringTransaction.setRecurrencePeriod(recurrencePeriodMillis); long recurringTransactionId = mTransactionsDbAdapter.addTransaction(recurringTransaction); PendingIntent recurringPendingIntent = PendingIntent.getBroadcast(getActivity().getApplicationContext(), (int) recurringTransactionId, Transaction.createIntent(mTransaction), PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstRunMillis, recurrencePeriodMillis, recurringPendingIntent); } //update widgets, if any WidgetConfigurationActivity.updateAllWidgets(getActivity().getApplicationContext()); finish(); }
From source file:com.FluksoViz.FluksoVizActivity.java
@Override public void onRestart() { super.onRestart(); my_app_prefs = PreferenceManager.getDefaultSharedPreferences(context); sensor_number = Integer.parseInt(my_app_prefs.getString("sensor_number", "1")); api_server_ip = my_app_prefs.getString("api_server", "178.79.177.6"); skip_initial_sensor_checks = (Boolean) my_app_prefs.getBoolean("skip_initial_sensor_checks", false); ip_addr = (String) my_app_prefs.getString("flukso_ip_addr", "10.10.10.10"); api_key_1 = (String) my_app_prefs.getString("sensor_1_api_key", "0.0.0.0"); api_key_2 = (String) my_app_prefs.getString("sensor_2_api_key", "0.0.0.0"); api_key_3 = (String) my_app_prefs.getString("sensor_3_api_key", "0.0.0.0"); api_token_1 = (String) my_app_prefs.getString("sensor_1_token", "0.0.0.0"); api_token_2 = (String) my_app_prefs.getString("sensor_2_token", "0.0.0.0"); api_token_3 = (String) my_app_prefs.getString("sensor_3_token", "0.0.0.0"); cost_fixedpart = Double.parseDouble(my_app_prefs.getString("cost_perkwh", "0")); cost_perkwh = Double.parseDouble(my_app_prefs.getString("cost_perkwh", "0")); cost_currencycode = (String) my_app_prefs.getString("cost_currencycode", Currency.getInstance(Locale.getDefault()).getCurrencyCode()); thread1_running = true;/* ww w . ja va2 s. c o m*/ thread2_running = true; // updateFromPreferences(); // refreshAplication(); }
From source file:org.openestate.io.is24_csv.Is24CsvRecord.java
public Currency getWaehrung() { String value = this.get(FIELD_WAEHRUNG); try {/* ww w.jav a 2 s . co m*/ return (value != null) ? Currency.getInstance(value) : Currency.getInstance("EUR"); } catch (IllegalArgumentException ex) { LOGGER.warn("Can't read currency '" + value + "'!"); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); return Currency.getInstance("EUR"); } }
From source file:org.broadleafcommerce.vendor.paypal.service.payment.PayPalResponseGeneratorImpl.java
protected void addPaymentInfoData(String rawResponse, PayPalPaymentResponse response) { PayPalPaymentInfo paymentInfo = new PayPalPaymentInfo(); response.setPaymentInfo(paymentInfo); String currencyCode = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTCURRENCYCODE, new Integer[] { 0 }, new String[] { "n" })); paymentInfo.setCurrencyCode(currencyCode); paymentInfo.setTransactionId(getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTTRANSACTIONID, new Integer[] { 0 }, new String[] { "n" }))); String paymentType = getResponseValue(rawResponse, MessageConstants.PROCESSPAYMENTPAYMENTTYPE); if (!StringUtils.isEmpty(paymentType)) { paymentInfo.setPaymentType(PayPalPaymentType.getInstance(paymentType)); }//from w w w .j ava2 s . c o m String orderTime = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTORDERITEM, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(orderTime)) { try { paymentInfo.setOrderTime(dateFormat.parse(orderTime)); } catch (ParseException e) { throw new RuntimeException("Unable to parse the date string (" + orderTime + ")"); } } String amount = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTAMOUNT, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(amount)) { paymentInfo.setTotalAmount(new Money(amount, Currency.getInstance(currencyCode))); } String feeAmount = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTFEEAMOUNT, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(feeAmount)) { paymentInfo.setFeeAmount(new Money(feeAmount, Currency.getInstance(currencyCode))); } String settleAmount = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTSETTLEAMOUNT, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(settleAmount)) { paymentInfo.setSettleAmount(new Money(settleAmount, Currency.getInstance(currencyCode))); } String taxAmount = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTTAXAMOUNT, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(taxAmount)) { paymentInfo.setTaxAmount(new Money(taxAmount, Currency.getInstance(currencyCode))); } String exchangeRate = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTEXCHANGERATE, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(exchangeRate)) { paymentInfo.setExchangeRate(new BigDecimal(exchangeRate)); } String paymentStatusType = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTPAYMENTSTATUSTYPE, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(paymentStatusType)) { paymentInfo.setPaymentStatusType(PayPalPaymentStatusType.getInstance(paymentStatusType)); } String pendingReasonType = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTPENDINGREASONTYPE, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(pendingReasonType)) { paymentInfo.setPendingReasonType(PayPalPendingReasonType.getInstance(pendingReasonType)); } String reasonCodeType = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTREASONCODETYPE, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(reasonCodeType)) { paymentInfo.setReasonCodeType(PayPalReasonCodeType.getInstance(reasonCodeType)); } String holdDecisionType = getResponseValue(rawResponse, replaceNumericBoundProperty( MessageConstants.PROCESSPAYMENTHOLDDECISIONTYPE, new Integer[] { 0 }, new String[] { "n" })); if (!StringUtils.isEmpty(holdDecisionType)) { paymentInfo.setHoldDecisionType(PayPalHoldDecisionType.getInstance(holdDecisionType)); } populateDetailErrors(rawResponse, response); }