Skip to main content

Invoice Calculation

This workflow is included in the Financial Accounts and Invoicing module.

Description​

This workflow has no description.

Properties​

This workflow has the following properties.

PropertyValue
NameInvoice Calculation
Codeworkflows_invoiceCalculation
TypeWorkflow
ContextModule
EnabledYes

Trigger​

The system triggers this workflow when items of the design below are created or edited. Where attributes are listed, an edit to anything else is ignored.

PropertyValue
Workflow typeEvent workflow
Applies toAccount Invoices
EventsCreate, Edit
CollectionsLive
Attributes listened forattributes_accountTransactionsAmount  (Amount)
attributes_accountInvoicesStatus  (Status)
attributes_accountInvoicesInvoiceLines  (Invoice Lines)

Actions​

This workflow runs 9 actions, in the order shown in this simplified diagram. Every action's full settings are in the configuration below.

Configuration​

The full configuration of this workflow, including every action's parameters.

Show configuration (336 lines)
{
"trigger": {
"dodiCode": "designs_accountInvoices",
"collections": [
"Live"
],
"events": [
"Create",
"Edit"
],
"attributesListeningFor": [
"attributes_accountTransactionsAmount",
"attributes_accountInvoicesStatus",
"attributes_accountInvoicesInvoiceLines"
]
},
"actions": [
{
"actionId": "5fbe6a1638709266c44cfabe",
"designCode": "designs_workflowRelationAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root.attributes_accountInvoicesInvoiceLines"
}
}
],
"variables": [],
"actions": [
{
"actionId": "5fd243455bfe6751289cf1fc",
"designCode": "designs_workflowEditItemAction",
"parameters": [
{
"attributeCode": "attributes_accountInvoiceLinesTax",
"attributeType": "Number",
"value": {
"script": "return taxAmount;"
}
},
{
"attributeCode": "attributes_accountInvoiceLinesTotal",
"attributeType": "Number",
"value": {
"script": "return taxAmount + subtotal;"
}
}
],
"variables": [
{
"name": "invoiceLineItemId",
"value": {
"inputParent": 0,
"itemValue": {
"property": "ItemId"
}
}
},
{
"name": "taxRate",
"value": {
"aqs": {
"type": "StatisticsAggregation",
"properties": {
"aggregationType": "Sum",
"dodiCode": "designs_taxRates",
"collectionCode": [
"Live"
],
"attributeCode": "attributes_taxRatesRate",
"parameters": [
{
"name": "invoiceLineItemId",
"type": "AlloyId"
}
]
},
"children": [
{
"type": "Equals",
"children": [
{
"type": "ItemProperty",
"properties": {
"itemPropertyName": "itemId",
"path": "root^attributes_accountInvoiceLinesTaxRate"
}
},
{
"type": "AlloyId",
"properties": {
"parameterName": "invoiceLineItemId"
}
}
]
}
]
}
}
},
{
"name": "subtotal",
"value": {
"inputParent": 0,
"itemValue": {
"attributeCode": "attributes_accountInvoiceLinesSubTotal"
}
}
},
{
"name": "taxAmount",
"value": {
"script": "return taxRate != null ? (taxRate * subtotal)/100.0 : 0.0;"
}
}
],
"actions": [
{
"actionId": "5fbe6d3738709266c44cfac0",
"designCode": "designs_workflowFilterAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowFilterActionsAqsQuery",
"value": {
"type": "Query",
"properties": {
"attributes": [
"attributes_itemsTitle",
"attributes_itemsSubtitle"
],
"collectionCode": "Live",
"dodiCode": "designInterfaces_accountInvoiceLines"
},
"children": [
{
"type": "Equals",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_accountInvoicesStatus",
"path": "root^attributes_accountInvoicesInvoiceLines"
}
},
{
"type": "AlloyId",
"properties": {
"value": [
"5c5a095ab8e88729d461bfa3",
"5c5a095db8e88729d461bfa4"
]
}
}
]
}
]
}
}
}
],
"variables": [],
"actions": [
{
"actionId": "5fbe6d9638709266c44cfac1",
"designCode": "designs_workflowEditItemAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowEditItemActionsLocked",
"value": true
}
}
],
"variables": [],
"actions": []
}
]
}
]
}
]
},
{
"actionId": "5fbe6a1938709266c44cfabf",
"designCode": "designs_workflowEditItemAction",
"parameters": [
{
"attributeCode": "attributes_accountInvoicesSubTotal",
"attributeType": "Number",
"value": {
"script": "return Variables.invoiceLinesSubtotal.AllValues.Values.Sum(x => x.SingleValue);"
}
},
{
"attributeCode": "attributes_accountInvoicesTax",
"attributeType": "Number",
"value": {
"script": "return Variables.invoiceLinesTax.AllValues.Values.Sum(x => x.SingleValue);"
}
},
{
"attributeCode": "attributes_accountTransactionsAmount",
"attributeType": "Number",
"value": {
"script": "return Variables.invoiceLinesSubtotal.AllValues.Values.Sum(x => x.SingleValue) + Variables.invoiceLinesTax.AllValues.Values.Sum(x => x.SingleValue);"
}
}
],
"variables": [
{
"name": "invoiceLinesSubtotal",
"value": {
"outputAction": "5fd243455bfe6751289cf1fc",
"itemValue": {
"attributeCode": "attributes_accountInvoiceLinesSubTotal"
}
}
},
{
"name": "invoiceLinesTax",
"value": {
"outputAction": "5fd243455bfe6751289cf1fc",
"itemValue": {
"attributeCode": "attributes_accountInvoiceLinesTax"
}
}
}
],
"actions": [
{
"actionId": "5fbe6e5e38709266c44cfac2",
"designCode": "designs_workflowFilterAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowFilterActionsAqsQuery",
"value": {
"type": "Query",
"properties": {
"attributes": [
"attributes_itemsTitle",
"attributes_itemsSubtitle"
],
"collectionCode": "Live",
"dodiCode": "designs_accountInvoices"
},
"children": [
{
"type": "Equals",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_accountInvoicesStatus"
}
},
{
"type": "AlloyId",
"properties": {
"value": [
"5c5a095ab8e88729d461bfa3",
"5c5a095db8e88729d461bfa4"
]
}
}
]
}
]
}
}
}
],
"variables": [],
"actions": [
{
"actionId": "5fd8b72af419820ea88ea4ca",
"designCode": "designs_workflowRunReportAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRunReportActionsReportDesignCode",
"value": "designs_accountInvoiceReports"
}
},
{
"attributeCode": "attributes_reportsName",
"attributeType": "String",
"value": {
"inputParent": 0,
"itemValue": {
"attributeCode": "attributes_accountInvoicesNumber"
}
}
}
],
"variables": [],
"actions": [
{
"actionId": "5fd8b736f419820ea88ea4cb",
"designCode": "designs_workflowRelationAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root^attributes_itemsWithReportsItemLevelReport<designs_accountInvoices>"
}
}
],
"variables": [],
"actions": [
{
"actionId": "5fbe6e6238709266c44cfac3",
"designCode": "designs_workflowEditItemAction",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowEditItemActionsLocked",
"value": true
}
}
],
"variables": [],
"actions": []
}
]
}
]
}
]
}
]
}
]
}