[BACK]Return to State.pm CVS log [TXT][DIR] Up to [local] / RT / Invoicing / lib / RTI

Diff for /RT/Invoicing/lib/RTI/State.pm between version 1.4 and 1.7

version 1.4, 2012/01/03 06:23:18 version 1.7, 2012/11/28 02:24:04
Line 7 
Line 7 
 use DateTime;  use DateTime;
 use Carp;  use Carp;
   
 use YAML::Any qw/ LoadFile DumpFile /;  use YAML::XS qw/ LoadFile DumpFile /;
   $YAML::XS::QuoteNumericStrings = 0;
 use RTI::Util qw/ ymd_to_DateTime /;  use RTI::Util qw/ ymd_to_DateTime /;
   
 my $file = '';  my $file = '';
Line 28 
Line 29 
             $invoice->{$_} = ymd_to_DateTime( $invoice->{$_} )              $invoice->{$_} = ymd_to_DateTime( $invoice->{$_} )
                 for qw/ invdate start end /;                  for qw/ invdate start end /;
         }          }
           foreach my $custid (keys %{ $self->{payment} || {} }) {
               foreach my $payment (@{ $self->{payment}->{$custid} || [] }) {
                    $payment->{date} = ymd_to_DateTime( $payment->{date} )
                        if $payment->{date};
               }
           }
     }      }
   
     bless $self, $class;      bless $self, $class;
Line 105 
Line 112 
         : $self->{_table}->{unpaid};          : $self->{_table}->{unpaid};
 }  }
   
   sub credits {
       my ( $self, $custid ) = @_;
   
       $self->_match_payments;
       return defined $custid
           ? $self->{_table}->{credit}->{$custid}
           : $self->{_table}->{credit};
   }
   
 sub save {  sub save {
     my ($self) = @_;      my ($self) = @_;
   
Line 135 
Line 151 
             else {              else {
                 delete $invoice->{$k};                  delete $invoice->{$k};
             }              }
           }
       }
       foreach my $custid (keys %{ $self->{payment} || {} }) {
           foreach my $payment (@{ $self->{payment}->{$custid} || [] }) {
                $payment->{date} = $payment->{date}->ymd
                    if ref $payment->{date} eq 'DateTime';
         }          }
     }      }
     DumpFile( $file, {%$self} ) or die "Unable to save state: $!";      DumpFile( $file, {%$self} ) or die "Unable to save state: $!";

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>