payment.amount
*
* com.alexanderlogistics.ZahlungseingangSaldoAdapter
*
* @version 1.0
* @author rsoika
*/
public class ZahlungseingangSaldoAdapter implements SignalAdapter {
private static Logger logger = Logger.getLogger(ZahlungseingangSaldoAdapter.class.getName());
@Inject
ZahlungseingangService zahlungseingangService;
@Inject
BusinessPartnerService businessPartnerService;
@Inject
InvoiceService invoiceService;
@Inject
ResourceBundleHandler resourceBundleHandler;
/**
* This method finds the outgoing invoices and updates the saldo
* (payment.total).
*
* @throws PluginException
*/
@Override
public ItemCollection execute(ItemCollection document, ItemCollection event)
throws AdapterException, PluginException {
updateSaldo(document);
// Update Debitor E-Mail
String bpid = InvoiceUtil.buildBPID(document.getItemValueString("dbtr.number"));
ItemCollection dbtrItemCol = businessPartnerService.getBusinessPartnerByID(bpid);
if (dbtrItemCol != null) {
document.setItemValue(MahnlaufService.ITEM_DBTR_EMAIL, dbtrItemCol.getItemValue("dbtr.mail"));
}
return document;
}
/**
* Diese methode aktuallisiert alle referenzen der aktuellen Rechnungen
*
* @param workitem
* @throws PluginException
*/
private void updateSaldo(ItemCollection workitem) throws PluginException {
// payment currency
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 paymentDetails = zahlungseingangService.loadPaymentDetails(workitem);
// get all Invoices of this Mahnlauf
List