update analyse zoll/eust
This commit is contained in:
parent
b3d0efad64
commit
f1b7c04603
2 changed files with 116 additions and 47 deletions
|
|
@ -62,7 +62,7 @@ public class AGLAnalyticController implements Serializable {
|
|||
}
|
||||
|
||||
if ("analytic.steuer.trend".equals(event.getKey())) {
|
||||
event.setValue(computeSteuerbescheideByWeek());
|
||||
event.setValue(accumulateSteuerbescheideByWeek());
|
||||
event.setLabel("Zoll & EUST");
|
||||
event.setDescription("Fälligkeiten nach KW");
|
||||
}
|
||||
|
|
@ -81,13 +81,39 @@ public class AGLAnalyticController implements Serializable {
|
|||
double result = 0;
|
||||
|
||||
for (ItemCollection steuerItemCol : list) {
|
||||
List<ItemCollection> positionsTabelle = InvoiceUtil.explodeChildList(steuerItemCol);
|
||||
for (ItemCollection pos : positionsTabelle) {
|
||||
if ("EUST".equalsIgnoreCase(pos.getItemValueString("activity.type"))) {
|
||||
result = result + pos.getItemValueDouble("amount");
|
||||
result = result + getZollBySteuerBeleg(steuerItemCol, "EUST");
|
||||
// List<ItemCollection> positionsTabelle =
|
||||
// InvoiceUtil.explodeChildList(steuerItemCol);
|
||||
// for (ItemCollection pos : positionsTabelle) {
|
||||
// if ("EUST".equalsIgnoreCase(pos.getItemValueString("activity.type"))) {
|
||||
// result = result + pos.getItemValueDouble("amount");
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
return InvoiceUtil.round(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet die Summe aller offenen Zoll Beträge
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private double computeSteuerbescheideZoll() {
|
||||
logger.info("compute Zoll...");
|
||||
List<ItemCollection> list = getSteuerbescheide();
|
||||
double result = 0;
|
||||
|
||||
for (ItemCollection steuerItemCol : list) {
|
||||
result = result + getZollBySteuerBeleg(steuerItemCol, "ZOLL");
|
||||
// List<ItemCollection> positionsTabelle =
|
||||
// InvoiceUtil.explodeChildList(steuerItemCol);
|
||||
// for (ItemCollection pos : positionsTabelle) {
|
||||
// if ("ZOLL".equalsIgnoreCase(pos.getItemValueString("activity.type"))) {
|
||||
// result = result + pos.getItemValueDouble("amount");
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
return InvoiceUtil.round(result);
|
||||
}
|
||||
|
|
@ -111,25 +137,20 @@ public class AGLAnalyticController implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Berechnet die Summe aller offenen Zoll Beträge
|
||||
* Berechnet die summ zoll/eust für einen Beleg
|
||||
*
|
||||
* @param steuerItemCol
|
||||
* @return
|
||||
*/
|
||||
private double computeSteuerbescheideZoll() {
|
||||
logger.info("compute Zoll...");
|
||||
List<ItemCollection> list = getSteuerbescheide();
|
||||
private double getZollBySteuerBeleg(ItemCollection steuerItemCol, String type) {
|
||||
double result = 0;
|
||||
|
||||
for (ItemCollection steuerItemCol : list) {
|
||||
List<ItemCollection> positionsTabelle = InvoiceUtil.explodeChildList(steuerItemCol);
|
||||
for (ItemCollection pos : positionsTabelle) {
|
||||
if ("ZOLL".equalsIgnoreCase(pos.getItemValueString("activity.type"))) {
|
||||
if (type.equalsIgnoreCase(pos.getItemValueString("activity.type"))) {
|
||||
result = result + pos.getItemValueDouble("amount");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return InvoiceUtil.round(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<ItemCollection> getSteuerbescheide() {
|
||||
|
|
@ -168,16 +189,11 @@ public class AGLAnalyticController implements Serializable {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
private String computeSteuerbescheideByWeek() {
|
||||
logger.info("compute steuer by kw...");
|
||||
private String accumulateSteuerbescheideByWeek() {
|
||||
logger.info("accumulate steuer by week...");
|
||||
|
||||
List<ItemCollection> list = getSteuerbescheide();
|
||||
|
||||
Map<Integer, Double> saldoByWeek = new HashMap<>();
|
||||
// SimpleDateFormat weekFormat = new SimpleDateFormat("w"); // 'w' gives the
|
||||
// week number
|
||||
// SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); // 'yyyy' for the
|
||||
// year
|
||||
Map<Integer, SteuerData> saldoByWeek = new HashMap<>();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int earliestWeek = Integer.MAX_VALUE;
|
||||
int latestWeek = Integer.MIN_VALUE;
|
||||
|
|
@ -194,7 +210,12 @@ public class AGLAnalyticController implements Serializable {
|
|||
int yearWeek = year * 100 + weekNumber; // Unique key for each year + week combination
|
||||
|
||||
// Accumulate the saldo per week
|
||||
saldoByWeek.put(yearWeek, saldoByWeek.getOrDefault(yearWeek, 0.0) + saldo);
|
||||
SteuerData steuerDataByWeek = saldoByWeek.getOrDefault(yearWeek, new SteuerData());
|
||||
double eust = getZollBySteuerBeleg(steuerItemCol, "EUST");
|
||||
double zoll = getZollBySteuerBeleg(steuerItemCol, "ZOLL");
|
||||
steuerDataByWeek.add(eust, zoll, saldo);
|
||||
|
||||
saldoByWeek.put(yearWeek, steuerDataByWeek);
|
||||
|
||||
// Track the earliest and latest weeks
|
||||
earliestWeek = Math.min(earliestWeek, yearWeek);
|
||||
|
|
@ -203,7 +224,9 @@ public class AGLAnalyticController implements Serializable {
|
|||
|
||||
// Step 2: Prepare the JSON structure and ensure we have all weeks from earliest
|
||||
// to latest
|
||||
JsonArrayBuilder dataBuilder = Json.createArrayBuilder();
|
||||
JsonArrayBuilder dataBuilderSaldo = Json.createArrayBuilder();
|
||||
JsonArrayBuilder dataBuilderEust = Json.createArrayBuilder();
|
||||
JsonArrayBuilder dataBuilderZoll = Json.createArrayBuilder();
|
||||
JsonArrayBuilder labelsBuilder = Json.createArrayBuilder();
|
||||
|
||||
Calendar startCal = Calendar.getInstance();
|
||||
|
|
@ -220,7 +243,10 @@ public class AGLAnalyticController implements Serializable {
|
|||
int yearWeek = year * 100 + weekNumber;
|
||||
|
||||
// Add the saldo for the week or 0.0 if no data
|
||||
dataBuilder.add(saldoByWeek.getOrDefault(yearWeek, 0.0));
|
||||
SteuerData steuerData = saldoByWeek.getOrDefault(yearWeek, new SteuerData());
|
||||
dataBuilderSaldo.add(steuerData.saldo);
|
||||
dataBuilderEust.add(steuerData.eust);
|
||||
dataBuilderZoll.add(steuerData.zoll);
|
||||
labelsBuilder.add(weekNumber + "/" + year); // Label as 'week/year'
|
||||
|
||||
// Move to the next week
|
||||
|
|
@ -232,14 +258,57 @@ public class AGLAnalyticController implements Serializable {
|
|||
.add("type", "bar")
|
||||
.add("data", Json.createObjectBuilder()
|
||||
.add("datasets", Json.createArrayBuilder()
|
||||
.add(Json.createObjectBuilder()
|
||||
.add("data", dataBuilder)))
|
||||
|
||||
.add(Json.createObjectBuilder() // First dataset for 'tax'
|
||||
.add("label", "Zoll")
|
||||
.add("backgroundColor", "#96f")
|
||||
.add("borderWidth", 1)
|
||||
.add("data", dataBuilderZoll))
|
||||
.add(Json.createObjectBuilder() // Second dataset for 'eust'
|
||||
.add("label", "EUSt")
|
||||
.add("backgroundColor", "#36a2eb")
|
||||
.add("borderWidth", 1)
|
||||
.add("data", dataBuilderEust))
|
||||
.add(Json.createObjectBuilder() // Third dataset for 'Saldo'
|
||||
.add("label", "Saldo")
|
||||
.add("backgroundColor", "#ff6384")
|
||||
.add("borderWidth", 1)
|
||||
.add("data", dataBuilderSaldo)))
|
||||
|
||||
.add("labels", labelsBuilder));
|
||||
|
||||
// Step 4: Return the JSON structure as a string
|
||||
JsonObject chartCfg = jsonBuilder.build();
|
||||
return chartCfg.toString(); // JSON as string
|
||||
|
||||
return chartCfg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to hold zoll and eust totls in an object. Needed to build
|
||||
* totals per week.
|
||||
*/
|
||||
class SteuerData {
|
||||
double total = 0.0;
|
||||
double zoll = 0.0;
|
||||
double eust = 0.0;
|
||||
double saldo = 0.0;
|
||||
|
||||
public SteuerData() {
|
||||
// default constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new zoll and eust values and updates the total
|
||||
*
|
||||
* @param eustNew eust value to be added
|
||||
* @param zollNew zoll value to be added
|
||||
*/
|
||||
public void add(double eustNew, double zollNew, double saldoNew) {
|
||||
eust = eust + eustNew;
|
||||
zoll = zoll + zollNew;
|
||||
saldo = saldo + saldoNew;
|
||||
// update total
|
||||
total = eust + zoll;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
<!-- origin at X=0.0 Y=0.0 --><bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:imixs="http://www.imixs.org/bpmn2" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:tl="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.4.RC1-v20220528-0836-B1" id="Definitions_1" name="Definitions 1" targetNamespace="http://www.imixs.org/bpmn2">
|
||||
<bpmn2:extensionElements>
|
||||
<imixs:item name="txtworkflowmodelversion" type="xs:string">
|
||||
<imixs:value><![CDATA[mahnlauf-de-1.0]]></imixs:value>
|
||||
<imixs:value><![CDATA[analyse-zolleust-de-1.0]]></imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="txtfieldmapping" type="xs:string">
|
||||
<imixs:value><![CDATA[Prozess-Verantwortliche| namprocessmanager]]></imixs:value>
|
||||
<imixs:value><![CDATA[Prozess-Assistenz | namprocessassist]]></imixs:value>
|
||||
<imixs:value><![CDATA[Buchhaltung | namprocessteam]]></imixs:value>
|
||||
<imixs:value><![CDATA[Prozess-Verantwortliche|namprocessmanager]]></imixs:value>
|
||||
<imixs:value><![CDATA[Prozess-Assistenz|namprocessassist]]></imixs:value>
|
||||
<imixs:value><![CDATA[Buchhaltung|namprocessteam]]></imixs:value>
|
||||
<imixs:value><![CDATA[Debitor-Mail|dbtr.mail]]></imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="txttimefieldmapping" type="xs:string">
|
||||
<imixs:value><![CDATA[Wiedervorlage | datDate]]></imixs:value>
|
||||
<imixs:value><![CDATA[Start | datFrom]]></imixs:value>
|
||||
<imixs:value><![CDATA[Ende | datTo]]></imixs:value>
|
||||
<imixs:value><![CDATA[Wiedervorlage|datDate]]></imixs:value>
|
||||
<imixs:value><![CDATA[Start|datFrom]]></imixs:value>
|
||||
<imixs:value><![CDATA[Ende|datTo]]></imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="txtplugins" type="xs:string">
|
||||
<imixs:value><![CDATA[org.imixs.workflow.engine.plugins.ResultPlugin]]></imixs:value>
|
||||
|
|
@ -74,7 +74,7 @@ th { font-weight: bold;}
|
|||
</html>]]></bpmn2:documentation>
|
||||
</bpmn2:message>
|
||||
<bpmn2:collaboration id="Collaboration_1" name="Mahnlauf">
|
||||
<bpmn2:participant id="Participant_1" name="Analyse" processRef="Process_1">
|
||||
<bpmn2:participant id="Participant_1" name="Analyse Zoll/EUSt" processRef="Process_1">
|
||||
<bpmn2:documentation id="documentation_sqQYFQ"/>
|
||||
</bpmn2:participant>
|
||||
<bpmn2:participant id="Participant_2" name="SEPA-Export Pool" processRef="eingangsrechnung-de"/>
|
||||
|
|
@ -82,7 +82,7 @@ th { font-weight: bold;}
|
|||
<bpmn2:process id="eingangsrechnung-de" isExecutable="false" name="Default Process">
|
||||
<bpmn2:documentation id="documentation_sxNNHw"/>
|
||||
</bpmn2:process>
|
||||
<bpmn2:process definitionalCollaborationRef="Collaboration_1" id="Process_1" isExecutable="false" name="Analyse">
|
||||
<bpmn2:process definitionalCollaborationRef="Collaboration_1" id="Process_1" isExecutable="false" name="Analyse Zoll/EUSt">
|
||||
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
|
||||
<bpmn2:lane id="Lane_1" name="Buchhaltung">
|
||||
<bpmn2:flowNodeRef>StartEvent_1</bpmn2:flowNodeRef>
|
||||
|
|
@ -250,7 +250,7 @@ th { font-weight: bold;}
|
|||
</imixs-form-section>
|
||||
|
||||
<imixs-form-section columns="2">
|
||||
<item name="analytic.steuer.trend" type="custom" path="alexander/analyze_chart" label="Forderungen:" />
|
||||
<item name="analytic.steuer.trend" type="custom" path="alexander/analyze_chart" label="Zoll/Eust in Kalenderwoche:" />
|
||||
</imixs-form-section>
|
||||
|
||||
</imixs-form>]]></bpmn2:documentation>
|
||||
|
|
@ -329,10 +329,10 @@ th { font-weight: bold;}
|
|||
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Default Process Diagram">
|
||||
<bpmndi:BPMNPlane bpmnElement="Collaboration_1" id="BPMNPlane_1">
|
||||
<bpmndi:BPMNShape bpmnElement="Participant_1" id="BPMNShape_Participant_1" isHorizontal="true">
|
||||
<dc:Bounds height="450.0" width="1180.0" x="100.0" y="150.0"/>
|
||||
<dc:Bounds height="330.0" width="960.0" x="100.0" y="150.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape bpmnElement="Lane_1" id="BPMNShape_Lane_1" isHorizontal="true">
|
||||
<dc:Bounds height="450.0" width="1150.0" x="130.0" y="150.0"/>
|
||||
<dc:Bounds height="330.0" width="930.0" x="130.0" y="150.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape bpmnElement="StartEvent_1" id="BPMNShape_1">
|
||||
<dc:Bounds height="36.0" width="36.0" x="197.0" y="297.0"/>
|
||||
Loading…
Reference in a new issue