Search in sources :

Example 1 with CustomerFlag

use of eu.ggnet.dwoss.rules.CustomerFlag in project dwoss by gg-net.

the class CustomerServiceBean method updateCustomerFlags.

@Override
public void updateCustomerFlags(long customerId, Set<CustomerFlag> flags) {
    Customer customer = customerEao.findById(customerId);
    customer.getFlags().clear();
    for (CustomerFlag customerFlag : flags) {
        customer.getFlags().add(customerFlag);
    }
}
Also used : UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) CustomerFlag(eu.ggnet.dwoss.rules.CustomerFlag)

Example 2 with CustomerFlag

use of eu.ggnet.dwoss.rules.CustomerFlag in project dwoss by gg-net.

the class ConverterUtil method mergeFromOld.

/**
 * Merges the old customer to a supplied new customer instance.
 * The new customer has all information of the old customer set to the first contact.
 * A Company may be added if the old.firma is not blank.
 * This Method also assumes, that there is exactly one Mandator used in creation with its defaults.
 * <p>
 * @param old               old customer
 * @param customer
 * @param mandatorMatchCode the mandatorMatchCode
 * @param defaults          the defaults as filter for specific mandator data.
 * @return new customer.
 */
public static Customer mergeFromOld(OldCustomer old, Customer customer, String mandatorMatchCode, DefaultCustomerSalesdata defaults) {
    customer.setComment(old.getAnmerkung());
    customer.getFlags().clear();
    for (CustomerFlag customerFlag : old.getFlags()) {
        customer.getFlags().add(customerFlag);
    }
    customer.getAdditionalCustomerIds().clear();
    customer.getAdditionalCustomerIds().putAll(old.getAdditionalCustomerIds());
    customer.setSource(old.getSource());
    customer.setKeyAccounter(old.getKeyAccounter());
    if (customer.getContacts().isEmpty())
        customer.getContacts().add(new Contact());
    Contact contact = customer.getContacts().get(0);
    contact.setFirstName(old.getVorname() == null ? "" : old.getVorname());
    contact.setLastName(old.getNachname() == null ? "" : old.getNachname());
    if (old.getTitel() != null) {
        switch(old.getTitel()) {
            case "Herr":
                contact.setSex(MALE);
                break;
            case "Frau":
                contact.setSex(FEMALE);
                break;
            default:
        }
    }
    contact.setPrefered(true);
    if (!StringUtils.isBlank(old.getFirma()) || !customer.getCompanies().isEmpty()) {
        if (customer.getCompanies().isEmpty())
            customer.getCompanies().add(new Company());
        Company company = customer.getCompanies().get(0);
        company.setName(old.getFirma());
        company.setLedger(old.getLedger());
        company.setTaxId(old.getTaxId());
        company.setPrefered(true);
    }
    for (Type t : EnumSet.of(EMAIL, FAX, PHONE, MOBILE)) {
        if (!StringUtils.isBlank(get(old, t)) || contact.prefered(t) != null) {
            if (contact.prefered(t) == null)
                contact.getCommunications().add(new Communication(t, true));
            contact.prefered(t).setIdentifier(get(old, t));
        }
    }
    if (!StringUtils.isBlank(old.getREAdresse()) || contact.prefered(INVOICE) != null) {
        if (contact.prefered(INVOICE) == null)
            contact.getAddresses().add(new Address(INVOICE));
        Address rad = contact.prefered(INVOICE);
        rad.setStreet(old.getREAdresse());
        rad.setCity(old.getREOrt() == null ? "" : old.getREOrt());
        rad.setZipCode(old.getREPlz() == null ? "" : old.getREPlz());
    }
    if (!StringUtils.isBlank(old.getLIAdresse()) || contact.prefered(SHIPPING) != null) {
        if (contact.prefered(SHIPPING) == null)
            contact.getAddresses().add(new Address(SHIPPING));
        Address sad = contact.prefered(SHIPPING);
        sad.setStreet(old.getLIAdresse());
        sad.setCity(old.getLIOrt() == null ? "" : old.getLIOrt());
        sad.setZipCode(old.getLIPlz() == null ? "" : old.getLIPlz());
    }
    MandatorMetadata m = customer.getMandatorMetadata(mandatorMatchCode);
    if (m == null)
        m = new MandatorMetadata();
    m.setMandatorMatchcode(mandatorMatchCode);
    m.clearSalesChannels();
    if (!old.getAllowedSalesChannels().equals(defaults.getAllowedSalesChannels())) {
        for (SalesChannel salesChannel : old.getAllowedSalesChannels()) {
            m.add(salesChannel);
        }
    }
    if (old.getPaymentCondition() == defaults.getPaymentCondition())
        m.setPaymentCondition(null);
    else
        m.setPaymentCondition(old.getPaymentCondition());
    if (old.getPaymentMethod() == defaults.getPaymentMethod())
        m.setPaymentMethod(null);
    else
        m.setPaymentMethod(old.getPaymentMethod());
    if (old.getShippingCondition() == defaults.getShippingCondition())
        m.setShippingCondition(null);
    else
        m.setShippingCondition(old.getShippingCondition());
    if (customer.getMandatorMetadata(mandatorMatchCode) == null && m.isSet())
        customer.getMandatorMetadata().add(m);
    return customer;
}
Also used : SalesChannel(eu.ggnet.dwoss.rules.SalesChannel) Type(eu.ggnet.dwoss.customer.ee.entity.Communication.Type) CustomerFlag(eu.ggnet.dwoss.rules.CustomerFlag)

