update zahlungseingang
This commit is contained in:
parent
f8313b7571
commit
98f3de046e
3 changed files with 32 additions and 23 deletions
|
|
@ -83,7 +83,7 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
|||
if (paymentWarning.isEmpty()) {
|
||||
// falls mehr einzelsummen eingeben wurden als der oben angegeben Total Pamyment
|
||||
// dann soll eine Warnung ausgegen werden.
|
||||
if ((masterPaymentAmount+masterPaymentDifference) != einzelPayments) {
|
||||
if ( roundD(masterPaymentAmount+masterPaymentDifference) != roundD(einzelPayments)) {
|
||||
document.setItemValue("payment.warning", "invalid saldo");
|
||||
throw new PluginException(PluginException.class.getName(),
|
||||
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
||||
|
|
@ -92,7 +92,7 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
|||
|
||||
}
|
||||
|
||||
einzelPayments = 0;
|
||||
|
||||
for (ItemCollection payment : paymentDetails) {
|
||||
|
||||
ItemCollection invoice = zahlungseingangService.findInvoice(payment.getUniqueID());
|
||||
|
|
@ -101,13 +101,10 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
|||
String invoiceNumber = invoice.getItemValueString("invoice.number");
|
||||
String invoiceCurrency = invoice.getItemValueString("invoice.currency");
|
||||
float invoiceSaldo = invoice.getItemValueFloat("invoice.saldo");
|
||||
float paymentAmount = payment.getItemValueFloat("payment.amount");
|
||||
float invoicePaymentAmount = payment.getItemValueFloat("payment.amount");
|
||||
float invoiceRate = invoice.getItemValueFloat("invoice.rate");
|
||||
|
||||
/**
|
||||
* Falls die Währung der Rechnung von der Währung der Zahlung abweicht, dann
|
||||
* rechnen wir den PaymentAmmout mit der Rate aus.
|
||||
*/
|
||||
|
||||
if (!invoiceCurrency.equals(paymentCurrency)) {
|
||||
if (invoiceRate == 0) {
|
||||
throw new PluginException(PluginException.class.getName(),
|
||||
|
|
@ -116,25 +113,31 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
|||
+ " nicht mit der Währung der Rechnung " + invoiceNumber + " übereinstimmt!");
|
||||
}
|
||||
}
|
||||
|
||||
einzelPayments = einzelPayments + paymentAmount;
|
||||
|
||||
// vergeiche Beträge
|
||||
if (Math.abs(paymentAmount) > Math.abs(invoiceSaldo)) {
|
||||
|
||||
/**
|
||||
* Falls die Währung der Rechnung von der Währung der Zahlung abweicht, dann
|
||||
* rechnen wir den PaymentAmmout mit der Rate aus.
|
||||
*/
|
||||
if ("EUR".equals(paymentCurrency) &&
|
||||
!invoiceCurrency.equals(paymentCurrency) && invoiceRate != 0) {
|
||||
invoicePaymentAmount = invoicePaymentAmount*invoiceRate;
|
||||
// runde auf 2 Stellen
|
||||
invoicePaymentAmount =roundF(invoicePaymentAmount);
|
||||
}
|
||||
|
||||
|
||||
// vergeiche Restsaldo mit payment für diese Rechnung
|
||||
if (Math.abs(invoicePaymentAmount) > Math.abs(invoiceSaldo)) {
|
||||
throw new PluginException(PluginException.class.getName(),
|
||||
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
||||
"Der Zahlungseingang kann nicht verbucht werden, da der Restsaldo der Rechnung "
|
||||
+ invoiceNumber + " kleiner als der Zahlbetrag ist!");
|
||||
}
|
||||
|
||||
// Saldoberechnung in Fremdwärung?
|
||||
if (!invoiceCurrency.equals(paymentCurrency) && invoiceRate != 0) {
|
||||
// Wenn es eien Fremdwährung war korregieren wir den Saldo auf basis des
|
||||
// Umrechnungskurses
|
||||
invoiceSaldo = invoiceSaldo - (paymentAmount * invoiceRate);
|
||||
} else {
|
||||
invoiceSaldo = invoiceSaldo - paymentAmount;
|
||||
}
|
||||
// jetzt den Rechnungsbetrag verkleinern
|
||||
invoiceSaldo = invoiceSaldo - invoicePaymentAmount;
|
||||
|
||||
|
||||
|
||||
invoice.setItemValue("invoice.saldo", invoiceSaldo);
|
||||
invoice.event(ZahlungseingangService.EVENT_UPDATE_INVOICE);
|
||||
|
|
@ -149,4 +152,10 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
|||
|
||||
}
|
||||
|
||||
private float roundF(float wert) {
|
||||
return Math.round(wert * 100.0f) / 100.0f;
|
||||
}
|
||||
private double roundD(double wert) {
|
||||
return Math.round(wert * 100.0f) / 100.0f;
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
<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: 150px;">Zahlbetrag</th>
|
||||
<th style=""></th>
|
||||
</tr>
|
||||
<ui:param name="invoices"
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@
|
|||
|
||||
|
||||
<td style="text-align: right;">
|
||||
<h:outputText rendered="#{payment.item['payment.currency'] eq 'EUR'}"
|
||||
<h:outputText rendered="#{payment.item['payment.currency'] eq 'EUR'}"
|
||||
value="#{paymentDetail.item['payment.amount']*workitem.item['invoice.rate']}">
|
||||
<f:convertNumber minFractionDigits="2" locale="de" />
|
||||
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" locale="de" />
|
||||
</h:outputText>
|
||||
<h:outputText rendered="#{payment.item['payment.currency'] eq 'EUR'}"
|
||||
value=" #{workitem.item['invoice.currency']}" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue