1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2015 Alexandre Terrasa <alexandre@moz-code.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Insurance refunds calculation tool.
19 # `refund` computes automatically the allowed refund for a reclamation according
20 # to an insurrance policy.
25 # > refund (<input_file> <output_file> | [OPTIONS])
30 # `refund` expects a JSON input file on the form:
34 # "dossier": "A100323",
39 # "date": "2015-01-11",
40 # "montant": "234.00$"
43 # "date": "2015-01-13",
44 # "montant": "128.00$"
47 # "date": "2015-01-23",
56 # You have to specify the path where `refund` should output the result file.
58 # Results are formatted as JSON:
67 # "date": "2015-01-11",
71 # "date": "2015-01-13",
75 # "date": "2015-01-23",
84 # `refund` can generate statistics about reclamations and refunds computed.
86 # * `-S`: display statistics
87 # * `-SR`: reset statistics
91 # In case of error, a JSON object is generated in place of the output file:
94 # { "message": "Invalid input data" }
101 # Display usage in console then leave.
105 print
"refund <input.json> <output.json>"
108 print
" -S\tShow stats in console"
109 print
" -RS\tClear stats"
113 var proc
= new RefundProcessor
115 if args
.length
== 1 then
116 var flag
= args
.first
117 if flag
== "-RS" then
120 else if flag
== "-S" then
124 print
"Error: Unknown flag {flag}."
127 else if args
.length
!= 2 then
128 print
"Error: Incorrect number of arguments. Got {args.length}, expected 2."
132 proc
.process
(args
[0], args
[1])