use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class ExporterOperation method toXls.
/**
* Creates a price compare sheet, expects a list of partNos and returns a xls File with last sales and estimated generated price
*
* @param partNos the partNos to inspect
* @return the xls file with informations
*/
private FileJacket toXls(String... partNos) {
// Create a Produkt with the part no;
SubMonitor m = monitorFactory.newSubMonitor("Auswertung über PartNos", partNos.length + 10);
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
ProductSpecEao productSpecEao = new ProductSpecEao(specEm);
StockUnitEao suEao = new StockUnitEao(stockEm);
DocumentEao documentEao = new DocumentEao(redTapeEm);
List<List<Object>> model = new ArrayList<>();
for (String partNo : partNos) {
m.worked(1, "loading: " + partNo);
List<Object> line = new ArrayList<>();
model.add(line);
partNo = partNo.trim();
line.add(partNo);
List<UniqueUnit> uus = uniqueUnitEao.findByProductPartNo(partNo);
if (uus.isEmpty()) {
line.add("Keine Geräte oder Produkte im System.");
for (int i = 0; i < 14; i++) line.add(null);
continue;
}
Product product = uus.get(0).getProduct();
line.add(ProductFormater.toName(product));
line.add(uus.size());
line.add(maxPrice(uus, PriceType.CUSTOMER));
line.add(minPrice(uus, PriceType.RETAILER));
List<Document> documents = documentEao.findInvoiceWithProdcutId(product.getId());
for (int i = 0; i < 3; i++) {
if (documents.size() > i) {
// TODO: Was balancingId
line.add(documents.get(i).getActual());
line.add(priceByProductId(documents.get(i), product.getId()));
} else {
line.add(null);
line.add(null);
}
}
PriceEngineResult per = priceEngine.estimate(uus.get(0), productSpecEao.findByProductId(product.getId()), suEao.findByUniqueUnitId(uus.get(0).getId()).getStock().getName());
line.add(per.getCostPrice());
line.add(per.getRetailerPrice());
line.add(per.getCustomerPrice());
line.add(per.getRulesLog());
}
m.message("creating File");
STable table = new STable();
CFormat euro = new CFormat(RIGHT, CURRENCY_EURO);
CFormat date = new CFormat(CENTER, SHORT_DATE);
table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("PartNo", 15)).add(new STableColumn("Name", 30));
table.add(new STableColumn("Menge im System", 12));
table.add(new STableColumn("VP(Min)", 12, euro)).add(new STableColumn("VP(Max)", 12, euro));
table.add(new STableColumn("Datum", 12, date)).add(new STableColumn("Vk", 12, euro));
table.add(new STableColumn("Datum", 12, date)).add(new STableColumn("Vk", 12, euro));
table.add(new STableColumn("Datum", 12, date)).add(new STableColumn("Vk", 12, euro));
table.add(new STableColumn("Cp", 12, euro)).add(new STableColumn("Hp", 12, euro)).add(new STableColumn("Ep", 12, euro));
table.add(new STableColumn("Rules", 40));
table.setModel(new STableModelList(model));
CCalcDocument cdoc = new TempCalcDocument("PartNoPrice_");
cdoc.add(new CSheet("PartNoPrice", table));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
FileJacket result = new FileJacket("PartNoPrice", ".xls", file);
m.finish();
return result;
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class ReceiptUnitOperationIT method assertsUpdate.
private void assertsUpdate(UniqueUnit receiptUnit, StockTransaction stockTransaction, ReceiptOperation receiptOperation, TradeName contractor) {
asserts(receiptUnit, stockTransaction, receiptOperation, contractor);
List<Dossier> allDossiers = redTapeAgent.findAllEager(Dossier.class);
List<Document> allDocumentsWithUnit = new ArrayList<>();
for (Dossier dossier : allDossiers) {
for (Document document : dossier.getActiveDocuments()) {
for (Position position : document.getPositions(PositionType.UNIT).values()) {
if (position.getUniqueUnitId() == receiptUnit.getId()) {
allDocumentsWithUnit.add(document);
}
}
}
}
List<Long> documentIds = new ArrayList<>();
for (Document document : allDocumentsWithUnit) {
documentIds.add(document.getId());
}
assertTrue("The UniqueUnit " + receiptUnit.getId() + " is in more than one document. DocumentsIds: " + documentIds, documentIds.size() <= 1);
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DossierCreateAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Dossier dos = Dl.remote().lookup(RedTapeWorker.class).create(customer.getId(), dispatch, Dl.local().lookup(Guardian.class).getUsername());
// This is safe, as a create will return exactly one document.
Document doc = dos.getDocuments().iterator().next();
Addresses addresses = Dl.remote().lookup(RedTapeWorker.class).requestAdressesByCustomer(customer.getId());
doc.setInvoiceAddress(addresses.getInvoice());
doc.setShippingAddress(addresses.getShipping());
Ui.exec(() -> {
Ui.build().parent(controller.getView()).swing().eval(() -> {
DocumentUpdateView docView = new DocumentUpdateView(doc);
docView.setController(new DocumentUpdateController(docView, doc));
docView.setCustomerValues(customer.getId());
return OkCancelWrap.vetoResult(docView);
}).opt().filter(r -> handleFailure(r, doc)).map(Reply::getPayload).ifPresent(this::handleSuccesses);
});
});
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DossierUpdateAction method handleSuccess.
private void handleSuccess(Document doc) {
Document result = Dl.remote().lookup(RedTapeWorker.class).update(doc, null, Dl.local().lookup(Guardian.class).getUsername());
redTapeController.reloadSelectionOnStateChange(result.getDossier());
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class RedTapeController method fillToolBar.
/**
* Fills the toolbar as well as organizing the popupmenus.
* <p/>
*/
public void fillToolBar() {
view.actionBar.removeAll();
view.actionBar.setLayout(new FlowLayout(FlowLayout.LEADING, 3, 3));
view.actionBar.add(new JButton(new AbstractAction("Kunden bearbeiten") {
@Override
public void actionPerformed(ActionEvent e) {
openUpdateCustomer(model.getPurchaseCustomer().getId());
view.customerDetailArea.setText(Dl.remote().lookup(CustomerService.class).asHtmlHighDetailed(model.getPurchaseCustomer().getId()));
}
}));
// build customer dependant actions.
if (getViewOnlyCustomerIds().contains(model.getPurchaseCustomer().getId())) {
// Don't allow anything here.
} else if (model.getPurchaseCustomer().getFlags().contains(CustomerFlag.SYSTEM_CUSTOMER)) {
view.actionBar.add(new JButton(new DossierCreateAction(parent(), false, RedTapeController.this, model.getPurchaseCustomer().getId())));
} else {
view.actionBar.add(new JButton(new DossierCreateAction(parent(), false, RedTapeController.this, model.getPurchaseCustomer().getId())));
view.actionBar.add(new JButton(new DossierCreateAction(parent(), true, RedTapeController.this, model.getPurchaseCustomer().getId())));
}
JToolBar.Separator sep = new JToolBar.Separator();
sep.setAlignmentX(JComponent.CENTER_ALIGNMENT);
view.actionBar.add(sep);
if (model.getSelectedDocument() != null && !getViewOnlyCustomerIds().contains(model.getPurchaseCustomer().getId())) {
Document selDocument = model.getSelectedDocument();
DossierUpdateAction action = new DossierUpdateAction(parent(), this, model.getPurchaseCustomer().getId(), model.getSelectedDocument());
view.actionBar.add(new JButton(action));
// Deactivate Button if a Update isn't possible or allowed.
if (!isSelectedDocumentEditable()) {
action.setEnabled(false);
}
if (selDocument.getType().equals(DocumentType.CREDIT_MEMO)) {
Dl.local().lookup(Guardian.class).add(action, CREATE_ANNULATION_INVOICE);
accessDependentActions.add(action);
}
view.setDocumentPopupActions(action, new AbstractAction("Details") {
@Override
public void actionPerformed(ActionEvent e) {
openDocumentViewer(model.getSelectedDocument());
}
});
view.actionBar.add(new JButton(new DocumentPrintAction(selDocument, DocumentViewType.DEFAULT, this, model.getPurchaseCustomer().getId())));
if (selDocument.getType() == DocumentType.ORDER)
view.actionBar.add(new JButton(new DocumentPrintAction(selDocument, DocumentViewType.RESERVATION, this, model.getPurchaseCustomer().getId())));
if (!EnumSet.of(DocumentType.ANNULATION_INVOICE, DocumentType.COMPLAINT, DocumentType.CREDIT_MEMO).contains(selDocument.getType())) {
view.actionBar.add(new DocumentPrintAction(selDocument, DocumentViewType.SHIPPING, this, model.getPurchaseCustomer().getId()));
}
}
for (Component component : view.actionBar.getComponents()) {
if (component instanceof JButton) {
((JButton) component).setBorder(new BevelBorder(SoftBevelBorder.LOWERED, Color.lightGray, Color.DARK_GRAY, Color.DARK_GRAY, Color.lightGray));
}
}
view.actionBar.revalidate();
view.actionBar.repaint();
}
Aggregations