Example usage for java.math BigDecimal movePointRight

List of usage examples for java.math BigDecimal movePointRight

Introduction

In this page you can find the example usage for java.math BigDecimal movePointRight.

Prototype

public BigDecimal movePointRight(int n) 

Source Link

Document

Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right.

Usage

From source file:org.apache.calcite.runtime.SqlFunctions.java

/** SQL <code>TRUNCATE</code> operator applied to BigDecimal values. */
public static BigDecimal struncate(BigDecimal b0, int b1) {
    return b0.movePointRight(b1).setScale(0, RoundingMode.DOWN).movePointLeft(b1);
}

From source file:org.kalypso.model.wspm.pdb.wspm.CheckinStatePdbOperation.java

private BigDecimal getStation(final IProfileFeature feature) {
    final BigDecimal station = feature.getBigStation();
    if (station == null)
        return null;

    return station.movePointRight(3);
}

From source file:org.multibit.utils.CSMiscUtils.java

public static BigInteger getRawUnitsFromDisplayString(CSAsset asset, String display) {
    BigDecimal result = null;
    try {//  www.  j  a v  a  2 s  .  com
        //System.out.println("Start to get raw units from: " + display);
        result = new BigDecimal(display);
    } catch (NumberFormatException nfe) {
        nfe.printStackTrace();
        return null;
    }

    // Reverse apply the multiple
    int decimalPlaces = CSMiscUtils.getNumberOfDisplayDecimalPlaces(asset);
    if (decimalPlaces != 0) {
        result = result.movePointRight(decimalPlaces);
    }
    // FIXME: what if multiple is 0.0? ignore? error?
    //   double multiple = asset.getMultiple();
    //   BigDecimal m = new BigDecimal(String.valueOf(multiple));
    //   result = result.divide(m, MathContext.DECIMAL32);

    //System.out.println("multiplier=" + m + ", removed multiplier =" + display);

    double interestRate = asset.getInterestRate();

    BigDecimal rate = new BigDecimal(String.valueOf(interestRate));
    rate = rate.divide(new BigDecimal(100));
    rate = rate.add(BigDecimal.ONE);

    Date issueDate = asset.getIssueDate();
    DateTime d1 = new DateTime(issueDate);
    DateTime d2 = new DateTime();
    int seconds = Math.abs(Seconds.secondsBetween(d1, d2).getSeconds());

    //System.out.println("...Number of seconds difference: " + seconds);

    BigDecimal elapsedSeconds = new BigDecimal(seconds);
    BigDecimal elapsedYears = elapsedSeconds.divide(new BigDecimal(COINSPARK_SECONDS_IN_YEAR),
            MathContext.DECIMAL32);
    //System.out.println("...Number of years difference: " + elapsedYears.toPlainString());

    double base = elapsedSeconds.doubleValue();
    double exp = elapsedYears.doubleValue();
    //System.out.println("...base=" + base + "  exponent=" + exp);
    double interestMultipler = Math.pow(rate.doubleValue(), elapsedYears.doubleValue());

    //System.out.println("interest multipler =" + interestMultipler);

    result = result.divide(new BigDecimal(String.valueOf(interestMultipler)), MathContext.DECIMAL32);

    //System.out.println("result = " + result.toPlainString());

    result = result.setScale(0, RoundingMode.DOWN);
    result = result.stripTrailingZeros();

    //System.out.println("result floored = " + result.toPlainString());

    String resultString = result.toPlainString();
    return new BigInteger(resultString);
}

From source file:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java

private void updateTotal() {
    RowValuesTableModel model = this.tableBonItem.getModel();

    long totalHT = 0;
    long totalTTC = 0;
    int columnIndexHT = model.getColumnIndexForElement(this.tableBonItem.getPrixTotalHTElement());
    int columnIndexTTC = model.getColumnIndexForElement(this.tableBonItem.getPrixTotalTTCElement());

    // columnIndexHT = model.getColumnIndexForElement(getTable().get);
    for (int i = 0; i < model.getRowCount(); i++) {
        BigDecimal nHT = (BigDecimal) model.getValueAt(i, columnIndexHT);
        totalHT += nHT.movePointRight(2).setScale(0, RoundingMode.HALF_UP).longValue();
        BigDecimal nTTC = (BigDecimal) model.getValueAt(i, columnIndexTTC);
        totalTTC += nTTC.movePointRight(2).setScale(0, RoundingMode.HALF_UP).longValue();
    }/*w  w w. ja  v a  2s .c om*/

    this.textTotalHT.setText(GestionDevise.currencyToString(totalHT));
    this.textTotalTVA.setText(GestionDevise.currencyToString(totalTTC - totalHT));
    this.textTotalTTC.setText(GestionDevise.currencyToString(totalTTC));
}

