forked from jf-tech/omniparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_header_footer.schema.json
92 lines (92 loc) · 4.45 KB
/
3_header_footer.schema.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
"parser_settings": {
"version": "omni.2.1",
"file_format_type": "fixedlength2"
},
"file_declaration": {
"envelopes" : [
{
"name": "HEADER", "min": 1, "max": 1, "header": "^A010", "footer": "^A999",
"columns": [ { "name": "carrier", "start_pos": 6, "length": 6, "line_pattern": "^A060" } ]
},
{
"name": "REC", "header": "^V010", "footer": "^V999", "is_target": true,
"columns": [
{ "name": "tracking_number", "start_pos": 6, "length": 15, "line_pattern": "^V020" },
{ "name": "delivery_date", "start_pos": 6, "length": 8, "line_pattern": "^V045" },
{ "name": "observation_type", "start_pos": 6, "length": 1, "line_pattern": "^V060" },
{ "name": "reason_for_observation", "start_pos": 6, "length": 2, "line_pattern": "^V070" },
{ "name": "date_observation", "start_pos": 6, "length": 8, "line_pattern": "^V080" },
{ "name": "time_observation", "start_pos": 6, "length": 6, "line_pattern": "^V081" },
{ "name": "weight_in_grams", "start_pos": 6, "length": 6, "line_pattern": "^V110" },
{ "name": "postal_code_addressee", "start_pos": 6, "length": 6, "line_pattern": "^V160" },
{ "name": "city_name_addressee", "start_pos": 6, "length": 24, "line_pattern": "^V180" },
{ "name": "country_code_addressee", "start_pos": 6, "length": 2, "line_pattern": "^V200" }
]
},
{ "name": "FOOTER", "min": 1, "max": 1, "header": "^Z001", "footer": "^Z999" }
]
},
"transform_declarations": {
"FINAL_OUTPUT": { "object": {
"tracking_number": { "xpath": "tracking_number" },
"carrier": { "custom_func": { "name": "lower", "args": [ { "xpath": "../HEADER/carrier" } ] } },
"estimated_delivery_date": { "custom_func": {
"name": "dateTimeToRFC3339",
"args": [
{ "xpath": "delivery_date" },
{ "const": "", "_comment": "input timezone" },
{ "const": "", "_comment": "output timezone" }
]
}},
"weight_in_kg": {
"custom_func": {
"name": "javascript",
"args": [
{ "const": "((/^[0-9]+$/.test(grams) ? parseFloat(grams) : 0.0) / 1000).toFixed(2)" },
{ "const": "grams" }, { "xpath": "weight_in_grams" }
]
},
"type": "float"
},
"events": { "array": [
{ "object": {
"event_date": { "template": "event_date_template" },
"location": { "object": {
"city": { "custom_func": {
"name": "javascript",
"args": [
{ "const": "event_country == 'NL' ? event_city : ''" },
{ "const": "event_country"}, { "xpath": "country_code_addressee" },
{ "const": "event_city"}, { "xpath": "city_name_addressee" }
]
}},
"zip": { "custom_func": {
"name": "javascript",
"args": [
{ "const": "event_country == 'NL' ? event_zip : '0000FF'" },
{ "const": "event_country"}, { "xpath": "country_code_addressee" },
{ "const": "event_zip"}, { "xpath": "postal_code_addressee" }
]
}},
"country": { "xpath": "country_code_addressee" }
}}
}}
]}
}},
"event_date_template": { "custom_func": {
"name": "dateTimeToRFC3339",
"args": [
{ "custom_func": {
"name": "concat",
"args": [
{ "xpath": "date_observation" },
{ "xpath": "time_observation" }
]
}},
{ "const": "", "_comment": "input timezone" },
{ "const": "", "_comment": "output timezone" }
]
}}
}
}