-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcalctax.pl
86 lines (77 loc) · 1.68 KB
/
calctax.pl
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
#!/usr/bin/perl
use strict;
use warnings;
=pod
Perl Example for debugging: Calc personal tax.
Usage:
calctax 10000
calctax
Location: Shanghai, China
tax exampt:
PIEE (楠일괏麴) 8%
MIEE (努좟괏麴) 2%
UIEE (呵撚괏麴) 0.5% (since 2013/10)
PHFEE (무생쏜) 7%
--- total: 17.5%
=cut
my $TAX_EXAMPT_BASE = 3500;
my $TAX_EXAMPT_RATE = 0.175; # PIEE(8%)
my @TAX_RATE = (
# limit, rate, minus
# if rateBase <= 1500 then tax = taxable * 0.03 - 0
[1500, 0.03, 0],
[4500, 0.1, 105],
[9000, 0.2, 555],
[35000, 0.25, 1005],
[55000, 0.3, 2755],
[80000, 0.35, 5505],
[undef, 0.45, 13505]
);
sub tax201109 # ($taxable, $forBonus)
{
my ($taxable, $forBonus) = @_;
my ($tax, $rateBase);
if (!$forBonus) {
$taxable -= $TAX_EXAMPT_RATE;
$rateBase = $taxable;
}
else {
$rateBase = $taxable / 12;
}
my $rate = 0;
for (@TAX_RATE) {
if (defined($_->[0]) && $rateBase <= $_->[0]) {
$rate = $_->[1];
$tax = $taxable * $rate - $_->[2];
last;
}
}
($tax, $rate);
}
sub showTax # ($amount, [$forBonus=0])
{
my ($amount, $forBonus) = @_;
my $taxable = $amount;
if (! $forBonus) {
$taxable -= $amount * $TAX_EXAMPT_RATE;
}
my ($tax, $rate) = tax201109($taxable, $forBonus);
printf "%s $amount: Tax=%.2f (Rate %.2f%%, Act.Rate %.2f%%)\n", ($forBonus? "Bonus": "Salary"), $tax, $rate*100, $tax/$amount*100;
}
if (@ARGV) {
for (@ARGV) {
next if /\D/;
showTax($_);
showTax($_, 1);
}
}
else {
for (3000, 5000, 8000, 10000, 12000, 15000, 18000, 20000, 23000, 25000, 30000)
{
showTax($_);
}
for (10000, 20000, 30000, 40000, 50000, 60000)
{
showTax($_, 'forBonus');
}
}