Example 3 with CustomerFlag

use of eu.ggnet.dwoss.rules.CustomerFlag in project dwoss by gg-net.

the class CustomerEnhanceController method buildFlagBox.

/**
 * Build up a ListView with CheckBoxes for the Set of CunstomerFlags
 */
private void buildFlagBox() {
    // transform a Set to a ObservableList of CustomerFlag
    List<CustomerFlag> templist = new ArrayList<>();
    flagsSet.forEach(f -> templist.add(f));
    ObservableList<CustomerFlag> allFlagsFromTheCustomer = FXCollections.observableArrayList(templist);
    // fill with all posibile flags
    ObservableList<CustomerFlag> observableArrayListOfAllFlags = FXCollections.observableArrayList(CustomerFlag.values());
    ObservableList<CustomerFlagWithSelect> listForTheView = FXCollections.observableArrayList();
    // fill the CustomerFlagWithSelect List
    observableArrayListOfAllFlags.stream().map((ovall) -> {
        CustomerFlagWithSelect cfs = new CustomerFlagWithSelect(ovall);
        if (allFlagsFromTheCustomer.contains(ovall)) {
            cfs.setSelected(true);
        }
        return cfs;
    }).forEachOrdered((cfs) -> {
        listForTheView.add(cfs);
    });
    listForTheView.forEach(flag -> flag.selectedProperty().addListener((observable, wasSelected, isSelected) -> {
        if (isSelected) {
            outputFlagslist.add(flag.getFlag());
        }
    }));
    ListView<CustomerFlagWithSelect> checklist = new ListView<>();
    checklist.setItems(listForTheView);
    checklist.setMinWidth(150.0);
    checklist.setCellFactory(CheckBoxListCell.forListView(CustomerFlagWithSelect::selectedProperty, new StringConverter<CustomerFlagWithSelect>() {

        @Override
        public String toString(CustomerFlagWithSelect object) {
            return object.getFlag().getName();
        }

        @Override
        public CustomerFlagWithSelect fromString(String string) {
            return null;
        }
    }));
    Label flagLable = new Label("Flags: ");
    flagVBox.getChildren().addAll(flagLable, checklist);
}
Also used : EventHandler(javafx.event.EventHandler) ButtonData(javafx.scene.control.ButtonBar.ButtonData) java.util(java.util) javafx.collections(javafx.collections) Initializable(javafx.fxml.Initializable) ExternalSystem(eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) URL(java.net.URL) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) Source(eu.ggnet.dwoss.customer.ee.entity.Customer.Source) Sex(eu.ggnet.dwoss.customer.ee.entity.Contact.Sex) Ui(eu.ggnet.saft.Ui) InvalidationListener(javafx.beans.InvalidationListener) CustomerFlag(eu.ggnet.dwoss.rules.CustomerFlag) Insets(javafx.geometry.Insets) AlertType(javafx.scene.control.Alert.AlertType) WINDOW_MODAL(javafx.stage.Modality.WINDOW_MODAL) javafx.beans.property(javafx.beans.property) AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) eu.ggnet.dwoss.customer.ee.entity(eu.ggnet.dwoss.customer.ee.entity) Node(javafx.scene.Node) StringConverter(javafx.util.StringConverter) Collectors(java.util.stream.Collectors) eu.ggnet.saft.api.ui(eu.ggnet.saft.api.ui) Consumer(java.util.function.Consumer) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) Data(lombok.Data) AllArgsConstructor(lombok.AllArgsConstructor) CustomerFlag(eu.ggnet.dwoss.rules.CustomerFlag) AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) StringConverter(javafx.util.StringConverter)

