Search in sources :

Example 1 with OldCustomer

use of eu.ggnet.dwoss.customer.ee.priv.OldCustomer in project dwoss by gg-net.

the class CustomerHtmlTryout method start.

@Override
public void start(Stage primaryStage) throws Exception {
    CustomerGenerator gen = new CustomerGenerator();
    Customer c1 = gen.makeOldCustomer();
    Customer c2 = gen.makeCustomer();
    DefaultCustomerSalesdata defaults = DefaultCustomerSalesdata.builder().allowedSalesChannels(EnumSet.of(SalesChannel.CUSTOMER)).paymentCondition(PaymentCondition.CUSTOMER).shippingCondition(ShippingCondition.DEALER_ONE).paymentMethod(PaymentMethod.DIRECT_DEBIT).build();
    String MATCHCODE = c1.getMandatorMetadata().stream().map(MandatorMetadata::getMandatorMatchcode).findFirst().orElse("NONE");
    OldCustomer c0 = ConverterUtil.convert(c1, MATCHCODE, defaults);
    WebView view = new WebView();
    view.getEngine().loadContent(Css.toHtml5WithStyle("<h1>OldCustomer.toHtml()</h1>" + c0.toHtmlHighDetailed() + "<hr /><h1>makeOldCustmer : Customer.toHtml(MATCHCODE,defaults)</h1>" + c1.toHtml(MATCHCODE, defaults) + "<hr /><h1>makeOldCustmer : Customer.toHtml()</h1>" + c1.toHtml() + "<hr /><h1>makeCustmer : Customer.toHtml()</h1>" + c2.toHtml()));
    primaryStage.setScene(new Scene(new BorderPane(view)));
    primaryStage.sizeToScene();
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene)

Example 2 with OldCustomer

use of eu.ggnet.dwoss.customer.ee.priv.OldCustomer in project dwoss by gg-net.

the class CustomerGenerator method makeOldCustomer.

public Customer makeOldCustomer(String mandatorMatchCode, DefaultCustomerSalesdata defaults) {
    Name name = GEN.makeName();
    GeneratedAddress address = GEN.makeAddress();
    OldCustomer old = new OldCustomer(null, (name.getGender() == Name.Gender.MALE ? "Herr" : "Frau"), name.getFirst(), name.getLast(), null, address.getStreet() + " " + address.getNumber(), address.getPostalCode(), address.getTown());
    if (R.nextInt(10) < 3)
        old.setAnmerkung("Eine wichtige Anmerkung");
    if (R.nextInt(10) < 3)
        old.setSource(Source.values()[R.nextInt(Source.values().length)]);
    if (R.nextInt(10) < 3) {
        old.getAdditionalCustomerIds().put(ExternalSystem.values()[R.nextInt(ExternalSystem.values().length)], RandomStringUtils.randomNumeric(5, 10));
    }
    for (CustomerFlag f : ALLOWED_FLAGS) {
        if (R.nextInt(10) < 3)
            old.addFlag(f);
    }
    old.setLedger(R.nextInt(10000));
    if (R.nextInt(10) < 3) {
        old.setFirma(old.getNachname() + " GmbH");
        old.setTaxId("HRB123456");
        old.getAllowedSalesChannels().add(RETAILER);
    }
    if (R.nextInt(10) < 3) {
        GeneratedAddress lia = GEN.makeAddress();
        old.setLIAdresse(lia.getStreet());
        old.setLIOrt(lia.getTown());
        old.setLIPlz(lia.getPostalCode());
    }
    old.setEmail(name.getLast().toLowerCase() + "@example.com");
    old.setTelefonnummer("+49 99 123456789");
    old.setHandynummer("+49 555 12344321");
    if (R.nextInt(10) < 3)
        old.setFaxnummer("+49 88 123456789");
    Customer c = new Customer();
    ConverterUtil.mergeFromOld(old, c, mandatorMatchCode, defaults);
    MandatorMetadata makeMandatorMetadata = makeMandatorMetadata();
    makeMandatorMetadata.setMandatorMatchcode(mandatorMatchCode);
    c.getMandatorMetadata().add(makeMandatorMetadata);
    return c;
}
Also used : OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer)

Example 3 with OldCustomer

use of eu.ggnet.dwoss.customer.ee.priv.OldCustomer in project dwoss by gg-net.

the class CustomerGeneratorOperation method scrambleAddress.

public void scrambleAddress(long customerId, AddressType type) {
    Customer c = cem.find(Customer.class, customerId);
    OldCustomer sc = ConverterUtil.convert(c, mandator.getMatchCode(), defaults);
    GeneratedAddress newAddress = GEN.makeAddress();
    if (type == INVOICE) {
        sc.setREAdresse(newAddress.getStreet());
        sc.setREOrt(newAddress.getTown());
        sc.setREPlz(newAddress.getPostalCode());
    } else {
        sc.setLIAdresse(newAddress.getStreet());
        sc.setLIOrt(newAddress.getTown());
        sc.setLIPlz(newAddress.getPostalCode());
    }
    ConverterUtil.mergeFromOld(sc, c, mandator.getMatchCode(), defaults);
}
Also used : OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) GeneratedAddress(eu.ggnet.dwoss.util.gen.GeneratedAddress)

Example 4 with OldCustomer

use of eu.ggnet.dwoss.customer.ee.priv.OldCustomer in project dwoss by gg-net.

the class CustomerSearchIT method convert.

