Example usage for java.util Currency getInstance

List of usage examples for java.util Currency getInstance

Introduction

In this page you can find the example usage for java.util Currency getInstance.

Prototype

public static Currency getInstance(Locale locale) 

Source Link

Document

Returns the Currency instance for the country of the given locale.

Usage

From source file:fr.hoteia.qalingo.core.web.util.impl.RequestUtilImpl.java

/**
 *
 *//*  w ww.  j av a  2 s .  co m*/
public NumberFormat getNumberFormat(final RequestData requestData, final String currencyCode,
        final RoundingMode roundingMode, final int maximumFractionDigits, final int minimumFractionDigits,
        final int maximumIntegerDigits, final int minimumIntegerDigits) throws Exception {
    final Localization localization = requestData.getLocalization();
    final Locale locale = localization.getLocale();
    NumberFormat formatter = NumberFormat.getCurrencyInstance(locale);
    formatter.setGroupingUsed(true);
    formatter.setParseIntegerOnly(false);
    formatter.setRoundingMode(roundingMode);
    Currency currency = Currency.getInstance(currencyCode);
    formatter.setCurrency(currency);

    formatter.setMaximumFractionDigits(maximumFractionDigits);
    formatter.setMinimumFractionDigits(minimumFractionDigits);

    formatter.setMaximumIntegerDigits(maximumIntegerDigits);
    formatter.setMinimumIntegerDigits(minimumIntegerDigits);

    return formatter;
}

From source file:org.gnucash.android.ui.transactions.NewTransactionFragment.java

/**
 * Initialize views in the fragment with information from a transaction.
 * This method is called if the fragment is used for editing a transaction
 *//*from ww  w.  ja va2  s.co  m*/
private void initializeViewsWithTransaction() {

    mNameEditText.setText(mTransaction.getName());
    mTransactionTypeButton.setChecked(mTransaction.getTransactionType() == TransactionType.DEBIT);
    mAmountEditText.setText(mTransaction.getAmount().toPlainString());
    mCurrencyTextView.setText(mTransaction.getAmount().getCurrency().getSymbol(Locale.getDefault()));
    mDescriptionEditText.setText(mTransaction.getDescription());
    mDateTextView.setText(DATE_FORMATTER.format(mTransaction.getTimeMillis()));
    mTimeTextView.setText(TIME_FORMATTER.format(mTransaction.getTimeMillis()));
    Calendar cal = GregorianCalendar.getInstance();
    cal.setTimeInMillis(mTransaction.getTimeMillis());
    mDate = mTime = cal;

    final long accountId = mTransactionsDbAdapter.getAccountID(mTransaction.getAccountUID());
    String code = mTransactionsDbAdapter.getCurrencyCode(accountId);
    Currency accountCurrency = Currency.getInstance(code);
    mCurrencyTextView.setText(accountCurrency.getSymbol());
}

From source file:org.openestate.io.examples.ImmobiliareItWritingExample.java

/**
 * Create a {@link Property} with some example data.
 *
 * @return/*from   w ww.j  a  v  a 2 s. co  m*/
 * created example object
 */
protected static Property createProperty() {
    // create an example real estate for rent
    Property obj = FACTORY.createFeedPropertiesProperty();
    obj.setBuildingStatus(Status.ABITABILE);
    obj.setCategory(Category.COMMERCIALE);
    obj.setDateExpiration(Calendar.getInstance());
    obj.setDateUpdated(Calendar.getInstance());
    obj.setOperation(Operation.WRITE);
    obj.setUniqueId(RandomStringUtils.randomAlphanumeric(5));

    obj.setAgent(FACTORY.createFeedPropertiesPropertyAgent());
    obj.getAgent().setEmail("agency@test.org");
    obj.getAgent().setOfficeName("agency name");

    obj.setBlueprints(FACTORY.createFeedPropertiesPropertyBlueprints());
    obj.getBlueprints().getBlueprint().add(createPictureExtended());
    obj.getBlueprints().getBlueprint().add(createPictureExtended());
    obj.getBlueprints().getBlueprint().add(createPictureExtended());

    obj.setBuilding(FACTORY.createBuilding());
    obj.getBuilding().setCategory(Category.COMMERCIALE);
    obj.getBuilding().setClazz(Clazz.SIGNORILE);
    obj.getBuilding().setDetail(PropertyTypeBusiness.ALBERGO);
    obj.getBuilding().setStatus(Status.DISCRETO);
    obj.getBuilding().setType(PropertyType.BUNGALOW);

    obj.setExtraFeatures(FACTORY.createFeedPropertiesPropertyExtraFeatures());
    obj.getExtraFeatures().setAirConditioning(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setBalcony(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setBathrooms(BigInteger.valueOf(RandomUtils.nextLong(1, 5)));
    obj.getExtraFeatures().setBeamHeight(BigInteger.valueOf(RandomUtils.nextLong(1, 10)));
    obj.getExtraFeatures().setBedrooms(BigInteger.valueOf(RandomUtils.nextLong(1, 5)));
    obj.getExtraFeatures().setBuildYear(RandomUtils.nextInt(1900, 2000));
    obj.getExtraFeatures().setDocDescription("some descriptions");
    obj.getExtraFeatures().setDocSpecification("some specifications");
    obj.getExtraFeatures().setElevator(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setFloorplannerUrl("http://floorplanner-url.it/");
    obj.getExtraFeatures().setFreeConditions("free conditions");
    obj.getExtraFeatures().setFurniture(Furniture.PARZIALMENTE_ARREDATO);
    obj.getExtraFeatures().setGarden(Garden.NESSUNO);
    obj.getExtraFeatures().setHeating(Heat.AUTONOMO);
    obj.getExtraFeatures().setKitchen(Kitchen.SEMI_ABITABILE);
    obj.getExtraFeatures().setNet(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setNumFloors(BigInteger.valueOf(RandomUtils.nextLong(1, 5)));
    obj.getExtraFeatures().setOverheadCrane(YesNoReady.READY);
    obj.getExtraFeatures().setReception(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setRentContract(Rental.LIBERO);
    obj.getExtraFeatures().setSecurityAlarm(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setTerrace(RandomUtils.nextInt(0, 2) == 1);
    obj.getExtraFeatures().setVirtualTour("virtual tour");

    obj.getExtraFeatures().setAdditionalCosts(FACTORY.createAdditionalCostsType());
    obj.getExtraFeatures().getAdditionalCosts().setCurrency(Currency.getInstance("EUR"));
    obj.getExtraFeatures().getAdditionalCosts().setValue(BigInteger.valueOf(RandomUtils.nextLong(0, 5000)));

    obj.getExtraFeatures().setExternalArea(FACTORY.createLandSizeType());
    obj.getExtraFeatures().getExternalArea().setUnit(LandSizeUnit.M2);
    obj.getExtraFeatures().getExternalArea().setValue(BigInteger.valueOf(RandomUtils.nextLong(50, 5000)));

    obj.getExtraFeatures().setFloor(FACTORY.createFloor());
    obj.getExtraFeatures().getFloor().setType(Floor.FloorType.INTERMEDIO);
    obj.getExtraFeatures().getFloor().setValue(BigInteger.valueOf(RandomUtils.nextLong(0, 10)));

    obj.getExtraFeatures().setGarage(FACTORY.createBox());
    obj.getExtraFeatures().getGarage().setType(Box.BoxType.POSTO_AUTO);
    obj.getExtraFeatures().getGarage().setValue(BigInteger.valueOf(RandomUtils.nextLong(0, 10)));

    obj.getExtraFeatures().setOfficeSize(FACTORY.createSizeType());
    obj.getExtraFeatures().getOfficeSize().setUnit(SizeUnit.M2);
    obj.getExtraFeatures().getOfficeSize().setValue(BigInteger.valueOf(RandomUtils.nextLong(5, 50)));

    obj.setFeatures(FACTORY.createFeedPropertiesPropertyFeatures());
    obj.getFeatures().setEnergyClass(ClassEnergy.D);
    obj.getFeatures().setRooms(RandomUtils.nextInt(1, 5));

    obj.getFeatures().setEnergyPerformance(FACTORY.createClassEnergyPerformance());
    obj.getFeatures().getEnergyPerformance().setCertified(RandomUtils.nextInt(0, 2) == 1);
    obj.getFeatures().getEnergyPerformance().setUnit(EnergyUnit.KWH_M2ANNO);
    obj.getFeatures().getEnergyPerformance().setValue("energy performance");

    obj.getFeatures().setPrice(FACTORY.createPriceType());
    obj.getFeatures().getPrice().setCurrency(Currency.getInstance("EUR"));
    obj.getFeatures().getPrice().setReserved(RandomUtils.nextInt(0, 2) == 1);
    obj.getFeatures().getPrice().setValue(BigInteger.valueOf(RandomUtils.nextLong(500, 5000000)));

    obj.getFeatures().setSize(FACTORY.createSizeType());
    obj.getFeatures().getSize().setUnit(SizeUnit.M2);
    obj.getFeatures().getSize().setValue(BigInteger.valueOf(RandomUtils.nextLong(50, 5000)));

    obj.setLocation(FACTORY.createLocationStructure());
    obj.getLocation().setAdministrativeArea("administrative area");
    obj.getLocation().setCountryCode("DE");

    obj.getLocation().setCity(FACTORY.createLocationStructureCity());
    obj.getLocation().getCity().setCode(BigInteger.ZERO);
    obj.getLocation().getCity().setValue("Berlin");

    obj.getLocation().setLocality(FACTORY.createLocationStructureLocality());
    obj.getLocation().getLocality().setLatitude(BigDecimal.valueOf(RandomUtils.nextDouble(0, 90)));
    obj.getLocation().getLocality().setLongitude(BigDecimal.valueOf(RandomUtils.nextDouble(0, 90)));
    obj.getLocation().getLocality().setPostalCode("13125");

    obj.getLocation().getLocality().setNeighbourhood(FACTORY.createLocationStructureLocalityNeighbourhood());
    obj.getLocation().getLocality().getNeighbourhood().setId(BigInteger.ZERO);
    obj.getLocation().getLocality().getNeighbourhood().setType(LocationNeighbourhoodType.DISTRICT);
    obj.getLocation().getLocality().getNeighbourhood().setValue("about the neighbourhood");

    obj.getLocation().getLocality().setThoroughfare(FACTORY.createLocationStructureLocalityThoroughfare());
    obj.getLocation().getLocality().getThoroughfare().setDisplay(RandomUtils.nextInt(0, 2) == 1);
    obj.getLocation().getLocality().getThoroughfare().setValue("about thoroughfare");

    obj.getLocation().setSubAdministrativeArea(FACTORY.createLocationStructureSubAdministrativeArea());
    obj.getLocation().getSubAdministrativeArea().setCode(RandomStringUtils.randomAlphanumeric(5));
    obj.getLocation().getSubAdministrativeArea().setValue("Berlin");

    obj.setPictures(FACTORY.createFeedPropertiesPropertyPictures());
    obj.getPictures().getPictureUrlAndPicture().add(createPicture());
    obj.getPictures().getPictureUrlAndPicture().add(createPicture());
    obj.getPictures().getPictureUrlAndPicture().add(createPicture());

    obj.setPropertyType(FACTORY.createProptype());
    obj.getPropertyType().setBusinessType(FACTORY.createBusinessElement());
    obj.getPropertyType().getBusinessType().setCategory(BusinessElement.BusinessElementCategory.IMMOBILE);
    obj.getPropertyType().getBusinessType().setValue(PropertyTypeBusiness.ALTRO);
    obj.getPropertyType().setTerrains(FACTORY.createTerrains());
    obj.getPropertyType().getTerrains().getTerrain().add(TerrainType.SEMINATIVO);
    obj.getPropertyType().setType(PropertyTypeSimple.CASA_INDIPENDENTE);

    obj.setTransactionType(FACTORY.createTransactionType());
    obj.getTransactionType().setAuction(RandomUtils.nextInt(0, 2) == 1);
    obj.getTransactionType().setOwnership(OwnershipType.PARZIALE);
    obj.getTransactionType().setValue("notes about transaction");

    obj.setVideos(FACTORY.createFeedPropertiesPropertyVideos());
    obj.getVideos().getVideo().add(createVideo());
    obj.getVideos().getVideo().add(createVideo());

    return obj;
}

From source file:com.dpcsoftware.mn.App.java

public String printMoney(float value) {
    int nFractionDigits = Currency.getInstance(Locale.getDefault()).getDefaultFractionDigits();
    String val = String.format("%." + nFractionDigits + "f", value);
    String symbol = prefs.getString("currencySymbol", rs.getString(R.string.standard_currency));
    if (prefs.getBoolean("cSymbolBefore", rs.getBoolean(R.bool.standard_currency_pos)) == true)
        return symbol + " " + val;
    else//from w  w w .ja  va  2 s.c o m
        return val + " " + symbol;
}

From source file:org.gnucash.android.ui.transaction.dialog.SplitEditorDialogFragment.java

/**
 * Binds the different UI elements of an inflated list view to corresponding actions
 * @param splitView Split item view// w w w.  ja va2  s . c o  m
 * @param split {@link org.gnucash.android.model.Split} to use to populate the view
 */
private void bindSplitView(final View splitView, Split split) {
    EditText splitMemoEditText = (EditText) splitView.findViewById(R.id.input_split_memo);
    final EditText splitAmountEditText = (EditText) splitView.findViewById(R.id.input_split_amount);
    ImageButton removeSplitButton = (ImageButton) splitView.findViewById(R.id.btn_remove_split);
    Spinner accountsSpinner = (Spinner) splitView.findViewById(R.id.input_accounts_spinner);
    final TextView splitCurrencyTextView = (TextView) splitView.findViewById(R.id.split_currency_symbol);
    final TextView splitUidTextView = (TextView) splitView.findViewById(R.id.split_uid);
    final TransactionTypeToggleButton splitTypeButton = (TransactionTypeToggleButton) splitView
            .findViewById(R.id.btn_split_type);

    splitAmountEditText.addTextChangedListener(new AmountInputFormatter(splitAmountEditText));

    removeSplitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mRemovedSplitUIDs.add(splitUidTextView.getText().toString());
            mSplitsLinearLayout.removeView(splitView);
            mSplitItemViewList.remove(splitView);
            updateTotal();
        }
    });

    updateTransferAccountsList(accountsSpinner);
    accountsSpinner.setOnItemSelectedListener(new TypeButtonLabelUpdater(splitTypeButton));

    Currency accountCurrency = Currency.getInstance(mAccountsDbAdapter.getCurrencyCode(mAccountUID));
    splitCurrencyTextView.setText(accountCurrency.getSymbol());
    splitTypeButton.setAmountFormattingListener(splitAmountEditText, splitCurrencyTextView);
    splitTypeButton.setChecked(mBaseAmount.signum() > 0);
    splitUidTextView.setText(UUID.randomUUID().toString());

    if (split != null) {
        splitAmountEditText.setText(split.getAmount().toPlainString());
        splitMemoEditText.setText(split.getMemo());
        splitUidTextView.setText(split.getUID());
        String splitAccountUID = split.getAccountUID();
        setSelectedTransferAccount(mAccountsDbAdapter.getAccountID(splitAccountUID), accountsSpinner);
        splitTypeButton.setAccountType(mAccountsDbAdapter.getAccountType(splitAccountUID));
        splitTypeButton.setChecked(split.getType());
    }

    //put these balance update triggers last last so as to avoid computing while still loading
    splitAmountEditText.addTextChangedListener(mBalanceUpdater);
    splitTypeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            updateTotal();
        }
    });
}

