update
This commit is contained in:
parent
02187332b0
commit
9ecb75888c
4 changed files with 92 additions and 24 deletions
|
|
@ -62,16 +62,22 @@ public class OPListController implements Serializable {
|
||||||
protected DocumentService documentService;
|
protected DocumentService documentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Methode liefert die Rechnungen zur gegebenen dbtrNumber. Die Methode
|
* Diese Methode wird für Zahlungseingänge und Mahnläufe verwendet.
|
||||||
* nutzt einen lokalen cache um die Zugriffe zu beschleunigen.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Befindet sich der Zahlungseingang in Erstellung (Task=1000) werden alle
|
* Die Metho liefert die Rechnungen zur gegebenen dbtrNumber. Die Methode nutzt
|
||||||
* offenen Rechnungen geholt. Zusätzlich werden auch alle diese Rechnungen
|
* einen lokalen cache um die Zugriffe zu beschleunigen.
|
||||||
* vorselektiert (Anforderung von Mary Mwangi). D.h. man muss ggf. Rechnungen
|
|
||||||
* manuell delselktieren wenn man diese nicht im Mahnlauf haben will.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Befindet sich der Zahlungseingang nicht mehr in erstellung werden nur die
|
* Befindet sich ein Zahlungseingang in Erstellung (Task=1000) werden alle
|
||||||
|
* offenen Rechnungen geholt.
|
||||||
|
* <p>
|
||||||
|
* Befindet sich ein Zahlungseingang nicht mehr in erstellung werden nur die
|
||||||
* Rechnugnen aus $workitemRef geholt!
|
* Rechnugnen aus $workitemRef geholt!
|
||||||
|
* <p>
|
||||||
|
* Bei verwendung im Mahnlauf werden zusätzlich auch alle diese Rechnungen
|
||||||
|
* vorselektiert (Anforderung von Mary Mwangi). D.h. es werden alle Checkboxen
|
||||||
|
* in der Maske 'selection_opliste_Mahnluaf' angewählt. D.h auch man muss ggf.
|
||||||
|
* Rechnungen manuell delselktieren wenn man diese nicht im Mahnlauf haben will.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @param _dbtrNumber
|
* @param _dbtrNumber
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -114,16 +120,32 @@ public class OPListController implements Serializable {
|
||||||
} catch (QueryException e) {
|
} catch (QueryException e) {
|
||||||
logger.severe("Failed to get op liste:" + e.getMessage());
|
logger.severe("Failed to get op liste:" + e.getMessage());
|
||||||
}
|
}
|
||||||
// wir selektieren hier alle fälligen Rechnungen vor, falls der Mahnlauf gerade
|
|
||||||
// erstellt
|
// Zahlugnseingang?
|
||||||
// wird.
|
if (workflowController.getWorkitem().getModelVersion().startsWith("zahlungseingang")) {
|
||||||
|
// berechnung des Basisumsatzes bei Fremdwährungen
|
||||||
|
for (ItemCollection invoice : invoiceList) {
|
||||||
|
float rate=invoice.getItemValueFloat("invoice.rate");
|
||||||
|
float maxSaldo=invoice.getItemValueFloat("invoice.saldo");
|
||||||
|
if (rate!=0) {
|
||||||
|
maxSaldo=maxSaldo/rate;
|
||||||
|
invoice.setItemValue("invoice.saldo.byrate",maxSaldo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mahnlauf ?
|
||||||
if (workflowController.getWorkitem().getModelVersion().startsWith("mahnlauf")) {
|
if (workflowController.getWorkitem().getModelVersion().startsWith("mahnlauf")) {
|
||||||
|
// wir selektieren hier alle fälligen Rechnungen vor, falls der Mahnlauf gerade
|
||||||
|
// erstellt wird.
|
||||||
if (workflowController.getWorkitem().getItemValueInteger("$version") == 0
|
if (workflowController.getWorkitem().getItemValueInteger("$version") == 0
|
||||||
|| (workflowController.getWorkitem().getItemValueInteger("$version") == 1
|
|| (workflowController.getWorkitem().getItemValueInteger("$version") == 1
|
||||||
&& workflowController.getWorkitem().getItemValueInteger("$lastevent") == 100)) {
|
&& workflowController.getWorkitem().getItemValueInteger("$lastevent") == 100)) {
|
||||||
List<String> intialSelection = new ArrayList<String>();
|
List<String> intialSelection = new ArrayList<String>();
|
||||||
for (ItemCollection invoice : invoiceList) {
|
for (ItemCollection invoice : invoiceList) {
|
||||||
|
// ist die Rechnung fällig?
|
||||||
if ("workitem".equals(invoice.getType()) && invoice.getTaskID() >= 5100) {
|
if ("workitem".equals(invoice.getType()) && invoice.getTaskID() >= 5100) {
|
||||||
intialSelection.add(invoice.getUniqueID());
|
intialSelection.add(invoice.getUniqueID());
|
||||||
}
|
}
|
||||||
|
|
@ -305,9 +327,9 @@ public class OPListController implements Serializable {
|
||||||
*/
|
*/
|
||||||
public double calculatePaymentDifference() {
|
public double calculatePaymentDifference() {
|
||||||
double paymentAmount = workflowController.getWorkitem().getItemValueDouble("payment.amount");
|
double paymentAmount = workflowController.getWorkitem().getItemValueDouble("payment.amount");
|
||||||
double paymentTotal = workflowController.getWorkitem().getItemValueDouble("payment.total");
|
double paymentTotal = workflowController.getWorkitem().getItemValueDouble("payment.total");
|
||||||
// paymentAmount - calculateInvoiceSaldo();
|
// paymentAmount - calculateInvoiceSaldo();
|
||||||
double result = paymentAmount -paymentTotal;
|
double result = paymentAmount - paymentTotal;
|
||||||
|
|
||||||
logger.info("...new PaymentDifference=" + result);
|
logger.info("...new PaymentDifference=" + result);
|
||||||
// rond with 2 digits
|
// rond with 2 digits
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,24 @@ public class MahnlaufExecuteAdapter implements SignalAdapter {
|
||||||
// get all Invoices of this Mahnlauf
|
// get all Invoices of this Mahnlauf
|
||||||
List<Map<String, List<Object>>> invoiceList = new ArrayList<Map<String, List<Object>>>();
|
List<Map<String, List<Object>>> invoiceList = new ArrayList<Map<String, List<Object>>>();
|
||||||
List<String> refList = mahnLaufWorkitem.getItemValue("$workitemref");
|
List<String> refList = mahnLaufWorkitem.getItemValue("$workitemref");
|
||||||
|
|
||||||
|
// sind die Wärhungen idendtisch (mischmasch geht niht)
|
||||||
|
String lastCurrency="";
|
||||||
|
for (String uniqueId : refList) {
|
||||||
|
ItemCollection invoice = workflowService.getWorkItem(uniqueId);
|
||||||
|
String invoiceCurrency=invoice.getItemValueString("invoice.currency");
|
||||||
|
if (lastCurrency.isEmpty()) {
|
||||||
|
lastCurrency=invoiceCurrency;
|
||||||
|
} else {
|
||||||
|
if (!lastCurrency.equals(invoiceCurrency)) {
|
||||||
|
throw new PluginException(MahnlaufRefAddAdapter.class.getName(), MahnlaufService.ERROR_WORKFLOW,
|
||||||
|
"In einem Mahnlauf können nur Rechnungen mit der selben Währung ausgewählt werden.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double saldo = 0;
|
double saldo = 0;
|
||||||
String currency = "";
|
String currency = "";
|
||||||
for (String uniqueId : refList) {
|
for (String uniqueId : refList) {
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,11 @@
|
||||||
<th style="width: 40px;"></th>
|
<th style="width: 40px;"></th>
|
||||||
|
|
||||||
<th style="width: 70px; text-align: right;">Kurs</th>
|
<th style="width: 70px; text-align: right;">Kurs</th>
|
||||||
<th style="width: 100px; text-align: right;">Basisumsatz</th>
|
<th style="width: 100px; text-align: right;">Basisumsatz</th><th />
|
||||||
|
|
||||||
<th style="width: 100px;">Saldo</th>
|
<th style="width: 100px;">Saldo</th><th />
|
||||||
|
<th style="width: 100px;">Saldo in EUR</th>
|
||||||
|
<th style=""></th>
|
||||||
<th style="width: 100px;">Zahlbetrag</th>
|
<th style="width: 100px;">Zahlbetrag</th>
|
||||||
<th style=""></th>
|
<th style=""></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -82,17 +84,31 @@
|
||||||
<td style="text-align: right;"><h:outputText
|
<td style="text-align: right;"><h:outputText
|
||||||
value="#{invoice.item['invoice.base.amount']}" >
|
value="#{invoice.item['invoice.base.amount']}" >
|
||||||
<f:convertNumber minFractionDigits="2" locale="de" />
|
<f:convertNumber minFractionDigits="2" locale="de" />
|
||||||
</h:outputText></td>
|
</h:outputText>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<!-- if not EUR -->
|
||||||
|
<h:outputText rendered="#{invoice.item['invoice.currency'] ne 'EUR'}" value=" EUR" />
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Saldo / offene Betrag -->
|
<!-- Saldo / offene Betrag -->
|
||||||
<td style="text-align: right; color: red;"><h:outputText
|
<td style="text-align: right; color: red;"><h:outputText
|
||||||
value="#{invoice.item['invoice.saldo']}">
|
value="#{invoice.item['invoice.saldo']}">
|
||||||
<f:convertNumber minFractionDigits="2" locale="de" />
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Saldo by rate / offene Betrag in Hauswährung -->
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<td style="color: red;"><h:outputText rendered="#{!empty invoice.item['invoice.saldo.byrate']}" value="EUR" /></td>
|
||||||
|
|
||||||
<!-- Teilbetrag -->
|
<!-- Teilbetrag -->
|
||||||
<td style="text-align: right;"><h:inputText id="payment_per_invoice" rendered="#{!readonly}"
|
<td style="text-align: right;"><h:inputText id="payment_per_invoice" rendered="#{!readonly}"
|
||||||
|
|
@ -127,8 +143,8 @@
|
||||||
|
|
||||||
<tr style="border-top: 1px solid #ccc;">
|
<tr style="border-top: 1px solid #ccc;">
|
||||||
<td />
|
<td />
|
||||||
<td /><td />
|
<td /><td /> <td /><td /><td /><td />
|
||||||
<td><strong>Summary</strong></td>
|
<td style="text-align: right;"><strong>Summary</strong></td><td />
|
||||||
|
|
||||||
<!-- Invoice total -->
|
<!-- Invoice total -->
|
||||||
<td style="text-align: right;"><strong> <h:panelGroup
|
<td style="text-align: right;"><strong> <h:panelGroup
|
||||||
|
|
@ -140,7 +156,7 @@
|
||||||
</strong></td>
|
</strong></td>
|
||||||
|
|
||||||
<td />
|
<td />
|
||||||
<td /><td /><td />
|
<td /><td />
|
||||||
|
|
||||||
<!-- Payment total -->
|
<!-- Payment total -->
|
||||||
<td style="text-align: right;"><strong> <h:panelGroup
|
<td style="text-align: right;"><strong> <h:panelGroup
|
||||||
|
|
@ -177,15 +193,21 @@
|
||||||
|
|
||||||
// set the payment amount to the invoice total if the field is still empty
|
// 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 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) {
|
function initInvoicePayment(element) {
|
||||||
console.log('...initInovicePayment...'+element.checked);
|
console.log('...initInovicePayment...'+element.checked);
|
||||||
|
|
||||||
var currentTD=$(element).closest('td');
|
var currentTD=$(element).closest('td');
|
||||||
var prevTD=$(currentTD).prev().prev();
|
var prevTD=$(currentTD).prev().prev().prev().prev().prev();
|
||||||
var amountValue=$(prevTD).text();
|
var amountValue=$(prevTD).text();
|
||||||
|
var invoiceCurrency=$(currentTD).prev().prev().prev().prev().text();
|
||||||
var amountTD=$(currentTD).prev();
|
var amountTD=$(currentTD).prev();
|
||||||
var amountInput=$("input",amountTD);
|
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 maxAmount=$("dd[data-item='payment.difference']").text();
|
||||||
|
|
||||||
maxAmount = maxAmount.replace(/\t/g, '');
|
maxAmount = maxAmount.replace(/\t/g, '');
|
||||||
maxAmount = maxAmount.replace('\n', '');
|
maxAmount = maxAmount.replace('\n', '');
|
||||||
|
|
||||||
|
|
@ -201,6 +223,12 @@
|
||||||
if (element.checked) {
|
if (element.checked) {
|
||||||
// wenn wir noch keinen wert haben, dann betrag übernehmen
|
// wenn wir noch keinen wert haben, dann betrag übernehmen
|
||||||
if ($(amountInput).val()=='' || $(amountInput).val()=='0,00') {
|
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);
|
$(amountInput).val(amountValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -395,7 +395,7 @@ result.isValid=true;
|
||||||
</imixs-form-section>
|
</imixs-form-section>
|
||||||
<imixs-form-section columns="2" >
|
<imixs-form-section columns="2" >
|
||||||
<item name="payment.amount" type="currency" required="true" label="Zahlbetrag:" />
|
<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:" />
|
<item name="payment.currency" type="selectOneMenu" required="true" options="EUR;USD" label="Währung:" />
|
||||||
</imixs-form-section>
|
</imixs-form-section>
|
||||||
|
|
||||||
<imixs-form-section label="Offene Posten" path="alexander/section_opliste" readonly="false" />
|
<imixs-form-section label="Offene Posten" path="alexander/section_opliste" readonly="false" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue