error handling payment
This commit is contained in:
parent
ca2e72bc37
commit
8e6f97ffa4
4 changed files with 55 additions and 8 deletions
|
|
@ -96,6 +96,25 @@ public class InvoiceService {
|
||||||
return currencyList;
|
return currencyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Hauptwährung zurück (1. in der liste)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws PluginException
|
||||||
|
*/
|
||||||
|
public String getCurrenciesOutMain() throws PluginException {
|
||||||
|
|
||||||
|
// ermittle die Hauptwährungen
|
||||||
|
ItemCollection configItemCollection = configService.loadConfiguration("AGL_CONFIGURATION");
|
||||||
|
List<String> currencyList = configItemCollection.getItemValue("currency.out");
|
||||||
|
if (currencyList == null || currencyList.size() < 1) {
|
||||||
|
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||||
|
InvoiceService.ERROR_CONFIG,
|
||||||
|
"missing Currency configuration - please check parameters");
|
||||||
|
}
|
||||||
|
return currencyList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liefert die Liste der Eingehenden Währungen
|
* Liefert die Liste der Eingehenden Währungen
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.imixs.workflow.ItemCollection;
|
||||||
import org.imixs.workflow.SignalAdapter;
|
import org.imixs.workflow.SignalAdapter;
|
||||||
import org.imixs.workflow.exceptions.AdapterException;
|
import org.imixs.workflow.exceptions.AdapterException;
|
||||||
import org.imixs.workflow.exceptions.PluginException;
|
import org.imixs.workflow.exceptions.PluginException;
|
||||||
|
import org.imixs.workflow.faces.util.ResourceBundleHandler;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
|
@ -34,6 +35,12 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
||||||
@Inject
|
@Inject
|
||||||
ZahlungseingangService zahlungseingangService;
|
ZahlungseingangService zahlungseingangService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
InvoiceService invoiceService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ResourceBundleHandler resourceBundleHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method finds the outgoing invoices and updates the saldo
|
* This method finds the outgoing invoices and updates the saldo
|
||||||
* (payment.total).
|
* (payment.total).
|
||||||
|
|
@ -85,9 +92,10 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
||||||
// dann soll eine Warnung ausgegen werden.
|
// dann soll eine Warnung ausgegen werden.
|
||||||
if (InvoiceUtil.round(masterPaymentAmount + masterPaymentDifference) != InvoiceUtil.round(einzelPayments)) {
|
if (InvoiceUtil.round(masterPaymentAmount + masterPaymentDifference) != InvoiceUtil.round(einzelPayments)) {
|
||||||
workitem.setItemValue("payment.warning", "invalid saldo");
|
workitem.setItemValue("payment.warning", "invalid saldo");
|
||||||
|
|
||||||
|
String message = resourceBundleHandler.findMessage("ERROR_PAYMENT2");
|
||||||
throw new PluginException(PluginException.class.getName(),
|
throw new PluginException(PluginException.class.getName(),
|
||||||
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED, message);
|
||||||
"Der Zahlungseingang ist nicht identisch mit den ausgebuchten Rechnungssalden. Sollte die Eingabe korrekt sein, wiederholen Sie die Aktion.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,12 +110,23 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
||||||
float invoicePaymentAmount = payment.getItemValueFloat("payment.amount");
|
float invoicePaymentAmount = payment.getItemValueFloat("payment.amount");
|
||||||
float invoiceRate = invoice.getItemValueFloat("invoice.rate");
|
float invoiceRate = invoice.getItemValueFloat("invoice.rate");
|
||||||
|
|
||||||
|
String mainCurrency = invoiceService.getCurrenciesOutMain();
|
||||||
|
if (!invoiceCurrency.equals(mainCurrency) && !paymentCurrency.equals(mainCurrency)) {
|
||||||
|
String message = resourceBundleHandler.findMessage("ERROR_PAYMENT4");
|
||||||
|
message = message.replace("{1}", mainCurrency);
|
||||||
|
throw new PluginException(PluginException.class.getName(),
|
||||||
|
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
||||||
|
message);
|
||||||
|
}
|
||||||
|
|
||||||
if (!invoiceCurrency.equals(paymentCurrency)) {
|
if (!invoiceCurrency.equals(paymentCurrency)) {
|
||||||
if (invoiceRate == 0) {
|
if (invoiceRate == 0) {
|
||||||
|
String message = resourceBundleHandler.findMessage("ERROR_PAYMENT1");
|
||||||
|
message = message.replace("{1}", paymentCurrency);
|
||||||
|
message = message.replace("{2}", invoiceNumber);
|
||||||
throw new PluginException(PluginException.class.getName(),
|
throw new PluginException(PluginException.class.getName(),
|
||||||
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
||||||
"Der Zahlungseingang kann nicht verbucht werden, da die Währung " + paymentCurrency
|
message);
|
||||||
+ " nicht mit der Währung der Rechnung " + invoiceNumber + " übereinstimmt!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,10 +144,10 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
||||||
// vergeiche Restsaldo mit payment für diese Rechnung
|
// vergeiche Restsaldo mit payment für diese Rechnung
|
||||||
if (!isPaymentBooked(workitem) && Math.abs(InvoiceUtil.round(invoicePaymentAmount)) > Math
|
if (!isPaymentBooked(workitem) && Math.abs(InvoiceUtil.round(invoicePaymentAmount)) > Math
|
||||||
.abs(InvoiceUtil.round(invoiceSaldo))) {
|
.abs(InvoiceUtil.round(invoiceSaldo))) {
|
||||||
|
String message = resourceBundleHandler.findMessage("ERROR_PAYMENT3");
|
||||||
|
message = message.replace("{1}", invoiceNumber);
|
||||||
throw new PluginException(PluginException.class.getName(),
|
throw new PluginException(PluginException.class.getName(),
|
||||||
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
|
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED, message);
|
||||||
"Der Zahlungseingang kann nicht verbucht werden, da der Restsaldo der Rechnung "
|
|
||||||
+ invoiceNumber + " kleiner als der Zahlbetrag ist!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// jetzt den Rechnungsbetrag verkleinern
|
// jetzt den Rechnungsbetrag verkleinern
|
||||||
|
|
@ -147,7 +166,7 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new PluginException(PluginException.class.getName(),
|
throw new PluginException(PluginException.class.getName(),
|
||||||
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED, "Rechnung konnte nicht gefunden werden!");
|
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED, "Invoice not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,7 @@ ERROR_MISSING_TAX=Eingabefehler - Die Steuer in Zeile {1} muss ausgefüllt sein!
|
||||||
ERROR_MISSING_NET=Eingabefehler - Der Nettobetrag in Zeile {1} darf nicht 0 sein!
|
ERROR_MISSING_NET=Eingabefehler - Der Nettobetrag in Zeile {1} darf nicht 0 sein!
|
||||||
ERROR_MISSING_PAYMENT=Eingabefehler - Bitte wählen Sie eine Zahlungsart aus!
|
ERROR_MISSING_PAYMENT=Eingabefehler - Bitte wählen Sie eine Zahlungsart aus!
|
||||||
|
|
||||||
|
ERROR_PAYMENT1="Der Zahlungseingang kann nicht verbucht werden, da die Währung {1} nicht mit der Währung der Rechnung {2} übereinstimmt!"
|
||||||
|
ERROR_PAYMENT2="Der Zahlungseingang ist nicht identisch mit den ausgebuchten Rechnungssalden. Sollte die Eingabe korrekt sein, wiederholen Sie die Aktion."
|
||||||
|
ERROR_PAYMENT3="Der Zahlungseingang kann nicht verbucht werden, da der Restsaldo der Rechnung {1} kleiner als der Zahlbetrag ist!"
|
||||||
|
ERROR_PAYMENT4="Wenigstens eine ausgewählte Währung muss der Hauptwährung {1} entsprechen!"
|
||||||
|
|
@ -63,3 +63,8 @@ ERROR_MISSING_TAX=Input error - The tax in line {1} must be filled in!
|
||||||
ERROR_MISSING_NET=Input error - The net amount in line {1} must not be 0!
|
ERROR_MISSING_NET=Input error - The net amount in line {1} must not be 0!
|
||||||
ERROR_MISSING_PAYMENT=Input error - Please select a payment method!
|
ERROR_MISSING_PAYMENT=Input error - Please select a payment method!
|
||||||
|
|
||||||
|
|
||||||
|
ERROR_PAYMENT1="The payment cannot be posted because the currency {1} does not match the invoice currency {2}!"
|
||||||
|
ERROR_PAYMENT2="The incoming payment does not match the posted invoice balances. If the input is correct, please repeat the action."
|
||||||
|
ERROR_PAYMENT3="The payment cannot be posted because the remaining balance of invoice {1} is less than the payment amount!"
|
||||||
|
ERROR_PAYMENT4="At least one selected currency must match the main currency {1}!"
|
||||||
Loading…
Reference in a new issue