From source file:org.broadleafcommerce.vendor.paypal.service.payment.PayPalResponseGeneratorImpl.java

protected PayPalDetailsResponse buildDetailsResponse(String rawResponse) {
    PayPalDetailsResponse response = new PayPalDetailsResponse();
    response.setResponseToken(getResponseValue(rawResponse, MessageConstants.TOKEN));
    response.setPhoneNumber(getResponseValue(rawResponse, MessageConstants.PHONENUM));
    String payPalAdjustment = getResponseValue(rawResponse, MessageConstants.PAYPALADJUSTMENT);
    if (!StringUtils.isEmpty(payPalAdjustment)) {
        response.setPayPalAdjustment(new Money(payPalAdjustment, Money.defaultCurrency()));
    }//  w w  w .j a  v a  2s.  c om
    response.setNote(getResponseValue(rawResponse, MessageConstants.NOTE));
    String checkoutStatus = getResponseValue(rawResponse, MessageConstants.CHECKOUTSTATUS);
    if (!StringUtils.isEmpty(checkoutStatus)) {
        response.setCheckoutStatusType(PayPalCheckoutStatusType.getInstance(checkoutStatus));
    }
    response.setEmailAddress(getResponseValue(rawResponse, MessageConstants.EMAILADDRESS));
    response.setPayerId(getResponseValue(rawResponse, MessageConstants.PAYERID));
    String payerStatus = getResponseValue(rawResponse, MessageConstants.PAYERSTATUS);
    if (!StringUtils.isEmpty(payerStatus)) {
        response.setPayerStatus(PayPalPayerStatusType.getInstance(payerStatus));
    }
    response.setCountryCode(getResponseValue(rawResponse, MessageConstants.COUNTRYCODE));
    response.setBusiness(getResponseValue(rawResponse, MessageConstants.BUSINESS));
    response.setPayerSalutation(getResponseValue(rawResponse, MessageConstants.PAYERSALUTATION));
    response.setPayerFirstName(getResponseValue(rawResponse, MessageConstants.PAYERFIRSTNAME));
    response.setPayerLastName(getResponseValue(rawResponse, MessageConstants.PAYERLASTNAME));
    response.setPayerMiddleName(getResponseValue(rawResponse, MessageConstants.PAYERMIDDLENAME));
    response.setPayerSuffix(getResponseValue(rawResponse, MessageConstants.PAYERSUFFIX));

    boolean eof = false;
    int number = 0;
    while (!eof) {
        String street = getResponseValue(rawResponse, replaceNumericBoundProperty(MessageConstants.SHIPTOSTREET,
                new Integer[] { number }, new String[] { "n" }));
        if (!StringUtils.isEmpty(street)) {
            PayPalPayerAddress address = new PayPalPayerAddress();
            address.setStreet(street);
            address.setName(getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.SHIPTONAME, new Integer[] { number }, new String[] { "n" })));
            address.setStreet2(getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.SHIPTOSTREET2, new Integer[] { number }, new String[] { "n" })));
            address.setCity(getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.SHIPTOCITY, new Integer[] { number }, new String[] { "n" })));
            address.setState(getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.SHIPTOSTATE, new Integer[] { number }, new String[] { "n" })));
            address.setZip(getResponseValue(rawResponse, replaceNumericBoundProperty(MessageConstants.SHIPTOZIP,
                    new Integer[] { number }, new String[] { "n" })));
            address.setCountryCode(getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.SHIPTOCOUNTRYCODE, new Integer[] { number }, new String[] { "n" })));
            address.setPhoneNumber(getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.SHIPTOPHONENUMBER, new Integer[] { number }, new String[] { "n" })));
            String addressStatus = getResponseValue(rawResponse, replaceNumericBoundProperty(
                    MessageConstants.ADDRESSSTATUS, new Integer[] { number }, new String[] { "n" }));
            if (!StringUtils.isEmpty(addressStatus)) {
                address.setAddressStatus(PayPalAddressStatusType.getInstance(addressStatus));
            }
            response.getAddresses().add(address);
        } else {
            eof = true;
        }
        number++;
    }

    PayPalPaymentDetails paymentDetails = new PayPalPaymentDetails();
    String currencyCode = getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTCURRENCYCODE, new Integer[] { 0 }, new String[] { "n" }));
    paymentDetails.setCurrencyCode(currencyCode);
    String paymentRequestAmount = getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTAMOUNT, new Integer[] { 0 }, new String[] { "n" }));
    if (!StringUtils.isEmpty(paymentRequestAmount)) {
        paymentDetails.setAmount(new Money(paymentRequestAmount, Currency.getInstance(currencyCode)));
    }
    String paymentRequestItemTotal = getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTITEMTOTAL, new Integer[] { 0 }, new String[] { "n" }));
    if (!StringUtils.isEmpty(paymentRequestItemTotal)) {
        paymentDetails.setItemTotal(new Money(paymentRequestItemTotal, Currency.getInstance(currencyCode)));
    }
    String paymentRequestShippingTotal = getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTSHIPPINGTOTAL, new Integer[] { 0 }, new String[] { "n" }));
    if (!StringUtils.isEmpty(paymentRequestShippingTotal)) {
        paymentDetails
                .setShippingTotal(new Money(paymentRequestShippingTotal, Currency.getInstance(currencyCode)));
    }
    String paymentRequestShippingDiscount = getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTSHIPPINGDISCOUNT, new Integer[] { 0 }, new String[] { "n" }));
    if (!StringUtils.isEmpty(paymentRequestShippingDiscount)) {
        paymentDetails.setShippingDiscount(
                new Money(paymentRequestShippingDiscount, Currency.getInstance(currencyCode)));
    }
    String paymentRequestTotalTax = getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTTOTALTAX, new Integer[] { 0 }, new String[] { "n" }));
    if (!StringUtils.isEmpty(paymentRequestTotalTax)) {
        paymentDetails.setTotalTax(new Money(paymentRequestTotalTax, Currency.getInstance(currencyCode)));
    }
    paymentDetails.setReferenceNumber(getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTREFERENCENUMBER, new Integer[] { 0 }, new String[] { "n" })));
    paymentDetails.setTransactionId(getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTTRANSACTIONID, new Integer[] { 0 }, new String[] { "n" })));
    paymentDetails.setPaymentMethod(getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTALLOWEDMETHOD, new Integer[] { 0 }, new String[] { "n" })));
    paymentDetails.setPaymentRequestId(getResponseValue(rawResponse, replaceNumericBoundProperty(
            MessageConstants.DETAILSPAYMENTREQUESTID, new Integer[] { 0 }, new String[] { "n" })));
    response.setPaymentDetails(paymentDetails);

    eof = false;
    number = 0;
    while (!eof) {
        String paymentRequestItemName = getResponseValue(rawResponse,
                replaceNumericBoundProperty(MessageConstants.DETAILSPAYMENTITEMNAME,
                        new Integer[] { 0, number }, new String[] { "n", "m" }));
        if (!StringUtils.isEmpty(paymentRequestItemName)) {
            PayPalPaymentItemDetails itemDetails = new PayPalPaymentItemDetails();
            itemDetails.setName(paymentRequestItemName);
            itemDetails.setDescription(getResponseValue(rawResponse,
                    replaceNumericBoundProperty(MessageConstants.DETAILSPAYMENTITEMDESCRIPTION,
                            new Integer[] { 0, number }, new String[] { "n", "m" })));
            String paymentRequestItemAmount = getResponseValue(rawResponse,
                    replaceNumericBoundProperty(MessageConstants.DETAILSPAYMENTITEMAMOUNT,
                            new Integer[] { 0, number }, new String[] { "n", "m" }));
            if (!StringUtils.isEmpty(paymentRequestItemAmount)) {
                itemDetails.setAmount(new Money(paymentRequestItemAmount, Currency.getInstance(currencyCode)));
            }
            itemDetails.setItemNumber(getResponseValue(rawResponse,
                    replaceNumericBoundProperty(MessageConstants.DETAILSPAYMENTITEMNUMBER,
                            new Integer[] { 0, number }, new String[] { "n", "m" })));
            String paymentRequestItemQuantity = getResponseValue(rawResponse,
                    replaceNumericBoundProperty(MessageConstants.DETAILSPAYMENTITEMQUANTITY,
                            new Integer[] { 0, number }, new String[] { "n", "m" }));
            if (!StringUtils.isEmpty(paymentRequestItemQuantity)) {
                itemDetails.setQuantity(Integer.valueOf(paymentRequestItemQuantity));
            }
            String paymentRequestItemTax = getResponseValue(rawResponse,
                    replaceNumericBoundProperty(MessageConstants.DETAILSPAYMENTITEMTAX,
                            new Integer[] { 0, number }, new String[] { "n", "m" }));
            if (!StringUtils.isEmpty(paymentRequestItemTax)) {
                itemDetails.setTax(new Money(paymentRequestItemTax, Currency.getInstance(currencyCode)));
            }
            paymentDetails.getItemDetails().add(itemDetails);
        } else {
            eof = true;
        }
        number++;
    }

    populateDetailErrors(rawResponse, response);

    return response;
}

