| 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
Condition0%0/3
not defined $orig_value or $new_value ne $orig_value
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 45 | return $self->form_fields_for( | ||||||||||||||||||||||||||||
| 46 | qw/description metadata auto_advance/, | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | ($self->{closed_value_changed} ? qw/closed/ : ()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 52 | 2 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||