Skip to content

O2C

Purpose

O2C DSL contains major O2C App features promoted to core.

Methods

Binding name: p6.o2c


fromXml

Convert a transactionInfo in a GPathResult format to an easy to handle object TransactionInfo.

Syntax

TransactionInfoResponse p6.o2c.fromXml(GPathResult ti)
Example
final gpath = p6.pipeline.getXml 'xml'
def ti = p6.o2c.fromXml gpath

toXml

Convert a TransactionInfo object to a transactionInfo in a GPathResult.

Syntax

GPathResult p6.o2c.toXml(TransactionInfoResponse ti)
Example
final ti = p6.o2c.transactionInfo {...}
def gpath = p6.o2c.toXml ti

transactionInfo

Create a TransactionInfo.

Syntax

    GPathResult p6.o2c.transactionInfo {...}
Example
final ti = p6.o2c.transactionInfo {
    id  'Invoice_10AQ1312_95294f99-1a48-402d-97c2-8eb045deccc8'
    creationDate  '2024-11-20T15:16:59.328+0000'
    transactionType  'Invoice'
    transactionNumber  '10AQ1312'
    sourceSystem  'Supplier System'
    targetSystem  'Peppol'
    sender  ''
    finalRecipient  '115609021'
    transferProtocol  ''
    deliveredVia  'Peppol'
    sourceDocumentFormat  'XML'
    sourceDocumentURI  'p6file:///opt/p6core.data/resources/sshd/repository/customer_drop/Invoices/processed/Demo Data_Invoice_ENGLISH_200 lines.csv'
    sourceDocumentContentType  'text/plain'
    pivotDocumentFormat  'UBL'
    pivotDocumentURI  'p6file:///opt/p6core.data/resources/documents/Invoice/Invoice_10AQ1312_95294f99-1a48-402d-97c2-8eb045deccc8.xml'
    pivotDocumentContentType  'text/xml; charsetutf-8'
    targetDocumentFormat  'UBL'
    targetDocumentURI  'p6file:///opt/p6core.data/resources/documents/Invoice/Invoice_10AQ1312_95294f99-1a48-402d-97c2-8eb045deccc8.xml'
    targetDocumentContentType  'text/xml; charsetutf-8'
    attachments { attachment {
                    fileName  '10AQ1312.pdf'
                    uri  'p6file:///opt/p6core.data/resources/documents/10AQ1312.pdf'
                    contentType  'application/pdf'
                }}
    technicalStatusCode  'Incomplete'
    technicalStatusMessage  'Incomplete'
    technicalStatusComment  ''
    technicalStatusDate  '2024-11-20T15:17:12.983+0000'
    functionalStatusCode  ''
    functionalStatusMessage  ''
    functionalStatusComment  ''
    functionalStatusDate  ''
    standardStatusCode  'Incomplete'
    standardStatusMessage  'Document is incomplete, please review task'
    standardStatusComment  ''
    standardStatusDate  '2024-11-20T15:17:12.983+0000'
    flags(['aavisible':true, 'eunread':false])
    orgPaths(['//devops-na-test2'])
    keyValues {
        keyValue {
            key  'Seller Name'
            value  'Martinez-Barnes'
        }
        keyValue {
            key  'Buyer Name'
            value  'Firestone / Tires Plus'
        }
    }
}

status

Create a Status.

Syntax

TransactionInfoStatusResponse status{...}
Example
 final technicalStatus = p6.o2c.status {
    code 'Ready to check'
    message 'Transaction ready to be submitted to content validation engine'
    comment ''
}

save

Save, can update Audit trail and route a TransactionInfo.

Syntax

void p6.o2c.save(
    TransactionInfoResponse ti,
    TransactionInfoStatusResponse technicalStatus, 
    TransactionInfoStatusResponse functionalStatus, 
    boolean updateAuditTrail, 
    String endpoint
)

If a Status is set to null, neither the status in the transactionInfo nor the AuditTrail will be updated.

If boolean updateAuditTrail is set to true, records will be added to AuditTrail:

  • record(s) of provided status(es)
  • record of Standard Status