From source file:org.gnucash.android.ui.transactions.NewTransactionFragment.java

/**
 * Initialize views with default data for new transactions
 *//* ww w .  j  a v  a  2 s.co  m*/
private void initalizeViews() {
    Date time = new Date(System.currentTimeMillis());
    mDateTextView.setText(DATE_FORMATTER.format(time));
    mTimeTextView.setText(TIME_FORMATTER.format(time));
    mTime = mDate = Calendar.getInstance();

    String typePref = PreferenceManager.getDefaultSharedPreferences(getActivity())
            .getString(getString(R.string.key_default_transaction_type), "DEBIT");
    if (typePref.equals("CREDIT")) {
        mTransactionTypeButton.setChecked(false);
    }

    final long accountId = getArguments().getLong(TransactionsListFragment.SELECTED_ACCOUNT_ID);
    String code = Money.DEFAULT_CURRENCY_CODE;
    if (accountId != 0)
        code = mTransactionsDbAdapter.getCurrencyCode(accountId);

    Currency accountCurrency = Currency.getInstance(code);
    mCurrencyTextView.setText(accountCurrency.getSymbol(Locale.getDefault()));
}

From source file:org.gnucash.android.ui.report.ReportSummaryFragment.java

/**
 * Manages all actions about displaying the pie chart
 *//*from   w  ww .  j  a va  2  s.co m*/
