debitor statistik

This commit is contained in:
Ralph Soika 2023-08-03 12:05:05 +02:00
parent 6aebef26a6
commit eb0154d0d1
5 changed files with 81 additions and 77 deletions

View file

@ -194,7 +194,7 @@ public class CargosoftController implements Serializable {
try { try {
List<ItemCollection> result = documentService.find(query, 20, 0, "$modified", true); List<ItemCollection> result = documentService.find(query, 20, 0, "$modified", true);
logger.info("found " + result.size() + " debitors..."); logger.fine("found " + result.size() + " debitors...");
if (result != null) { if (result != null) {
for (ItemCollection dbtr : result) { for (ItemCollection dbtr : result) {
// Aenderugn 22. Jun wir geben das K/D direkt witer // Aenderugn 22. Jun wir geben das K/D direkt witer

View file

@ -18,12 +18,15 @@ import java.util.TreeMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.imixs.workflow.ItemCollection; import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.QueryException; import org.imixs.workflow.exceptions.QueryException;
import org.imixs.workflow.faces.data.WorkflowController; import org.imixs.workflow.faces.data.WorkflowController;
import org.imixs.workflow.office.views.SearchController; import org.imixs.workflow.office.views.SearchController;
@ -54,12 +57,32 @@ public class DebitorStatistikController implements Serializable {
@Inject @Inject
protected SearchController searchController; protected SearchController searchController;
// private ItemCollection workitem = null; @Inject
protected KreditorDebitorService kreditorDebitorService;
public DebitorStatistikController() { /**
// workitem = new ItemCollection(); * Initialize default behavior initialize an opitonal id from the query string
*
*/
@PostConstruct
public void init() {
// extract the processref and page from the query string
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, String> paramMap = fc.getExternalContext().getRequestParameterMap();
String id = paramMap.get("dbtr.number");
if (id != null && !id.isEmpty()) {
workflowController.getWorkitem().setItemValue("dbtr.number", id);
try {
ItemCollection dbtr = kreditorDebitorService.findDebitor(id);
if (dbtr != null) {
workflowController.getWorkitem().setItemValue("dbtr.name", dbtr.getItemValueString("_vendor_name"));
}
} catch (PluginException e) {
// e.printStackTrace();
}
}
} }
public ItemCollection getWorkitem() { public ItemCollection getWorkitem() {
return workflowController.getWorkitem(); return workflowController.getWorkitem();
} }
@ -68,6 +91,15 @@ public class DebitorStatistikController implements Serializable {
return 0; return 0;
} }
/**
* Gibt eine bookmarkable url zurück.
* Wir vom Aktualisieren button in der Page genutzt
*
* @return
*/
public String getBookmark() {
return "/pages/dbtr-stats.xhtml?dbtr.number=" + getDbtNr() + "&faces-redirect=true";
}
/* /*
* Gesamt * Gesamt
*/ */
@ -78,6 +110,9 @@ public class DebitorStatistikController implements Serializable {
} }
public int getRechnungen() { public int getRechnungen() {
int result = 0; int result = 0;
if (getDbtNr().isEmpty()) {
return 0;
}
try { try {
result = documentService result = documentService
.count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr() .count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr()
@ -99,7 +134,9 @@ public class DebitorStatistikController implements Serializable {
} }
public int getRechnungenBezahlt() { public int getRechnungenBezahlt() {
int result = 0; int result = 0;
if (getDbtNr().isEmpty()) {
return 0;
}
try { try {
result = documentService result = documentService
.count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr() .count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr()
@ -120,7 +157,9 @@ public class DebitorStatistikController implements Serializable {
} }
public int getRechnungenOffen() { public int getRechnungenOffen() {
int result = 0; int result = 0;
if (getDbtNr().isEmpty()) {
return 0;
}
try { try {
result = documentService result = documentService
.count("(type:workitem) AND dbtr.number:" + getDbtNr() .count("(type:workitem) AND dbtr.number:" + getDbtNr()
@ -141,6 +180,9 @@ public class DebitorStatistikController implements Serializable {
} }
public int getRechnungenFaellig() { public int getRechnungenFaellig() {
int result = 0; int result = 0;
if (getDbtNr().isEmpty()) {
return 0;
}
try { try {
result = documentService result = documentService
.count("(type:workitem) AND dbtr.number:" + getDbtNr() .count("(type:workitem) AND dbtr.number:" + getDbtNr()
@ -161,6 +203,9 @@ public class DebitorStatistikController implements Serializable {
} }
public int getRechnungenGemahnt() { public int getRechnungenGemahnt() {
int result = 0; int result = 0;
if (getDbtNr().isEmpty()) {
return 0;
}
try { try {
result = documentService result = documentService
.count("(type:workitem ) AND dbtr.number:" + getDbtNr() .count("(type:workitem ) AND dbtr.number:" + getDbtNr()
@ -181,7 +226,9 @@ public class DebitorStatistikController implements Serializable {
} }
public int getRechnungenInkasso() { public int getRechnungenInkasso() {
int result = 0; int result = 0;
if (getDbtNr().isEmpty()) {
return 0;
}
try { try {
result = documentService result = documentService
.count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr() .count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr()
@ -197,7 +244,7 @@ public class DebitorStatistikController implements Serializable {
* *
* @return * @return
*/ */
private String getDbtNr() { public String getDbtNr() {
String dbtNr = getWorkitem().getItemValueString("dbtr.number"); String dbtNr = getWorkitem().getItemValueString("dbtr.number");
if (dbtNr.startsWith("D") || dbtNr.startsWith("K")) { if (dbtNr.startsWith("D") || dbtNr.startsWith("K")) {
dbtNr = dbtNr.substring(1); dbtNr = dbtNr.substring(1);
@ -246,16 +293,18 @@ public class DebitorStatistikController implements Serializable {
// recompute // recompute
stats = new TreeMap<String, DebitorStatistikData>(); stats = new TreeMap<String, DebitorStatistikData>();
if (getDbtNr().isEmpty()) {
return stats;
}
// invoice.date:[20210101 TO 20210201] // invoice.date:[20210101 TO 20210201]
DateFormat df = new SimpleDateFormat("yyyymmdd"); DateFormat df = new SimpleDateFormat("yyyymmdd");
String query = "(type:workitemarchive) AND dbtr.number:" + getDbtNr() String query = "(type:workitemarchive) AND invoice.date:[20221201 TO 20500101] AND dbtr.number:" + getDbtNr()
+ " AND $workflowgroup:\"Rechnungsausgang\" AND ($taskid:[5900 TO 5999])"; + " AND $workflowgroup:\"Rechnungsausgang\" AND ($taskid:[5900 TO 5999])";
// query = query + " AND (invoice.date:[" + df.format(from) + " TO " + // query = query + " AND (invoice.date:[" + df.format(from) + " TO " +
// df.format(to) + "])"; // df.format(to) + "])";
logger.info("query = " + query); logger.fine("query = " + query);
try { try {
List<ItemCollection> invoices = documentService List<ItemCollection> invoices = documentService
.findStubs(query, 9999, 0, "$created", false); .findStubs(query, 9999, 0, "$created", false);
@ -263,14 +312,12 @@ public class DebitorStatistikController implements Serializable {
for (ItemCollection invoice : invoices) { for (ItemCollection invoice : invoices) {
try { try {
logger.warning("Rechnung: " + invoice.getUniqueID()); logger.fine("Rechnung: " + invoice.getUniqueID());
Date invoiceDate = invoice.getItemValueDate("invoice.date"); Date invoiceDate = invoice.getItemValueDate("invoice.date");
Date invoiceDueDate = invoice.getItemValueDate("invoice.duedate"); Date invoiceDueDate = invoice.getItemValueDate("invoice.duedate");
Date paymentDate = findPaymentDateByWorkitem(invoice); Date paymentDate = findPaymentDateByWorkitem(invoice);
if (paymentDate == null) { if (paymentDate == null) {
// fall back method
logger.warning("Es wurde kein Zahlungseingang gefunden"); logger.warning("Es wurde kein Zahlungseingang gefunden");
// paymentDate = findPaymentDateByLog(invoice);
continue; continue;
} }
@ -281,10 +328,8 @@ public class DebitorStatistikController implements Serializable {
// create a new one // create a new one
statData = new DebitorStatistikData(invoiceDate); statData = new DebitorStatistikData(invoiceDate);
} }
// jetzt irgendwas ausrechnen // jetzt irgendwas ausrechnen
statData.compute(invoiceDate, invoiceDueDate, paymentDate); statData.compute(invoiceDate, invoiceDueDate, paymentDate);
// .. und wieder speichern // .. und wieder speichern
stats.put(statData.toString(), statData); stats.put(statData.toString(), statData);
@ -300,10 +345,7 @@ public class DebitorStatistikController implements Serializable {
} catch (QueryException e) { } catch (QueryException e) {
logger.severe("Failed to get statistic: " + e.getMessage()); logger.severe("Failed to get statistic: " + e.getMessage());
} }
// Step 2: Sort the list based on the alphanumeric order of the keys // Step 2: Sort the list based on the alphanumeric order of the keys
// stats = new TreeMap<>(stats);
completeMissingMonths(); completeMissingMonths();
return stats; return stats;

View file

@ -48,9 +48,9 @@ public class DebitorStatistikData {
// und was nun? // und was nun?
count++; count++;
logger.info("...invoiceDate= " + invoiceDate); logger.fine("...invoiceDate= " + invoiceDate);
logger.info("...invoiceDueDate= " + invoiceDueDate); logger.fine("...invoiceDueDate= " + invoiceDueDate);
logger.info("...paymentDate= " + paymentDate); logger.fine("...paymentDate= " + paymentDate);
// Fälligkeit in Tagen // Fälligkeit in Tagen
long milliseconds1 = invoiceDate.getTime(); long milliseconds1 = invoiceDate.getTime();
@ -58,7 +58,7 @@ public class DebitorStatistikData {
// Berechnen Sie die Differenz in Millisekunden // Berechnen Sie die Differenz in Millisekunden
long diffMilliseconds = milliseconds2 - milliseconds1; long diffMilliseconds = milliseconds2 - milliseconds1;
long dueTime = diffMilliseconds / (24 * 60 * 60 * 1000); long dueTime = diffMilliseconds / (24 * 60 * 60 * 1000);
logger.info("...Fälligkeit in tagen= " + dueTime); logger.fine("...Fälligkeit in tagen= " + dueTime);
totalDueDays = totalDueDays + dueTime; totalDueDays = totalDueDays + dueTime;
// averageDueDays = (long) (totalDueDays / count); // averageDueDays = (long) (totalDueDays / count);
@ -73,7 +73,7 @@ public class DebitorStatistikData {
// Fix differenz // Fix differenz
// paymentTime = paymentTime - dueTime; // paymentTime = paymentTime - dueTime;
logger.info("...Zahlung erfolgte nach tagen= " + paymentTime); logger.fine("...Zahlung erfolgte nach tagen= " + paymentTime);
totalPaymentDays = totalPaymentDays + paymentTime; totalPaymentDays = totalPaymentDays + paymentTime;
// averagePaymentDays = (long) (totalPaymentDays / count); // averagePaymentDays = (long) (totalPaymentDays / count);
averagePaymentDays = Math.round((double) totalPaymentDays / count); averagePaymentDays = Math.round((double) totalPaymentDays / count);

View file

@ -97,7 +97,8 @@ public class OPListController implements Serializable {
} }
// Compute all open invoices if TASK_ERSTELLUNG.... // Compute all open invoices if TASK_ERSTELLUNG....
if (workflowController.getWorkitem().getTaskID() == TASK_ERSTELLUNG) { if (workflowController.getWorkitem().getTaskID() == 0
|| workflowController.getWorkitem().getTaskID() == TASK_ERSTELLUNG) {
// return empty list if dbtr is not set // return empty list if dbtr is not set
if (_dbtrNumber == null || _dbtrNumber.isEmpty()) { if (_dbtrNumber == null || _dbtrNumber.isEmpty()) {
@ -117,7 +118,7 @@ public class OPListController implements Serializable {
lastDbtrNumber = _dbtrNumber; lastDbtrNumber = _dbtrNumber;
lastCurrencyFilter = currencyFilter; lastCurrencyFilter = currencyFilter;
invoiceList = new ArrayList<ItemCollection>(); invoiceList = new ArrayList<ItemCollection>();
logger.info("....loading open Invoices for " + _dbtrNumber); logger.fine("....loading open Invoices for " + _dbtrNumber);
// Aus der dbtrNummer muss das führendde D entfernt werden // Aus der dbtrNummer muss das führendde D entfernt werden
// wir speichern dieses zwar im Zahlungseingangs Workflow, aber eine // wir speichern dieses zwar im Zahlungseingangs Workflow, aber eine

View file

@ -5,22 +5,16 @@
xmlns:a="http://xmlns.jcp.org/jsf/passthrough" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs" xmlns:a="http://xmlns.jcp.org/jsf/passthrough" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs"
template="/layout/template.xhtml"> template="/layout/template.xhtml">
<!-- <!--
Debitor Statistik page Debitor Statistik page
--> -->
<ui:define name="scripts"> <ui:define name="scripts">
<script type="text/javascript" <script type="text/javascript"
src="#{facesContext.externalContext.requestContextPath}/js/imixs-office.workitem.custom.js?build=#{app.application_build_timestamp}"></script> src="#{facesContext.externalContext.requestContextPath}/js/imixs-office.workitem.custom.js?build=#{app.application_build_timestamp}"></script>
<script type="text/javascript"> <script type="text/javascript">
/*<![CDATA[*/ /*<![CDATA[*/
$(document).ready( $(document).ready(
function () { function () {
// set navigation cookie // set navigation cookie
@ -33,10 +27,10 @@
$("[data-id='search_action']").click(); $("[data-id='search_action']").click();
} }
}); });
// init dbtr name - mangic hidden call....
var dbtrName = "#{debitorStatistikController.workitem.item['dbtr.name']}";
}); });
// This method refreshs the layout // This method refreshs the layout
function updatePanel(data) { function updatePanel(data) {
if (data.status === 'success') { if (data.status === 'success') {
@ -44,23 +38,16 @@
} }
}; };
/*]]>*/ /*]]>*/
</script> </script>
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
<f:view> <f:view>
<!-- load Mahnwesen --> <!-- load Mahnwesen -->
<ui:param name="mahnwesen" value="#{teamController.getProcessByName('Mahnwesen')}"></ui:param> <ui:param name="mahnwesen" value="#{teamController.getProcessByName('Mahnwesen')}"></ui:param>
<h:form> <h:form>
<ui:include src="/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml"> <ui:include src="/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml">
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" /> <ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
</ui:include> </ui:include>
@ -78,9 +65,6 @@
<h:panelGroup styleClass="imixs-board" layout="block" id="dbtr_statistic_board"> <h:panelGroup styleClass="imixs-board" layout="block" id="dbtr_statistic_board">
<div class="imixs-header"> <div class="imixs-header">
<h1> <h1>
<!-- notes --> <!-- notes -->
@ -113,19 +97,13 @@
<h:panelGroup layout="" styleClass="pull-right" id="portlet_worklist_nav"> <h:panelGroup layout="" styleClass="pull-right" id="portlet_worklist_nav">
</h:panelGroup> </h:panelGroup>
</h1> </h1>
</div> </div>
<div class="imixs-body" style="margin-left: 10px;"> <div class="imixs-body" style="margin-left: 10px;">
<!-- *** Chart Overview --> <!-- *** Chart Overview -->
<div class="monitoring-section"> <div class="monitoring-section">
<h2>Überblick <h3>#{debitorStatistikController.workitem.item['dbtr.name']}</h3>
</h2>
<div class=" imixs-form-section-2"> <div class=" imixs-form-section-2">
<dl> <dl>
<dt> <dt>
@ -136,43 +114,26 @@
pt:data-item="dbtr.number" pt:data-item="dbtr.number"
pt:data-resultlist="autocomplete-resultlist-cargosoft" pt:data-resultlist="autocomplete-resultlist-cargosoft"
pt:autocomplete="off" /> pt:autocomplete="off" />
<h:commandButton value="Aktualisieren">
<f:ajax render="dbtr_statistic_board" onevent="updatePanel"
execute="@form" />
</h:commandButton>
</dd> </dd>
<h:commandButton value="Statistik neu berechnen" action="#{debitorStatistikController.getBookmark()}" />
</dl> </dl>
test=#{debitorStatistikController.workitem.item['dbtr.number']}
</div> </div>
<h:panelGroup rendered="#{! empty debitorStatistikController.workitem.item['dbtr.number']}">
<h3>Statistik</h3>
<h3>Statistik</h3> <ui:include src="/pages/workitems/forms/alexander/section_debitor_statistic.xhtml">
<ui:include src="/pages/workitems/forms/alexander/section_debitor_statistic.xhtml"> <ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" /> </ui:include>
</h:panelGroup>
</ui:include>
<h3>Offene Posten</h3> <h3>Offene Posten</h3>
<ui:include src="/pages/workitems/forms/alexander/section_opliste_readonly.xhtml"> <ui:include src="/pages/workitems/forms/alexander/section_opliste_readonly.xhtml">
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" /> <ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
</ui:include> </ui:include>
</div> </div>
</div> </div>
<div class="imixs-footer"></div> <div class="imixs-footer"></div>
</h:panelGroup> </h:panelGroup>
</h:form> </h:form>
</f:view> </f:view>
</ui:define> </ui:define>