Example 4 with CustomerFlag

use of eu.ggnet.dwoss.rules.CustomerFlag in project dwoss by gg-net.

the class ConverterUtil method convert.

/**
 * Converts a customer to old customer.
 * <p>
 * @param c                 the customer
 * @param mandatorMatchCode the mandator matchcode
 * @param defaults          the defaults
 * @return the converted old customer
 */
public static OldCustomer convert(Customer c, String mandatorMatchCode, DefaultCustomerSalesdata defaults) {
    OldCustomer old = new OldCustomer();
    old.setId((int) c.getId());
    old.setAnmerkung(c.getComment());
    for (CustomerFlag flag : c.getFlags()) {
        old.addFlag(flag);
    }
    old.getAdditionalCustomerIds().putAll(c.getAdditionalCustomerIds());
    old.setKeyAccounter(c.getKeyAccounter());
    old.setSource(c.getSource());
    if (!c.getCompanies().isEmpty()) {
        Company company = c.getCompanies().get(0);
        old.setFirma(company.getName());
        old.setLedger(company.getLedger());
        old.setTaxId(company.getTaxId());
    }
    if (!c.getContacts().isEmpty()) {
        Contact contact = c.getContacts().get(0);
        old.setVorname(contact.getFirstName());
        old.setNachname(contact.getLastName());
        if (contact.getSex() != null)
            switch(contact.getSex()) {
                case MALE:
                    old.setTitel("Herr");
                    break;
                case FEMALE:
                    old.setTitel("Frau");
                    break;
            }
        for (Communication com : contact.getCommunications()) {
            set(old, com.getType(), com.getIdentifier());
        }
        for (Address address : contact.getAddresses()) {
            switch(address.getPreferedType()) {
                case INVOICE:
                    old.setREAdresse(address.getStreet());
                    old.setREOrt(address.getCity());
                    old.setREPlz(address.getZipCode());
                    break;
                case SHIPPING:
                    old.setLIAdresse(address.getStreet());
                    old.setLIOrt(address.getCity());
                    old.setLIPlz(address.getZipCode());
                    break;
            }
        }
    }
    MandatorMetadata.MergedView metadata = new MandatorMetadata.MergedView(c.getMandatorMetadata(mandatorMatchCode), defaults);
    old.setAllowedSalesChannels(new HashSet<>(metadata.getAllowedSalesChannels()));
    old.setPaymentCondition(metadata.getPaymentCondition());
    old.setPaymentMethod(metadata.getPaymentMethod());
    old.setShippingCondition(metadata.getShippingCondition());
    return old;
}
Also used : CustomerFlag(eu.ggnet.dwoss.rules.CustomerFlag)

Aggregations

CustomerFlag (eu.ggnet.dwoss.rules.CustomerFlag)4 eu.ggnet.dwoss.customer.ee.entity (eu.ggnet.dwoss.customer.ee.entity)1 Type (eu.ggnet.dwoss.customer.ee.entity.Communication.Type)1 Sex (eu.ggnet.dwoss.customer.ee.entity.Contact.Sex)1 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)1 ExternalSystem (eu.ggnet.dwoss.customer.ee.entity.Customer.ExternalSystem)1 Source (eu.ggnet.dwoss.customer.ee.entity.Customer.Source)1 AddressLabel (eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel)1 OldCustomer (eu.ggnet.dwoss.customer.ee.priv.OldCustomer)1 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)1 SalesChannel (eu.ggnet.dwoss.rules.SalesChannel)1 Ui (eu.ggnet.saft.Ui)1 eu.ggnet.saft.api.ui (eu.ggnet.saft.api.ui)1 URL (java.net.URL)1 java.util (java.util)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Platform (javafx.application.Platform)1 InvalidationListener (javafx.beans.InvalidationListener)1 javafx.beans.property (javafx.beans.property)1