private void displayChart() {
    mChart.highlightValues(null);
    mChart.clear();

    PieData pieData = PieChartFragment.groupSmallerSlices(getData(), getActivity());
    if (pieData != null && pieData.getYValCount() != 0) {
        mChart.setData(pieData);
        float sum = mChart.getData().getYValueSum();
        String total = getResources().getString(R.string.label_chart_total);
        String currencySymbol = Currency.getInstance(GnuCashApplication.getDefaultCurrencyCode())
                .getSymbol(Locale.getDefault());
        mChart.setCenterText(
                String.format(PieChartFragment.TOTAL_VALUE_LABEL_PATTERN, total, sum, currencySymbol));
        mChart.animateXY(1800, 1800);
        mChart.setTouchEnabled(true);
    } else {
        mChart.setData(getEmptyData());
    }

    mChart.invalidate();
}

From source file:com.facebook.unity.FB.java

@UnityCallable
public static void LogAppEvent(String params_str) {
    Log.v(TAG, "LogAppEvent(" + params_str + ")");
    UnityParams unity_params = UnityParams.parse(params_str);

    Bundle parameters = new Bundle();
    if (unity_params.has("parameters")) {
        UnityParams unity_params_parameter = unity_params.getParamsObject("parameters");
        parameters = unity_params_parameter.getStringParams();
    }/* ww w .  j a v  a2s. c  o  m*/

    if (unity_params.has("logPurchase")) {
        FB.getAppEventsLogger().logPurchase(new BigDecimal(unity_params.getDouble("logPurchase")),
                Currency.getInstance(unity_params.getString("currency")), parameters);
    } else if (unity_params.hasString("logEvent")) {
        if (unity_params.has("valueToSum")) {
            FB.getAppEventsLogger().logEvent(unity_params.getString("logEvent"),
                    unity_params.getDouble("valueToSum"), parameters);
        } else {
            FB.getAppEventsLogger().logEvent(unity_params.getString("logEvent"), parameters);
        }
    } else {
        Log.e(TAG, "couldn't logPurchase or logEvent params: " + params_str);
    }
}

