| 1 | package Net::KashFlow; | ||||||||||
| 2 | 3 | ▶ | use Carp qw/croak/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use Net::KashFlowAPI; # Autogenerated SOAP::Lite stubs | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 3 | our $VERSION = '0.04'; # VERSION: generated by DZP::OurPkgVersion | |||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 11 | 0 | my ( $self, %args ) = @_; | |||||||||
| 12 | 0 | for (qw/username password/) { | |||||||||
| 13 | 0 | ▶ | croak("You need to pass a '$_'") unless $args{$_}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | } | ||||||||||
| 15 | 0 | bless {%args}, $self; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub _c { | ||||||||
|
Subroutine
_c: not called CC=2 SCAR=17.9
| |||||||||||
| 19 | 0 | my ( $self, $method, @args ) = @_; | |||||||||
| 20 | my ( $result, $status, $explanation ) = | ||||||||||
| 21 | 0 | KashFlowAPI->$method( $self->{username}, $self->{password}, @args ); | |||||||||
| 22 | 0 | ▶ | if ($explanation) { croak($explanation) } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | return $result; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub get_supplier { | ||||||||
|
Subroutine
get_supplier: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 28 | 0 | my ( $self, $thing, $by_id ) = @_; | |||||||||
| 29 | 0 | my $method = "GetSupplier"; | |||||||||
| 30 | 0 | ▶ | if ($by_id) { $method .= "ByID" } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | my $supplier; | |||||||||
| 32 | 0 | eval { $supplier = $self->_c( $method, $thing ) }; | |||||||||
| 33 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | return 0 unless $supplier->{SupplierID}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | $supplier = bless $supplier, "Net::KashFlow::Supplier"; | |||||||||
| 36 | 0 | $supplier->{kf} = $self; | |||||||||
| 37 | 0 | return $supplier; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub get_supplier_by_id { $_[0]->get_supplier( $_[1], 1 ) } | ||||||||
|
Subroutine
get_supplier_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub get_customer { | ||||||||
|
Subroutine
get_customer: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 45 | 0 | my ( $self, $thing, $by_id ) = @_; | |||||||||
| 46 | 0 | my $method = "GetCustomer"; | |||||||||
| 47 | 0 | ▶ | if ( $thing =~ /@/ ) { $method .= "ByEmail" } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | ▶ | if ($by_id) { $method .= "ByID" } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | my $customer; | |||||||||
| 50 | 0 | eval { $customer = $self->_c( $method, $thing ) }; | |||||||||
| 51 | 0 | ▶ | if ( $@ =~ /no customer/ ) { return } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | $customer = bless $customer, "Net::KashFlow::Customer"; | |||||||||
| 54 | 0 | $customer->{kf} = $self; | |||||||||
| 55 | 0 | return $customer; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | sub get_customer_by_id { $_[0]->get_customer( $_[1], 1 ) } | ||||||||
|
Subroutine
get_customer_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 60 | |||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub get_customers { | ||||||||
|
Subroutine
get_customers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 63 | 0 | my $self = shift; | |||||||||
| 64 | return | ||||||||||
| 65 | 0 | map { $_->{kf} = $self; bless $_, "Net::KashFlow::Customer" } | |||||||||
| 66 | 0 | @{ $self->_c("GetCustomers")->{Customer} }; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub create_customer { | ||||||||
|
Subroutine
create_customer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | 0 | my ( $self, $data ) = @_; | |||||||||
| 72 | 0 | my $id = $self->_c( "InsertCustomer", $data ); | |||||||||
| 73 | 0 | return $self->get_customer_by_id($id); | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub get_invoice { | ||||||||
|
Subroutine
get_invoice: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 78 | 0 | my ( $self, $thing, $by_id ) = @_; | |||||||||
| 79 | 0 | my $method = "GetInvoice"; | |||||||||
| 80 | 0 | ▶ | if ($by_id) { $method .= "ByID" } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | my $invoice; | |||||||||
| 82 | 0 | eval { $invoice = $self->_c( $method, $thing ) }; | |||||||||
| 83 | 0 | ▶ | if ( $@ =~ /no invoice/ ) { return } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | ▶ | return unless $invoice->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | 0 | $invoice = bless $invoice, "Net::KashFlow::Invoice"; | |||||||||
| 87 | 0 | $invoice->{kf} = $self; | |||||||||
| 88 | 0 | $invoice->{Lines} = bless $invoice->{Lines}, "InvoiceLineSet"; # Urgh | |||||||||
| 89 | 0 | return $invoice; | |||||||||
| 90 | } | ||||||||||
| 91 | 0 | ▶ | sub get_invoice_by_id { $_[0]->get_invoice( $_[1], 1 ) } | ||||||||
|
Subroutine
get_invoice_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | 0 | ▶ | sub get_invoice_pdf { | ||||||||
|
Subroutine
get_invoice_pdf: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 95 | 0 | my ( $self, $id ) = @_; | |||||||||
| 96 | 0 | my $i = $self->get_invoice($id); | |||||||||
| 97 | 0 | ▶ | return unless $i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | 0 | my $uri = undef; | |||||||||
| 99 | 0 | eval { $uri = $self->_c( "PrintInvoice", $id ) }; | |||||||||
| 100 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | 0 | return $uri; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | sub get_invoice_paypal_link { | ||||||||
|
Subroutine
get_invoice_paypal_link: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 106 | 0 | my ( $self, $id ) = @_; | |||||||||
| 107 | 0 | my $i = $self->get_invoice($id); | |||||||||
| 108 | 0 | ▶ | return unless $i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | 0 | my $uri = undef; | |||||||||
| 110 | 0 | eval { $uri = $self->_c( "GetPaypalLink", $id ) }; | |||||||||
| 111 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | 0 | return $uri; | |||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | |||||||||||
| 116 | 0 | ▶ | sub get_overdue_invoices { | ||||||||
|
Subroutine
get_overdue_invoices: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 117 | 0 | my ($self) = @_; | |||||||||
| 118 | 0 | my $invoices = undef; | |||||||||
| 119 | 0 | eval { $invoices = $self->_c("GetInvoices_Overdue") }; | |||||||||
| 120 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | 0 | my @invoices = (); | |||||||||
| 122 | 0 | ▶ | if ( ref $invoices->{Invoice} eq 'ARRAY' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 123 | 0 | for my $i ( @{ $invoices->{Invoice} } ) { | |||||||||
| 124 | 0 | $i = bless $i, "Net::KashFlow::Invoice"; | |||||||||
| 125 | 0 | $i->{kf} = $self; | |||||||||
| 126 | 0 | $i->{Lines} = bless $i->{Lines}, "InvoiceLineSet"; | |||||||||
| 127 | 0 | push @invoices, $i; | |||||||||
| 128 | } | ||||||||||
| 129 | } | ||||||||||
| 130 | else { | ||||||||||
| 131 | 0 | my $i = $invoices->{Invoice}; | |||||||||
| 132 | 0 | ▶ | return unless $i->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 133 | 0 | $i = bless $i, "Net::KashFlow::Invoice"; | |||||||||
| 134 | 0 | $i->{kf} = $self; | |||||||||
| 135 | 0 | $i->{Lines} = bless $i->{Lines}, "InvoiceLineSet"; | |||||||||
| 136 | 0 | push @invoices, $i; | |||||||||
| 137 | } | ||||||||||
| 138 | 0 | return @invoices; | |||||||||
| 139 | } | ||||||||||
| 140 | |||||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | sub get_unpaid_invoices { | ||||||||
|
Subroutine
get_unpaid_invoices: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 143 | 0 | my ($self) = @_; | |||||||||
| 144 | 0 | my $invoices = undef; | |||||||||
| 145 | 0 | eval { $invoices = $self->_c("GetInvoices_Unpaid") }; | |||||||||
| 146 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 147 | 0 | my @invoices = (); | |||||||||
| 148 | 0 | ▶ | if ( ref $invoices->{Invoice} eq 'ARRAY' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 149 | 0 | for my $i ( @{ $invoices->{Invoice} } ) { | |||||||||
| 150 | 0 | $i = bless $i, "Net::KashFlow::Invoice"; | |||||||||
| 151 | 0 | $i->{kf} = $self; | |||||||||
| 152 | 0 | $i->{Lines} = bless $i->{Lines}, "InvoiceLineSet"; | |||||||||
| 153 | 0 | push @invoices, $i; | |||||||||
| 154 | } | ||||||||||
| 155 | } | ||||||||||
| 156 | else { | ||||||||||
| 157 | 0 | my $i = $invoices->{Invoice}; | |||||||||
| 158 | 0 | ▶ | return unless $i->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 159 | 0 | $i = bless $i, "Net::KashFlow::Invoice"; | |||||||||
| 160 | 0 | $i->{kf} = $self; | |||||||||
| 161 | 0 | $i->{Lines} = bless $i->{Lines}, "InvoiceLineSet"; | |||||||||
| 162 | 0 | push @invoices, $i; | |||||||||
| 163 | } | ||||||||||
| 164 | 0 | return @invoices; | |||||||||
| 165 | } | ||||||||||
| 166 | |||||||||||
| 167 | |||||||||||
| 168 | 0 | ▶ | sub get_invoices_for_customer { | ||||||||
|
Subroutine
get_invoices_for_customer: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 169 | 0 | my ( $self, $customer ) = @_; | |||||||||
| 170 | 0 | my $c = $self->get_customer_by_id($customer); | |||||||||
| 171 | 0 | ▶ | die "No such customer" unless $c; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 172 | 0 | my $invoices = (); | |||||||||
| 173 | 0 | eval { $invoices = $self->_c( "GetInvoicesForCustomer", $customer ) }; | |||||||||
| 174 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 175 | 0 | my @invoices = (); | |||||||||
| 176 | 0 | ▶ | if ( ref $invoices->{Invoice} eq 'ARRAY' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | |||||||||||
| 178 | 0 | for my $i ( @{ $invoices->{Invoice} } ) { | |||||||||
| 179 | 0 | $i = bless $i, "Net::KashFlow::Invoice"; | |||||||||
| 180 | 0 | $i->{kf} = $self; | |||||||||
| 181 | 0 | $i->{Lines} = bless $i->{Lines}, "InvoiceLineSet"; | |||||||||
| 182 | 0 | push @invoices, $i; | |||||||||
| 183 | } | ||||||||||
| 184 | } | ||||||||||
| 185 | else { | ||||||||||
| 186 | 0 | my $i = $invoices->{Invoice}; | |||||||||
| 187 | 0 | ▶ | return unless $i->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 188 | 0 | $i = bless $i, "Net::KashFlow::Invoice"; | |||||||||
| 189 | 0 | $i->{kf} = $self; | |||||||||
| 190 | 0 | $i->{Lines} = bless $i->{Lines}, "InvoiceLineSet"; | |||||||||
| 191 | 0 | push @invoices, $i; | |||||||||
| 192 | } | ||||||||||
| 193 | 0 | return @invoices; | |||||||||
| 194 | } | ||||||||||
| 195 | |||||||||||
| 196 | |||||||||||
| 197 | 0 | ▶ | sub create_invoice { | ||||||||
|
Subroutine
create_invoice: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 198 | 0 | my ( $self, $data ) = @_; | |||||||||
| 199 | 0 | my $id = $self->_c( "InsertInvoice", $data ); | |||||||||
| 200 | 0 | return $self->get_invoice($id); | |||||||||
| 201 | } | ||||||||||
| 202 | |||||||||||
| 203 | |||||||||||
| 204 | 0 | ▶ | sub delete_invoice { | ||||||||
|
Subroutine
delete_invoice: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 205 | 0 | my ( $self, $data ) = @_; | |||||||||
| 206 | 0 | my $invoice = $self->get_invoice($data); | |||||||||
| 207 | 0 | ▶ | return 0 if !$invoice; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 208 | 0 | eval { $self->_c( "DeleteInvoice", $data ) }; | |||||||||
| 209 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 210 | 0 | $invoice = undef; | |||||||||
| 211 | 0 | $invoice = $self->get_invoice($data); | |||||||||
| 212 | 0 | ▶ | return 0 if $invoice->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 213 | 0 | return 1; | |||||||||
| 214 | } | ||||||||||
| 215 | |||||||||||
| 216 | |||||||||||
| 217 | 0 | ▶ | sub get_receipt { | ||||||||
|
Subroutine
get_receipt: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 218 | 0 | my ( $self, $thing, $by_id ) = @_; | |||||||||
| 219 | 0 | my $method = "GetReceipt"; | |||||||||
| 220 | 0 | ▶ | if ($by_id) { $method .= "ByID" } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 221 | 0 | my $receipt; | |||||||||
| 222 | 0 | eval { $receipt = $self->_c( $method, $thing ) }; | |||||||||
| 223 | 0 | ▶ | if ( $@ =~ /no receipt/ ) { return } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 224 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 225 | 0 | ▶ | return unless $receipt->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 226 | 0 | $receipt = bless $receipt, "Net::KashFlow::Receipt"; | |||||||||
| 227 | 0 | $receipt->{kf} = $self; | |||||||||
| 228 | 0 | $receipt->{Lines} = bless $receipt->{Lines}, "InvoiceLineSet"; # Urgh | |||||||||
| 229 | 0 | return $receipt; | |||||||||
| 230 | } | ||||||||||
| 231 | |||||||||||
| 232 | |||||||||||
| 233 | 0 | ▶ | sub get_receipt_by_id { $_[0]->get_receipt( $_[1], 1 ) } | ||||||||
|
Subroutine
get_receipt_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 234 | |||||||||||
| 235 | |||||||||||
| 236 | 0 | ▶ | sub get_receipts_for_supplier { | ||||||||
|
Subroutine
get_receipts_for_supplier: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 237 | 0 | my ( $self, $id ) = @_; | |||||||||
| 238 | 0 | my $s = $self->get_supplier_by_id($id); | |||||||||
| 239 | 0 | ▶ | die "No such supplier" unless $s; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 240 | 0 | my $rs = (); | |||||||||
| 241 | 0 | eval { $rs = $self->_c( "GetReceiptsForSupplier", $s->SupplierID ) }; | |||||||||
| 242 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 243 | 0 | my @rs = (); | |||||||||
| 244 | 0 | ▶ | if ( ref $rs->{Invoice} eq 'ARRAY' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 245 | |||||||||||
| 246 | 0 | for my $r ( @{ $rs->{Invoice} } ) { | |||||||||
| 247 | 0 | $r = bless $r, "Net::KashFlow::Receipt"; | |||||||||
| 248 | 0 | $r->{kf} = $self; | |||||||||
| 249 | 0 | $r->{Lines} = bless $r->{Lines}, "InvoiceLineSet"; | |||||||||
| 250 | 0 | push @rs, $r; | |||||||||
| 251 | } | ||||||||||
| 252 | } | ||||||||||
| 253 | else { | ||||||||||
| 254 | 0 | my $r = $rs->{Invoice}; | |||||||||
| 255 | 0 | ▶ | return unless $r->{InvoiceNumber}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 256 | 0 | $r = bless $r, "Net::KashFlow::Receipt"; | |||||||||
| 257 | 0 | $r->{kf} = $self; | |||||||||
| 258 | 0 | $r->{Lines} = bless $r->{Lines}, "InvoiceLineSet"; | |||||||||
| 259 | 0 | push @rs, $r; | |||||||||
| 260 | } | ||||||||||
| 261 | 0 | return @rs; | |||||||||
| 262 | } | ||||||||||
| 263 | |||||||||||
| 264 | |||||||||||
| 265 | 0 | ▶ | sub create_receipt { | ||||||||
|
Subroutine
create_receipt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 266 | 0 | my ( $self, $data ) = @_; | |||||||||
| 267 | 0 | my $id = $self->_c( "InsertReceipt", $data ); | |||||||||
| 268 | 0 | return $self->get_receipt($id); | |||||||||
| 269 | } | ||||||||||
| 270 | |||||||||||
| 271 | |||||||||||
| 272 | 0 | ▶ | sub get_invoice_payment { | ||||||||
|
Subroutine
get_invoice_payment: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 273 | 0 | my ( $self, $data ) = @_; | |||||||||
| 274 | 0 | my $payment; | |||||||||
| 275 | 0 | eval { $payment = $self->_c( "GetInvoicePayment", $data ) }; | |||||||||
| 276 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 277 | 0 | ▶ | return unless $payment->{Payment}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 278 | 0 | $payment = bless $payment->{Payment}, "Net::KashFlow::Payment"; | |||||||||
| 279 | 0 | $payment->{kf} = $self; | |||||||||
| 280 | 0 | return $payment; | |||||||||
| 281 | } | ||||||||||
| 282 | |||||||||||
| 283 | |||||||||||
| 284 | 0 | ▶ | sub delete_invoice_payment { | ||||||||
|
Subroutine
delete_invoice_payment: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 285 | 0 | my ( $self, $data ) = @_; | |||||||||
| 286 | 0 | eval { $self->_c( "DeleteInvoicePayment", $data ) }; | |||||||||
| 287 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 288 | 0 | return 1; | |||||||||
| 289 | } | ||||||||||
| 290 | |||||||||||
| 291 | |||||||||||
| 292 | 0 | ▶ | sub get_vat_rates { | ||||||||
|
Subroutine
get_vat_rates: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 293 | 0 | my $self = shift; | |||||||||
| 294 | 0 | my $rates; | |||||||||
| 295 | 0 | eval { $rates = $self->_c("GetVATRates") }; | |||||||||
| 296 | 0 | ▶ | die $@ . "\n" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 297 | |||||||||||
| 298 | 0 | my @rates; | |||||||||
| 299 | |||||||||||
| 300 | 0 | ▶ | if ( ref $rates->{BasicDataset} eq 'ARRAY' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 301 | 0 | for my $r ( @{ $rates->{BasicDataset} } ) { | |||||||||
| 302 | 0 | push @rates, $r->{Value}; | |||||||||
| 303 | } | ||||||||||
| 304 | } | ||||||||||
| 305 | else { | ||||||||||
| 306 | 0 | push @rates, $rates->{BasicDataset}->{Value}; | |||||||||
| 307 | } | ||||||||||
| 308 | 0 | return @rates; | |||||||||
| 309 | } | ||||||||||
| 310 | |||||||||||
| 311 | package Net::KashFlow::Base; | ||||||||||
| 312 | 3 | ▶ | use base 'Class::Accessor'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 313 | |||||||||||
| 314 | 0 | ▶ | sub update { | ||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
| |||||||||||
| 315 | 0 | my $self = shift; | |||||||||
| 316 | 0 | my $copy = {%$self}; | |||||||||
| 317 | 0 | delete $copy->{kf}; | |||||||||
| 318 | 0 | $self->{kf}->_c( "Update" . $self->_this(), $copy ); | |||||||||
| 319 | } | ||||||||||
| 320 | |||||||||||
| 321 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
| |||||||||||
| 322 | 0 | my $self = shift; | |||||||||
| 323 | 0 | my $copy = {%$self}; | |||||||||
| 324 | 0 | delete $copy->{kf}; | |||||||||
| 325 | 0 | $self->{kf}->_c( "Delete" . $self->_this(), $copy ); | |||||||||
| 326 | } | ||||||||||
| 327 | |||||||||||
| 328 | package Net::KashFlow::Customer; | ||||||||||
| 329 | |||||||||||
| 330 | |||||||||||
| 331 | 3 | ▶ | use base 'Net::KashFlow::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 332 | 3 | __PACKAGE__->mk_accessors( | |||||||||
| 333 | qw( | ||||||||||
| 334 | CustomerID Code Name Contact Telephone Mobile Fax Email Address1 Address2 | ||||||||||
| 335 | Address3 Address4 Postcode Website EC OutsideEC Notes Source Discount | ||||||||||
| 336 | ShowDiscount PaymentTerms ExtraText1 ExtraText2 ExtraText3 ExtraText4 | ||||||||||
| 337 | ExtraText5 ExtraText6 ExtraText7 ExtraText8 ExtraText9 ExtraText10 ExtraText11 | ||||||||||
| 338 | ExtraText12 ExtraText13 ExtraText14 ExtraText15 ExtraText16 ExtraText17 | ||||||||||
| 339 | ExtraText18 ExtraText19 ExtraText20 CheckBox1 CheckBox2 CheckBox3 CheckBox4 | ||||||||||
| 340 | CheckBox5 CheckBox6 CheckBox7 CheckBox8 CheckBox9 CheckBox10 CheckBox11 | ||||||||||
| 341 | CheckBox12 CheckBox13 CheckBox14 CheckBox15 CheckBox16 CheckBox17 CheckBox18 | ||||||||||
| 342 | CheckBox19 CheckBox20 Created Updated CurrencyID ContactTitle ContactFirstName | ||||||||||
| 343 | ContactLastName CustHasDeliveryAddress DeliveryAddress1 DeliveryAddress2 | ||||||||||
| 344 | DeliveryAddress3 DeliveryAddress4 DeliveryPostcode | ||||||||||
| 345 | ) | ||||||||||
| 346 | ); | ||||||||||
| 347 | 0 | ▶ | sub _this { "Customer" } | ||||||||
|
Subroutine
_this: not called CC=1 SCAR=6.9
| |||||||||||
| 348 | |||||||||||
| 349 | 0 | ▶ | sub invoices { | ||||||||
|
Subroutine
invoices: not called CC=1 SCAR=6.9
| |||||||||||
| 350 | 0 | my $self = shift; | |||||||||
| 351 | return map { | ||||||||||
| 352 | 0 | $_->{kf} = $self->{kf}; | |||||||||
| 353 | 0 | $_->{Lines} = bless $_->{Lines}, "InvoiceLineSet"; # Urgh | |||||||||
| 354 | 0 | bless $_, "Net::KashFlow::Invoice" | |||||||||
| 355 | 0 | } @{ $self->{kf}->_c( "GetInvoicesForCustomer", $self->CustomerID ) | |||||||||
| 356 | 0 | ->{Invoice} }; | |||||||||
| 357 | } | ||||||||||
| 358 | |||||||||||
| 359 | package Net::KashFlow::Invoice; | ||||||||||
| 360 | 3 | ▶ | use base 'Net::KashFlow::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 361 | 0 | ▶ | sub _this { "Invoice" } | ||||||||
|
Subroutine
_this: not called CC=1 SCAR=6.9
| |||||||||||
| 362 | 3 | __PACKAGE__->mk_accessors( | |||||||||
| 363 | qw/ | ||||||||||
| 364 | DueDate NetAmount ProjectID Lines CustomerReference InvoiceDate InvoiceNumber | ||||||||||
| 365 | SuppressTotal CustomerID Customer CurrencyCode ReadableString ExchangeRate | ||||||||||
| 366 | VATAmount AmountPaid Paid InvoiceDBID EstimateCategory NetAmount | ||||||||||
| 367 | / | ||||||||||
| 368 | ); | ||||||||||
| 369 | |||||||||||
| 370 | |||||||||||
| 371 | 0 | ▶ | sub add_line { | ||||||||
|
Subroutine
add_line: not called CC=1 SCAR=6.9
| |||||||||||
| 372 | 0 | my ( $self, $data ) = @_; | |||||||||
| 373 | 0 | $self->{kf}->_c( "InsertInvoiceLine", $self->InvoiceDBID, $data ); | |||||||||
| 374 | } | ||||||||||
| 375 | |||||||||||
| 376 | 0 | ▶ | sub pay { | ||||||||
|
Subroutine
pay: not called CC=1 SCAR=6.9
| |||||||||||
| 377 | 0 | my ( $self, $data ) = @_; | |||||||||
| 378 | 0 | $data->{PayInvoice} = $self->{InvoiceNumber}; | |||||||||
| 379 | 0 | $self->{kf}->_c( "InsertInvoicePayment", $data ); | |||||||||
| 380 | } | ||||||||||
| 381 | |||||||||||
| 382 | 0 | ▶ | sub email { | ||||||||
|
Subroutine
email: not called CC=3 SCAR=24.8
| |||||||||||
| 383 | 0 | my ( $self, $data ) = @_; | |||||||||
| 384 | 0 | $data->{InvoiceNumber} = $self->{InvoiceNumber}; | |||||||||
| 385 | 0 | for (qw/FromEmail FromName SubjectLine Body RecipientEmail/) { | |||||||||
| 386 | 0 | ▶ | die "You must supply the $_ parameter" unless $data->{$_}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 387 | } | ||||||||||
| 388 | 0 | $self->{kf}->_c( "EmailInvoice", $data ); | |||||||||
| 389 | } | ||||||||||
| 390 | |||||||||||
| 391 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
| |||||||||||
| 392 | 0 | my ( $self, $data ) = @_; | |||||||||
| 393 | 0 | $data->{InvoiceNumber} = $self->{InvoiceNumber}; | |||||||||
| 394 | 0 | $self->{kf}->_c( "DeleteInvoice", $data ); | |||||||||
| 395 | } | ||||||||||
| 396 | |||||||||||
| 397 | package Net::KashFlow::Receipt; | ||||||||||
| 398 | 3 | ▶ | use base 'Net::KashFlow::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 399 | 0 | ▶ | sub _this { "Receipt" } | ||||||||
|
Subroutine
_this: not called CC=1 SCAR=6.9
| |||||||||||
| 400 | 3 | __PACKAGE__->mk_accessors( | |||||||||
| 401 | qw/ | ||||||||||
| 402 | InvoiceDBID InvoiceNumber InvoiceDate DueDate Paid CustomerID | ||||||||||
| 403 | CustomerReference NetAmount VatAmount AmountPaid Lines | ||||||||||
| 404 | / | ||||||||||
| 405 | ); | ||||||||||
| 406 | |||||||||||
| 407 | |||||||||||
| 408 | 0 | ▶ | sub add_line { | ||||||||
|
Subroutine
add_line: not called CC=1 SCAR=6.9
| |||||||||||
| 409 | 0 | my ( $self, $data ) = @_; | |||||||||
| 410 | 0 | $self->{kf}->_c( "InsertReceiptLine", $self->InvoiceDBID, $data ); | |||||||||
| 411 | } | ||||||||||
| 412 | |||||||||||
| 413 | 0 | ▶ | sub delete_line { | ||||||||
|
Subroutine
delete_line: not called CC=1 SCAR=6.9
| |||||||||||
| 414 | 0 | my ( $self, $id ) = @_; | |||||||||
| 415 | 0 | $self->{kf}->_c( "DeleteReceiptLine", $id, $self->{InvoiceNumber} ); | |||||||||
| 416 | } | ||||||||||
| 417 | |||||||||||
| 418 | 0 | ▶ | sub pay { | ||||||||
|
Subroutine
pay: not called CC=1 SCAR=6.9
| |||||||||||
| 419 | 0 | my ( $self, $data ) = @_; | |||||||||
| 420 | 0 | $data->{PayInvoice} = $self->{InvoiceNumber}; | |||||||||
| 421 | 0 | $self->{kf}->_c( "InsertReceiptPayment", $data ); | |||||||||
| 422 | } | ||||||||||
| 423 | |||||||||||
| 424 | package Net::KashFlow::Payment; | ||||||||||
| 425 | 3 | ▶ | use base 'Net::KashFlow::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 426 | 0 | ▶ | sub _this { "Payment" } | ||||||||
|
Subroutine
_this: not called CC=1 SCAR=6.9
| |||||||||||
| 427 | 3 | __PACKAGE__->mk_accessors( | |||||||||
| 428 | qw/ | ||||||||||
| 429 | PayID PayInvoice PayDate PayNote PayMethod PayAccount PayAmount | ||||||||||
| 430 | / | ||||||||||
| 431 | ); | ||||||||||
| 432 | |||||||||||
| 433 | |||||||||||
| 434 | package Net::KashFlow::Supplier; | ||||||||||
| 435 | 3 | ▶ | use base 'Net::KashFlow::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 436 | 0 | ▶ | sub _this { "Supplier" } | ||||||||
|
Subroutine
_this: not called CC=1 SCAR=6.9
| |||||||||||
| 437 | 3 | __PACKAGE__->mk_accessors(qw/SupplierID Code/); | |||||||||
| 438 | |||||||||||
| 439 | |||||||||||
| 440 | 3 | 1; # End of Net::KashFlow | |||||||||
| 441 | |||||||||||
| 442 | __END__ | ||||||||||