use of eu.ggnet.dwoss.event.AddressChange in project dwoss by gg-net.
the class RedTapeAddressOperationIT method testAdressChanges.
@Test
public void testAdressChanges() {
long customerId = cgo.makeCustomer();
Dossier dos = redTapeWorker.create(customerId, false, arranger);
Document doc = dos.getActiveDocuments().get(0);
addRandomPositions(doc);
doc = redTapeWorker.update(doc, null, arranger);
// start assertion
assertEquals(doc.getInvoiceAddress(), redTapeWorker.requestAdressesByCustomer(customerId).getInvoice());
// change adress and assert the changes
cgo.scrambleAddress(customerId, AddressType.INVOICE);
assertFalse(doc.getInvoiceAddress().equals(redTapeWorker.requestAdressesByCustomer(customerId).getInvoice()));
// update adresses to all document adresses and assert changes
redTapeWorker.updateAllDocumentAdresses(new AddressChange(customerId, "Test", AddressType.INVOICE, "", ""));
doc = redTapeAgent.findByIdEager(Dossier.class, dos.getId()).getActiveDocuments().get(0);
assertEquals(doc.getInvoiceAddress(), redTapeWorker.requestAdressesByCustomer(customerId).getInvoice());
}
use of eu.ggnet.dwoss.event.AddressChange in project dwoss by gg-net.
the class CustomerEditView method pre.
@Override
public boolean pre(CloseType type) {
if (type == CloseType.CANCEL) {
return true;
}
if (titleBox.getSelectedItem() == null) {
JOptionPane.showMessageDialog(this, "Titel ist nicht gesetzt.");
return false;
}
if (!ValidationUtil.isValidOrShow(SwingUtilities.getWindowAncestor(this), customer))
return false;
customer.setTitel(titleBox.getSelectedItem().toString());
customer.setFlags(customerFlagsModel.getMarked());
if ((PaymentCondition) paymentConditionBox.getSelectedItem() != PaymentCondition.CUSTOMER)
customer.setHaendler(true);
// TODO: A Nullpointer here may be possible as I moved the Formater to the OldCustomer itself. If true add null check before.
if (!original.toInvoiceAddress().equals(customer.toInvoiceAddress())) {
changedAdresses.add(new AddressChange(original.getId(), Dl.local().lookup(Guardian.class).getUsername(), INVOICE, original.toInvoiceAddress(), customer.toInvoiceAddress()));
}
if (!original.toShippingAddress().equals(customer.toShippingAddress())) {
changedAdresses.add(new AddressChange(original.getId(), Dl.local().lookup(Guardian.class).getUsername(), SHIPPING, original.toInvoiceAddress(), customer.toInvoiceAddress()));
}
return true;
}
use of eu.ggnet.dwoss.event.AddressChange in project dwoss by gg-net.
the class OldCustomerUpi method updateCustomer.
@Override
public boolean updateCustomer(UiParent parent, long customerId) {
OldCustomer customer = Dl.remote().lookup(OldCustomerAgent.class).findById(customerId);
CustomerEditView ec = new CustomerEditView();
ec.setCustomer(customer);
// HINT: This was RedTapeView as parrent. If users complain about the location of create customer, add it to Workspace or else.
OkCancelDialog<CustomerEditView> dialog = new OkCancelDialog<>(SwingCore.windowAncestor(Optional.ofNullable(parent).map(UiParent::swingOrMain).orElse(null)).orElse(SwingCore.mainFrame()), Dialog.ModalityType.DOCUMENT_MODAL, "Kunden editieren", ec);
dialog.setVisible(true);
boolean changed = false;
if (dialog.getCloseType() == CloseType.OK) {
Dl.remote().lookup(OldCustomerAgent.class).store(ec.getCustomer());
for (AddressChange addressChange : ec.getChangedAdresses()) {
if (JOptionPane.showOptionDialog(dialog, "Adresse wurde geändert, soll diese Änderung an allen Dokumenten des Kunden übernommen werden?", "Adressänderung", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null) == JOptionPane.YES_OPTION) {
Dl.remote().lookup(AddressService.class).notifyAddressChange(addressChange);
}
changed = true;
}
}
return changed;
}
Aggregations