private Customer convert(OldCustomer old) {
    Customer customer = new Customer();
    ConverterUtil.mergeFromOld(old, customer, mandator.getMatchCode(), salesData);
    return customer;
}
Also used : Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer)

Example 5 with OldCustomer

use of eu.ggnet.dwoss.customer.ee.priv.OldCustomer in project dwoss by gg-net.

the class CustomerSearchIT method testLucenceSearch.

@Test
public void testLucenceSearch() throws Exception {
    OldCustomer c1 = new OldCustomer("Die Firma", "Herr", "Max", "Mustermann", "Keine Bemerkungen", "Helle Strasse 22", "12345", "Musterhausen");
    OldCustomer c2 = new OldCustomer(null, "Frau", "Marria", "Mustermann", "Grosse Tüten", "Dunkle Allee 7", "12345", "Musterhausen", "Dünne Gasse 2", "22222", "Wolfsstaaad");
    c2.setPaymentMethod(PaymentMethod.DIRECT_DEBIT);
    c2.addFlag(CustomerFlag.CONFIRMS_DOSSIER);
    c1.setPaymentCondition(PaymentCondition.CUSTOMER);
    // by pp
    OldCustomer c3 = new OldCustomer("Schlagstock Ltd.", "Herr", "Michael", "Wankelmeier", "Bloß freundlich sein !!!", "Adamsweg 3", "00666", "Eisenhüttenstadt");
    c3.addFlag(CustomerFlag.CONFIRMS_DOSSIER);
    c3.addFlag(CustomerFlag.CONFIRMED_CASH_ON_DELIVERY);
    c3.setPaymentMethod(PaymentMethod.CASH_ON_DELIVERY);
    c3.setAllowedSalesChannels(EnumSet.of(SalesChannel.CUSTOMER, SalesChannel.RETAILER));
    c3.setPaymentCondition(PaymentCondition.DEALER_3_PERCENT_DISCOUNT);
    c3.setShippingCondition(ShippingCondition.DEALER_ONE);
    OldCustomer c4 = new OldCustomer(null, "Frau", "Lisa", "Lüstling", null, "Freie Straße 2", "98745", "Heimwehrhausen", "Dünne Gasse 2", "22222", "Heimwehrhausen");
    c4.addFlag(CustomerFlag.CONFIRMS_DOSSIER);
    c4.setAllowedSalesChannels(EnumSet.of(SalesChannel.CUSTOMER));
    c4.setPaymentCondition(PaymentCondition.EMPLOYEE);
    c4.setShippingCondition(ShippingCondition.DEALER_ONE);
    c4.setPaymentMethod(PaymentMethod.INVOICE);
    utx.begin();
    em.joinTransaction();
    em.persist(convert(c1));
    em.persist(convert(c2));
    em.persist(convert(c3));
    em.persist(convert(c4));
    utx.commit();
    List<Customer> find = eao.find("schlag*");
    assertThat(find).as("Result of search").hasSize(1);
    assertTrue("Only One element should be here: " + find, find.size() == 1);
    find = eao.find("schlag");
    assertTrue("No element should be here: " + find, find.isEmpty());
    find = eao.find("schlagstock ltd");
    assertTrue("One element should be here: " + find, find.size() == 1);
    // Testing Search via Provider
    assertThat(searchProvider).as("Searchprovider").isNotNull().returns(GlobalKey.Component.CUSTOMER, e -> e.getSource());
    SearchRequest req = new SearchRequest("schlag*");
    int estimateMaxResults = searchProvider.estimateMaxResults(req);
    assertThat(estimateMaxResults).as("estimated max results").isEqualTo(1);
    List<ShortSearchResult> result = searchProvider.search(req, 0, 10);
    assertThat(result).as("Searchresult").hasSize(1);
}
Also used : OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) Customer(eu.ggnet.dwoss.customer.ee.entity.Customer) OldCustomer(eu.ggnet.dwoss.customer.ee.priv.OldCustomer) Test(org.junit.Test)

Aggregations

OldCustomer (eu.ggnet.dwoss.customer.ee.priv.OldCustomer)11 Customer (eu.ggnet.dwoss.customer.ee.entity.Customer)3 OldCustomerAgent (eu.ggnet.dwoss.customer.ee.priv.OldCustomerAgent)3 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)2 OkCancelDialog (eu.ggnet.dwoss.util.OkCancelDialog)2 Test (org.junit.Test)2 AbstractGuardian (eu.ggnet.dwoss.common.AbstractGuardian)1 CustomerGenerator (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator)1 MandatorMetadata (eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata)1 AddressService (eu.ggnet.dwoss.customer.opi.AddressService)1 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)1 CustomerService (eu.ggnet.dwoss.customer.opi.CustomerService)1 CustomerCreateWithSearchController (eu.ggnet.dwoss.customer.ui.old.CustomerCreateWithSearchController)1 CustomerCreateWithSearchView (eu.ggnet.dwoss.customer.ui.old.CustomerCreateWithSearchView)1 AddressChange (eu.ggnet.dwoss.event.AddressChange)1 Mandators (eu.ggnet.dwoss.mandator.Mandators)1 DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)1 GeneratedAddress (eu.ggnet.dwoss.util.gen.GeneratedAddress)1 AuthenticationException (eu.ggnet.saft.core.auth.AuthenticationException)1 UiParent (eu.ggnet.saft.core.ui.UiParent)1