This commit is contained in:
Ralph Soika 2022-11-03 15:30:15 +01:00
parent 7835b685cf
commit a31540ce02
4 changed files with 73 additions and 24 deletions

View file

@ -114,21 +114,23 @@ public class OPListController implements Serializable {
} catch (QueryException e) {
logger.severe("Failed to get op liste:" + e.getMessage());
}
// wir selektieren hier alle fälligen Rechnungen vor, falls der Mahnlauf gerade erstellt
// wir selektieren hier alle fälligen Rechnungen vor, falls der Mahnlauf gerade
// erstellt
// wird.
if (workflowController.getWorkitem().getModelVersion().startsWith("mahnlauf")) {
if (workflowController.getWorkitem().getItemValueInteger("$version") == 0
|| (workflowController.getWorkitem().getItemValueInteger("$version") == 1
&& workflowController.getWorkitem().getItemValueInteger("$lastevent") == 100)) {
List<String> intialSelection = new ArrayList<String>();
for (ItemCollection invoice : invoiceList) {
if ("workitem".equals(invoice.getType()) && invoice.getTaskID()>=5100) {
if ("workitem".equals(invoice.getType()) && invoice.getTaskID() >= 5100) {
intialSelection.add(invoice.getUniqueID());
}
}
workflowController.getWorkitem().setItemValue("$workitemref", intialSelection);
}
}
} else {
// We are no longer in TASK_ERSTELLUNG, so
// fetch only selected invoices
@ -286,14 +288,32 @@ public class OPListController implements Serializable {
*/
public double calculateInvoiceSaldo() {
double result = 0;
if (invoiceList != null) {
for (ItemCollection invoice : invoiceList) {
result = result + invoice.getItemValueDouble("invoice.saldo");
}
}
// rond with 2 digits
return Math.round(result * 100.0) / 100.0;
}
/**
* Berechnet den noch offenen Differenz vom Zahlbetrag
*
* @return
*/
public double calculatePaymentDifference() {
double paymentAmount = workflowController.getWorkitem().getItemValueDouble("payment.amount");
double paymentTotal = workflowController.getWorkitem().getItemValueDouble("payment.total");
// paymentAmount - calculateInvoiceSaldo();
double result = paymentAmount -paymentTotal;
logger.info("...new PaymentDifference=" + result);
// rond with 2 digits
return Math.round(result * 100.0) / 100.0;
}
/**
* Returns true if the reminder date is today or in the past
*

View file

@ -16,6 +16,17 @@
<h:panelGroup layout="block" styleClass="imixs-form-section"
id="oplist-table" binding="#{opListContainer}">
<dl>
<dt>Restbetrag:</dt>
<dd style="color:red;" data-item='payment.difference'>
<h:outputText value="#{opListController.calculatePaymentDifference()}">
<f:convertNumber minFractionDigits="2" locale="de" />
</h:outputText>
</dd>
</dl>
<table style="width: 100%; margin: 5px;">
<tr>
<th style="text-align: left;">#{message['form.invoicenumber']}</th>
@ -88,7 +99,7 @@
value="#{invoice.item['payment.amount']}"
style="width:100px;text-align: right;">
<f:convertNumber minFractionDigits="2" locale="de" />
<f:ajax event="change" execute="#{opListContainer.clientId}"
<f:ajax event="change" execute="#{formComponents.clientId} #{opListContainer.clientId}"
listener="#{opListController.updateChildList(workitem)}"
render="#{opListContainer.clientId}"></f:ajax>
</h:inputText>
@ -105,7 +116,7 @@
<td><h:selectBooleanCheckbox class="invoice_selector" rendered="#{!readonly}"
value="#{invoice.item['selected']}"
onclick="initInvoicePayment(this)">
<f:ajax event="change" execute="#{opListContainer.clientId}"
<f:ajax event="change" execute="#{formComponents.clientId} #{opListContainer.clientId}"
listener="#{opListController.updateChildList(workitem)}"
render="#{opListContainer.clientId}"></f:ajax>
</h:selectBooleanCheckbox></td>
@ -154,12 +165,18 @@
/*<![CDATA[*/
$(document).ready(
function() {
// update the checkboxes of the stored invoice uniqueIDs
// updateInvoiceSelection();
// 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);
}
});
// 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
function initInvoicePayment(element) {
console.log('...initInovicePayment...'+element.checked);
@ -168,9 +185,21 @@
var amountValue=$(prevTD).text();
var amountTD=$(currentTD).prev();
var amountInput=$("input",amountTD);
// wenn wir noch keinen wert dann betrag übernehmen
var maxAmount=$("dd[data-item='payment.difference']").text();
maxAmount = maxAmount.replace(/\t/g, '');
maxAmount = maxAmount.replace('\n', '');
v1=amountValue.replace(".","");
v1=Number(v1.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') {
$(amountInput).val(amountValue);
}

View file

@ -97,7 +97,7 @@
</ui:repeat>
<tr style="border-top: 1px solid #ccc;">
<td />
<td /><td />
<td /><td />
<td><strong>Summary</strong></td>

View file

@ -390,7 +390,7 @@ result.isValid=true;
<item name="payment.date" type="date" required="true" label="Datum:" />
</imixs-form-section>
<imixs-form-section>
<item name="name" type="text" required="true" label="Referenz:" />
<item name="name" type="text" required="false" label="Referenz:" />
</imixs-form-section>
<imixs-form-section columns="2" >
@ -480,7 +480,7 @@ result.isValid=true;
<bpmn2:documentation id="Documentation_16"><![CDATA[<?xml version="1.0"?>
<imixs-form>
<imixs-form-section columns="2" label="Zahlungsdaten">
<item name="name" type="text" required="true" label="Referenz:" />
<item name="name" type="text" required="false" label="Referenz:" />
<item name="dbtr.number" type="text" required="true" label="Debitor:" />
<item name="payment.amount" type="currency" required="true" label="Zahlbetrag:" />
<item name="payment.currency" type="selectOneMenu" required="true" options="EUR;CHF;SEK;RUB;NOK;GBP;USD;CAD" label="Währung:" />