neue Rundungsfunktion

This commit is contained in:
Ralph Soika 2023-03-14 16:25:36 +01:00
parent 1127211706
commit 41c6ac7cbf
7 changed files with 28 additions and 28 deletions

View file

@ -0,0 +1,10 @@
package com.alexanderlogistics;
public class InvoiceUtil {
public static double round(double value) {
value = value * 100;
long tmp = Math.round(value);
return (double) tmp / 100;
}
}

View file

@ -252,7 +252,7 @@ public class OPListController implements Serializable {
} }
// rond with 2 digits // rond with 2 digits
workitem.replaceItemValue("payment.total", Math.round(paymentTotal * 100.0) / 100.0); workitem.replaceItemValue("payment.total", InvoiceUtil.round(paymentTotal));
// update childitems // update childitems
workitem.replaceItemValue(ZahlungseingangService.ITEM_PAYMENT_DETAILS, mapInvoiceItems); workitem.replaceItemValue(ZahlungseingangService.ITEM_PAYMENT_DETAILS, mapInvoiceItems);
// Update $workitemref // Update $workitemref
@ -296,7 +296,7 @@ public class OPListController implements Serializable {
result = result + invoice.getItemValueDouble("invoice.total"); result = result + invoice.getItemValueDouble("invoice.total");
} }
// rond with 2 digits // rond with 2 digits
return Math.round(result * 100.0) / 100.0; return InvoiceUtil.round(result);
} }
@ -313,7 +313,7 @@ public class OPListController implements Serializable {
} }
} }
// rond with 2 digits // rond with 2 digits
return Math.round(result * 100.0) / 100.0; return InvoiceUtil.round(result);
} }
@ -332,7 +332,7 @@ public class OPListController implements Serializable {
logger.fine("...new PaymentDifference=" + result); logger.fine("...new PaymentDifference=" + result);
// rond with 2 digits // rond with 2 digits
return Math.round(result * 100.0) / 100.0; return InvoiceUtil.round(result);
} }
/** /**
@ -354,7 +354,7 @@ public class OPListController implements Serializable {
} }
} }
// rond with 2 digits // rond with 2 digits
return Math.round(result * 100.0) / 100.0; return InvoiceUtil.round(result);
} }
/** /**

View file

@ -223,12 +223,12 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
// EUR // EUR
row.getCell(6).setCellValue(total); row.getCell(6).setCellValue(total);
row.getCell(7).setCellValue(currency); row.getCell(7).setCellValue(currency);
saldoEUR = roundD(saldoEUR + total); saldoEUR = InvoiceUtil.round(saldoEUR + total);
} else { } else {
// USD // USD
row.getCell(8).setCellValue(total); row.getCell(8).setCellValue(total);
row.getCell(9).setCellValue(currency); row.getCell(9).setCellValue(currency);
saldoUSD = roundD(saldoUSD + total); saldoUSD = InvoiceUtil.round(saldoUSD + total);
} }
row.getCell(10).setCellValue(invoice.getItemValueString("$workflowstatus")); row.getCell(10).setCellValue(invoice.getItemValueString("$workflowstatus"));
@ -388,11 +388,7 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
} }
return result; return result;
} }
private double roundD(double wert) {
return Math.round(wert * 100.0f) / 100.0f;
}
public static boolean isOverdue(Date date, int taskid) { public static boolean isOverdue(Date date, int taskid) {
Date now = new Date(); Date now = new Date();

View file

@ -61,7 +61,7 @@ public class ZahlungsavisController implements Serializable {
} }
} }
// rond with 2 digits // rond with 2 digits
return Math.round(result * 100.0) / 100.0; return InvoiceUtil.round(result);
} }

View file

@ -83,7 +83,7 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
if (paymentWarning.isEmpty()) { if (paymentWarning.isEmpty()) {
// falls mehr einzelsummen eingeben wurden als der oben angegeben Total Pamyment // falls mehr einzelsummen eingeben wurden als der oben angegeben Total Pamyment
// dann soll eine Warnung ausgegen werden. // dann soll eine Warnung ausgegen werden.
if ( roundD(masterPaymentAmount+masterPaymentDifference) != roundD(einzelPayments)) { if ( InvoiceUtil.round(masterPaymentAmount+masterPaymentDifference) != InvoiceUtil.round(einzelPayments)) {
document.setItemValue("payment.warning", "invalid saldo"); document.setItemValue("payment.warning", "invalid saldo");
throw new PluginException(PluginException.class.getName(), throw new PluginException(PluginException.class.getName(),
ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED, ZahlungseingangService.ERROR_PAYMENT_BOOKING_FAILED,
@ -122,12 +122,12 @@ public class ZahlungseingangSaldoAdapter implements SignalAdapter {
!invoiceCurrency.equals(paymentCurrency) && invoiceRate != 0) { !invoiceCurrency.equals(paymentCurrency) && invoiceRate != 0) {
invoicePaymentAmount = invoicePaymentAmount*invoiceRate; invoicePaymentAmount = invoicePaymentAmount*invoiceRate;
// runde auf 2 Stellen // runde auf 2 Stellen
invoicePaymentAmount =roundF(invoicePaymentAmount); invoicePaymentAmount =(float) InvoiceUtil.round(invoicePaymentAmount);
} }
// vergeiche Restsaldo mit payment für diese Rechnung // vergeiche Restsaldo mit payment für diese Rechnung
if (Math.abs(invoicePaymentAmount) > Math.abs(invoiceSaldo)) { if (Math.abs(invoicePaymentAmount) > Math.abs(InvoiceUtil.round(invoiceSaldo))) {
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 der Restsaldo der Rechnung " "Der Zahlungseingang kann nicht verbucht werden, da der Restsaldo der Rechnung "
@ -152,10 +152,4 @@ 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;
}
} }

View file

@ -31,6 +31,7 @@ import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.ProcessingErrorException; import org.imixs.workflow.exceptions.ProcessingErrorException;
import org.imixs.workflow.exceptions.QueryException; import org.imixs.workflow.exceptions.QueryException;
import com.alexanderlogistics.InvoiceUtil;
import com.alexanderlogistics.KreditorDebitorService; import com.alexanderlogistics.KreditorDebitorService;
/** /**
@ -406,6 +407,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
} }
} }
total=InvoiceUtil.round(total);
invoiceWorkitem.setItemValue("invoice.total", total); invoiceWorkitem.setItemValue("invoice.total", total);
invoiceWorkitem.setItemValue("invoice.saldo", total); invoiceWorkitem.setItemValue("invoice.saldo", total);
// implode die Splitbuchungen // implode die Splitbuchungen
@ -455,12 +457,8 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
workflowService.processWorkItem(invoiceWorkitem); workflowService.processWorkItem(invoiceWorkitem);
} }
public static void updateSpaceRef(ItemCollection invoice) {
}
/** /**
* Convert the List of ItemCollections back into a List of Map elements * Convert the List of ItemCollections back into a List of Map elements
* *

View file

@ -12,6 +12,8 @@ import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.faces.data.WorkflowController; import org.imixs.workflow.faces.data.WorkflowController;
import com.alexanderlogistics.InvoiceUtil;
/** /**
* Der InkassoController dient dazu eine bereits zugewiesene Rechnung * Der InkassoController dient dazu eine bereits zugewiesene Rechnung
* wieder aus dem Inkasso zu entfernen. * wieder aus dem Inkasso zu entfernen.
@ -58,7 +60,7 @@ public class InkassoController implements Serializable {
} }
} }
// rond with 2 digits // rond with 2 digits
return Math.round(result * 100.0) / 100.0; return InvoiceUtil.round(result);
} }