Stripe/Invoice.pm

filter: Statementstmt 84.0% 37 / 44 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 3 / 5 Podpod n/a totaltotal 66.6% 40 / 60 CC 5 SCAR 18.1
CC
5
Cov
70%
_closed_change_detector
12.0
form_fields
5.3
BEGIN
1.1
CRAP 6.1
« Stripe/Resource.pm ↑ Summary Stripe/List.pm »
1 package Net::Stripe::Invoice;
2 2 $Net::Stripe::Invoice::VERSION = '0.43';
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Kavorka;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 extends 'Net::Stripe::Resource';
6  
7 # ABSTRACT: represent an Invoice object from Stripe
8  
9 2 has 'id' => ( is => 'ro', isa => 'Maybe[Str]' );
10 2 has 'created' => ( is => 'ro', isa => 'Maybe[Int]' );
11 2 has 'subtotal' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
12 2 has 'amount_due' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
13 2 has 'attempt_count' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
14 2 has 'attempted' => ( is => 'ro', isa => 'Maybe[Bool|Object]', required => 1 );
15 2 has 'closed' => ( is => 'ro', isa => 'Maybe[Bool|Object]', trigger => \&_closed_change_detector);
16 2 has 'auto_advance' => ( is => 'ro', isa => 'Maybe[Bool]');
17 2 has 'created' => ( is => 'ro', isa => 'Maybe[Int]' );
18 2 has 'customer' => ( is => 'ro', isa => 'Maybe[Str]', required => 1 );
19 2 has 'date' => ( is => 'ro', isa => 'Maybe[Str]' );
20 2 has 'lines' => ( is => 'ro', isa => 'Net::Stripe::List', required => 1 );
21 2 has 'paid' => ( is => 'ro', isa => 'Maybe[Bool|Object]', required => 1 );
22 2 has 'period_end' => ( is => 'ro', isa => 'Maybe[Int]' );
23 2 has 'period_start' => ( is => 'ro', isa => 'Maybe[Int]' );
24 2 has 'starting_balance' => ( is => 'ro', isa => 'Maybe[Int]' );
25 2 has 'subtotal' => ( is => 'ro', isa => 'Maybe[Int]' );
26 2 has 'total' => ( is => 'ro', isa => 'Maybe[Int]', required => 1 );
27 2 has 'charge' => ( is => 'ro', isa => 'Maybe[Str]' );
28 2 has 'ending_balance' => ( is => 'ro', isa => 'Maybe[Int]' );
29 2 has 'next_payment_attempt' => ( is => 'ro', isa => 'Maybe[Int]' );
30 2 has 'metadata' => ( is => 'rw', isa => 'HashRef');
31 2 has 'description' => (is => 'rw', isa => 'Maybe[Str]');
32  
33 0 ▶sub _closed_change_detector {
Subroutine _closed_change_detector: not called CC=3 SCAR=24.8
34 0 my ($instance, $new_value, $orig_value) = @_;
35 # Strip can update invoices but only wants to see the closed flag if it has been changed.
36 # Meaning if you retrieve an invoice then try to update it, and it is already closed
37 # it will reject the update.
38 0 ▶ if (!defined($orig_value) || $new_value ne $orig_value) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $orig_value or $new_value ne $orig_value) 0 0 0
Condition0%0/3
not defined $orig_value or $new_value ne $orig_value
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $orig_value or $new_value ne $orig_value
not defined $orig_value $new_value ne $orig_value
Truth table0%0/3
not(A) or B
A= not defined $orig_valueB= $new_value ne $orig_value
ABresult
1X1
011
000
39 0 $instance->{closed_value_changed} = 1;
40 }
41 0 return;
42 }
43  
44 0 ▶method form_fields {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine form_fields: not called CC=3 SCAR=16.7
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
45 return $self->form_fields_for(
46 qw/description metadata auto_advance/,
47 0 ▶ ($self->{closed_value_changed} ? qw/closed/ : ())
Branch: 1 branch
BranchTrueFalseTotal
$self->{'closed_value_changed'} ? : 0 0 0
48 );
49 }
50  
51 2 __PACKAGE__->meta->make_immutable;
52 2 1;
53  
54 __END__
« Stripe/Resource.pm ↑ Summary Stripe/List.pm »