From 268f24fafccebd74969d83c28c18822ca539220b Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Fri, 29 Jan 2021 14:39:19 +0100 Subject: [PATCH] udpate --- .../CargosoftExportAdapter.java | 64 +++++- .../com/alexanderlogistics/TestValidator.java | 19 ++ .../webapp/js/imixs-office.workitem.custom.js | 2 +- .../forms/alexander/sub_positionen.xhtml | 23 +- .../forms/alexander/sub_positionen_read.xhtml | 6 +- .../cargosoft/cargosoft-1.0.0.imixs-report | 2 +- reports/cargosoft/cargosoft-1.0.1.xsl | 163 ++++++++++++++ .../{ => deprecated}/cargosoft-1.0.0.xsl | 0 .../cargosoft/test/cargosoft-1.0.-muster.xsl | 202 ------------------ reports/cargosoft/test/positionen.out.xml | 19 +- reports/cargosoft/test/positionen.xml | 73 ++++++- workflow/rechnungseingang-de-1.0.2.bpmn | 1 + 12 files changed, 351 insertions(+), 223 deletions(-) create mode 100644 office-alexander-logistics-app/src/main/java/com/alexanderlogistics/TestValidator.java create mode 100644 reports/cargosoft/cargosoft-1.0.1.xsl rename reports/cargosoft/{ => deprecated}/cargosoft-1.0.0.xsl (100%) delete mode 100644 reports/cargosoft/test/cargosoft-1.0.-muster.xsl diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CargosoftExportAdapter.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CargosoftExportAdapter.java index 2920a63..46a25a6 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CargosoftExportAdapter.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CargosoftExportAdapter.java @@ -11,6 +11,7 @@ import javax.xml.bind.JAXBException; import javax.xml.transform.TransformerException; import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.imixs.archive.core.SnapshotService; import org.imixs.workflow.FileData; import org.imixs.workflow.ItemCollection; import org.imixs.workflow.SignalAdapter; @@ -27,14 +28,16 @@ import org.imixs.workflow.exceptions.PluginException; * report = report definition to transfere the workitem into the cargosoft xml * structure * - *

- * *

  * {@code
         cargosoft
        
    }
  * 
+ *

