use of eu.ggnet.dwoss.mandator.api.value.PostLedger in project dwoss by gg-net.
the class PositionUpdateCask method accept.
@Override
public void accept(PositionAndTaxType posAndTax) {
if (posAndTax == null)
return;
this.position = posAndTax.getPosition();
PostLedger postLedger = Dl.local().lookup(CachedMandators.class).loadPostLedger();
final List<Ledger> ledgers = postLedger.getAlternatives(position.getType(), posAndTax.getTaxType());
bookingAccountBox.setModel(new DefaultComboBoxModel(ledgers.toArray()));
this.positionTypeField.setText(position.getType() != null ? position.getType().getName() : "Nicht angegeben");
this.taxedConverter.taxed = position.getTax() + 1;
this.taxField.setText(TAX.format(position.getTax()));
this.setPositionName(position.getName());
this.setPrice(position.getPrice());
this.setDescription(position.getDescription());
this.setAmount(position.getAmount());
this.setPreDecimal((int) (position.getAmount() - (position.getAmount() % 1)));
this.setPostDecimal((int) ((position.getAmount() % 1) * 100));
if (position.getBookingAccount().isPresent()) {
// Remapping of the ledger.
if (!ledgers.contains(position.getBookingAccount().get())) {
Ui.build(this).alert("Buchungskonto " + position.getBookingAccount().get() + " nicht für diese Position und Steuer konfiguriert. Wurde auf Standard gesetzt");
if (!ledgers.isEmpty())
this.setBookingAccount(ledgers.get(0));
} else {
this.setBookingAccount(ledgers.get(ledgers.indexOf(position.getBookingAccount().get())));
}
}
this.accessCos = Dl.local().lookup(Guardian.class);
if (position.getDocument() != null && EnumSet.of(DocumentType.ANNULATION_INVOICE, DocumentType.CREDIT_MEMO).contains(position.getDocument().getType())) {
disableComponents(preDecimalSpinner, postDecimalSpinner, nameArea, bookingAccountBox, priceField, afterTaxPriceField, descriptionArea);
accessCos.add(priceSumField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
accessCos.add(afterTaxSumField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
accessCos.add(priceField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
accessCos.add(afterTaxPriceField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
} else {
if (position.getType() == PRODUCT_BATCH || position.getType() == UNIT) {
disableComponents(postDecimalSpinner);
accessCos.add(priceField, UPDATE_PRICE_OF_UNITS_AND_PRODUCT_BATCH);
accessCos.add(afterTaxPriceField, UPDATE_PRICE_OF_UNITS_AND_PRODUCT_BATCH);
}
if (position.getType() == UNIT) {
disableComponents(preDecimalSpinner);
bookingAccountBox.setEnabled(true);
}
if (position.getType() == COMMENT) {
disableComponents(priceField, priceSumField, afterTaxPriceField, afterTaxSumField, preDecimalSpinner, postDecimalSpinner);
}
if (position.getType() == SHIPPING_COST) {
disableComponents(nameArea, afterTaxPriceField, afterTaxSumField, preDecimalSpinner, postDecimalSpinner);
}
if (EnumSet.of(COMMENT, SERVICE, PRODUCT_BATCH).contains(position.getType())) {
nameArea.setEditable(true);
if (position.getType() == SERVICE)
bookingAccountBox.setEnabled(true);
}
}
}
use of eu.ggnet.dwoss.mandator.api.value.PostLedger in project dwoss by gg-net.
the class DocumentUpdateView method taxChangeButtonActionPerformed.
// GEN-LAST:event_convertToWarrantyPositionButtonActionPerformed
private void taxChangeButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_taxChangeButtonActionPerformed
Ui.exec(() -> {
Ui.build(this).fx().eval(() -> new TaxChangePane()).opt().ifPresent(taxType -> {
L.debug("Changeing Tax to {}", taxType);
document.setTaxType(taxType);
final PostLedger ledgers = Dl.local().lookup(CachedMandators.class).loadPostLedger();
document.getPositions().values().forEach(p -> {
p.setTax(taxType.getTax());
p.setBookingAccount(ledgers.get(p.getType(), taxType).orElse(null));
});
refreshAll();
});
});
}
Aggregations