diff --git a/RFXtoRP_HsrReceiptList.ftl b/RFXtoRP_HsrReceiptList.ftl index 3d67332..3bb5391 100644 --- a/RFXtoRP_HsrReceiptList.ftl +++ b/RFXtoRP_HsrReceiptList.ftl @@ -79,12 +79,42 @@ } <#else> <#if receipt.receipt_type?? && receipt.receipt_type == "030" && receipt.receipt_confirmed == "true"> - { - <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted> - "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowReceiptCompleted.ftl"> - } + <#if receipt.origin_order_line_depot?? && receipt.origin_order_line_depot!=""> + <#assign ID = "${receipt.origin_order_line_depot?trim?json_string}${receipt.activity_code?trim?json_string}${receipt.originator_code?trim?json_string}${receipt.receipt_reference?trim?json_string}"/> + <#else> + <#assign ID = "R${receipt.physical_depot_code?trim?json_string}${receipt.activity_code?trim?json_string}${receipt.originator_code?trim?json_string}${receipt.receipt_year}${receipt.receipt_number}"/> + + <#assign payload = '{"Header": {"ProjectID": "${projectRP!""}"},"IDs": [{"RefID": ${ID}"}]}' /> + <#assign queryApiReflexPlatformID = QueryApiReflexPlatformID.ExecutionflowGetByIds> + <#assign response = QueryApiReflexPlatformCall.call(queryApiReflexPlatformID,payload) /> + <#assign executionflowRP = JsonUtil.jsonToMap(response)> + <#if executionflowRP?? && executionflowRP.Objects?? && executionflowRP.Objects[0]?? && executionflowRP.Objects[0].ID.RefID?? > + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowReceiptCompleted.ftl"> + } + <#else> + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowDetected.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_TransfertReceiptExpected.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowCustomFieldsUpdated> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_TransfertCustomFieldsUpdated.ftl"> + } + <#else> <#if receipt.receipt_confirmed?? && receipt.receipt_confirmed == "true" && receipt.confirmation_total_level_1==0 && receipt.confirmation_total_level_2==0 && receipt.confirmation_total_level_3==0> { @@ -95,12 +125,32 @@ } <#else> <#if receipt.receipt_confirmed ?? && receipt.receipt_confirmed == "true" > - { - <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted> - "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_HsrReceiptList_ExecutionflowReceiptCompleted.ftl"> - } + <#assign ID = "R${receipt.physical_depot_code?trim?json_string}${receipt.activity_code?trim?json_string}${receipt.originator_code?trim?json_string}${receipt.receipt_year}${receipt.receipt_number}"/> + <#assign payload = '{"Header": {"ProjectID": "${projectRP!""}"},"IDs": [{"RefID": ${ID}"}]}' /> + <#assign queryApiReflexPlatformID = QueryApiReflexPlatformID.ExecutionflowGetByIds> + <#assign response = QueryApiReflexPlatformCall.call(queryApiReflexPlatformID,payload) /> + <#assign executionflowRP = JsonUtil.jsonToMap(response)> + <#if executionflowRP?? && executionflowRP.Objects?? && executionflowRP.Objects[0]?? && executionflowRP.Objects[0].ID.RefID?? > + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ExecutionflowReceiptCompleted.ftl"> + } + <#else> + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ReceiptExpected.ftl"> + } + <#else> <#if receipt.receipt_type?? && receipt.receipt_type == "030" && receipt.receipt_confirmed == "false" && receipt.line_list??> <#if receipt.receipt_reference?? && receipt.receipt_reference!=""> @@ -110,14 +160,12 @@ "apiReflexPlatformID" : "${apiReflexPlatformID}", "datas" : <#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowDetected.ftl"> - }, { <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected> "apiReflexPlatformID" : "${apiReflexPlatformID}", "datas" : <#include "RFXtoRP_HsrReceiptList_TransfertReceiptExpected.ftl"> - } ] <#else>