From source file:org.opentaps.dataimport.CustomerDecoder.java

public List<GenericValue> decode(GenericValue entry, Timestamp importTimestamp, Delegator delegator,
        LocalDispatcher dispatcher, Object... args) throws Exception {
    List<GenericValue> toBeStored = FastList.newInstance();

    String baseCurrencyUomId = UtilCommon.getOrgBaseCurrency(organizationPartyId, delegator);

    /***********************/
    /** Import Party data **/
    /***********************/

    // create the Person and Party with the roles for each depending on whether companyName or lastName is present
    String companyPartyId = null;
    String personPartyId = null;//  w ww .  jav  a 2s. c o m
    String primaryPartyId = null; // this will be the partyId most other artifacts are associated with.  If company is present, it will be company, otherwise person
    String primaryPartyName = null;
    GenericValue partySupplementalData = null; // this will be the party Supplemental Data to keep the primary contact mech
    if ((entry.get("lastName") != null) && !("".equals(entry.getString("lastName")))) {
        personPartyId = delegator.getNextSeqId("Party");
        toBeStored.addAll(UtilImport.makePartyWithRoles(personPartyId, "PERSON",
                UtilMisc.toList("CONTACT", "BILL_TO_CUSTOMER"), delegator));
        GenericValue person = delegator.makeValue("Person", UtilMisc.toMap("partyId", personPartyId,
                "firstName", entry.getString("firstName"), "lastName", entry.getString("lastName")));
        toBeStored.add(person);
        Map<String, Object> partyRelationship = UtilMisc.toMap("partyIdTo", initialResponsiblePartyId,
                "roleTypeIdTo", initialResponsibleRoleTypeId, "partyIdFrom", personPartyId, "roleTypeIdFrom",
                "CONTACT", "partyRelationshipTypeId", "RESPONSIBLE_FOR", "fromDate", importTimestamp);
        partyRelationship.put("securityGroupId", "CONTACT_OWNER");
        toBeStored.add(delegator.makeValue("PartyRelationship", partyRelationship));
        primaryPartyId = personPartyId;
        primaryPartyName = org.ofbiz.party.party.PartyHelper.getPartyName(person);
        Debug.logInfo("Creating Person [" + personPartyId + "] for Customer [" + entry.get("customerId") + "].",
                MODULE);
    }
    if ((entry.get("companyName") != null) && !("".equals(entry.getString("companyName")))) {
        companyPartyId = delegator.getNextSeqId("Party");
        toBeStored.addAll(UtilImport.makePartyWithRoles(companyPartyId, "PARTY_GROUP",
                UtilMisc.toList("ACCOUNT", "BILL_TO_CUSTOMER"), delegator));
        GenericValue partyGroup = delegator.makeValue("PartyGroup",
                UtilMisc.toMap("partyId", companyPartyId, "groupName", entry.getString("companyName")));
        toBeStored.add(partyGroup);
        Map<String, Object> partyRelationship = UtilMisc.toMap("partyIdTo", initialResponsiblePartyId,
                "roleTypeIdTo", initialResponsibleRoleTypeId, "partyIdFrom", companyPartyId, "roleTypeIdFrom",
                "ACCOUNT", "partyRelationshipTypeId", "RESPONSIBLE_FOR", "fromDate", importTimestamp);
        partyRelationship.put("securityGroupId", "ACCOUNT_OWNER");
        toBeStored.add(delegator.makeValue("PartyRelationship", partyRelationship));
        // make the person a Contact of the company Account
        if (UtilValidate.isNotEmpty(personPartyId)) {
            partyRelationship = UtilMisc.toMap("partyIdFrom", personPartyId, "roleTypeIdFrom", "CONTACT",
                    "partyRelationshipTypeId", "CONTACT_REL_INV", "partyIdTo", companyPartyId, "roleTypeIdTo",
                    "ACCOUNT", "fromDate", importTimestamp);
            toBeStored.add(delegator.makeValue("PartyRelationship", partyRelationship));
        }

        primaryPartyId = companyPartyId;
        primaryPartyName = org.ofbiz.party.party.PartyHelper.getPartyName(partyGroup);
        Debug.logInfo(
                "Creating PartyGroup [" + companyPartyId + "] for Customer [" + entry.get("customerId") + "].",
                MODULE);
    }

    if (primaryPartyId == null) {
        Debug.logWarning("No person or company associated with customer [" + entry.get("customerId") + "]",
                MODULE);
        return null;
    }

    // associate person with company
    if ((companyPartyId != null) && (personPartyId != null)) {
        Map<String, Object> partyRelationship = UtilMisc.toMap("partyIdTo", companyPartyId, "roleTypeIdTo",
                "ACCOUNT", "partyIdFrom", personPartyId, "roleTypeIdFrom", "CONTACT", "partyRelationshipTypeId",
                "CONTACT_REL_INV", "fromDate", importTimestamp);
        toBeStored.add(delegator.makeValue("PartyRelationship", partyRelationship));
    }

    /*******************************************************************************************************/
    /** Import contact mechs.  Note that each contact mech will be associated with the company and person. */
    /*******************************************************************************************************/

    String billingContactMechId = null; // for later use with things that need billing address
    if (!UtilValidate.isEmpty(entry.getString("address1"))) {
        // associate this as the GENERAL_LOCATION and BILLING_LOCATION
        GenericValue contactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId",
                delegator.getNextSeqId("ContactMech"), "contactMechTypeId", "POSTAL_ADDRESS"));
        GenericValue mainPostalAddress = UtilImport.makePostalAddress(contactMech,
                entry.getString("companyName"), entry.getString("firstName"), entry.getString("lastName"),
                entry.getString("attnName"), entry.getString("address1"), entry.getString("address2"),
                entry.getString("city"), entry.getString("stateProvinceGeoId"), entry.getString("postalCode"),
                entry.getString("postalCodeExt"), entry.getString("countryGeoId"), delegator);
        toBeStored.add(contactMech);
        toBeStored.add(mainPostalAddress);
        if (personPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("GENERAL_LOCATION", mainPostalAddress,
                    personPartyId, importTimestamp, delegator));
            toBeStored.add(UtilImport.makeContactMechPurpose("BILLING_LOCATION", mainPostalAddress,
                    personPartyId, importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("contactMechId",
                    contactMech.get("contactMechId"), "partyId", personPartyId, "fromDate", importTimestamp)));
            toBeStored.add(UtilImport.makePartySupplementalData(partySupplementalData, personPartyId,
                    "primaryPostalAddressId", mainPostalAddress, delegator));
        }
        if (companyPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("GENERAL_LOCATION", mainPostalAddress,
                    companyPartyId, importTimestamp, delegator));
            toBeStored.add(UtilImport.makeContactMechPurpose("BILLING_LOCATION", mainPostalAddress,
                    companyPartyId, importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("contactMechId",
                    contactMech.get("contactMechId"), "partyId", companyPartyId, "fromDate", importTimestamp)));
            toBeStored.add(UtilImport.makePartySupplementalData(partySupplementalData, companyPartyId,
                    "primaryPostalAddressId", mainPostalAddress, delegator));
        }
        billingContactMechId = contactMech.getString("contactMechId");
    }

    if (!UtilValidate.isEmpty(entry.getString("shipToAddress1"))) {
        // associate this as SHIPPING_LOCATION
        GenericValue contactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId",
                delegator.getNextSeqId("ContactMech"), "contactMechTypeId", "POSTAL_ADDRESS"));
        GenericValue secondaryPostalAddress = UtilImport.makePostalAddress(contactMech,
                entry.getString("shipToCompanyName"), entry.getString("shipToFirstName"),
                entry.getString("shipToLastName"), entry.getString("shipToAttnName"),
                entry.getString("shipToAddress1"), entry.getString("shipToAddress2"),
                entry.getString("shipToCity"), entry.getString("shipToStateProvinceGeoId"),
                entry.getString("shipToPostalCode"), entry.getString("shipToPostalCodeExt"),
                entry.getString("shipToCountryGeoId"), delegator);
        toBeStored.add(contactMech);
        toBeStored.add(secondaryPostalAddress);
        if (personPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("SHIPPING_LOCATION", secondaryPostalAddress,
                    personPartyId, importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("contactMechId",
                    contactMech.get("contactMechId"), "partyId", personPartyId, "fromDate", importTimestamp)));
        }
        if (companyPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("SHIPPING_LOCATION", secondaryPostalAddress,
                    companyPartyId, importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("contactMechId",
                    contactMech.get("contactMechId"), "partyId", companyPartyId, "fromDate", importTimestamp)));
        }
    }

    if (!UtilValidate.isEmpty(entry.getString("primaryPhoneNumber"))) {
        // associate this as PRIMARY_PHONE
        GenericValue contactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId",
                delegator.getNextSeqId("ContactMech"), "contactMechTypeId", "TELECOM_NUMBER"));
        GenericValue primaryNumber = UtilImport.makeTelecomNumber(contactMech,
                entry.getString("primaryPhoneCountryCode"), entry.getString("primaryPhoneAreaCode"),
                entry.getString("primaryPhoneNumber"), delegator);
        toBeStored.add(contactMech);
        toBeStored.add(primaryNumber);
        if (personPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("PRIMARY_PHONE", primaryNumber, personPartyId,
                    importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", contactMech.get("contactMechId"), "partyId", personPartyId,
                            "fromDate", importTimestamp, "extension",
                            entry.getString("primaryPhoneExtension"))));
            toBeStored.add(UtilImport.makePartySupplementalData(partySupplementalData, personPartyId,
                    "primaryTelecomNumberId", primaryNumber, delegator));
        }
        if (companyPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("PRIMARY_PHONE", primaryNumber, companyPartyId,
                    importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", contactMech.get("contactMechId"), "partyId", companyPartyId,
                            "fromDate", importTimestamp, "extension",
                            entry.getString("primaryPhoneExtension"))));
            toBeStored.add(UtilImport.makePartySupplementalData(partySupplementalData, companyPartyId,
                    "primaryTelecomNumberId", primaryNumber, delegator));
        }
    }

    if (!UtilValidate.isEmpty(entry.getString("secondaryPhoneNumber"))) {
        // this one has no contactmech purpose type
        GenericValue contactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId",
                delegator.getNextSeqId("ContactMech"), "contactMechTypeId", "TELECOM_NUMBER"));
        GenericValue secondaryNumber = UtilImport.makeTelecomNumber(contactMech,
                entry.getString("secondaryPhoneCountryCode"), entry.getString("secondaryPhoneAreaCode"),
                entry.getString("secondaryPhoneNumber"), delegator);
        toBeStored.add(contactMech);
        toBeStored.add(secondaryNumber);
        if (personPartyId != null) {
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", contactMech.get("contactMechId"), "partyId", personPartyId,
                            "fromDate", importTimestamp, "extension",
                            entry.getString("secondaryPhoneExtension"))));
        }
        if (companyPartyId != null) {
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", contactMech.get("contactMechId"), "partyId", companyPartyId,
                            "fromDate", importTimestamp, "extension",
                            entry.getString("secondaryPhoneExtension"))));
        }
    }

    if (!UtilValidate.isEmpty(entry.getString("faxNumber"))) {
        // associate this as FAX_NUMBER
        GenericValue contactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId",
                delegator.getNextSeqId("ContactMech"), "contactMechTypeId", "TELECOM_NUMBER"));
        GenericValue faxNumber = UtilImport.makeTelecomNumber(contactMech, entry.getString("faxCountryCode"),
                entry.getString("faxAreaCode"), entry.getString("faxNumber"), delegator);
        toBeStored.add(contactMech);
        toBeStored.add(faxNumber);
        if (personPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("FAX_NUMBER", faxNumber, personPartyId,
                    importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("contactMechId",
                    contactMech.get("contactMechId"), "partyId", personPartyId, "fromDate", importTimestamp)));
        }
        if (companyPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("FAX_NUMBER", faxNumber, companyPartyId,
                    importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("contactMechId",
                    contactMech.get("contactMechId"), "partyId", companyPartyId, "fromDate", importTimestamp)));
        }
    }

    if (!UtilValidate.isEmpty(entry.getString("didNumber"))) {
        // associate this as PHONE_DID
        GenericValue contactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId",
                delegator.getNextSeqId("ContactMech"), "contactMechTypeId", "TELECOM_NUMBER"));
        GenericValue didNumber = UtilImport.makeTelecomNumber(contactMech, entry.getString("didCountryCode"),
                entry.getString("didAreaCode"), entry.getString("didNumber"), delegator);
        toBeStored.add(contactMech);
        toBeStored.add(didNumber);
        if (personPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("PHONE_DID", didNumber, personPartyId,
                    importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", contactMech.get("contactMechId"), "partyId", personPartyId,
                            "fromDate", importTimestamp, "extension", entry.getString("didExtension"))));
        }
        if (companyPartyId != null) {
            toBeStored.add(UtilImport.makeContactMechPurpose("PHONE_DID", didNumber, companyPartyId,
                    importTimestamp, delegator));
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", contactMech.get("contactMechId"), "partyId", companyPartyId,
                            "fromDate", importTimestamp, "extension", entry.getString("didExtension"))));
        }
    }

    if (!UtilValidate.isEmpty(entry.getString("emailAddress"))) {
        // make the email address
        GenericValue emailContactMech = delegator.makeValue("ContactMech",
                UtilMisc.toMap("contactMechId", delegator.getNextSeqId("ContactMech"), "contactMechTypeId",
                        "EMAIL_ADDRESS", "infoString", entry.getString("emailAddress")));
        toBeStored.add(emailContactMech);
        if (personPartyId != null) {
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", emailContactMech.get("contactMechId"), "partyId",
                            personPartyId, "fromDate", importTimestamp)));
            toBeStored.add(UtilImport.makeContactMechPurpose("PRIMARY_EMAIL", emailContactMech, personPartyId,
                    importTimestamp, delegator));
            toBeStored.add(UtilImport.makePartySupplementalData(partySupplementalData, personPartyId,
                    "primaryEmailId", emailContactMech, delegator));
        }
        if (companyPartyId != null) {
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", emailContactMech.get("contactMechId"), "partyId",
                            companyPartyId, "fromDate", importTimestamp)));
            toBeStored.add(UtilImport.makeContactMechPurpose("PRIMARY_EMAIL", emailContactMech, companyPartyId,
                    importTimestamp, delegator));
            toBeStored.add(UtilImport.makePartySupplementalData(partySupplementalData, companyPartyId,
                    "primaryEmailId", emailContactMech, delegator));
        }
    }

    if (!UtilValidate.isEmpty(entry.getString("webAddress"))) {
        // make the web address
        GenericValue webContactMech = delegator.makeValue("ContactMech",
                UtilMisc.toMap("contactMechId", delegator.getNextSeqId("ContactMech"), "contactMechTypeId",
                        "WEB_ADDRESS", "infoString", entry.getString("webAddress")));
        toBeStored.add(webContactMech);
        if (personPartyId != null) {
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", webContactMech.get("contactMechId"), "partyId",
                            personPartyId, "fromDate", importTimestamp)));
            toBeStored.add(UtilImport.makeContactMechPurpose("PRIMARY_WEB_URL", webContactMech, personPartyId,
                    importTimestamp, delegator));
        }
        if (companyPartyId != null) {
            toBeStored.add(delegator.makeValue("PartyContactMech",
                    UtilMisc.toMap("contactMechId", webContactMech.get("contactMechId"), "partyId",
                            companyPartyId, "fromDate", importTimestamp)));
            toBeStored.add(UtilImport.makeContactMechPurpose("PRIMARY_WEB_URL", webContactMech, companyPartyId,
                    importTimestamp, delegator));
        }
    }

    /*****************************/
    /** Import Party notes. **/
    /*****************************/

    if (!UtilValidate.isEmpty(entry.getString("note"))) {
        // make the party note
        if (personPartyId != null) {
            GenericValue noteData = delegator.makeValue("NoteData",
                    UtilMisc.toMap("noteId", delegator.getNextSeqId("NoteData"), "noteInfo",
                            entry.getString("note"), "noteParty", initialResponsiblePartyId, "noteDateTime",
                            importTimestamp));
            toBeStored.add(noteData);
            toBeStored.add(delegator.makeValue("PartyNote",
                    UtilMisc.toMap("noteId", noteData.get("noteId"), "partyId", personPartyId)));
        }
        if (companyPartyId != null) {
            GenericValue noteData = delegator.makeValue("NoteData",
                    UtilMisc.toMap("noteId", delegator.getNextSeqId("NoteData"), "noteInfo",
                            entry.getString("note"), "noteParty", initialResponsiblePartyId, "noteDateTime",
                            importTimestamp));
            toBeStored.add(noteData);
            toBeStored.add(delegator.makeValue("PartyNote",
                    UtilMisc.toMap("noteId", noteData.get("noteId"), "partyId", companyPartyId)));
        }
    }

    /*****************************/
    /** Import Pricing data. **/
    /*****************************/

    if (!UtilValidate.isEmpty(entry.getString("discount"))) {
        BigDecimal discount = entry.getBigDecimal("discount").abs().negate();
        discount = discount.movePointRight(2);
        // Apply price rule only to company
        if (companyPartyId != null) {
            // productPriceRule
            String productPriceRuleId = delegator.getNextSeqId("ProductPriceRule");
            String priceRuleName = "Imported rule for ";
            priceRuleName += UtilValidate.isEmpty(entry.get("companyName")) ? "partyId: " + companyPartyId
                    : entry.getString("companyName");
            toBeStored.add(delegator.makeValue("ProductPriceRule",
                    UtilMisc.toMap("productPriceRuleId", productPriceRuleId, "ruleName", priceRuleName,
                            "isSale", "N", "fromDate", importTimestamp)));
            // productPriceCond
            toBeStored.add(delegator.makeValue("ProductPriceCond",
                    UtilMisc.toMap("productPriceRuleId", productPriceRuleId, "productPriceCondSeqId",
                            UtilFormatOut.formatPaddedNumber(1, 2), "inputParamEnumId", "PRIP_PARTY_ID",
                            "operatorEnumId", "PRC_EQ", "condValue", companyPartyId)));
            // productPriceAction
            toBeStored.add(delegator.makeValue("ProductPriceAction",
                    UtilMisc.toMap("productPriceRuleId", productPriceRuleId, "productPriceActionSeqId",
                            UtilFormatOut.formatPaddedNumber(1, 2), "productPriceActionTypeId", "PRICE_POL",
                            "amount", discount)));
        }
    }

    /***********************************/
    /** Import Party Classifications. **/
    /***********************************/

    if (!UtilValidate.isEmpty(entry.getString("partyClassificationTypeId"))) {
        // Apply classification only to partyGroup
        if (companyPartyId != null) {
            String partyClassificationTypeId = entry.getString("partyClassificationTypeId");
            if (delegator.findByPrimaryKey("PartyClassificationType",
                    UtilMisc.toMap("partyClassificationTypeId", partyClassificationTypeId)) != null) {
                GenericValue partyClassificationGroup = EntityUtil
                        .getFirst(delegator.findByAnd("PartyClassificationGroup",
                                UtilMisc.toMap("partyClassificationTypeId", partyClassificationTypeId)));
                if (partyClassificationGroup != null) {
                    toBeStored.add(delegator.makeValue("PartyClassification",
                            UtilMisc.toMap("partyId", companyPartyId, "partyClassificationGroupId",
                                    partyClassificationGroup.getString("partyClassificationGroupId"),
                                    "fromDate", importTimestamp)));
                } else {
                    Debug.logInfo("No partyClassificationGroups exist for partyClassificationId"
                            + partyClassificationTypeId + ", ignoring for customerId "
                            + entry.getString("customerId"), MODULE);
                }
            } else {
                Debug.logInfo(
                        "partyClassificationTypeId" + partyClassificationTypeId
                                + "does not exist, ignoring for customerId " + entry.getString("customerId"),
                        MODULE);
            }
        }
    }

    // associate party with DONOTSHIP_CUSTOMERS classification group if disableShipping is set.
    String disableShipping = entry.getString("disableShipping");
    if (UtilValidate.isNotEmpty(disableShipping) && "Y".equals(disableShipping)) {
        Map<String, Object> partyClassification = null;
        if (UtilValidate.isNotEmpty(companyPartyId)) {
            partyClassification = UtilMisc.toMap("partyId", companyPartyId, "partyClassificationGroupId",
                    "DONOTSHIP_CUSTOMERS", "fromDate", importTimestamp);
            toBeStored.add(delegator.makeValue("PartyClassification", partyClassification));
        }
        if (UtilValidate.isNotEmpty(personPartyId)) {
            partyClassification = UtilMisc.toMap("partyId", personPartyId, "partyClassificationGroupId",
                    "DONOTSHIP_CUSTOMERS", "fromDate", importTimestamp);
            toBeStored.add(delegator.makeValue("PartyClassification", partyClassification));
        }
    }

    /*****************************/
    /** Import Accounting data. **/
    /*****************************/

    if (!UtilValidate.isEmpty(entry.getString("creditCardNumber"))) {
        // we need a person with a first and last name, otherwise the import data is malformed
        if (personPartyId == null && UtilValidate.isEmpty(entry.getString("firstName"))
                && UtilValidate.isEmpty(entry.getString("lastName"))) {
            Debug.logWarning(
                    "Failed to import Credit Card for Party [" + primaryPartyId
                            + "]:  First and Last name missing for customer [" + entry.get("customerId") + "].",
                    MODULE);
        } else {
            // associate this with primaryPartyId as a PaymentMethod of CREDIT_CARD type
            GenericValue paymentMethod = delegator.makeValue("PaymentMethod",
                    UtilMisc.toMap("paymentMethodId", delegator.getNextSeqId("PaymentMethod"),
                            "paymentMethodTypeId", "CREDIT_CARD", "partyId", primaryPartyId, "fromDate",
                            importTimestamp));
            toBeStored.add(paymentMethod);

            // translate the credit card data into a form acceptable to CreditCard
            String cardNumber = UtilValidate.stripCharsInBag(entry.getString("creditCardNumber"),
                    UtilValidate.creditCardDelimiters);
            String cardType = UtilValidate.getCardType(cardNumber);
            String expireDate = UtilImport.decodeExpireDate(entry.getString("creditCardExpDate"));
            if (expireDate == null) {
                Debug.logWarning(
                        "Failed to decode creditCardExpDate [" + entry.getString("creditCardExpDate")
                                + "] into form MM/YYYY for customer [" + entry.get("customerId") + "].",
                        MODULE);
            } else {
                Map<String, Object> input = UtilMisc.<String, Object>toMap("paymentMethodId",
                        paymentMethod.get("paymentMethodId"), "cardNumber", cardNumber, "cardType", cardType,
                        "expireDate", expireDate);
                input.put("firstNameOnCard", entry.get("firstName"));
                input.put("lastNameOnCard", entry.get("lastName"));
                input.put("companyNameOnCard", entry.get("companyName"));
                input.put("contactMechId", billingContactMechId);
                toBeStored.add(delegator.makeValue("CreditCard", input));
            }
        }
    }

    toBeStored.addAll(createBalances(primaryPartyId, entry.getBigDecimal("outstandingBalance"), importTimestamp,
            baseCurrencyUomId, delegator));
    toBeStored
            .addAll(createSalesAgreement(entry, primaryPartyId, primaryPartyName, importTimestamp, delegator));

    // save the primary party Id
    entry.put("primaryPartyId", primaryPartyId);
    toBeStored.add(entry);

    return toBeStored;
}