diff --git a/RFXtoRP_HliAntRecLr.ftl b/RFXtoRP_HliAntRecLr.ftl index 295e220..e119dee 100644 --- a/RFXtoRP_HliAntRecLr.ftl +++ b/RFXtoRP_HliAntRecLr.ftl @@ -11,38 +11,43 @@ <#switch cloudEventMsg.action> <#case "C"> - <#-- *********************************************** Action = CREATE ******************** --> + <#-- *********************************************** Action = CREATE ******************** --> + <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign ancReceiptLine = JsonUtil.jsonToMap(dataRfx)> - [ + <#assign AncReceipt = JsonUtil.jsonToMap(dataRfx)> + [ + <#if AncReceipt.line_list?? && AncReceipt.line_list[0]??> { - <#stop "create anticipated receipt line"> + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderLinesAdded> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HliAntRecLr_OrderLinesAdded.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderReceiptExpected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrAntRec_ReceiptExpected.ftl"> } ] - <#break> + <#else> + <#stop> + + <#break> + <#case "U"> <#-- *********************************************** Action = UPDATE ******************** --> <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign ancReceiptLine = JsonUtil.jsonToMap(dataRfx)> - [ - { - <#stop "update anticipated receipt line"> - } - ] - <#break> - + <#assign AncReceipt = JsonUtil.jsonToMap(dataRfx)> + <#stop> + <#break> <#case "D"> - <#-- *********************************************** Action = DELETE ******************** --> - <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign ancReceiptLine = JsonUtil.jsonToMap(dataRfx)> - [ - { - <#stop "delete anticipated receipt line"> - } - ] - <#break> - - + <#-- *********************************************** Action = DELETE ******************** --> + <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> + <#assign AncReceipt = JsonUtil.jsonToMap(dataRfx)> + <#stop> + <#break> + <#default> <#stop > diff --git a/RFXtoRP_HliAntRecLr_OrderLinesAdded.ftl b/RFXtoRP_HliAntRecLr_OrderLinesAdded.ftl new file mode 100644 index 0000000..4c533a1 --- /dev/null +++ b/RFXtoRP_HliAntRecLr_OrderLinesAdded.ftl @@ -0,0 +1,47 @@ +<#include "ReflexUtils.ftl"> +<#include "HfRpConfig.ftl"> +<#include "ActorPrefix.ftl"> + +[ + { + "Header": { + "ProjectID": "${projectRP}" + }, + "ID": { + <#if AncReceipt.anticipated_receipt_reference?? && AncReceipt.anticipated_receipt_reference!=""> + "RefID": "${AncReceipt.anticipated_receipt_reference?json_string}" + <#else> + "RefID": "AR-${AncReceipt.physical_depot_code?trim?json_string}${AncReceipt.activity_code?trim?json_string}${AncReceipt.originator_code?trim?json_string}${AncReceipt.anticipated_receipt_year?json_string}${AncReceipt.anticipated_receipt_number?json_string}" + + }, + "Payload": { + "Lines": [ + <#-- Lines iteration --> + <#list AncReceipt.line_list?filter(l -> l??) as line> + { + <#if line.anticipated_receipt_reference_line_no?? && line.anticipated_receipt_reference_line_no!=0> + "LineID": "${line.anticipated_receipt_reference_line_no}", + <#else> + "LineID": "${line.anticipated_receipt_line_number}", + + <#-- Line Metadata inclusion --> + <#include "RFXtoRP_HsrAntRec_Created_LineMetadata.ftl">, + "RequestedContent":{ + "Goods":{ + "ItemID":"${line.item_code?trim?json_string!"0"}", + "LVBranchID":"${line.item_lv_code?trim?json_string!"0"}", + <#-- Segmentation Keys inclusion --> + <#include "RFXtoRP_HsrAntRec_Created_SegmentationKeys.ftl"> + }, + "Quantity" : + { + "LVID": "${quantity_in_base_lv_RP_Cst}", + "Value": ${line.planned_quantity_in_base_lv!0} + } + } + }<#sep>, + + ] + } +} +]