If endpoint is set to null, the transactionInfo won’t be rooted. If the value is empty the transactionInfo will be rooted to the DEFAULT_ENDPOINT = 'seda:p6router.TransactionRouter'. Otherwise, the transactionInfo will be rooted to the value provided.

Example

Creation of a TransactionInfo:

final ti = p6.o2c.transactionInfo {...}
final technicalStatus = p6.o2c.status {
    code 'Ready to check'
    message 'Transaction ready to be submitted to content validation engine'
    comment ''
}    
p6.o2c.save ti technicalStatus null true null

Update a TransactionInfo:

final gpath = p6.pipeline.getXml 'xml'
final ti = p6.o2c.fromXml gpath

def keyValue = p6.o2c.transaction.keyValue {
        key  'Currency'
        value  'EUR'
    }
ti.addKeyValues([keyValue])

final technicalStatus = p6.o2c.status {
    code 'Incomplete'
    message 'Document is incomplete, please review task'
    comment ''
}
p6.o2c.save ti technicalStatus null false 'seda:p6router.PeppolTransactionRouter'

getTransactionNextEndpoint

Get Camel Endpoint from Setting-next-step-per-trx-status O2C table.

Syntax

String getTransactionNextEndpoint(RoutingSettingDescription settingDescription)
Example
def setting = p6.o2c.settingDescription {
    supplierId 'supplier'
    network 'Peppol'
    tpId '1234'
    transactionType 'Invoice'
    statusType 'Technical'
    statusCode 'Ready to check'
}
def endpoint = p6.o2c.getTransactionNextEndpoint setting

validateContentCheck

Validate the UBL document with the Content Check. Return a list of TransactionInfo Issues.
A list of all methods availabled for the Method column of UBL-pivot_Content-check table. A list of all field label and error translation sorted by Translation Key is available to use in Complex Check.

A TransactionInfo issue is composed of: - level: the level of error (ex:Error,ERP). - type: the type of the check (ex:Specific Check). - message: the error message. - field: the field label, it can be from the translation files or by default the FieldLabel column of UBL-pivot_Content-check table. - contentCheckFieldType: the field type for the custom form in Workflow Task view (ex:Any,Files,Number,Select,Text). - value: the value of the field. - path: the path used to set the corrected value. - listOfValues: The list of correct value to fix the error (not mandatory can be empty).

Syntax

List<TransactionInfoIssueResponse> validateContentCheck(String ubl, String endpoint, String customer, String transactionType)
Example
def invoice = p6.pipeline.get 'UBL'
def issues = validateContentCheck invoice 'Peppol' 'Martinez-Barnes' 'Invoice'

In the script of the Complex check, after the check, use the dsl to generate issues and set it in the pipeline as usual.

final fieldLabel = p6.i18n.translate('Amalto_O2C#contentcheck.fieldlabel.Invoice_CurrencyCode')
final error = p6.i18n.format(
                p6.i18n.translate('Amalto_O2C#contentcheck.error.currency'),
                ['name', fieldLabel, 'value', 'AAA']
)
def issues = p6.o2c.transactionInfo.issues {
            issue {
                level  'Error'
                type  'Specific Check'
                message  error
                field  fieldLabel
                contentCheckFieldType  'Select'
                value  'AAA'
                path  '/Invoice/DocumentCurrencyCode'
                listOfValues(['EUR', 'USD', 'GBP'])
            }
}
p6.pipeline.put 'complex_check_error' issues.toString()

final fieldLabel = p6.i18n.translate('Amalto_O2C#contentcheck.fieldlabel.Invoice_CurrencyCode')
final error = p6.i18n.format(
                p6.i18n.translate('Amalto_O2C#contentcheck.error.currency'),
                ['name', fieldLabel, 'value', 'AAA']
)
def issues = p6.o2c.transactionInfo.issues {
            issue {
               level  'Error'
               type  'Specific Check'
               message  error
               field  fieldLabel
               contentCheckFieldType  'Select'
               value  'AAA'
               path  '/Invoice/DocumentCurrencyCode'
               options {
                  option {
                   value 'EUR'
                   label 'Euro'
                  },
                  option {
                   value 'GBP'
                   label 'Livre Sterling'
                  }
               }
            }
}
p6.pipeline.put 'complex_check_error' issues.toString()