+ * Because we also export the attachment data to cargosoft, the adaper lookups + * the conente of the attachment in the snapshot of the origin workitem + * * * @version 1.0 * @author rsoika @@ -49,18 +52,19 @@ public class CargosoftExportAdapter implements SignalAdapter { private static Logger logger = Logger.getLogger(CargosoftExportAdapter.class.getName()); - @Inject @ConfigProperty(name = FTPConnector.ENV_EXPORT_FTP_HOST) Optional ftpServer; - @Inject WorkflowService workflowService; + @Inject + SnapshotService snapshotService; + @Inject ReportService reportService; - + @Inject FTPConnector ftpConnector; @@ -89,7 +93,9 @@ public class CargosoftExportAdapter implements SignalAdapter { } List sourceData = new ArrayList(); - sourceData.add(document); + // add the file data form the snapshot origin workitem + ItemCollection documentWithFileData = loadFileDataFromSnapshot(document); + sourceData.add(documentWithFileData); // start transformation FileData exportFile = reportService.transformDataSource(report, sourceData, document.getUniqueID() + ".xml"); @@ -101,7 +107,7 @@ public class CargosoftExportAdapter implements SignalAdapter { logger.info("ftp transfer..."); ftpConnector.put(exportFile); } - + // finally append the success event id document.event(EVENT_SUCCESS); @@ -114,4 +120,48 @@ public class CargosoftExportAdapter implements SignalAdapter { return document; } + /** + * This method lookups the origin snapshot data and add the content of the $file + * to the export document + * + * @param document + * @return + */ + @SuppressWarnings("unchecked") + private ItemCollection loadFileDataFromSnapshot(ItemCollection document) { + ItemCollection origin = null; + ItemCollection result = (ItemCollection) document.clone(); + + // find the origin document + List refs = document.getItemValue(WorkflowService.UNIQUEIDREF); + for (String ref : refs) { + origin = workflowService.getWorkItem(ref); + if ("Rechnungseingang".equals(origin.getWorkflowGroup())) { + break; + } + origin = null; + } + + // we should have found the origin... + if (origin != null) { + ItemCollection snapshot = snapshotService.findSnapshot(origin); + // we should have found a snapshot... + if (snapshot != null) { + List fileDataList = snapshot.getFileData(); + // transfer origin file content + result.removeItem("$file"); + for (FileData filedata : fileDataList) { + result.addFileData(filedata); + } + } else { + logger.warning("...did not found snapshot for origin workitem " + origin.getUniqueID()); + } + } else { + logger.warning("...did not found origin workitem " + document.getUniqueID()); + } + + return result; + + } + } \ No newline at end of file diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/TestValidator.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/TestValidator.java new file mode 100644 index 0000000..dfb72e9 --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/TestValidator.java @@ -0,0 +1,19 @@ +package com.alexanderlogistics; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; + +@FacesValidator("com.validators.MyValidator") +public class TestValidator implements Validator{ + + @Override + public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { + // TODO Auto-generated method stub + + } + + +} diff --git a/office-alexander-logistics-app/src/main/webapp/js/imixs-office.workitem.custom.js b/office-alexander-logistics-app/src/main/webapp/js/imixs-office.workitem.custom.js index 40c2cdf..5607f87 100644 --- a/office-alexander-logistics-app/src/main/webapp/js/imixs-office.workitem.custom.js +++ b/office-alexander-logistics-app/src/main/webapp/js/imixs-office.workitem.custom.js @@ -13,7 +13,7 @@ $(document).ready(function() { if (date.val()!="" && period.val()=="") { // no data - so build the period from 05.12.2020 part1=date.val().substring(6,10); - part2=date.val().substring(0,2); + part2=date.val().substring(3,5); newval=""+part1 +part2; $("input[data-item='invoice.period']").val(newval); } diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen.xhtml index a3d1bb9..bfce698 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen.xhtml @@ -17,7 +17,8 @@ # Positionsnummer * - Steuer + Steuer + Leistungsart Netto Brutto @@ -45,6 +46,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen_read.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen_read.xhtml index bf6ab9c..02b7c70 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen_read.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/sub_positionen_read.xhtml @@ -14,7 +14,8 @@ # Positionsnummer * - Steuer + Steuer + Leistungsart Netto Brutto @@ -31,6 +32,8 @@ + + @@ -49,6 +52,7 @@ + Summe: diff --git a/reports/cargosoft/cargosoft-1.0.0.imixs-report b/reports/cargosoft/cargosoft-1.0.0.imixs-report index cb2c205..2a445a6 100644 --- a/reports/cargosoft/cargosoft-1.0.0.imixs-report +++ b/reports/cargosoft/cargosoft-1.0.0.imixs-report @@ -1 +1 @@ -$uniqueid$workflowgroup$taskid$workflowsummaryinvoice.numberinvoice.dateinvoice.totalinvoice.currencycdtr.namecdtr.ibancdtr.bicdbtr.namedbtr.ibandbtr.bicpayment.typeUTF-8Cargosoft Export - only the XSL Template is needed here!cargosoft<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:strip-space elements="*" /> <xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" /> <xsl:template match="/"> <xsl:variable name="date" select="/data/document/item[@name='$modified']/value" /> <Invoices version="2020.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Message> <SenderID>Imixs-Office-Workflow</SenderID> <ReceiverID>Cargosoft</ReceiverID> <MessageID><xsl:value-of select="/data/document/item[@name='$uniqueid']/value" /></MessageID> <MessageDate> <DateTime><xsl:value-of select="$date" /></DateTime> </MessageDate> </Message> <xsl:apply-templates select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']" /> </Invoices> </xsl:template> <!-- This template builds invoice info --> <xsl:template match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']"> <xsl:variable name="date" select="item[@name='$modified']/value"/> <xsl:variable name="currency" select="item[@name='invoice.currency']/value"/> <Invoice> <InvoiceHeader> <Client> <Codes> <!-- Als Typ muss „cs“ übermittelt werden und im Code wird dann der Cargosoft Mandant erwartet. --> <Code Type="cs">001</Code> </Codes> </Client> <!-- Hier muss eine eindeutige Belegnummer für jeden einzelnen Beleg übermittelt werden. Es muss sich um eine Nummer handeln, die pro Beleg hochgezählt wird und darf sich nicht überschneiden mit dem CargoSoft Belegnummernkreis. Daher den Nummernkreis vorher mit CargoSoft absprechen. --> <InvoiceNumber><xsl:value-of select="item[@name='numsequencenumber']/value" /></InvoiceNumber> <InvoiceType> <Codes> <Code Type="cs">INVOICE</Code> </Codes> </InvoiceType> <InvoiceCurrency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </InvoiceCurrency> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="item[@name='invoice.total']/value" /></Value> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> </Amount> </NetAmount> <VATInformation> <VATAmount> <Amount isDomesticCurrency="true"> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value>0</Value> </Amount> </VATAmount> </VATInformation> </InvoiceAmount> <CollectionInvoice>false</CollectionInvoice> <xsl:if test="string-length(item[@name='invoice.period']/value) > 0"> <BookingPeriod><xsl:value-of select="item[@name='invoice.period']/value" /></BookingPeriod> </xsl:if> <Booked>false</Booked> <InvoiceDate><xsl:value-of select="item[@name='invoice.date']/value" /></InvoiceDate> <InvoiceAddress type="CN"> <Codes> <Code Type="cs"><xsl:value-of select="item[@name='cdtr.number']/value" /></Code> </Codes> </InvoiceAddress> <!-- <References> <Reference type="cs">201606-ABS1425131</Reference> </References> --> </InvoiceHeader> <InvoiceRows> <xsl:for-each select="item[@name='_childitems']/value"> <InvoiceRow> <Row><xsl:value-of select="./item[@name='numpos']/value" /></Row> <FileNumber><xsl:value-of select="./item[@name='name']/value" /></FileNumber> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="./item[@name='amount']/value" /></Value> </Amount> </NetAmount> <VATInformation> <VAT> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='tax']/value" /></Code> </Codes> </VAT> </VATInformation> </InvoiceAmount> <ActivityType> <Codes> <Code Type="cs">ACT</Code> </Codes> </ActivityType> </InvoiceRow> </xsl:for-each> </InvoiceRows> </Invoice> </xsl:template> </xsl:stylesheet>/office-alexander-logistics/reports/cargosoft/cargosoft-1.0.0.xsl \ No newline at end of file +$uniqueid$workflowgroup$taskid$workflowsummaryinvoice.numberinvoice.dateinvoice.totalinvoice.currencycdtr.namecdtr.ibancdtr.bicdbtr.namedbtr.ibandbtr.bicpayment.typeUTF-8Cargosoft Export - only the XSL Template is needed here!cargosoft<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:strip-space elements="*" /> <xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" /> <xsl:template match="/"> <xsl:variable name="date" select="/data/document/item[@name='$modified']/value" /> <Invoices version="2020.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Message> <SenderID>Imixs-Office-Workflow</SenderID> <ReceiverID>Cargosoft</ReceiverID> <MessageID><xsl:value-of select="/data/document/item[@name='$uniqueid']/value" /></MessageID> <MessageDate> <DateTime><xsl:value-of select="$date" /></DateTime> </MessageDate> </Message> <xsl:apply-templates select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']" /> </Invoices> </xsl:template> <!-- This template builds invoice info --> <xsl:template match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']"> <xsl:variable name="date" select="item[@name='$modified']/value"/> <xsl:variable name="currency" select="item[@name='invoice.currency']/value"/> <Invoice> <InvoiceHeader> <Client> <Codes> <!-- Als Typ muss „cs“ übermittelt werden und im Code wird dann der Cargosoft Mandant erwartet. --> <Code Type="cs">001</Code> </Codes> </Client> <!-- Hier muss eine eindeutige Belegnummer für jeden einzelnen Beleg übermittelt werden. Es muss sich um eine Nummer handeln, die pro Beleg hochgezählt wird und darf sich nicht überschneiden mit dem CargoSoft Belegnummernkreis. Daher den Nummernkreis vorher mit CargoSoft absprechen. --> <InvoiceNumber><xsl:value-of select="item[@name='numsequencenumber']/value" /></InvoiceNumber> <InvoiceType> <Codes> <Code Type="cs">INVOICE</Code> </Codes> </InvoiceType> <InvoiceCurrency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </InvoiceCurrency> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="item[@name='invoice.total']/value" /></Value> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> </Amount> </NetAmount> <VATInformation> <VATAmount> <Amount isDomesticCurrency="true"> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value>0</Value> </Amount> </VATAmount> </VATInformation> </InvoiceAmount> <CollectionInvoice>false</CollectionInvoice> <xsl:if test="string-length(item[@name='invoice.period']/value) > 0"> <BookingPeriod><xsl:value-of select="item[@name='invoice.period']/value" /></BookingPeriod> </xsl:if> <Booked>false</Booked> <InvoiceDate><xsl:value-of select="item[@name='invoice.date']/value" /></InvoiceDate> <InvoiceAddress type="CN"> <Codes> <Code Type="cs"><xsl:value-of select="item[@name='cdtr.number']/value" /></Code> </Codes> </InvoiceAddress> <References> <Reference type="cs"><xsl:value-of select="item[@name='invoice.number']/value" /></Reference> </References> <!-- Attachements --> <xsl:if test="item[@name='$file.count']/value > 0"> <Attachments> <xsl:for-each select="item[@name='$file']/value/item"> <Attachment> <xsl:attribute name="id"><xsl:value-of select="./value/item[@name='md5checksum']/value" /></xsl:attribute> <xsl:attribute name="version">1</xsl:attribute> <Filename><xsl:value-of select="./@name" /></Filename> <Description>Imixs-Office-Workflow</Description> <Content><xsl:value-of select="./value[2]" /></Content> </Attachment> </xsl:for-each> </Attachments> </xsl:if> </InvoiceHeader> <InvoiceRows> <xsl:for-each select="item[@name='_childitems']/value"> <InvoiceRow> <Row><xsl:value-of select="./item[@name='numpos']/value" /></Row> <FileNumber><xsl:value-of select="./item[@name='name']/value" /></FileNumber> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="./item[@name='amount']/value" /></Value> </Amount> </NetAmount> <VATInformation> <VAT> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='tax']/value" /></Code> </Codes> </VAT> </VATInformation> </InvoiceAmount> <ActivityType> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='category']/value" /></Code> </Codes> </ActivityType> </InvoiceRow> </xsl:for-each> </InvoiceRows> </Invoice> </xsl:template> </xsl:stylesheet>/office-alexander-logistics/reports/cargosoft/cargosoft-1.0.1.xsl \ No newline at end of file diff --git a/reports/cargosoft/cargosoft-1.0.1.xsl b/reports/cargosoft/cargosoft-1.0.1.xsl new file mode 100644 index 0000000..c506b38 --- /dev/null +++ b/reports/cargosoft/cargosoft-1.0.1.xsl @@ -0,0 +1,163 @@ + + + + + + + + + + + + + Imixs-Office-Workflow + Cargosoft + + + + + + + + + + + + + + + + + + + + + + + + 001 + + + + + + + INVOICE + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + false + + + + false + + + + + + + + + + + + + + + + + + + + 1 + + Imixs-Office-Workflow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reports/cargosoft/cargosoft-1.0.0.xsl b/reports/cargosoft/deprecated/cargosoft-1.0.0.xsl similarity index 100% rename from reports/cargosoft/cargosoft-1.0.0.xsl rename to reports/cargosoft/deprecated/cargosoft-1.0.0.xsl diff --git a/reports/cargosoft/test/cargosoft-1.0.-muster.xsl b/reports/cargosoft/test/cargosoft-1.0.-muster.xsl deleted file mode 100644 index 9eff569..0000000 --- a/reports/cargosoft/test/cargosoft-1.0.-muster.xsl +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - Imixs-Office-Workflow - Cargosoft - 1 - - - - - - - - - - - - 001 - - - - - - - INVOICE - - - - - - - - - - - - - EUR - - - 500 - - - - - - - - EUR - - - 0 - - - - - false - false - 2016-07-06T00:00:00.0Z - - - 9999999 - - - - 201606-ABS1425131 - - - - - 1 - 999-201606-99999 - - - - - - EUR - - - 300.00 - - - - - - 45 - - - - - - - ACT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/reports/cargosoft/test/positionen.out.xml b/reports/cargosoft/test/positionen.out.xml index b8b15a6..9741db9 100644 --- a/reports/cargosoft/test/positionen.out.xml +++ b/reports/cargosoft/test/positionen.out.xml @@ -60,6 +60,21 @@ 9876545 + + RE2020110040 + + + + vwicn285.png + Imixs-Office-Workflow + 067C441F2E760E359803560975AB26F5067C441F2E760E359803560975AB26F5== + + + vwicn259.png + Imixs-Office-Workflow + 48350AFE4ABBFAB516F1CF4DD9CB64CE48350AFE4ABBFAB516F1CF4DD9CB64CE== + + @@ -86,7 +101,7 @@ - ACT + FRACHT @@ -114,7 +129,7 @@ - ACT + ZOLL diff --git a/reports/cargosoft/test/positionen.xml b/reports/cargosoft/test/positionen.xml index 688f34d..6224895 100644 --- a/reports/cargosoft/test/positionen.xml +++ b/reports/cargosoft/test/positionen.xml @@ -22,13 +22,64 @@ 2020-11-30T15:27:14.411|cargosoft-export-1.0|1000.300|1800| - + + + image/png + 067C441F2E760E359803560975AB26F5067C441F2E760E359803560975AB26F5== + + + rsoika + + + 1646 + + + 2021-01-29T13:36:31.923+01:00 + + + vwicn285.png + + + 067C441F2E760E359803560975AB26F5 + + + rsoika + + + + + image/png + 48350AFE4ABBFAB516F1CF4DD9CB64CE48350AFE4ABBFAB516F1CF4DD9CB64CE== + + + rsoika + + + 1275 + + + 2021-01-29T13:36:31.923+01:00 + + + vwicn259.png + + + 48350AFE4ABBFAB516F1CF4DD9CB64CE + + + rsoika + + + + + - 0 + 2 - + vwicn285.png + vwicn259.png true @@ -105,6 +156,9 @@ 0EU + + FRACHT + 1 @@ -119,6 +173,9 @@ 0EU + + ZOLL + 2 @@ -127,9 +184,9 @@ - - - + + + missign cargosoft configuration in model event - please check model configuration @@ -164,10 +221,10 @@ 1.00345 - + 9876545 - + rsoika diff --git a/workflow/rechnungseingang-de-1.0.2.bpmn b/workflow/rechnungseingang-de-1.0.2.bpmn index 1aa090c..04fba4e 100644 --- a/workflow/rechnungseingang-de-1.0.2.bpmn +++ b/workflow/rechnungseingang-de-1.0.2.bpmn @@ -436,6 +436,7 @@ var b= workitem.get("order.total")[0]; SequenceFlow_8 SequenceFlow_51 +