|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Tax calculation and rate finding class. |
|
4
|
|
|
* |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
defined( 'ABSPATH' ) || exit; |
|
8
|
|
|
|
|
9
|
|
|
class WPInv_EUVat { |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Retrieves an instance of this class. |
|
13
|
|
|
* |
|
14
|
|
|
* @deprecated |
|
15
|
|
|
* @return WPInv_EUVat |
|
16
|
|
|
*/ |
|
17
|
|
|
public static function get_instance() { |
|
18
|
|
|
return new self(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @deprecated |
|
23
|
|
|
*/ |
|
24
|
|
|
public function init() {} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @deprecated |
|
28
|
|
|
*/ |
|
29
|
|
|
public static function section_vat_settings() {} |
|
30
|
|
|
|
|
31
|
|
|
public static function get_eu_states( $sort = true ) { |
|
32
|
|
|
$eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
33
|
|
|
if ( $sort ) { |
|
34
|
|
|
$sort = sort( $eu_states ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public static function get_gst_countries( $sort = true ) { |
|
41
|
|
|
$gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
42
|
|
|
|
|
43
|
|
|
if ( $sort ) { |
|
44
|
|
|
$sort = sort( $gst_countries ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public static function is_eu_state( $country_code ) { |
|
51
|
|
|
$return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
52
|
|
|
|
|
53
|
|
|
return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public static function is_gst_country( $country_code ) { |
|
57
|
|
|
$return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
58
|
|
|
|
|
59
|
|
|
return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @deprecated |
|
64
|
|
|
*/ |
|
65
|
|
|
public function enqueue_vat_scripts() {} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @deprecated |
|
69
|
|
|
*/ |
|
70
|
|
|
public function load_vat_scripts(){} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @deprecated |
|
74
|
|
|
*/ |
|
75
|
|
|
public static function enqueue_admin_scripts() {} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @deprecated |
|
79
|
|
|
*/ |
|
80
|
|
|
public static function vat_rates_settings() {} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* |
|
84
|
|
|
* @deprecated |
|
85
|
|
|
*/ |
|
86
|
|
|
public static function vat_settings() {} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* |
|
90
|
|
|
* @deprecated |
|
91
|
|
|
*/ |
|
92
|
|
|
public static function maxmind_folder() { |
|
93
|
|
|
return false; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* |
|
98
|
|
|
* @deprecated |
|
99
|
|
|
*/ |
|
100
|
|
|
public static function geoip2_download_database() {} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* |
|
104
|
|
|
* @deprecated |
|
105
|
|
|
*/ |
|
106
|
|
|
public static function geoip2_download_file() {} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @deprecated |
|
110
|
|
|
*/ |
|
111
|
|
|
public static function load_geoip2() {} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @deprecated |
|
115
|
|
|
*/ |
|
116
|
|
|
public static function geoip2_country_dbfile() { |
|
117
|
|
|
return false; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @deprecated |
|
122
|
|
|
*/ |
|
123
|
|
|
public static function geoip2_city_dbfile() { |
|
124
|
|
|
return false; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @deprecated |
|
129
|
|
|
*/ |
|
130
|
|
|
public static function geoip2_country_reader() { |
|
131
|
|
|
return false; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @deprecated |
|
136
|
|
|
*/ |
|
137
|
|
|
public static function geoip2_city_reader() { |
|
138
|
|
|
return false; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @deprecated |
|
143
|
|
|
*/ |
|
144
|
|
|
public static function geoip2_country_record() { |
|
145
|
|
|
return false; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @deprecated |
|
150
|
|
|
*/ |
|
151
|
|
|
public static function geoip2_city_record() { |
|
152
|
|
|
return false; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @deprecated |
|
157
|
|
|
*/ |
|
158
|
|
|
public static function geoip2_country_code() { |
|
159
|
|
|
wpinv_get_default_country(); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @deprecated |
|
164
|
|
|
*/ |
|
165
|
|
|
public static function get_country_by_ip() { |
|
166
|
|
|
return getpaid_get_ip_country(); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @deprecated |
|
171
|
|
|
*/ |
|
172
|
|
|
public static function sanitize_vat_settings() {} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @deprecated |
|
176
|
|
|
*/ |
|
177
|
|
|
public static function sanitize_vat_rates() {} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @deprecated |
|
181
|
|
|
*/ |
|
182
|
|
|
public static function add_class() {} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @deprecated |
|
186
|
|
|
*/ |
|
187
|
|
|
public static function delete_class() {} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @deprecated |
|
191
|
|
|
*/ |
|
192
|
|
|
public static function update_eu_rates() {} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @deprecated |
|
196
|
|
|
*/ |
|
197
|
|
|
public static function hide_vat_fields() {} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @deprecated |
|
201
|
|
|
*/ |
|
202
|
|
|
public static function same_country_rule() { |
|
203
|
|
|
return wpinv_same_country_exempt_vat(); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Retrieves the vat name. |
|
208
|
|
|
*/ |
|
209
|
|
|
public function get_vat_name() { |
|
210
|
|
|
$vat_name = wpinv_get_option( 'vat_name' ); |
|
211
|
|
|
return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name ); |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
public static function get_company_name() { |
|
215
|
|
|
$company_name = wpinv_get_option( 'vat_company_name' ); |
|
216
|
|
|
|
|
217
|
|
|
return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
public static function get_vat_number() { |
|
221
|
|
|
$vat_number = wpinv_get_option( 'vat_number' ); |
|
222
|
|
|
|
|
223
|
|
|
return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
public static function is_vat_validated() { |
|
227
|
|
|
$validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
228
|
|
|
|
|
229
|
|
|
return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @deprecated |
|
234
|
|
|
*/ |
|
235
|
|
|
public static function sanitize_vat() {} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @deprecated |
|
239
|
|
|
*/ |
|
240
|
|
|
public static function offline_check( $vat_number ) { |
|
241
|
|
|
return wpinv_regex_validate_vat_number( $vat_number ); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* @deprecated |
|
246
|
|
|
*/ |
|
247
|
|
|
public static function vies_check() {} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* @deprecated |
|
251
|
|
|
*/ |
|
252
|
|
|
public static function check_vat() {} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @deprecated |
|
256
|
|
|
*/ |
|
257
|
|
|
public static function request_euvatrates() { |
|
258
|
|
|
return array(); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* @deprecated |
|
263
|
|
|
*/ |
|
264
|
|
|
public static function requires_vat() {} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* @deprecated |
|
268
|
|
|
*/ |
|
269
|
|
|
public static function tax_label() {} |
|
270
|
|
|
|
|
271
|
|
|
public static function standard_rates_label() { |
|
272
|
|
|
return __( 'Standard Rates', 'invoicing' ); |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* @deprecated |
|
277
|
|
|
*/ |
|
278
|
|
|
public static function get_rate_classes() { |
|
279
|
|
|
return array(); |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* @deprecated |
|
284
|
|
|
*/ |
|
285
|
|
|
public static function get_all_classes() { |
|
286
|
|
|
return array(); |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @deprecated |
|
291
|
|
|
*/ |
|
292
|
|
|
public static function get_class_desc() { |
|
293
|
|
|
return ''; |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
/** |
|
297
|
|
|
* @deprecated |
|
298
|
|
|
*/ |
|
299
|
|
|
public static function get_vat_groups() {} |
|
300
|
|
|
|
|
301
|
|
|
public static function get_rules() { |
|
302
|
|
|
$vat_rules = array( |
|
303
|
|
|
'digital' => __( 'Digital Product', 'invoicing' ), |
|
304
|
|
|
'physical' => __( 'Physical Product', 'invoicing' ), |
|
305
|
|
|
'_exempt' => __( 'Tax-Free Product', 'invoicing' ), |
|
306
|
|
|
); |
|
307
|
|
|
return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* @deprecated |
|
312
|
|
|
*/ |
|
313
|
|
|
public static function get_vat_rates() { |
|
314
|
|
|
return array(); |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* @deprecated |
|
319
|
|
|
*/ |
|
320
|
|
|
public static function get_non_standard_rates() { |
|
321
|
|
|
return array(); |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* @deprecated |
|
326
|
|
|
*/ |
|
327
|
|
|
public static function allow_vat_rules() { |
|
328
|
|
|
return wpinv_use_taxes(); |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* @deprecated |
|
333
|
|
|
*/ |
|
334
|
|
|
public static function allow_vat_classes() { |
|
335
|
|
|
return wpinv_use_taxes(); |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* @deprecated |
|
340
|
|
|
*/ |
|
341
|
|
|
public static function get_item_class( $postID ) { |
|
342
|
|
|
return get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* @deprecated |
|
347
|
|
|
*/ |
|
348
|
|
|
public static function item_class_label() { |
|
349
|
|
|
return ''; |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* @deprecated |
|
354
|
|
|
*/ |
|
355
|
|
|
public static function get_item_rule( $postID ) { |
|
356
|
|
|
return get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* @deprecated |
|
361
|
|
|
*/ |
|
362
|
|
|
public static function item_rule_label() { |
|
363
|
|
|
return ''; |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
/** |
|
367
|
|
|
* @deprecated |
|
368
|
|
|
*/ |
|
369
|
|
|
public static function item_has_digital_rule() { |
|
370
|
|
|
return true; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* @deprecated |
|
375
|
|
|
*/ |
|
376
|
|
|
public static function invoice_has_digital_rule() { |
|
377
|
|
|
return false; |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* @deprecated |
|
382
|
|
|
*/ |
|
383
|
|
|
public static function item_is_taxable() { |
|
384
|
|
|
return true; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
/** |
|
388
|
|
|
* @deprecated |
|
389
|
|
|
*/ |
|
390
|
|
|
public static function find_rate() { |
|
391
|
|
|
return array(); |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
/** |
|
395
|
|
|
* @deprecated |
|
396
|
|
|
*/ |
|
397
|
|
|
public static function get_rate() { |
|
398
|
|
|
return 0; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* @deprecated |
|
403
|
|
|
*/ |
|
404
|
|
|
public static function current_vat_data() {} |
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* @deprecated |
|
408
|
|
|
*/ |
|
409
|
|
|
public static function get_user_country() {} |
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* @deprecated |
|
413
|
|
|
*/ |
|
414
|
|
|
public static function set_user_country() {} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* @deprecated |
|
418
|
|
|
*/ |
|
419
|
|
|
public static function get_user_vat_number() {} |
|
420
|
|
|
|
|
421
|
|
|
/** |
|
422
|
|
|
* @deprecated |
|
423
|
|
|
*/ |
|
424
|
|
|
public static function get_user_company() {} |
|
425
|
|
|
|
|
426
|
|
|
/** |
|
427
|
|
|
* @deprecated |
|
428
|
|
|
*/ |
|
429
|
|
|
public static function save_user_vat_details() {} |
|
430
|
|
|
|
|
431
|
|
|
/** |
|
432
|
|
|
* @deprecated |
|
433
|
|
|
*/ |
|
434
|
|
|
public static function ajax_vat_validate() {} |
|
435
|
|
|
|
|
436
|
|
|
/** |
|
437
|
|
|
* @deprecated |
|
438
|
|
|
*/ |
|
439
|
|
|
public static function validate_vat_number() {} |
|
440
|
|
|
|
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
|