{
	"name": "form/manager/delivery_reliability2/delivery_reliability_map.json",
	"definition": {
		"day_difference": {
			"map": [
				[
					"if",
					["ordr.confirmed_delivery_date", ">", "1970-01-01"],
					[
						["target_date", "=", "ordr.confirmed_delivery_date"],
						["day_difference", "=", ["dayDifference", ["ordr.confirmed_delivery_date", "ordr.actual_delivery_date"]]]
					],
					"elseif",
					["ordr.delivery_date", ">", "1970-01-01"],
					[
						["target_date", "=", "ordr.delivery_date"],
						["day_difference", "=", ["dayDifference", ["ordr.delivery_date", "ordr.actual_delivery_date"]]]
					],
					"else",
					[
						["target_date", "=", "ordr.actual_delivery_date"],
						["day_difference", "=", 0],
						[
							"graph_warning",
							"=",
							[
								"concat",
								[
									"Error in sales order: ",
									"ordr.order_id",
									"#",
									"ordr.row_number",
									", delivery date = ",
									"ordr.delivery_date",
									", delivered date = ",
									"ordr.actual_delivery_date",
									", confirmed delivery date = ",
									"ordr.confirmed_delivery_date",
									", delivery_state = ",
									"ordr.delivery_state",
									".<br/>"
								]
							]
						]
					]
				]
			]
		}
	}
}
