diff --git a/RFXtoRP_HsaIpgMove_GoodsReceived.ftl b/RFXtoRP_HsaIpgMove_GoodsReceived.ftl index ba4a89c..eebe3e3 100644 --- a/RFXtoRP_HsaIpgMove_GoodsReceived.ftl +++ b/RFXtoRP_HsaIpgMove_GoodsReceived.ftl @@ -32,24 +32,15 @@ <#if reflexMvtStockInterface.ipg_move_type?? && reflexMvtStockInterface.ipg_move_type=="120"> <#-- if it is a transfer-type movement --> <#if reflexMvtStockInterface.origin_order_line_reference?? && reflexMvtStockInterface.origin_order_line_reference!=""> "ExecutionflowID": "${reflexMvtStockInterface.original_receipt_physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.origin_order_line_reference?trim?json_string}", - "OrderID": "${reflexMvtStockInterface.origin_order_line_reference?trim?json_string}", <#else> <#if reflexMvtStockInterface.receipt_reference?? && reflexMvtStockInterface.receipt_reference!="" && !reflexMvtStockInterface.receipt_reference?starts_with(reflexMvtStockInterface.original_receipt_physical_depot_code + reflexMvtStockInterface.activity_code + reflexMvtStockInterface.receipt_year_number)> "ExecutionflowID": "${reflexMvtStockInterface.original_receipt_physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.receipt_reference?trim?json_string}", - "OrderID": "${reflexMvtStockInterface.receipt_reference?trim?json_string}", <#else> "ExecutionflowID": "R${reflexMvtStockInterface.physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.receipt_year_number}${reflexMvtStockInterface.receipt_number}", - "OrderID": "R${reflexMvtStockInterface.physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.receipt_year_number}${reflexMvtStockInterface.receipt_number}", <#else> - <#if reflexMvtStockInterface.receipt_reference?? && reflexMvtStockInterface.receipt_reference!=""> "ExecutionflowID": "R${reflexMvtStockInterface.physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.receipt_year_number}${reflexMvtStockInterface.receipt_number}", - "OrderID": "${reflexMvtStockInterface.receipt_reference?trim?json_string}", - <#else> - "ExecutionflowID": "R${reflexMvtStockInterface.physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.receipt_year_number}${reflexMvtStockInterface.receipt_number}", - "OrderID": "R${reflexMvtStockInterface.physical_depot_code}${reflexMvtStockInterface.activity_code}${reflexMvtStockInterface.originator_code}${reflexMvtStockInterface.receipt_year_number}${reflexMvtStockInterface.receipt_number}", - <#if reflexMvtStockInterface.origin_order_line_number_reference?? && reflexMvtStockInterface.origin_order_line_number_reference!=0 && reflexMvtStockInterface.ipg_move_type=="120"> "LineID": "${reflexMvtStockInterface.origin_order_line_number_reference}", diff --git a/RFXtoRP_HsrAntRec.ftl b/RFXtoRP_HsrAntRec.ftl index 976149f..4976de3 100644 --- a/RFXtoRP_HsrAntRec.ftl +++ b/RFXtoRP_HsrAntRec.ftl @@ -1,5 +1,5 @@ <#-- **** input parameters ***** --> -<#-- input : message HARDIS WMS --> +<#-- input : message HARDIS WMS for anticipated receipt --> <#-- project : projectId in HARDIS SC NETWORK --> <#-- organisation : organisationtId in HARDIS SC NETWORK --> @@ -14,31 +14,61 @@ <#-- *********************************************** Action = CREATE ******************** --> <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign ancReceipt = JsonUtil.jsonToMap(dataRfx)> - [ + <#assign AncReceipt = JsonUtil.jsonToMap(dataRfx)> + [ + <#if AncReceipt.line_list?? && AncReceipt.line_list[0]??> { - <#stop > - } + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderCreated> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrAntRec_Created.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderReceiptExpected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrAntRec_ReceiptExpected.ftl"> + } ] + <#else> + <#stop> + <#break> <#case "U"> <#-- *********************************************** Action = UPDATE ******************** --> <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign ancReceipt = JsonUtil.jsonToMap(dataRfx)> + <#assign AncReceipt = JsonUtil.jsonToMap(dataRfx)> [ - { - <#stop > - } + <#if AncReceipt.generated?? && AncReceipt.generated.total_level_1_quantity==0 && AncReceipt.generated.total_level_2_quantity==0 && AncReceipt.generated.total_level_3_quantity==0 && AncReceipt.anticipated_receipt_closed == "true" && AncReceipt.all_receipt_validated=="true"> + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderCancelled> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrAntRec_Cancelled.ftl"> + } + <#else> + <#if AncReceipt.anticipated_receipt_closed == "true" && AncReceipt.all_receipt_validated=="true"> + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderReceiptCompleted> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrAntRec_ReceiptCompleted.ftl"> + } + + ] <#break> <#case "D"> <#-- *********************************************** Action = DELETE ******************** --> <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign ancReceipt = JsonUtil.jsonToMap(dataRfx)> + <#assign AncReceipt = JsonUtil.jsonToMap(dataRfx)> [ - { - <#stop > + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.OrderCancelled> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrAntRec_Cancelled.ftl"> } ] <#break> diff --git a/RFXtoRP_HsrAntRec_Cancelled.ftl b/RFXtoRP_HsrAntRec_Cancelled.ftl new file mode 100644 index 0000000..274abdd --- /dev/null +++ b/RFXtoRP_HsrAntRec_Cancelled.ftl @@ -0,0 +1,25 @@ +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> +<#--<#assign receipt_status_datetime = RfxDateTimetoUTCWithTimezone(receipt.creation_datetime,time_zone_rfx) /> --> +<#assign now = .now?string("yyyy-MM-dd'T'HH:mm:ss'Z'") /> +[ + { + "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?json_string}${AncReceipt.activity_code?json_string}${AncReceipt.originator_code?json_string}${AncReceipt.anticipated_receipt_year?json_string}${AncReceipt.anticipated_receipt_number?json_string}", + + "RefDate": { + "DateTime": "${now}", + "AuthorTimeZone": "${time_zone_rfx}" + } + }, + + "Payload": {} + + } +] diff --git a/RFXtoRP_HsrAntRec_Created.ftl b/RFXtoRP_HsrAntRec_Created.ftl new file mode 100644 index 0000000..656876f --- /dev/null +++ b/RFXtoRP_HsrAntRec_Created.ftl @@ -0,0 +1,111 @@ +<#include "ReflexUtils.ftl"> +<#include "HfRpConfig.ftl"> +<#include "ActorPrefix.ftl"> + +[ + { + <#assign receipt_datetime = RfxDateTimetoUTCWithTimezone(AncReceipt.planned_receipt_datetime,time_zone_rfx) /> + <#assign now = .now?string("yyyy-MM-dd'T'HH:mm:ss'Z'") /> + "Header": { + "ProjectID": "${projectRP}" + }, + "ID": { + "CustomFields": [ + { + "Key": "anticipated_receipt_reference", + "Value": "${AncReceipt.anticipated_receipt_reference?json_string}" + }, + { + "Key": "anticipated_receipt_year", + "Value": "${AncReceipt.anticipated_receipt_year?json_string}" + }, + { + "Key": "anticipated_receipt_number", + "Value": "${AncReceipt.anticipated_receipt_number?json_string}" + }, + { + "Key": "originator_code", + "Value": "${AncReceipt.originator_code?json_string}" + }, + { + "Key": "activity_code", + "Value": "${AncReceipt.activity_code?json_string}" + }, + { + "Key": "depot_code", + "Value": "${AncReceipt.physical_depot_code?json_string}" + }, + { + "Key": "anticipated", + "Value": "true" + } + ], + <#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": { + "ShipFrom": { + "ActorID": "${RFXtoRPprefixSupplier(AncReceipt.original_code?json_string)}" + }, + "ShipTo": { + "ActorID": "${RFXtoRPprefixDepot(AncReceipt.physical_depot_code?json_string)}" + }, + "CreationDateTime": { + "DateTime": "${now}", + "AuthorTimeZone": "${time_zone_rfx}" + }, + "LanguageCodeISO6391":"fr", + "Anticipated": true, + <#-- Header Metadata inclusion --> + <#include "RFXtoRP_HsrAntRec_Created_HeaderMetadata.ftl">, + "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>, + + ] + <#if AncReceipt.planned_receipt_datetime?? && AncReceipt.planned_receipt_datetime!="0000-00-00T00:00:00"> + , + "RequestedMilestones" : + { + "RequestedDeliveryDateTime" : + { + "DateTime": "${receipt_datetime}", + "AuthorTimeZone": "${time_zone_rfx}" + } + } + + <#if AncReceipt.carrier_code?? && AncReceipt.carrier_code != ""> + , + "Carrier": + { + "ActorID":"${RFXtoRPprefixCarrier(AncReceipt.carrier_code?trim?json_string)}" + } + + } +} +] diff --git a/RFXtoRP_HsrAntRec_Created_HeaderMetadata.ftl b/RFXtoRP_HsrAntRec_Created_HeaderMetadata.ftl new file mode 100644 index 0000000..40f44a9 --- /dev/null +++ b/RFXtoRP_HsrAntRec_Created_HeaderMetadata.ftl @@ -0,0 +1,19 @@ +<#-- use protobuf of class HsrReceiptList to find HARDIS WMS fields names --> + +<#-- +<#-- Best practices: + If the SK is of type: + - string: add ?json_string (e.g. "${stock.batch_1?json_string}") + - boolean: possible values: true and false + - datetime: expected format: 2025-10-30T10:12:10.000Z + - decimal number: the separator is a point (e.g. 10.5) +"MetaData": [ + { + "Key": "OrderType", + "Value": { "String" : "${order.optional_attributes.reason_code}"} + } + ], +--> + + +"MetaData": [ ] \ No newline at end of file diff --git a/RFXtoRP_HsrAntRec_Created_LineMetadata.ftl b/RFXtoRP_HsrAntRec_Created_LineMetadata.ftl new file mode 100644 index 0000000..b920b69 --- /dev/null +++ b/RFXtoRP_HsrAntRec_Created_LineMetadata.ftl @@ -0,0 +1,10 @@ +<#-- use protobuf of class HsrReceiptList to find HARDIS WMS fields names --> + +<#-- Best practices: + If the SK is of type: + - string: add ?json_string (e.g. "${stock.batch_1?json_string}") + - boolean: possible values: true and false + - datetime: expected format: 2025-10-30T10:12:10.000Z + - decimal number: the separator is a point (e.g. 10.5)--> + +"MetaData": [ ] \ No newline at end of file diff --git a/RFXtoRP_HsrAntRec_Created_SegmentationKeys.ftl b/RFXtoRP_HsrAntRec_Created_SegmentationKeys.ftl new file mode 100644 index 0000000..de24f8b --- /dev/null +++ b/RFXtoRP_HsrAntRec_Created_SegmentationKeys.ftl @@ -0,0 +1,47 @@ +<#-- use protobuf of class HsrReceiptList to find HARDIS WMS fields names --> + +<#-- +<#-- Best practices: + If the SK is of type: + - string: add ?json_string (e.g. "${stock.batch_1?json_string}") + - boolean: possible values: true and false + - datetime: expected format: 2025-10-30T10:12:10.000Z + - decimal number: the separator is a point (e.g. 10.5) +"SegmentationKeys": [ + { + "Key": "Grade", + "Value": { "String" : "${line.grade_code}"} + }, + { + "Key": "Owner", + "Value": { "String" : "${line.owner_code}"} + }, + { + "Key": "BatchNumber", + <#if reflexMvtStockInterface.batch_1 == ""> + "Value": { "String" : "no batch"} + <#else> + "Value": { "String" : "${line_without_detail.batch_1}"} + + }, + { + "Key": "HeldForSpecificCode", + <#if line_without_detail.hold_for_specific_code == "true"> + "Value": { "Bool" : "True"} + <#else> + "Value": { "Bool" : "False"} + }, + + { + <#assign manufacturing_date = line_without_detail.ipg_date_of_manufacture_date?datetime(rfx_date_format_default)?iso_utc /> + "Key": "ManufacturingDate", + "Value": "Timestamp": { + "AuthorTimeZone": "${time_zone_rfx}", + "DateTime": "${manufacturing_date}" + } + } + + ] + +--> +"SegmentationKeys": [ ] \ No newline at end of file diff --git a/RFXtoRP_HsrAntRec_ReceiptCompleted.ftl b/RFXtoRP_HsrAntRec_ReceiptCompleted.ftl new file mode 100644 index 0000000..aa64359 --- /dev/null +++ b/RFXtoRP_HsrAntRec_ReceiptCompleted.ftl @@ -0,0 +1,25 @@ +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> +<#--<#assign receipt_status_datetime = RfxDateTimetoUTCWithTimezone(receipt.creation_datetime,time_zone_rfx) /> --> +<#assign now = .now?string("yyyy-MM-dd'T'HH:mm:ss'Z'") /> +[ + { + "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}", + + "RefDate": { + "DateTime": "${now}", + "AuthorTimeZone": "${time_zone_rfx}" + } + }, + + "Payload": {} + + } +] diff --git a/RFXtoRP_HsrAntRec_ReceiptExpected.ftl b/RFXtoRP_HsrAntRec_ReceiptExpected.ftl new file mode 100644 index 0000000..fcbc6eb --- /dev/null +++ b/RFXtoRP_HsrAntRec_ReceiptExpected.ftl @@ -0,0 +1,25 @@ +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> +<#--<#assign receipt_status_datetime = RfxDateTimetoUTCWithTimezone(receipt.creation_datetime,time_zone_rfx) /> --> +<#assign now = .now?string("yyyy-MM-dd'T'HH:mm:ss'Z'") /> +[ + { + "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}", + + "RefDate": { + "DateTime": "${now}", + "AuthorTimeZone": "${time_zone_rfx}" + } + }, + + "Payload": {} + + } +] diff --git a/RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl b/RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl index 05e7ace..eca0f87 100644 --- a/RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl +++ b/RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl @@ -33,7 +33,18 @@ { "Key": "order_number", "Value": "${receipt.receipt_number}" + }, + <#if receipt.line_list[0]?? && receipt.line_list[0].line_anticipated?? && receipt.line_list[0].line_anticipated.anticipated_receipt_year!=0 && receipt.line_list[0].line_anticipated.anticipated_receipt_number!=0 > + { + "Key": "anticipated", + "Value": "true" } + <#else> + { + "Key": "anticipated", + "Value": "false" + } + ], "RefID": "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}", "RefDate": { @@ -63,10 +74,14 @@ "ActorID": "${RFXtoRPprefixDepot(receipt.physical_depot_code?trim?json_string)}" }, "ShipToAcked": true, - <#if receipt.receipt_reference?? && receipt.receipt_reference!=""> - "OrderID":"${receipt.receipt_reference?trim?json_string}", + <#if receipt.line_list[0]?? && receipt.line_list[0].line_anticipated?? && receipt.line_list[0].line_anticipated.anticipated_receipt_year!=0 && receipt.line_list[0].line_anticipated.anticipated_receipt_reference?? && receipt.line_list[0].line_anticipated.anticipated_receipt_reference=="" > + "OrderID":"AR-${receipt.line_list[0].line_anticipated.anticipated_receipt_depot_code?trim?json_string}${receipt.line_list[0].line_anticipated.anticipated_receipt_activity_code?trim?json_string}${receipt.line_list[0].line_anticipated.anticipated_receipt_originator_code?trim?json_string}${receipt.line_list[0].line_anticipated.anticipated_receipt_year}${receipt.line_list[0].line_anticipated.anticipated_receipt_number}", <#else> - "OrderID":"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}", + <#if receipt.receipt_reference?? && receipt.receipt_reference!=""> + "OrderID":"${receipt.receipt_reference?trim?json_string}", + <#else> + "OrderID":"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}", + <#if receipt.carrier_informations.carrier_code != ""> "Carrier":