From source file:de.hybris.platform.commerceservices.order.impl.DefaultCommerceCheckoutServiceTest.java

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    commerceCheckoutService = new DefaultCommerceCheckoutService();
    commerceCheckoutService.setModelService(modelService);
    commerceCheckoutService.setCommerceCartCalculationStrategy(commerceCartCalculationStrategy);
    commerceCheckoutService.setDeliveryService(deliveryService);
    commerceCheckoutService.setI18nService(i18nService);
    commerceCheckoutService.setPaymentService(paymentService);
    commerceCheckoutService.setOrderService(orderService);
    commerceCheckoutService.setBaseSiteService(siteService);
    commerceCheckoutService.setBaseStoreService(baseStoreService);
    commerceCheckoutService.setPromotionsService(promotionsService);
    commerceCheckoutService.setCalculationService(calculationService);
    commerceCheckoutService.setExternalTaxesService(externalTaxesService);
    commerceCheckoutService.setCommonI18NService(commonI18NService);
    commerceCheckoutService.setCommercePaymentAuthorizationStrategy(paymentAuthorizationStrategy);
    commerceCheckoutService.setCommercePlaceOrderStrategy(commercePlaceOrderStrategy);
    commerceCheckoutService.setCommercePaymentInfoStrategy(commercePaymentInfoStrategy);
    commerceCheckoutService.setCommerceDeliveryModeValidationStrategy(commerceDeliveryModeValidationStrategy);
    commerceCheckoutService.setCommercePaymentProviderStrategy(commercePaymentProviderStrategy);
    commerceCheckoutService.setCommerceDeliveryAddressStrategy(commerceDeliveryAddressStrategy);
    commerceCheckoutService.setCommerceDeliveryModeStrategy(commerceDeliveryModeStrategy);

    cartModel = mock(CartModel.class);
    orderModel = mock(OrderModel.class);
    deliveryAddress = mock(AddressModel.class);
    customerModel = mock(CustomerModel.class);
    deliveryModeModel = mock(DeliveryModeModel.class);
    paymentInfoModel = mock(CreditCardPaymentInfoModel.class);
    currencyModel = mock(CurrencyModel.class);
    currency = Currency.getInstance("USD");
    transactionEntryModel = mock(PaymentTransactionEntryModel.class);
    paymentTransactionModel = mock(PaymentTransactionModel.class);
    orderEntryModel1 = mock(OrderEntryModel.class);
    orderEntryModel2 = mock(OrderEntryModel.class);
    siteModel = mock(BaseSiteModel.class);
    storeModel = mock(BaseStoreModel.class);
    languageModel = mock(LanguageModel.class);

    given(cartModel.getUser()).willReturn(customerModel);
    given(customerModel.getAddresses()).willReturn(addressBook);
    given(deliveryAddress.getShippingAddress()).willReturn(Boolean.FALSE);
    given(cartModel.getCurrency()).willReturn(currencyModel);
    given(currencyModel.getIsocode()).willReturn(TEST_CURRENCY_ISO);
    given(i18nService.getBestMatchingJavaCurrency(TEST_CURRENCY_ISO)).willReturn(currency);
    given(customerModel.getUid()).willReturn(TEST_CUSTOMER_UID);
    given(cartModel.getTotalPrice()).willReturn(Double.valueOf(99.99d));
    given(paymentService.authorize(anyString(), any(BigDecimal.class), any(Currency.class),
            any(AddressModel.class), anyString(), anyString(), anyString())).willReturn(transactionEntryModel);
    given(transactionEntryModel.getPaymentTransaction()).willReturn(paymentTransactionModel);
    given(orderEntryModel1.getEntryNumber()).willReturn(Integer.valueOf(0));
    given(orderEntryModel2.getEntryNumber()).willReturn(Integer.valueOf(1));
    given(siteService.getCurrentBaseSite()).willReturn(siteModel);
    given(baseStoreService.getCurrentBaseStore()).willReturn(storeModel);
    given(storeModel.getPaymentProvider()).willReturn(TEST_PSP);
    given(paymentInfoModel.getBillingAddress()).willReturn(deliveryAddress);
    given(orderModel.getPaymentInfo()).willReturn(paymentInfoModel);
    given(orderModel.getLanguage()).willReturn(languageModel);
    final Collection collection = new HashSet<AddressModel>();
    collection.add(deliveryAddress);/*from   ww  w .j  a  va  2 s.  c om*/
    given(deliveryService.getSupportedDeliveryAddressesForOrder(cartModel, true))
            .willReturn(new ArrayList<AddressModel>(collection));
    given(deliveryService.getSupportedDeliveryAddressesForOrder(cartModel, false))
            .willReturn(new ArrayList<AddressModel>(collection));
}