use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class AnnulationInvoiceAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Calendar release = Calendar.getInstance();
release.setTime(doc.getHistory().getRelease());
Calendar beforeOneYear = Calendar.getInstance();
beforeOneYear.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR) - 1);
if (beforeOneYear.after(release) && JOptionPane.CANCEL_OPTION == JOptionPane.showConfirmDialog(parent, "Der Vorgang ist über ein Jahr alt und die Garantie ist abgelaufen!\nMöchten sie fortfahren?", "Garantie Warnung", JOptionPane.OK_CANCEL_OPTION)) {
return;
}
List<AfterInvoicePosition> creditPositions = new ArrayList<>();
for (Position position : doc.getPositions().values()) {
if (position.getType() != PositionType.COMMENT)
creditPositions.add(new AfterInvoicePosition(position));
}
CreditMemoView view = new CreditMemoView(creditPositions);
OkCancelDialog<CreditMemoView> dialog = new OkCancelDialog<>(getValue(Action.NAME).toString(), view);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
if (dialog.getCloseType() == CloseType.OK) {
doc.removeAllPositions();
for (Position position : view.getPositions()) {
position.setPrice(position.getPrice() * (-1));
doc.append(position);
}
doc.setType(DocumentType.ANNULATION_INVOICE);
doc.setDirective(Directive.BALANCE_REPAYMENT);
Document d = Dl.remote().lookup(RedTapeWorker.class).update(doc, view.getStockLocation(), Dl.local().lookup(Guardian.class).getUsername());
controller.reloadSelectionOnStateChange(d.getDossier());
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class ComplaintAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Calendar release = Calendar.getInstance();
release.setTime(doc.getHistory().getRelease());
Calendar beforeOneYear = Calendar.getInstance();
beforeOneYear.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR) - 1);
if (beforeOneYear.after(release) && JOptionPane.CANCEL_OPTION == JOptionPane.showConfirmDialog(parent, "Der Vorgang ist über ein Jahr alt und die Garantie ist abgelaufen!\nMöchten sie fortfahren?", "Garantie Warnung", JOptionPane.OK_CANCEL_OPTION)) {
return;
}
List<AfterInvoicePosition> creditPositions = new ArrayList<>();
for (Position position : doc.getPositions().values()) {
if (position.getType() != PositionType.COMMENT) {
AfterInvoicePosition aiPosition = new AfterInvoicePosition(position);
if (doc.getDossier().isDispatch() && position.getType() == PositionType.SHIPPING_COST)
aiPosition.setParticipate(true);
creditPositions.add(aiPosition);
}
}
ComplaintView view = new ComplaintView(creditPositions);
OkCancelDialog<ComplaintView> dialog = new OkCancelDialog<>("Reklamation anmelden", view);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
if (dialog.getCloseType() == CloseType.OK) {
doc.removeAllPositions();
for (Position position : view.getPositions()) {
doc.append(position);
}
doc.setType(DocumentType.COMPLAINT);
doc.setDirective(Directive.WAIT_FOR_COMPLAINT_COMPLETION);
Document d = Dl.remote().lookup(RedTapeWorker.class).update(doc, null, Dl.local().lookup(Guardian.class).getUsername());
controller.reloadSelectionOnStateChange(d.getDossier());
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class RedTapeView method initFxComponents.
private void initFxComponents() {
final JFXPanel jfxp = new JFXPanel();
positionFxPanel.add(jfxp, BorderLayout.CENTER);
Platform.runLater(() -> {
SelectionEnhancer<Position> selectionEnhancer = (selected) -> {
if (selected != null && selected.getType() == UNIT)
return Arrays.asList(new PicoUnit(selected.getUniqueUnitId(), selected.getName()));
return Collections.EMPTY_LIST;
};
selector = Ops.seletor(Position.class, selectionEnhancer);
BorderPane pane = new BorderPane();
Scene scene = new Scene(pane, javafx.scene.paint.Color.ALICEBLUE);
final ListView<Position> positionsFxList = new ListView<>();
MultipleSelectionModel<Position> selectionModel = positionsFxList.getSelectionModel();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
selectionModel.selectedItemProperty().addListener((ob, o, n) -> {
selector.selected(n);
});
positionsFxList.setCellFactory(new PositionListCell.Factory());
positionsFxList.setItems(positions);
positionsFxList.setContextMenu(FxOps.contextMenuOf(selectionModel, selectionEnhancer));
positionsFxList.setOnMouseClicked(FxOps.defaultMouseEventOf(selectionModel));
/*
positionsFxList.setOnMouseClicked((evt) -> {
if ( positionsFxList.getSelectionModel().isEmpty() ) return;
if ( evt.getButton() != PRIMARY ) return;
if ( evt.getClickCount() != 2 ) return;
HtmlDialog d = new HtmlDialog(RedTapeView.this, ModalityType.MODELESS);
d.setText(controller.getDetailedPositionToHtml(positionsFxList.getSelectionModel().getSelectedItem()));
d.setVisible(true);
});
*/
pane.setCenter(positionsFxList);
jfxp.setScene(scene);
});
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class ShippingCostHelper method modifyOrAddShippingCost.
/**
* Method to update/refresh the shipping cost of a {@link Document}.
* <p>
* @param doc the {@link Document} entity.
* @param shippingCondition the condition on which the shipping cost is calculated
*/
public static void modifyOrAddShippingCost(Document doc, ShippingCondition shippingCondition) {
int amountOfPositions = doc.getPositions(PositionType.UNIT).size();
for (Position position : doc.getPositions(PositionType.PRODUCT_BATCH).values()) {
// just quick for the warranty extension. sucks a bit if we ever wouldhave a refurbished id on another product batch
if (!StringUtils.isBlank(position.getRefurbishedId()))
continue;
amountOfPositions += position.getAmount();
}
double costs = 0;
if (Dl.remote().contains(ShippingCostService.class))
costs = Dl.remote().lookup(ShippingCostService.class).calculate(amountOfPositions, doc.getDossier().getPaymentMethod(), shippingCondition);
SortedMap<Integer, Position> positions = doc.getPositions(PositionType.SHIPPING_COST);
if (positions.isEmpty()) {
doc.append(Position.builder().type(PositionType.SHIPPING_COST).name("Versandkosten").description("Versandkosten zu Vorgang: " + doc.getDossier().getIdentifier()).amount(1).price(costs).tax(doc.getTaxType().getTax()).bookingAccount(Dl.local().lookup(CachedMandators.class).loadPostLedger().get(PositionType.SHIPPING_COST, doc.getTaxType()).orElse(null)).build());
} else {
Position next = positions.values().iterator().next();
next.setPrice(costs);
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class ServiceViewCask method templateListMouseClicked.
// </editor-fold>//GEN-END:initComponents
private void templateListMouseClicked(java.awt.event.MouseEvent evt) {
// GEN-FIRST:event_templateListMouseClicked
if (evt.getClickCount() == 2) {
Position template = (Position) templateList.getSelectedValue();
position = Position.builder().amount(template.getAmount()).bookingAccount(template.getBookingAccount().orElse(null)).description(template.getDescription()).name(template.getName()).price(template.getPrice()).tax(taxType.getTax()).type(template.getType()).uniqueUnitProductId(template.getUniqueUnitProductId()).build();
positionView.accept(new PositionAndTaxType(position, taxType));
}
}
Aggregations