debitor statistik
This commit is contained in:
parent
6aebef26a6
commit
eb0154d0d1
5 changed files with 81 additions and 77 deletions
|
|
@ -194,7 +194,7 @@ public class CargosoftController implements Serializable {
|
|||
|
||||
try {
|
||||
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) {
|
||||
for (ItemCollection dbtr : result) {
|
||||
// Aenderugn 22. Jun wir geben das K/D direkt witer
|
||||
|
|
|
|||
|
|
@ -18,12 +18,15 @@ import java.util.TreeMap;
|
|||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.ConversationScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.engine.DocumentService;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
import org.imixs.workflow.faces.data.WorkflowController;
|
||||
import org.imixs.workflow.office.views.SearchController;
|
||||
|
|
@ -54,12 +57,32 @@ public class DebitorStatistikController implements Serializable {
|
|||
@Inject
|
||||
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() {
|
||||
return workflowController.getWorkitem();
|
||||
}
|
||||
|
|
@ -68,6 +91,15 @@ public class DebitorStatistikController implements Serializable {
|
|||
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
|
||||
*/
|
||||
|
|
@ -78,6 +110,9 @@ public class DebitorStatistikController implements Serializable {
|
|||
}
|
||||
public int getRechnungen() {
|
||||
int result = 0;
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
result = documentService
|
||||
.count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr()
|
||||
|
|
@ -99,7 +134,9 @@ public class DebitorStatistikController implements Serializable {
|
|||
}
|
||||
public int getRechnungenBezahlt() {
|
||||
int result = 0;
|
||||
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
result = documentService
|
||||
.count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr()
|
||||
|
|
@ -120,7 +157,9 @@ public class DebitorStatistikController implements Serializable {
|
|||
}
|
||||
public int getRechnungenOffen() {
|
||||
int result = 0;
|
||||
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
result = documentService
|
||||
.count("(type:workitem) AND dbtr.number:" + getDbtNr()
|
||||
|
|
@ -141,6 +180,9 @@ public class DebitorStatistikController implements Serializable {
|
|||
}
|
||||
public int getRechnungenFaellig() {
|
||||
int result = 0;
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
result = documentService
|
||||
.count("(type:workitem) AND dbtr.number:" + getDbtNr()
|
||||
|
|
@ -161,6 +203,9 @@ public class DebitorStatistikController implements Serializable {
|
|||
}
|
||||
public int getRechnungenGemahnt() {
|
||||
int result = 0;
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
result = documentService
|
||||
.count("(type:workitem ) AND dbtr.number:" + getDbtNr()
|
||||
|
|
@ -181,7 +226,9 @@ public class DebitorStatistikController implements Serializable {
|
|||
}
|
||||
public int getRechnungenInkasso() {
|
||||
int result = 0;
|
||||
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
result = documentService
|
||||
.count("(type:workitem OR type:workitemarchive) AND dbtr.number:" + getDbtNr()
|
||||
|
|
@ -197,7 +244,7 @@ public class DebitorStatistikController implements Serializable {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
private String getDbtNr() {
|
||||
public String getDbtNr() {
|
||||
String dbtNr = getWorkitem().getItemValueString("dbtr.number");
|
||||
if (dbtNr.startsWith("D") || dbtNr.startsWith("K")) {
|
||||
dbtNr = dbtNr.substring(1);
|
||||
|
|
@ -246,16 +293,18 @@ public class DebitorStatistikController implements Serializable {
|
|||
|
||||
// recompute
|
||||
stats = new TreeMap<String, DebitorStatistikData>();
|
||||
|
||||
if (getDbtNr().isEmpty()) {
|
||||
return stats;
|
||||
}
|
||||
// invoice.date:[20210101 TO 20210201]
|
||||
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])";
|
||||
|
||||
// query = query + " AND (invoice.date:[" + df.format(from) + " TO " +
|
||||
// df.format(to) + "])";
|
||||
logger.info("query = " + query);
|
||||
logger.fine("query = " + query);
|
||||
try {
|
||||
List<ItemCollection> invoices = documentService
|
||||
.findStubs(query, 9999, 0, "$created", false);
|
||||
|
|
@ -263,14 +312,12 @@ public class DebitorStatistikController implements Serializable {
|
|||
for (ItemCollection invoice : invoices) {
|
||||
try {
|
||||
|
||||
logger.warning("Rechnung: " + invoice.getUniqueID());
|
||||
logger.fine("Rechnung: " + invoice.getUniqueID());
|
||||
Date invoiceDate = invoice.getItemValueDate("invoice.date");
|
||||
Date invoiceDueDate = invoice.getItemValueDate("invoice.duedate");
|
||||
Date paymentDate = findPaymentDateByWorkitem(invoice);
|
||||
if (paymentDate == null) {
|
||||
// fall back method
|
||||
logger.warning("Es wurde kein Zahlungseingang gefunden");
|
||||
// paymentDate = findPaymentDateByLog(invoice);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -281,10 +328,8 @@ public class DebitorStatistikController implements Serializable {
|
|||
// create a new one
|
||||
statData = new DebitorStatistikData(invoiceDate);
|
||||
}
|
||||
|
||||
// jetzt irgendwas ausrechnen
|
||||
statData.compute(invoiceDate, invoiceDueDate, paymentDate);
|
||||
|
||||
// .. und wieder speichern
|
||||
stats.put(statData.toString(), statData);
|
||||
|
||||
|
|
@ -300,10 +345,7 @@ public class DebitorStatistikController implements Serializable {
|
|||
} catch (QueryException e) {
|
||||
logger.severe("Failed to get statistic: " + e.getMessage());
|
||||
}
|
||||
|
||||
// Step 2: Sort the list based on the alphanumeric order of the keys
|
||||
|
||||
// stats = new TreeMap<>(stats);
|
||||
completeMissingMonths();
|
||||
return stats;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ public class DebitorStatistikData {
|
|||
// und was nun?
|
||||
count++;
|
||||
|
||||
logger.info("...invoiceDate= " + invoiceDate);
|
||||
logger.info("...invoiceDueDate= " + invoiceDueDate);
|
||||
logger.info("...paymentDate= " + paymentDate);
|
||||
logger.fine("...invoiceDate= " + invoiceDate);
|
||||
logger.fine("...invoiceDueDate= " + invoiceDueDate);
|
||||
logger.fine("...paymentDate= " + paymentDate);
|
||||
|
||||
// Fälligkeit in Tagen
|
||||
long milliseconds1 = invoiceDate.getTime();
|
||||
|
|
@ -58,7 +58,7 @@ public class DebitorStatistikData {
|
|||
// Berechnen Sie die Differenz in Millisekunden
|
||||
long diffMilliseconds = milliseconds2 - milliseconds1;
|
||||
long dueTime = diffMilliseconds / (24 * 60 * 60 * 1000);
|
||||
logger.info("...Fälligkeit in tagen= " + dueTime);
|
||||
logger.fine("...Fälligkeit in tagen= " + dueTime);
|
||||
|
||||
totalDueDays = totalDueDays + dueTime;
|
||||
// averageDueDays = (long) (totalDueDays / count);
|
||||
|
|
@ -73,7 +73,7 @@ public class DebitorStatistikData {
|
|||
|
||||
// Fix differenz
|
||||
// paymentTime = paymentTime - dueTime;
|
||||
logger.info("...Zahlung erfolgte nach tagen= " + paymentTime);
|
||||
logger.fine("...Zahlung erfolgte nach tagen= " + paymentTime);
|
||||
totalPaymentDays = totalPaymentDays + paymentTime;
|
||||
// averagePaymentDays = (long) (totalPaymentDays / count);
|
||||
averagePaymentDays = Math.round((double) totalPaymentDays / count);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ public class OPListController implements Serializable {
|
|||
}
|
||||
|
||||
// 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
|
||||
if (_dbtrNumber == null || _dbtrNumber.isEmpty()) {
|
||||
|
|
@ -117,7 +118,7 @@ public class OPListController implements Serializable {
|
|||
lastDbtrNumber = _dbtrNumber;
|
||||
lastCurrencyFilter = currencyFilter;
|
||||
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
|
||||
// wir speichern dieses zwar im Zahlungseingangs Workflow, aber eine
|
||||
|
|
|
|||
|
|
@ -5,22 +5,16 @@
|
|||
xmlns:a="http://xmlns.jcp.org/jsf/passthrough" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs"
|
||||
template="/layout/template.xhtml">
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
Debitor Statistik page
|
||||
|
||||
Debitor Statistik page
|
||||
-->
|
||||
|
||||
<ui:define name="scripts">
|
||||
|
||||
<script type="text/javascript"
|
||||
src="#{facesContext.externalContext.requestContextPath}/js/imixs-office.workitem.custom.js?build=#{app.application_build_timestamp}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
/*<![CDATA[*/
|
||||
|
||||
|
||||
$(document).ready(
|
||||
function () {
|
||||
// set navigation cookie
|
||||
|
|
@ -33,10 +27,10 @@
|
|||
$("[data-id='search_action']").click();
|
||||
}
|
||||
});
|
||||
|
||||
// init dbtr name - mangic hidden call....
|
||||
var dbtrName = "#{debitorStatistikController.workitem.item['dbtr.name']}";
|
||||
});
|
||||
|
||||
|
||||
// This method refreshs the layout
|
||||
function updatePanel(data) {
|
||||
if (data.status === 'success') {
|
||||
|
|
@ -44,23 +38,16 @@
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/*]]>*/
|
||||
</script>
|
||||
</ui:define>
|
||||
|
||||
|
||||
<ui:define name="content">
|
||||
|
||||
|
||||
<f:view>
|
||||
<!-- load Mahnwesen -->
|
||||
<ui:param name="mahnwesen" value="#{teamController.getProcessByName('Mahnwesen')}"></ui:param>
|
||||
|
||||
|
||||
<h:form>
|
||||
|
||||
|
||||
<ui:include src="/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml">
|
||||
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
|
||||
</ui:include>
|
||||
|
|
@ -78,9 +65,6 @@
|
|||
|
||||
<h:panelGroup styleClass="imixs-board" layout="block" id="dbtr_statistic_board">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="imixs-header">
|
||||
<h1>
|
||||
<!-- notes -->
|
||||
|
|
@ -113,19 +97,13 @@
|
|||
<h:panelGroup layout="" styleClass="pull-right" id="portlet_worklist_nav">
|
||||
</h:panelGroup>
|
||||
</h1>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="imixs-body" style="margin-left: 10px;">
|
||||
|
||||
|
||||
<!-- *** Chart Overview -->
|
||||
|
||||
<div class="monitoring-section">
|
||||
<h2>Überblick
|
||||
|
||||
</h2>
|
||||
<h3>#{debitorStatistikController.workitem.item['dbtr.name']}</h3>
|
||||
<div class=" imixs-form-section-2">
|
||||
<dl>
|
||||
<dt>
|
||||
|
|
@ -136,43 +114,26 @@
|
|||
pt:data-item="dbtr.number"
|
||||
pt:data-resultlist="autocomplete-resultlist-cargosoft"
|
||||
pt:autocomplete="off" />
|
||||
<h:commandButton value="Aktualisieren">
|
||||
<f:ajax render="dbtr_statistic_board" onevent="updatePanel"
|
||||
execute="@form" />
|
||||
</h:commandButton>
|
||||
|
||||
</dd>
|
||||
<h:commandButton value="Statistik neu berechnen" action="#{debitorStatistikController.getBookmark()}" />
|
||||
</dl>
|
||||
test=#{debitorStatistikController.workitem.item['dbtr.number']}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h3>Statistik</h3>
|
||||
<ui:include src="/pages/workitems/forms/alexander/section_debitor_statistic.xhtml">
|
||||
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
|
||||
|
||||
</ui:include>
|
||||
|
||||
<h:panelGroup rendered="#{! empty debitorStatistikController.workitem.item['dbtr.number']}">
|
||||
<h3>Statistik</h3>
|
||||
<ui:include src="/pages/workitems/forms/alexander/section_debitor_statistic.xhtml">
|
||||
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
|
||||
</ui:include>
|
||||
</h:panelGroup>
|
||||
<h3>Offene Posten</h3>
|
||||
<ui:include src="/pages/workitems/forms/alexander/section_opliste_readonly.xhtml">
|
||||
<ui:param name="workitem" value="#{debitorStatistikController.workitem}" />
|
||||
|
||||
</ui:include>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="imixs-footer"></div>
|
||||
|
||||
</h:panelGroup>
|
||||
|
||||
|
||||
|
||||
</h:form>
|
||||
</f:view>
|
||||
</ui:define>
|
||||
|
|
|
|||
Loading…
Reference in a new issue