This commit is contained in:
Ralph Soika 2024-10-31 12:30:11 +01:00
parent f9bee7a6a8
commit e8219ca579
5 changed files with 5525 additions and 203 deletions

View file

@ -11,6 +11,8 @@
- Lucene Index: item 'cdtr.name' und 'document.company' wurde in den index aufgenommen wegen AI Examples Adapter
- Fix Fälligkeit in maske
- Fix XML Schnittstelle Cargosoft Sammelgutschrift
- Zahlungseingang kann nun korrigiert werden. => modell update 'zahlungseingang-de-1.0.5' und 'rechnungsausgang-de-1.0.13'
- fix Zahlungseingangs Formular
**Migration**

View file

@ -35,7 +35,7 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
ZahlungseingangService zahlungseingangService;
/**
* This method finds the outgoing invoicdes and updates the saldo
* This method finds the outgoing invoices and updates the saldo
* (payment.total).
*
* @throws PluginException
@ -50,20 +50,20 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
}
/**
* Diese method hängt eine referenz der aktuellen Rechnung an den Zahlungsavis
* Diese methode aktuallisiert alle referenzen der aktuellen Rechnungen
*
* @param document
* @param workitem
* @throws PluginException
*/
private void updateSaldo(ItemCollection document) throws PluginException {
private void updateSaldo(ItemCollection workitem) throws PluginException {
// payment currency
String paymentCurrency = document.getItemValueString("payment.currency");
double masterPaymentAmount = document.getItemValueDouble("payment.amount");
double masterPaymentDifference = document.getItemValueDouble("payment.difference");
String paymentWarning = document.getItemValueString("payment.warning");
String paymentCurrency = workitem.getItemValueString("payment.currency");
double masterPaymentAmount = workitem.getItemValueDouble("payment.amount");
double masterPaymentDifference = workitem.getItemValueDouble("payment.difference");
String paymentWarning = workitem.getItemValueString("payment.warning");
List<ItemCollection> paymentDetails = zahlungseingangService.loadPaymentDetails(document);
List<ItemCollection> paymentDetails = zahlungseingangService.loadPaymentDetails(workitem);
if (paymentDetails.size() == 0) {
throw new PluginException(PluginException.class.getName(),
@ -84,7 +84,7 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
// falls mehr einzelsummen eingeben wurden als der oben angegeben Total Pamyment
// dann soll eine Warnung ausgegen werden.
if (InvoiceUtil.round(masterPaymentAmount + masterPaymentDifference) != InvoiceUtil.round(einzelPayments)) {
document.setItemValue("payment.warning", "invalid saldo");
workitem.setItemValue("payment.warning", "invalid saldo");
throw new PluginException(PluginException.class.getName(),
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
"Der Zahlungseingang ist nicht identisch mit den ausgebuchten Rechnungssalden. Sollte die Eingabe korrekt sein, wiederholen Sie die Aktion.");
@ -123,7 +123,8 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
}
// vergeiche Restsaldo mit payment für diese Rechnung
if (Math.abs(InvoiceUtil.round(invoicePaymentAmount)) > Math.abs(InvoiceUtil.round(invoiceSaldo))) {
if (!isPaymentBooked(workitem) && Math.abs(InvoiceUtil.round(invoicePaymentAmount)) > Math
.abs(InvoiceUtil.round(invoiceSaldo))) {
throw new PluginException(PluginException.class.getName(),
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
"Der Zahlungseingang kann nicht verbucht werden, da der Restsaldo der Rechnung "
@ -131,8 +132,14 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
}
// jetzt den Rechnungsbetrag verkleinern
invoiceSaldo = invoiceSaldo - invoicePaymentAmount;
// Falls die Rechnung bereits 5900 (Bezahlt) ist wird der Saldo korrigiert und
// wieder aufgerechnet
if (isPaymentBooked(workitem)) {
// STORNO
invoiceSaldo = invoiceSaldo + invoicePaymentAmount;
} else {
invoiceSaldo = invoiceSaldo - invoicePaymentAmount;
}
invoiceSaldo = (float) InvoiceUtil.round(invoiceSaldo);
invoice.setItemValue("invoice.saldo", invoiceSaldo);
invoice.event(ZahlungseingangService.EVENT_UPDATE_INVOICE);
@ -147,4 +154,14 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
}
/**
* Returns true wenn der Zahlungseingang bereits gebucht ist
*
* @param workitem
* @return
*/
public boolean isPaymentBooked(ItemCollection workitem) {
return (workitem.getTaskID() == 1900);
}
}

View file

@ -1,19 +1,14 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:i="http://java.sun.com/jsf/composite/imixs"
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:i="http://java.sun.com/jsf/composite/imixs"
xmlns:marty="http://java.sun.com/jsf/composite/marty">
<!-- Shows the op liste fo rthe current dbtr.number -->
<h:commandScript name="calculateOpSummary"
execute="invoiceRefHolder_ID" render="opcalculater_id" />
<h:commandScript name="calculateOpSummary" execute="invoiceRefHolder_ID" render="opcalculater_id" />
<h:panelGroup layout="block" styleClass="imixs-form-section"
id="oplist-table" binding="#{opListContainer}">
<h:panelGroup layout="block" styleClass="imixs-form-section" id="oplist-table" binding="#{opListContainer}">
<dl>
@ -36,92 +31,108 @@
<th style="text-align: right;">S/H</th>
<th style="width: 40px;"></th>
<th style="width: 70px; text-align: right;">Kurs</th>
<th style="width: 100px; text-align: right;">Basisumsatz</th><th />
<th style="width: 70px; text-align: right;">Kurs</th>
<th style="width: 100px; text-align: right;">Basisumsatz</th>
<th />
<th style="width: 100px;">Saldo</th><th />
<th style="width: 100px;">Saldo</th>
<th />
<th style="width: 100px;">Saldo in EUR</th>
<th style=""></th>
<th style="width: 150px;">Zahlbetrag</th>
<th style=""></th>
</tr>
<ui:param name="invoices"
value="#{opListController.getInvoices(workitem.item['dbtr.number'])}"></ui:param>
<ui:param name="invoices" value="#{opListController.getInvoices(workitem.item['dbtr.number'])}"></ui:param>
<ui:repeat value="#{invoices}" var="invoice">
<tr>
<td><h:link outcome="/pages/workitems/workitem">
#{invoice.item['invoice.number']}
<f:param name="id" value="#{invoice.item['$uniqueid']}" />
<td>
<h:link outcome="/pages/workitems/workitem">
#{invoice.item['invoice.number']}
<f:param name="id" value="#{invoice.item['$uniqueid']}" />
</h:link>
<h:outputText escape="false" value="#{invoice.item['_img']}" />
</td>
</td>
<td><h:outputText value="#{invoice.item['invoice.date']}">
<f:convertDateTime pattern="#{message.datePatternShort}"
timeZone="#{message.timeZone}" />
</h:outputText></td>
<td><h:outputText value="#{invoice.item['invoice.duedate']}">
<f:convertDateTime pattern="#{message.datePatternShort}"
timeZone="#{message.timeZone}" />
</h:outputText></td>
<td>
<h:outputText value="#{invoice.item['invoice.date']}">
<f:convertDateTime pattern="#{message.datePatternShort}" timeZone="#{message.timeZone}" />
</h:outputText>
</td>
<td>
<h:outputText value="#{invoice.item['invoice.duedate']}">
<f:convertDateTime pattern="#{message.datePatternShort}" timeZone="#{message.timeZone}" />
</h:outputText>
</td>
<td><h:outputText value="#{invoice.item['$workflowstatus']}" /></td>
<td>
<h:outputText value="#{invoice.item['$workflowstatus']}" />
</td>
<!-- Rechnngsbetrag -->
<td style="text-align: right;"><h:outputText
value="#{invoice.item['invoice.total']}">
<td style="text-align: right;">
<h:outputText value="#{invoice.item['invoice.total']}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText></td>
</h:outputText>
</td>
<td><h:outputText value="#{invoice.item['invoice.currency']}" /></td>
<td>
<h:outputText value="#{invoice.item['invoice.currency']}" />
</td>
<td style="text-align:right;"><h:outputText value="#{invoice.item['invoice.rate']}" /></td>
<td style="text-align:right;">
<h:outputText value="#{invoice.item['invoice.rate']}" />
</td>
<td style="text-align: right;"><h:outputText
value="#{invoice.item['invoice.base.amount']}" >
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
<td style="text-align: right;">
<h:outputText value="#{invoice.item['invoice.base.amount']}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
</td>
<td>
<!-- if not EUR -->
<h:outputText rendered="#{invoice.item['invoice.currency'] ne 'EUR'}" value=" EUR" />
<!-- if not EUR -->
<h:outputText rendered="#{invoice.item['invoice.currency'] ne 'EUR'}" value=" EUR" />
</td>
<!-- Saldo / offene Betrag -->
<td style="text-align: right; color: red;"><h:outputText
value="#{invoice.item['invoice.saldo']}">
<td style="text-align: right; color: red;">
<h:outputText value="#{invoice.item['invoice.saldo']}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" locale="de" />
</h:outputText></td>
</h:outputText>
</td>
<td style="color: red;"><h:outputText value="#{invoice.item['invoice.currency']}" /></td>
<td style="color: red;">
<h:outputText value="#{invoice.item['invoice.currency']}" />
</td>
<!-- Saldo by rate / offene Betrag in Hauswährung -->
<td style="text-align: right; color: red;"><h:outputText
value="#{invoice.item['invoice.saldo.byrate']}">
<td style="text-align: right; color: red;">
<h:outputText value="#{invoice.item['invoice.saldo.byrate']}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" locale="de" />
</h:outputText></td>
</h:outputText>
</td>
<td style="color: red;"><h:outputText rendered="#{!empty invoice.item['invoice.saldo.byrate']}" value="EUR" /></td>
<td style="color: red;">
<h:outputText rendered="#{!empty invoice.item['invoice.saldo.byrate']}" value="EUR" />
</td>
<!-- Teilbetrag -->
<td style="text-align: right;"><h:inputText id="payment_per_invoice" rendered="#{!readonly}"
value="#{invoice.item['payment.amount']}"
style="width:100px;text-align: right;">
<td style="text-align: right;">
<h:inputText id="payment_per_invoice" rendered="#{!readonly}"
value="#{invoice.item['payment.amount']}" style="width:100px;text-align: right;">
<f:convertNumber minFractionDigits="2" locale="de" />
<f:ajax event="change" execute="#{formComponents.clientId} #{opListContainer.clientId}"
listener="#{opListController.updateChildList(workitem)}"
render="#{opListContainer.clientId}"></f:ajax>
</h:inputText>
<h:outputText rendered="#{readonly}"
value="#{invoice.item['payment.amount']}"
<h:outputText rendered="#{readonly}" value="#{invoice.item['payment.amount']}"
style="width:100px; ">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
@ -130,13 +141,14 @@
<!-- CheckBox -->
<td><h:selectBooleanCheckbox class="invoice_selector" rendered="#{!readonly}"
value="#{invoice.item['selected']}"
onclick="initInvoicePayment(this)">
<td>
<h:selectBooleanCheckbox class="invoice_selector" rendered="#{!readonly}"
value="#{invoice.item['selected']}" onclick="initInvoicePayment(this)">
<f:ajax event="change" execute="#{formComponents.clientId} #{opListContainer.clientId}"
listener="#{opListController.updateChildList(workitem)}"
render="#{opListContainer.clientId}"></f:ajax>
</h:selectBooleanCheckbox></td>
</h:selectBooleanCheckbox>
</td>
</tr>
@ -144,12 +156,13 @@
<tr style="border-top: 1px solid #ccc;">
<td />
<td /><td />
<td />
<td />
<td style="text-align: left;"><strong>Summary</strong></td>
<!-- Invoice total -->
<td style="text-align: right;"><strong> <h:panelGroup
id="invoice_total">
<td style="text-align: right;"><strong>
<h:panelGroup id="invoice_total">
<h:outputText value="#{opListController.calculateInvoiceTotal('EUR')}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
@ -160,32 +173,36 @@
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
</h:panelGroup>
</strong></td>
</strong></td>
<td><strong>EUR<br />USD</strong></td>
<td /><td /><td /> <td />
<td />
<td /><td />
<td />
<td />
<td />
<td />
<td />
<td />
<!-- Payment total -->
<td style="text-align: right;"><strong> <h:panelGroup
id="payment_saldo">
<td style="text-align: right;"><strong>
<h:panelGroup id="payment_saldo">
<h:outputText value="#{workitem.item['payment.currency']} " />
<h:outputText value="#{workitem.item['payment.total']}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
</h:panelGroup>
</strong>
<!-- Anzeige des Zahlbetrgs in EUR bei Fremdwärungszahlung -->
<ui:fragment rendered="#{workitem.item['payment.currency'] ne 'EUR'}">
<br />
EUR <h:outputText value="#{opListController.calculatePaymentSaldoEUR()}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
</ui:fragment>
</strong>
<!-- Anzeige des Zahlbetrgs in EUR bei Fremdwärungszahlung -->
<ui:fragment rendered="#{workitem.item['payment.currency'] ne 'EUR'}">
<br />
EUR <h:outputText value="#{opListController.calculatePaymentSaldoEUR()}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
</ui:fragment>
</td>
@ -195,8 +212,7 @@
</table>
<!-- dieses feld speichert die selection der rechnungen -->
<h:inputTextarea id="invoiceRefHolder_ID"
converter="org.imixs.VectorConverter" class="invoice_selection_list"
<h:inputTextarea id="invoiceRefHolder_ID" converter="org.imixs.VectorConverter" class="invoice_selection_list"
style="display:none;" value="#{workitem.itemList['$workitemref']}" />
@ -204,111 +220,120 @@
<script type="text/javascript">
/*<![CDATA[*/
$(document).ready(
function() {
function () {
// default payment date
var inputPaymentDate=$("input[data-item='payment.date']");
if (inputPaymentDate && inputPaymentDate.val()==='') {
const d = new Date();
const text = d.getDate()+'.'+(d.getMonth()+1) + '.'+d.getFullYear();// d.toString();
inputPaymentDate.val(text);
}
var inputPaymentDate = $("input[data-item='payment.date']");
if (inputPaymentDate && inputPaymentDate.val() === '') {
const d = new Date();
const text = d.getDate() + '.' + (d.getMonth() + 1) + '.' + d.getFullYear();// d.toString();
inputPaymentDate.val(text);
}
//add a onChange handler for data-item payment.amount to update default
var inputPaymentAmount = $("input[data-item='payment.amount']");
$(inputPaymentAmount).change(
function () {
var maxAmount = $("dd[data-item='payment.difference']");
maxAmount.text($(this).val());
}
);
});
// set the payment amount to the invoice total if the field is still empty
// if the paymetn dif is lower than the invoice saldo we take the dif amount
// if the currecny is not EUR and not equal go home!
function initInvoicePayment(element) {
console.log('...initInovicePayment...'+element.checked);
// set the payment amount to the invoice total if the field is still empty
// if the paymetn dif is lower than the invoice saldo we take the dif amount
// if the currecny is not EUR and not equal go home!
function initInvoicePayment(element) {
// console.log('...initInvoicePayment...' + element.checked);
var currentTD=$(element).closest('td');
var prevTD=$(currentTD).prev().prev().prev().prev().prev();
var amountValue=$(prevTD).text();
var invoiceCurrency=$(currentTD).prev().prev().prev().prev().text();
var amountTD=$(currentTD).prev();
var amountInput=$("input",amountTD);
var paymentCurrencyFeld=$("select[data-item='payment.currency']");
var paymentCurrency=$(paymentCurrencyFeld).children("option:selected").val();
var saldoMaxByRate=$(amountTD).prev().prev().text();
var maxAmount=$("dd[data-item='payment.difference']").text();
var currentTD = $(element).closest('td');
var prevTD = $(currentTD).prev().prev().prev().prev().prev();
var amountValue = $(prevTD).text();
var invoiceCurrency = $(currentTD).prev().prev().prev().prev().text();
var amountTD = $(currentTD).prev();
var amountInput = $("input", amountTD);
var paymentCurrencyFeld = $("select[data-item='payment.currency']");
var paymentCurrency = $(paymentCurrencyFeld).children("option:selected").val();
var saldoMaxByRate = $(amountTD).prev().prev().text();
var maxAmount = $("dd[data-item='payment.difference']").text();
maxAmount = maxAmount.replace(/\t/g, '');
maxAmount = maxAmount.replace('\n', '');
maxAmount = maxAmount.replace(/\t/g, '');
maxAmount = maxAmount.replace('\n', '');
v1=amountValue.replace(".","");
v1=Number(v1.replace(",","."));
v1 = amountValue.replace(".", "");
v1 = Number(v1.replace(",", "."));
v2=maxAmount.replace(".","");
v2=Number(v2.replace(",","."));
v2 = maxAmount.replace(".", "");
v2 = Number(v2.replace(",", "."));
if (v1>v2) {
amountValue=maxAmount;
}
if (element.checked) {
// wenn wir noch keinen wert haben, dann betrag übernehmen
if ($(amountInput).val()=='' || $(amountInput).val()=='0,00') {
// wenn wir einen saldo.max.byrate haben
if (paymentCurrency==='EUR' && saldoMaxByRate>'') {
amountValue=saldoMaxByRate;
} else {
amountValue=amountValue;
}
$(amountInput).val(amountValue);
if (v1 > v2) {
amountValue = maxAmount;
}
if (element.checked) {
// wenn wir noch keinen wert haben, dann betrag übernehmen
if ($(amountInput).val() == '' || $(amountInput).val() == '0,00') {
// wenn wir einen saldo.max.byrate haben
if (paymentCurrency === 'EUR' && saldoMaxByRate > '') {
amountValue = saldoMaxByRate;
} else {
amountValue = amountValue;
}
} else {
// clear value
$(amountInput).val("");
$(amountInput).val(amountValue);
}
} else {
// clear value
$(amountInput).val("");
}
}
// This method refreshs the layout of the invoice checkboxes
function updateInvoiceSelection() {
selection = $('.invoice_selection_list').val();
const selectionArr = selection.split("\n");
for (const invoiceID of selectionArr) {
if (invoiceID && invoiceID != "") {
$("#" + invoiceID).prop('checked', true);//=true;
}
}
// This method refreshs the layout of the invoice checkboxes
function updateInvoiceSelection() {
selection = $('.invoice_selection_list').val();
const selectionArr = selection.split("\n");
for (const invoiceID of selectionArr) {
if (invoiceID && invoiceID!="") {
$("#"+invoiceID).prop('checked', true);//=true;
// on change handler....
$('input[type="checkbox"].selection_checkbox').change(
function () {
var id = $(this).attr('id');
var check = $(this).prop('checked');
//console.log("Change: " + id + " to " + check);
// get selection
var selection = $('.invoice_selection_list')
.val();
const selectionArr = selection.split("\n");
// selected
if (check) {
selectionArr.push(id);
}
}
// unselected
if (!check) {
var i = selectionArr.indexOf(id);
selectionArr.splice(i, i);
}
//console.log("new selection=" + selectionArr.join(','));
selection = $('.invoice_selection_list').val(
selectionArr.join('\n'));
// on change handler....
$('input[type="checkbox"].selection_checkbox').change(
function() {
var id = $(this).attr('id');
var check = $(this).prop('checked');
//console.log("Change: " + id + " to " + check);
// refresh the opcalculator...
calculateOpSummary();
});
// get selection
var selection = $('.invoice_selection_list')
.val();
const selectionArr = selection.split("\n");
// selected
if (check) {
selectionArr.push(id);
}
// unselected
if (!check) {
var i = selectionArr.indexOf(id);
selectionArr.splice(i, i);
}
//console.log("new selection=" + selectionArr.join(','));
selection = $('.invoice_selection_list').val(
selectionArr.join('\n'));
// refresh the opcalculator...
calculateOpSummary();
});
}
/*
* Hilfsmethode die nur fur Ajax Events in JSF render verwendet wird
*/
function ajaxUpdateInvoiceSelection(data) {
if (data.status === 'success') {
updateInvoiceSelection();
}
/*
* Hilfsmethode die nur fur Ajax Events in JSF render verwendet wird
*/
function ajaxUpdateInvoiceSelection(data) {
if (data.status === 'success') {
updateInvoiceSelection();
}
}
}
/*]]>*/
@ -318,4 +343,3 @@
</ui:composition>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff