@@ -12,26 +12,44 @@ def compute_exploitation_share(data):
1212 participation = data ["participation" ]
1313 impot = data ["impot" ]
1414 resultat_exploitation = data ["resultat_exploitation" ]
15+ benefice_attribue = data ["benefice_attribue" ]
1516
1617 # If any values unknown, cannot compute score
1718 if isnan (impot ):
1819 return - 3100
1920 if impot < 0 :
2021 return - 3200
21- if (
22- any (isnan (value ) for value in [resultat_exploitation ])
23- or resultat_exploitation < 0
24- ):
25- return float ("nan" )
22+ if isnan (resultat_exploitation ):
23+ return - 7100
24+ if isnan (benefice_attribue ):
25+ benefice_attribue = 0
26+ if resultat_exploitation + benefice_attribue <= 0 :
27+ return - 7200
2628
2729 if isnan (participation ):
2830 participation = 0
2931 # Compute score if possible
3032 shared_part = participation + impot
31- if resultat_exploitation > 0 :
32- return shared_part / resultat_exploitation
3333
34- return float ("nan" )
34+ total_resultat = resultat_exploitation + benefice_attribue
35+ result = shared_part / total_resultat
36+
37+ if result < 0 and participation < 0 :
38+ return - 10000
39+
40+ if result > 10 :
41+ resultat_exceptionnel = data ["resultat_exceptionnel" ]
42+ resultat_financier = data ["resultat_financier" ]
43+ if isnan (resultat_financier ):
44+ resultat_financier = 0
45+ if isnan (resultat_exceptionnel ):
46+ resultat_exceptionnel = 0
47+ if resultat_exceptionnel + resultat_financier > total_resultat :
48+ return - 8000
49+ if result > 1000 :
50+ return - 9999
51+
52+ return result
3553
3654
3755def compute_overall_wages_weight (data ):
@@ -59,8 +77,22 @@ def compute_overall_wages_weight(data):
5977
6078 result = (salaires + cotisations_sociales ) / charges
6179
62- if result < 0 and charges < 0 :
63- return - 6300
80+ if result < 0 :
81+ if charges < 0 :
82+ return - 6300
83+ elif cotisations_sociales < 0 :
84+ return - 2300
85+ elif salaires < 0 :
86+ return - 1300
87+
88+ if result > 2 :
89+ if cotisations_sociales > charges and salaires > charges :
90+ return - 6400
91+ elif cotisations_sociales > charges :
92+ return - 2500
93+ elif salaires > charges :
94+ return - 1400
95+ return - 9999
6496
6597 return result
6698
@@ -96,6 +128,8 @@ def compute_wage_quality(data):
96128 return - 1300
97129 if cotisations_sociales < 0 :
98130 return - 2300
131+ if ratio > 2 :
132+ return - 2400
99133 return ratio
100134
101135
@@ -151,16 +185,25 @@ def compute_profit_sharing(data):
151185 ):
152186 return float ("nan" )
153187
154- somme_resultats = resultat_financier + resultat_exploitation + resultat_exceptionnel
155- if somme_resultats == 0 :
156- return float ("nan" )
188+ if isnan (benefice_attribue ):
189+ benefice_attribue = 0
190+ somme_resultats = (
191+ resultat_financier
192+ + resultat_exploitation
193+ + resultat_exceptionnel
194+ + benefice_attribue
195+ )
196+
197+ if somme_resultats <= 0 :
198+ return - 9000
157199
158200 if isnan (participation ):
159201 participation = 0
160202
161203 result = (participation + impot ) / somme_resultats
162- if result < 0 and not isnan (benefice_attribue ) and benefice_attribue > 0 :
163- return - 5100
204+
205+ if result < 0 and participation < 0 :
206+ return - 10000
164207
165208 return result
166209
@@ -196,17 +239,17 @@ def compute_exploitation_part(data):
196239 ) == 0 :
197240 return float ("nan" )
198241
199- result = (data ["produits_exploitation" ] + data ["charges_exploitation" ]) / (
200- data ["produits_exploitation" ]
201- + data ["charges_exploitation" ]
202- + data ["produits_exceptionnel" ]
203- + data ["charges_exceptionnel" ]
204- + data ["produits_financier" ]
205- + data ["charges_financier" ]
242+ result = (
243+ abs (data ["produits_exploitation" ]) + abs (data ["charges_exploitation" ])
244+ ) / (
245+ abs (data ["produits_exploitation" ])
246+ + abs (data ["charges_exploitation" ])
247+ + abs (data ["produits_exceptionnel" ])
248+ + abs (data ["charges_exceptionnel" ])
249+ + abs (data ["produits_financier" ])
250+ + abs (data ["charges_financier" ])
206251 )
207- if result < 0 :
208- if data ["charges_exploitation" ] < 0 :
209- return - 6300
252+
210253 return result
211254
212255
@@ -224,3 +267,6 @@ def compute_data_availability(data):
224267 data_available += 1
225268
226269 return data_available / len (data )
270+
271+
272+ # SELECT * FROM `annual_statistics` where stats_type != 4 and value not in (-4300, -6300, -6100, -6200, -5100, -1000, -1100, -1200, -1300, -2000, -2100, -2200, -2300, -2400, -2500, -3100, -3200, -4100, -4200, -4300, -1400, -6400, -7100, -7200, -8000, -9000, -9999, -10000) ORDER BY `annual_statistics`.`value` ASC;
0 commit comments