lib/Finance/Tax/Aruba/Role/BBO/TaxYear.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 4 / 4 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 13 / 13 Podpod 100% 9 / 9 totaltotal 100% 72 / 72 CC 6 SCAR 6.9
CC
6
Cov
100%
_customs_sum
4.0
net_payable
3.0
BEGIN
1.0
CRAP 2.0
« lib/Finance/Tax/Aruba/Income/2023.pm ↑ Summary lib/Finance/Tax/Aruba/BBO/2020.pm »
1 package Finance::Tax::Aruba::Role::BBO::TaxYear;
2 8 our $VERSION = '0.015';
3 8 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: A role that implements BBO (turnover tax) logic
6  
7 8 requires qw(
8 is_year
9 );
10  
11 # The 7% is made up of BAZV (3%) and BBO (4%). rate is their sum, and can
12 # be overridden as a whole.
13 8 has bazv_rate => (
14 is => 'ro',
15 isa => 'Num',
16 default => 0.03,
17 );
18  
19 8 has bbo_rate => (
20 is => 'ro',
21 isa => 'Num',
22 default => 0.04,
23 );
24  
25 8 has rate => (
26 is => 'ro',
27 isa => 'Num',
28 lazy => 1,
29 builder => '_build_rate',
30 );
31  
32 12 ▶sub _build_rate {
Subroutine _build_rate: called CC=1 SCAR=0.0
33 12 my $self = shift;
34 12 return sprintf('%.4f', $self->bazv_rate + $self->bbo_rate) + 0;
35 }
36  
37 # Whether import BBO (paid to Customs at the border) is creditable
38 # against domestic BBO owed for this tax year -- see net_payable. This
39 # distinction changed at some point (the rule and/or the rate for
40 # imports specifically), which is the whole reason this is a per-year
41 # plugin the same as Income:: is, rather than one flat rate. Each year
42 # class overrides this via `has '+bbo_at_border' => (default => ...)`.
43 8 has bbo_at_border => (
44 is => 'ro',
45 isa => 'Bool',
46 default => 0,
47 );
48  
49 # Unlike VAT/BTW, BBO isn't added on top of a price -- the amount you
50 # bill a domestic customer already contains the tax you owe on it, so
51 # the tax owed is simply the billed amount times the rate.
52 14 ▶sub domestic_tax {
Subroutine domestic_tax: called CC=1 SCAR=0.0
Pod documented
53 14 my ($self, $amount) = @_;
54 14 return $self->_round($amount * $self->rate);
55 }
56  
57 # The BAZV part of the domestic tax. The BBO part is the remainder, so
58 # the two always add up to domestic_tax.
59 4 ▶sub domestic_tax_bazv {
Subroutine domestic_tax_bazv: called CC=1 SCAR=0.0
Pod documented
60 4 my ($self, $amount) = @_;
61 4 return $self->_round($amount * $self->bazv_rate);
62 }
63  
64 2 ▶sub domestic_tax_bbo {
Subroutine domestic_tax_bbo: called CC=1 SCAR=0.0
Pod documented
65 2 my ($self, $amount) = @_;
66 2 return $self->_round(
67 $self->domestic_tax($amount) - $self->domestic_tax_bazv($amount));
68 }
69  
70 # What you actually keep from a domestic sale once BBO is set aside.
71 1 ▶sub domestic_net {
Subroutine domestic_net: called CC=1 SCAR=0.0
Pod documented
72 1 my ($self, $amount) = @_;
73 1 return $self->_round($amount - $self->domestic_tax($amount));
74 }
75  
76 # BBO paid to Customs on an imported good, at the border, at the same
77 # rate as a domestic sale.
78 2 ▶sub import_tax {
Subroutine import_tax: called CC=1 SCAR=0.0
Pod documented
79 2 my ($self, $amount) = @_;
80 2 return $self->_round($amount * $self->rate);
81 }
82  
83 # A service billed to a client outside Aruba is zero-rated: BBO is a
84 # tax on local turnover, so it doesn't apply "across the border" the
85 # other way either. Kept as its own method (rather than just always
86 # being 0 inline at the call site) so the exemption is a documented,
87 # named rule instead of an implicit absence.
88 2 ▶sub export_tax {
Subroutine export_tax: called CC=1 SCAR=0.0
Pod documented
89 2 return 0;
90 }
91  
92 # Customs invoices the BBO on an import separately. The seller or the
93 # importer pays it. It only offsets domestic BBO when the invoice is held
94 # by the importer (held => 1), e.g. the seller paid and forwarded it.
95 8 ▶sub customs_offset {
Subroutine customs_offset: called CC=1 SCAR=0.0
Pod documented
96 8 my ($self, $invoices) = @_;
97 8 return $self->_round($self->_customs_sum($invoices, 1));
98 }
99  
100 1 ▶sub customs_not_forwarded {
Subroutine customs_not_forwarded: called CC=1 SCAR=0.0
Pod documented
101 1 my ($self, $invoices) = @_;
102 1 return $self->_round($self->_customs_sum($invoices, 0));
103 }
104  
105 9 ▶sub _customs_sum {
Subroutine _customs_sum: called CC=4 SCAR=13.9
106 9 my ($self, $invoices, $held) = @_;
107 9 my $sum = 0;
108 9 ▶ foreach (@{ $invoices // [] }) {
Condition100%2/2
$invoices // []
l!l
72
MC/DC100%1/1
$invoices // []
$invoices
Truth table100%2/2
A
A= $invoices
Aresult
11
00
109 10 ▶ $sum += $_->{amount} if !!$_->{held} == !!$held;
Branch: 1 branch
BranchTrueFalseTotal
if !!$_->{"held"} == !!$held 6 4 10
110 }
111 9 return $sum;
112 }
113  
114 # A negative result is a credit carried forward, not an error. Customs
115 # invoices only offset for a tax year where bbo_at_border is true.
116 8 ▶sub net_payable {
Subroutine net_payable: called CC=3 SCAR=11.0
Pod documented
117 8 my ($self, %args) = @_;
118 8 ▶ my $domestic = $args{domestic} // 0;
Condition100%2/2
$args{"domestic"} // 0
l!l
62
MC/DC100%1/1
$args{"domestic"} // 0
$args{"domestic"}
Truth table100%2/2
A
A= $args{"domestic"}
Aresult
11
00
119  
120 8 my $domestic_tax = $self->domestic_tax($domestic);
121 8 ▶ return $domestic_tax unless $self->bbo_at_border;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->bbo_at_border 1 7 8
122  
123 7 return $self->_round($domestic_tax - $self->customs_offset($args{customs}));
124 }
125  
126 39 ▶sub _round {
Subroutine _round: called CC=1 SCAR=0.0
127 39 my ($self, $amount) = @_;
128 39 return sprintf('%.2f', $amount) + 0;
129 }
130  
131 8 1;
132  
133 __END__
« lib/Finance/Tax/Aruba/Income/2023.pm ↑ Summary lib/Finance/Tax/Aruba/BBO/2020.pm »