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();
}
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;
}
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);
}
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;
}
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);
}
Aggregations