line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::Tax::Withholding::JP; |
2
|
6
|
|
|
6
|
|
298990
|
use 5.008001; |
|
6
|
|
|
|
|
53
|
|
3
|
6
|
|
|
6
|
|
27
|
use strict; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
114
|
|
4
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
185
|
|
5
|
6
|
|
|
6
|
|
1860
|
use Time::Seconds; |
|
6
|
|
|
|
|
12670
|
|
|
6
|
|
|
|
|
406
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.08"; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
35
|
use constant { border => 1000000 }; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
563
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %consumption = ( |
12
|
|
|
|
|
|
|
rate => 0.10, |
13
|
|
|
|
|
|
|
name => 'æ¶è²»ç¨', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @history = ({ |
17
|
|
|
|
|
|
|
rate => 0.03, |
18
|
|
|
|
|
|
|
since => '1989-04-01', |
19
|
|
|
|
|
|
|
until => '1997-03-31', |
20
|
|
|
|
|
|
|
},{ |
21
|
|
|
|
|
|
|
rate => 0.05, |
22
|
|
|
|
|
|
|
since => '1997-04-01', |
23
|
|
|
|
|
|
|
until => '2014-03-31', |
24
|
|
|
|
|
|
|
},{ |
25
|
|
|
|
|
|
|
rate => 0.08, |
26
|
|
|
|
|
|
|
since => '2014-04-01', |
27
|
|
|
|
|
|
|
until => '2019-09-30', |
28
|
|
|
|
|
|
|
}); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %withholding = ( |
31
|
|
|
|
|
|
|
rate => 0.10, |
32
|
|
|
|
|
|
|
name => 'æºæ³å¾´å', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my %special = ( |
36
|
|
|
|
|
|
|
rate => 0.0021, |
37
|
|
|
|
|
|
|
name => '復èç¹å¥æå¾ç¨', |
38
|
|
|
|
|
|
|
since => '2013-01-01', |
39
|
|
|
|
|
|
|
until => '2037-12-31', |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
6
|
|
2730
|
use Moose; |
|
6
|
|
|
|
|
2332031
|
|
|
6
|
|
|
|
|
44
|
|
43
|
6
|
|
|
6
|
|
40698
|
use Time::Piece; |
|
6
|
|
|
|
|
31926
|
|
|
6
|
|
|
|
|
28
|
|
44
|
|
|
|
|
|
|
my $t = localtime(); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has price => ( is => 'rw', isa => 'Int', default => 0 ); |
47
|
|
|
|
|
|
|
has amount => ( is => 'rw', isa => 'Int', default => 1 ); |
48
|
|
|
|
|
|
|
has date => ( is => 'rw', isa => 'Str', default => $t->ymd() ); |
49
|
|
|
|
|
|
|
has no_wh => ( is => 'ro', isa => 'Bool', default => 0 ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
52
|
6
|
|
|
6
|
|
745
|
no Moose; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
34
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub net { |
55
|
5
|
|
|
5
|
1
|
20
|
my $self = shift; |
56
|
5
|
|
|
|
|
96
|
return $self->price(@_); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub subtotal { |
60
|
131
|
|
|
131
|
1
|
134
|
my $self = shift; |
61
|
131
|
|
|
|
|
2605
|
return $self->price() * $self->amount(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub tax { |
65
|
48
|
|
|
48
|
1
|
71
|
my $self = shift; |
66
|
48
|
|
|
|
|
66
|
return int( $self->subtotal() * $self->tax_rate() ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub full { |
70
|
29
|
|
|
29
|
1
|
41
|
my $self = shift; |
71
|
29
|
|
|
|
|
46
|
return int( $self->subtotal() + $self->tax() ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub withholding { |
75
|
36
|
|
|
36
|
1
|
2271
|
my $self = shift; |
76
|
36
|
100
|
|
|
|
804
|
return 0 if $self->no_wh(); |
77
|
24
|
|
|
|
|
54
|
my $rate = $self->wh_rate(); |
78
|
24
|
100
|
|
|
|
176
|
if( $self->subtotal() <= border ) { |
79
|
18
|
|
|
|
|
31
|
return int( $self->subtotal() * $rate ); |
80
|
|
|
|
|
|
|
}else{ |
81
|
6
|
|
|
|
|
8
|
my $base = $self->subtotal() - border; |
82
|
6
|
|
|
|
|
33
|
return int( $base * $rate * 2 + border * $rate ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub tax_rate { |
87
|
48
|
|
|
48
|
0
|
59
|
my $self = shift; |
88
|
48
|
|
|
|
|
868
|
my $date = $t->strptime( $self->date(), '%Y-%m-%d' ); |
89
|
48
|
100
|
|
|
|
4091
|
return 0 if $date < $t->strptime( $history[0]{'since'}, '%Y-%m-%d' ); |
90
|
46
|
100
|
|
|
|
3923
|
return $consumption{'rate'} if $date > $t->strptime( $history[-1]{'until'}, '%Y-%m-%d' ) + ONE_DAY; |
91
|
|
|
|
|
|
|
|
92
|
10
|
|
|
|
|
1434
|
foreach my $h (@history) { |
93
|
22
|
100
|
|
|
|
1624
|
next unless $date < $t->strptime( $h->{'until'}, '%Y-%m-%d' ) + ONE_DAY; |
94
|
8
|
50
|
|
|
|
1052
|
return $h->{'rate'} if $date >= $t->strptime( $h->{'since'}, '%Y-%m-%d' ); |
95
|
|
|
|
|
|
|
} |
96
|
2
|
|
|
|
|
265
|
return $consumption{'rate'}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub wh_rate { |
100
|
24
|
|
|
24
|
0
|
27
|
my $self = shift; |
101
|
24
|
|
|
|
|
31
|
my $rate = $withholding{'rate'}; |
102
|
24
|
|
|
|
|
62
|
my $since = $t->strptime( $special{'since'}, '%Y-%m-%d' ); |
103
|
24
|
|
|
|
|
1859
|
my $until = $t->strptime( $special{'until'}, '%Y-%m-%d' ); |
104
|
24
|
|
|
|
|
2088
|
my $date = $t->strptime( $self->date(), '%Y-%m-%d' ); |
105
|
|
|
|
|
|
|
|
106
|
24
|
100
|
100
|
|
|
1662
|
return $rate if $date < $since or $until < $date; |
107
|
20
|
|
|
|
|
693
|
return $rate + $special{'rate'}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub total { |
111
|
18
|
|
|
18
|
1
|
31
|
my $self = shift; |
112
|
18
|
|
|
|
|
35
|
return $self->full - $self->withholding; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=encoding utf-8 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Business::Tax::Withholding::JP - auto calculation for Japanese tax and withholding |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Business::Tax::Withholding::JP - æ¥æ¬ã®æ¶è²»ç¨ã¨æºæ³å¾´åã®ãããããè¨ç®ãèªååãã¾ãã |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SYNOPSIS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
use Business::Tax::Withholding::JP; |
129
|
|
|
|
|
|
|
my $calc = Business::Tax::Withholding::JP->new( price => 10000 ); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$calc->net(); # 10000 |
132
|
|
|
|
|
|
|
$calc->amount(); # 1 |
133
|
|
|
|
|
|
|
$calc->subtotal(); # 10000 |
134
|
|
|
|
|
|
|
$calc->tax(); # 800 |
135
|
|
|
|
|
|
|
$calc->full(); # 10800 |
136
|
|
|
|
|
|
|
$calc->withholding(); # 1021 |
137
|
|
|
|
|
|
|
$calc->total(); # 9779 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# Or you can set the date in period of special tax will expire |
140
|
|
|
|
|
|
|
$calc = Business::Tax::Withholding::JP->new( date => '2038-01-01' ); |
141
|
|
|
|
|
|
|
$calc->price(10000); |
142
|
|
|
|
|
|
|
$calc->withholding(); # 1000 |
143
|
|
|
|
|
|
|
$calc->total(); # 9800 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# And you may ignore the withholdings |
146
|
|
|
|
|
|
|
$calc = Business::Tax::Withholding::JP->new( no_wh => 1 ); |
147
|
|
|
|
|
|
|
$calc->price(10000); # 10000 |
148
|
|
|
|
|
|
|
$calc->amount(2); # 2 |
149
|
|
|
|
|
|
|
$calc->subtotal(); # 20000 |
150
|
|
|
|
|
|
|
$calc->tax(); # 1600 |
151
|
|
|
|
|
|
|
$calc->withholding(); # 0 |
152
|
|
|
|
|
|
|
$calc->total(); # 21600 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# After 2019/10/01, this module will calculate with 10% consumption tax |
155
|
|
|
|
|
|
|
$calc = Business::Tax::Withholding::JP->new( price => 10000 ); |
156
|
|
|
|
|
|
|
$calc->net(); # 10000 |
157
|
|
|
|
|
|
|
$calc->amount(2); # 2 |
158
|
|
|
|
|
|
|
$calc->subtotal(); # 20000 |
159
|
|
|
|
|
|
|
$calc->tax(); # 2000 |
160
|
|
|
|
|
|
|
$calc->withholding(); # 2042 |
161
|
|
|
|
|
|
|
$calc->total(); # 19958 |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 DESCRIPTION |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Business::Tax::Withholding::JP |
166
|
|
|
|
|
|
|
is useful calculator for long term in Japanese Business. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
You can get correctly taxes and withholdings from price in your context |
169
|
|
|
|
|
|
|
without worrying about the special tax for reconstructing from the Earthquake. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
the consumption tax B<rate is 8% (automatically up to 10% after 2019/10/01)> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
You can also ignore the withholings. It means this module can be a tax calculator |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Business::Tax::Withholding::JP ã¯æ¥æ¬ã®ãã¸ãã¹ã§é·æçã«ä½¿ããã¢ã¸ã¥ã¼ã«ã§ãã |
176
|
|
|
|
|
|
|
ç¹å¥å¾©èæå¾ç¨ã®æéãå¿é
ãããã¨ãªããè«æ±ä¾¡æ ¼ããæ£ããç¨éé¡ã¨æºæ³å¾´åé¡ãè¨ç®ã§ãã¾ãã |
177
|
|
|
|
|
|
|
ãªããæºæ³å¾´åãããªãçµçã«ã対å¿ãã¾ããB<æ¶è²»ç¨çã¯8%ã2019å¹´10æ1æ¥ããèªåçã«10ï¼
> ã§ãã |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 Constructor |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head3 new( price => I<Int>, amount => I<Int>, date => I<Date>, no_wh => I<Bool> ); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
You can omit these paramators. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
ãã©ã¡ã¼ã¿ã¯æå®ããªãã¦æ§ãã¾ããã |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item price |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
the price of your products will be set. defaults 0. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
ç¨æä¾¡æ ¼ãæå®ãã¦ãã ãããæå®ããªããã°0ã§ãã |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item amount |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
the amount of your products will be set. defaults 1. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
æ°éãæå®ãã¦ãã ãããæå®ããªããã°1ã§ãã |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item date |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
You can set payday. the net of tax and withholding depends on this. default is today. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
æ¯ææ¥ãæå®ãã¦ãã ãããæ¶è²»ç¨é¡ã¨æºæ³å¾´åé¡ãå¤åãã¾ããæå®ããªããã°ä»æ¥ã¨ãã¦è¨ç®ãã¾ãã |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item no_wh |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
If you set this flag, the all you can get is only tax and total. defaults 0 and this is read-only. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
ãã®ãã©ã°ãç«ã¦ãã¨ãã®ã¢ã¸ã¥ã¼ã«ã®é·æãå°ç¡ãã«ã§ãã¾ããåæå¤ã¯ãã¡ãã0ã§ããã¨ããå¤ãããã¨ã¯ã§ãã¾ããã |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=back |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 Methods and subroutine |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=over |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item price |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
You can reset the price. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
price ã«å¤ã代å
¥å¯è½ã§ãã |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item amount |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
You can reset the amount. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
amount ã«å¤ã代å
¥å¯è½ã§ãã |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item date |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
You can reset the payday like 'YYYY-MM-DD' |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
date ã«ãå¤ã代å
¥å¯è½ã§ãããã©ã¼ãããã¯'YYYY-MM-DD'ï¼-åºåãï¼ã§ãã |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item net |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
You can get the net of your pay. it's equal to the price. |
240
|
|
|
|
|
|
|
So it's the alias of price(). |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
net 㯠price ã¨åãåãããã¾ãã |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item subtotal |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
it returns price() * amount() |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
subtotal ã¯å¤ã¨æ°éã®ç©ï¼å°è¨ï¼ãè¿ãã¾ãã |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item tax |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
You can get the net of your tax. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
ç¨é¡ã®ã¿ãåå¾ãããå ´åã¯ãã¡ãã |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item full |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
You can get the net of your pay including tax. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
ç¨è¾¼éé¡ãç¥ãããå ´åã¯ãã¡ãã |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=item withholding |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
You can get the net of your withholding from your pay. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
æºæ³å¾´åé¡ãç¥ãããå ´åã¯ãã¡ãã |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=item total |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
You can get the total of your pay including tax without withholding |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
æºæ³å¾´åé¡ãå·®ãå¼ããç¨è¾¼æ¯æé¡ãç¥ãããå ´åã¯ãã¡ããã使ããã ããã |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=back |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 LICENSE |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Copyright (C) Yuki Yoshida(worthmine). |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
281
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 AUTHOR |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Yuki Yoshida E<lt>worthmine@gmail.comE<gt> |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=cut |