voip: add start time for calls to invoice details
[freeside.git] / FS / FS / part_pkg.pm
1 package FS::part_pkg;
2
3 use strict;
4 use vars qw( @ISA %freq %plans $DEBUG );
5 use Carp qw(carp cluck);
6 use Tie::IxHash;
7 use FS::Conf;
8 use FS::Record qw( qsearch qsearchs dbh dbdef );
9 use FS::pkg_svc;
10 use FS::part_svc;
11 use FS::cust_pkg;
12 use FS::agent_type;
13 use FS::type_pkgs;
14 use FS::part_pkg_option;
15
16 @ISA = qw( FS::Record );
17
18 $DEBUG = 0;
19
20 =head1 NAME
21
22 FS::part_pkg - Object methods for part_pkg objects
23
24 =head1 SYNOPSIS
25
26   use FS::part_pkg;
27
28   $record = new FS::part_pkg \%hash
29   $record = new FS::part_pkg { 'column' => 'value' };
30
31   $custom_record = $template_record->clone;
32
33   $error = $record->insert;
34
35   $error = $new_record->replace($old_record);
36
37   $error = $record->delete;
38
39   $error = $record->check;
40
41   @pkg_svc = $record->pkg_svc;
42
43   $svcnum = $record->svcpart;
44   $svcnum = $record->svcpart( 'svc_acct' );
45
46 =head1 DESCRIPTION
47
48 An FS::part_pkg object represents a package definition.  FS::part_pkg
49 inherits from FS::Record.  The following fields are currently supported:
50
51 =over 4
52
53 =item pkgpart - primary key (assigned automatically for new package definitions)
54
55 =item pkg - Text name of this package definition (customer-viewable)
56
57 =item comment - Text name of this package definition (non-customer-viewable)
58
59 =item promo_code - Promotional code
60
61 =item setup - Setup fee expression (deprecated)
62
63 =item freq - Frequency of recurring fee
64
65 =item recur - Recurring fee expression (deprecated)
66
67 =item setuptax - Setup fee tax exempt flag, empty or `Y'
68
69 =item recurtax - Recurring fee tax exempt flag, empty or `Y'
70
71 =item taxclass - Tax class 
72
73 =item plan - Price plan
74
75 =item plandata - Price plan data (deprecated - see L<FS::part_pkg_option> instead)
76
77 =item disabled - Disabled flag, empty or `Y'
78
79 =back
80
81 =head1 METHODS
82
83 =over 4 
84
85 =item new HASHREF
86
87 Creates a new package definition.  To add the package definition to
88 the database, see L<"insert">.
89
90 =cut
91
92 sub table { 'part_pkg'; }
93
94 =item clone
95
96 An alternate constructor.  Creates a new package definition by duplicating
97 an existing definition.  A new pkgpart is assigned and `(CUSTOM) ' is prepended
98 to the comment field.  To add the package definition to the database, see
99 L<"insert">.
100
101 =cut
102
103 sub clone {
104   my $self = shift;
105   my $class = ref($self);
106   my %hash = $self->hash;
107   $hash{'pkgpart'} = '';
108   $hash{'comment'} = "(CUSTOM) ". $hash{'comment'}
109     unless $hash{'comment'} =~ /^\(CUSTOM\) /;
110   #new FS::part_pkg ( \%hash ); # ?
111   new $class ( \%hash ); # ?
112 }
113
114 =item insert [ , OPTION => VALUE ... ]
115
116 Adds this package definition to the database.  If there is an error,
117 returns the error, otherwise returns false.
118
119 Currently available options are: I<pkg_svc>, I<primary_svc>, I<cust_pkg>, 
120 I<custnum_ref> and I<options>.
121
122 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
123 values, appropriate FS::pkg_svc records will be inserted.
124
125 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
126 FS::pkg_svc record will be updated.
127
128 If I<cust_pkg> is set to a pkgnum of a FS::cust_pkg record (or the FS::cust_pkg
129 record itself), the object will be updated to point to this package definition.
130
131 In conjunction with I<cust_pkg>, if I<custnum_ref> is set to a scalar reference,
132 the scalar will be updated with the custnum value from the cust_pkg record.
133
134 If I<options> is set to a hashref of options, appropriate FS::part_pkg_option
135 records will be inserted.
136
137 =cut
138
139 sub insert {
140   my $self = shift;
141   my %options = @_;
142   warn "FS::part_pkg::insert called on $self with options ".
143        join(', ', map "$_=>$options{$_}", keys %options)
144     if $DEBUG;
145
146   local $SIG{HUP} = 'IGNORE';
147   local $SIG{INT} = 'IGNORE';
148   local $SIG{QUIT} = 'IGNORE';
149   local $SIG{TERM} = 'IGNORE';
150   local $SIG{TSTP} = 'IGNORE';
151   local $SIG{PIPE} = 'IGNORE';
152
153   my $oldAutoCommit = $FS::UID::AutoCommit;
154   local $FS::UID::AutoCommit = 0;
155   my $dbh = dbh;
156
157   warn "  saving legacy plandata" if $DEBUG;
158   my $plandata = $self->get('plandata');
159   $self->set('plandata', '');
160
161   warn "  inserting part_pkg record" if $DEBUG;
162   my $error = $self->SUPER::insert;
163   if ( $error ) {
164     $dbh->rollback if $oldAutoCommit;
165     return $error;
166   }
167
168   if ( $plandata ) {
169
170     warn "  inserting part_pkg_option records for plandata" if $DEBUG;
171     foreach my $part_pkg_option ( 
172       map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
173                                    return "illegal plandata: $plandata";
174                                  };
175             new FS::part_pkg_option {
176               'pkgpart'     => $self->pkgpart,
177               'optionname'  => $1,
178               'optionvalue' => $2,
179             };
180           }
181       split("\n", $plandata)
182     ) {
183       my $error = $part_pkg_option->insert;
184       if ( $error ) {
185         $dbh->rollback if $oldAutoCommit;
186         return $error;
187       }
188     }
189
190   } elsif ( $options{'options'} ) {
191
192     warn "  inserting part_pkg_option records for options hashref" if $DEBUG;
193     foreach my $optionname ( keys %{$options{'options'}} ) {
194
195       my $part_pkg_option =
196         new FS::part_pkg_option {
197           'pkgpart'     => $self->pkgpart,
198           'optionname'  => $optionname,
199           'optionvalue' => $options{'options'}->{$optionname},
200         };
201
202       my $error = $part_pkg_option->insert;
203       if ( $error ) {
204         $dbh->rollback if $oldAutoCommit;
205         return $error;
206       }
207
208     }
209
210   }
211
212   my $conf = new FS::Conf;
213   if ( $conf->exists('agent_defaultpkg') ) {
214     warn "  agent_defaultpkg set; allowing all agents to purchase package"
215       if $DEBUG;
216     foreach my $agent_type ( qsearch('agent_type', {} ) ) {
217       my $type_pkgs = new FS::type_pkgs({
218         'typenum' => $agent_type->typenum,
219         'pkgpart' => $self->pkgpart,
220       });
221       my $error = $type_pkgs->insert;
222       if ( $error ) {
223         $dbh->rollback if $oldAutoCommit;
224         return $error;
225       }
226     }
227   }
228
229   warn "  inserting pkg_svc records" if $DEBUG;
230   my $pkg_svc = $options{'pkg_svc'} || {};
231   foreach my $part_svc ( qsearch('part_svc', {} ) ) {
232     my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
233     my $primary_svc = $options{'primary_svc'} == $part_svc->svcpart ? 'Y' : '';
234
235     my $pkg_svc = new FS::pkg_svc( {
236       'pkgpart'     => $self->pkgpart,
237       'svcpart'     => $part_svc->svcpart,
238       'quantity'    => $quantity, 
239       'primary_svc' => $primary_svc,
240     } );
241     my $error = $pkg_svc->insert;
242     if ( $error ) {
243       $dbh->rollback if $oldAutoCommit;
244       return $error;
245     }
246   }
247
248   if ( $options{'cust_pkg'} ) {
249     warn "  updating cust_pkg record " if $DEBUG;
250     my $old_cust_pkg =
251       ref($options{'cust_pkg'})
252         ? $options{'cust_pkg'}
253         : qsearchs('cust_pkg', { pkgnum => $options{'cust_pkg'} } );
254     ${ $options{'custnum_ref'} } = $old_cust_pkg->custnum
255       if $options{'custnum_ref'};
256     my %hash = $old_cust_pkg->hash;
257     $hash{'pkgpart'} = $self->pkgpart,
258     my $new_cust_pkg = new FS::cust_pkg \%hash;
259     local($FS::cust_pkg::disable_agentcheck) = 1;
260     my $error = $new_cust_pkg->replace($old_cust_pkg);
261     if ( $error ) {
262       $dbh->rollback if $oldAutoCommit;
263       return "Error modifying cust_pkg record: $error";
264     }
265   }
266
267   warn "  commiting transaction" if $DEBUG;
268   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
269
270   '';
271 }
272
273 =item delete
274
275 Currently unimplemented.
276
277 =cut
278
279 sub delete {
280   return "Can't (yet?) delete package definitions.";
281 # check & make sure the pkgpart isn't in cust_pkg or type_pkgs?
282 }
283
284 =item replace OLD_RECORD [ , OPTION => VALUE ... ]
285
286 Replaces OLD_RECORD with this one in the database.  If there is an error,
287 returns the error, otherwise returns false.
288
289 Currently available options are: I<pkg_svc> and I<primary_svc>
290
291 If I<pkg_svc> is set to a hashref with svcparts as keys and quantities as
292 values, the appropriate FS::pkg_svc records will be replace.
293
294 If I<primary_svc> is set to the svcpart of the primary service, the appropriate
295 FS::pkg_svc record will be updated.
296
297 =cut
298
299 sub replace {
300   my( $new, $old ) = ( shift, shift );
301   my %options = @_;
302   warn "FS::part_pkg::replace called on $new to replace $old ".
303        "with options %options"
304     if $DEBUG;
305
306   local $SIG{HUP} = 'IGNORE';
307   local $SIG{INT} = 'IGNORE';
308   local $SIG{QUIT} = 'IGNORE';
309   local $SIG{TERM} = 'IGNORE';
310   local $SIG{TSTP} = 'IGNORE';
311   local $SIG{PIPE} = 'IGNORE';
312
313   my $oldAutoCommit = $FS::UID::AutoCommit;
314   local $FS::UID::AutoCommit = 0;
315   my $dbh = dbh;
316
317   warn "  saving legacy plandata" if $DEBUG;
318   my $plandata = $new->get('plandata');
319   $new->set('plandata', '');
320
321   warn "  deleting old part_pkg_option records" if $DEBUG;
322   foreach my $part_pkg_option ( $old->part_pkg_option ) {
323     my $error = $part_pkg_option->delete;
324     if ( $error ) {
325       $dbh->rollback if $oldAutoCommit;
326       return $error;
327     }
328   }
329
330   warn "  replacing part_pkg record" if $DEBUG;
331   my $error = $new->SUPER::replace($old);
332   if ( $error ) {
333     $dbh->rollback if $oldAutoCommit;
334     return $error;
335   }
336
337   warn "  inserting part_pkg_option records for plandata" if $DEBUG;
338   foreach my $part_pkg_option ( 
339     map { /^(\w+)=(.*)$/ or do { $dbh->rollback if $oldAutoCommit;
340                                  return "illegal plandata: $plandata";
341                                };
342           new FS::part_pkg_option {
343             'pkgpart'     => $new->pkgpart,
344             'optionname'  => $1,
345             'optionvalue' => $2,
346           };
347         }
348     split("\n", $plandata)
349   ) {
350     my $error = $part_pkg_option->insert;
351     if ( $error ) {
352       $dbh->rollback if $oldAutoCommit;
353       return $error;
354     }
355   }
356
357   warn "  replacing pkg_svc records" if $DEBUG;
358   my $pkg_svc = $options{'pkg_svc'} || {};
359   foreach my $part_svc ( qsearch('part_svc', {} ) ) {
360     my $quantity = $pkg_svc->{$part_svc->svcpart} || 0;
361     my $primary_svc = $options{'primary_svc'} == $part_svc->svcpart ? 'Y' : '';
362
363     my $old_pkg_svc = qsearchs('pkg_svc', {
364       'pkgpart' => $old->pkgpart,
365       'svcpart' => $part_svc->svcpart,
366     } );
367     my $old_quantity = $old_pkg_svc ? $old_pkg_svc->quantity : 0;
368     my $old_primary_svc =
369       ( $old_pkg_svc && $old_pkg_svc->dbdef_table->column('primary_svc') )
370         ? $old_pkg_svc->primary_svc
371         : '';
372     next unless $old_quantity != $quantity || $old_primary_svc ne $primary_svc;
373   
374     my $new_pkg_svc = new FS::pkg_svc( {
375       'pkgpart'     => $new->pkgpart,
376       'svcpart'     => $part_svc->svcpart,
377       'quantity'    => $quantity, 
378       'primary_svc' => $primary_svc,
379     } );
380     my $error = $old_pkg_svc
381                   ? $new_pkg_svc->replace($old_pkg_svc)
382                   : $new_pkg_svc->insert;
383     if ( $error ) {
384       $dbh->rollback if $oldAutoCommit;
385       return $error;
386     }
387   }
388
389   warn "  commiting transaction" if $DEBUG;
390   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
391   '';
392 }
393
394 =item check
395
396 Checks all fields to make sure this is a valid package definition.  If
397 there is an error, returns the error, otherwise returns false.  Called by the
398 insert and replace methods.
399
400 =cut
401
402 sub check {
403   my $self = shift;
404   warn "FS::part_pkg::check called on $self" if $DEBUG;
405
406   for (qw(setup recur plandata)) {
407     #$self->set($_=>0) if $self->get($_) =~ /^\s*$/; }
408     return "Use of $_ field is deprecated; set a plan and options"
409       if length($self->get($_));
410     $self->set($_, '');
411   }
412
413   if ( $self->dbdef_table->column('freq')->type =~ /(int)/i ) {
414     my $error = $self->ut_number('freq');
415     return $error if $error;
416   } else {
417     $self->freq =~ /^(\d+[dw]?)$/
418       or return "Illegal or empty freq: ". $self->freq;
419     $self->freq($1);
420   }
421
422   my $error = $self->ut_numbern('pkgpart')
423     || $self->ut_text('pkg')
424     || $self->ut_text('comment')
425     || $self->ut_textn('promo_code')
426     || $self->ut_alphan('plan')
427     || $self->ut_enum('setuptax', [ '', 'Y' ] )
428     || $self->ut_enum('recurtax', [ '', 'Y' ] )
429     || $self->ut_textn('taxclass')
430     || $self->ut_enum('disabled', [ '', 'Y' ] )
431     || $self->SUPER::check
432   ;
433   return $error if $error;
434
435   return 'Unknown plan '. $self->plan
436     unless exists($plans{$self->plan});
437
438   '';
439 }
440
441 =item pkg_svc
442
443 Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package
444 definition (with non-zero quantity).
445
446 =cut
447
448 sub pkg_svc {
449   my $self = shift;
450   #sort { $b->primary cmp $a->primary } 
451     grep { $_->quantity }
452       qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
453 }
454
455 =item svcpart [ SVCDB ]
456
457 Returns the svcpart of the primary service definition (see L<FS::part_svc>)
458 associated with this package definition (see L<FS::pkg_svc>).  Returns
459 false if there not a primary service definition or exactly one service
460 definition with quantity 1, or if SVCDB is specified and does not match the
461 svcdb of the service definition, 
462
463 =cut
464
465 sub svcpart {
466   my $self = shift;
467   my $svcdb = scalar(@_) ? shift : '';
468   my @svcdb_pkg_svc =
469     grep { ( $svcdb eq $_->part_svc->svcdb || !$svcdb ) } $self->pkg_svc;
470   my @pkg_svc = ();
471   @pkg_svc = grep { $_->primary_svc =~ /^Y/i } @svcdb_pkg_svc
472     if dbdef->table('pkg_svc')->column('primary_svc');
473   @pkg_svc = grep {$_->quantity == 1 } @svcdb_pkg_svc
474     unless @pkg_svc;
475   return '' if scalar(@pkg_svc) != 1;
476   $pkg_svc[0]->svcpart;
477 }
478
479 =item payby
480
481 Returns a list of the acceptable payment types for this package.  Eventually
482 this should come out of a database table and be editable, but currently has the
483 following logic instead:
484
485 If the package is free, the single item B<BILL> is
486 returned, otherwise, the single item B<CARD> is returned.
487
488 (CHEK?  LEC?  Probably shouldn't accept those by default, prone to abuse)
489
490 =cut
491
492 sub payby {
493   my $self = shift;
494   if ( $self->is_free ) {
495     ( 'BILL' );
496   } else {
497     ( 'CARD' );
498   }
499 }
500
501 =item is_free
502
503 Returns true if this package is free.  
504
505 =cut
506
507 sub is_free {
508   my $self = shift;
509   unless ( $self->plan ) {
510     $self->setup =~ /^\s*0+(\.0*)?\s*$/
511       && $self->recur =~ /^\s*0+(\.0*)?\s*$/;
512   } elsif ( $self->can('is_free_options') ) {
513     not grep { $_ !~ /^\s*0*(\.0*)?\s*$/ }
514          map { $self->option($_) } 
515              $self->is_free_options;
516   } else {
517     warn "FS::part_pkg::is_free: FS::part_pkg::". $self->plan. " subclass ".
518          "provides neither is_free_options nor is_free method; returning false";
519     0;
520   }
521 }
522
523 =item freq_pretty
524
525 Returns an english representation of the I<freq> field, such as "monthly",
526 "weekly", "semi-annually", etc.
527
528 =cut
529
530 tie %freq, 'Tie::IxHash', 
531   '0'  => '(no recurring fee)',
532   '1d' => 'daily',
533   '1w' => 'weekly',
534   '2w' => 'biweekly (every 2 weeks)',
535   '1'  => 'monthly',
536   '2'  => 'bimonthly (every 2 months)',
537   '3'  => 'quarterly (every 3 months)',
538   '6'  => 'semiannually (every 6 months)',
539   '12' => 'annually',
540   '24' => 'biannually (every 2 years)',
541 ;
542
543 sub freq_pretty {
544   my $self = shift;
545   my $freq = $self->freq;
546   if ( exists($freq{$freq}) ) {
547     $freq{$freq};
548   } else {
549     my $interval = 'month';
550     if ( $freq =~ /^(\d+)([dw])$/ ) {
551       my %interval = ( 'd'=>'day', 'w'=>'week' );
552       $interval = $interval{$2};
553     }
554     if ( $1 == 1 ) {
555       "every $interval";
556     } else {
557       "every $freq ${interval}s";
558     }
559   }
560 }
561
562 =item plandata
563
564 For backwards compatibility, returns the plandata field as well as all options
565 from FS::part_pkg_option.
566
567 =cut
568
569 sub plandata {
570   my $self = shift;
571   carp "plandata is deprecated";
572   if ( @_ ) {
573     $self->SUPER::plandata(@_);
574   } else {
575     my $plandata = $self->get('plandata');
576     my %options = $self->options;
577     $plandata .= join('', map { "$_=$options{$_}\n" } keys %options );
578     $plandata;
579   }
580 }
581
582 =item part_pkg_option
583
584 Returns all options as FS::part_pkg_option objects (see
585 L<FS::part_pkg_option>).
586
587 =cut
588
589 sub part_pkg_option {
590   my $self = shift;
591   qsearch('part_pkg_option', { 'pkgpart' => $self->pkgpart } );
592 }
593
594 =item options 
595
596 Returns a list of option names and values suitable for assigning to a hash.
597
598 =cut
599
600 sub options {
601   my $self = shift;
602   map { $_->optionname => $_->optionvalue } $self->part_pkg_option;
603 }
604
605 =item option OPTIONNAME
606
607 Returns the option value for the given name, or the empty string.
608
609 =cut
610
611 sub option {
612   my( $self, $opt, $ornull ) = @_;
613   my $part_pkg_option =
614     qsearchs('part_pkg_option', {
615       pkgpart    => $self->pkgpart,
616       optionname => $opt,
617   } );
618   return $part_pkg_option->optionvalue if $part_pkg_option;
619   my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
620                      split("\n", $self->get('plandata') );
621   return $plandata{$opt} if exists $plandata{$opt};
622   cluck "Package definition option $opt not found in options or plandata!\n"
623     unless $ornull;
624   '';
625 }
626
627 =item _rebless
628
629 Reblesses the object into the FS::part_pkg::PLAN class (if available), where
630 PLAN is the object's I<plan> field.  There should be better docs
631 on how to create new price plans, but until then, see L</NEW PLAN CLASSES>.
632
633 =cut
634
635 sub _rebless {
636   my $self = shift;
637   my $plan = $self->plan;
638   my $class = ref($self). "::$plan";
639   eval "use $class;";
640   #die $@ if $@;
641   bless($self, $class) unless $@;
642   $self;
643 }
644
645 #fallbacks that eval the setup and recur fields, for backwards compat
646
647 sub calc_setup {
648   my $self = shift;
649   warn 'no price plan class for '. $self->plan. ", eval-ing setup\n";
650   $self->_calc_eval('setup', @_);
651 }
652
653 sub calc_recur {
654   my $self = shift;
655   warn 'no price plan class for '. $self->plan. ", eval-ing recur\n";
656   $self->_calc_eval('recur', @_);
657 }
658
659 use vars qw( $sdate @details );
660 sub _calc_eval {
661   #my( $self, $field, $cust_pkg ) = @_;
662   my( $self, $field, $cust_pkg, $sdateref, $detailsref ) = @_;
663   *sdate = $sdateref;
664   *details = $detailsref;
665   $self->$field() =~ /^(.*)$/
666     or die "Illegal $field (pkgpart ". $self->pkgpart. '): '.
667             $self->$field(). "\n";
668   my $prog = $1;
669   return 0 if $prog =~ /^\s*$/;
670   my $value = eval $prog;
671   die $@ if $@;
672   $value;
673 }
674
675 #fallback that return 0 for old legacy packages with no plan
676
677 sub calc_remain { 0; }
678 sub calc_cancel { 0; }
679
680 =back
681
682 =head1 SUBROUTINES
683
684 =over 4
685
686 =item plan_info
687
688 =cut
689
690 my %info;
691 foreach my $INC ( @INC ) {
692   foreach my $file ( glob("$INC/FS/part_pkg/*.pm") ) {
693     warn "attempting to load plan info from $file\n" if $DEBUG;
694     $file =~ /\/(\w+)\.pm$/ or do {
695       warn "unrecognized file in $INC/FS/part_pkg/: $file\n";
696       next;
697     };
698     my $mod = $1;
699     my $info = eval "use FS::part_pkg::$mod; ".
700                     "\\%FS::part_pkg::$mod\::info;";
701     if ( $@ ) {
702       die "error using FS::part_pkg::$mod (skipping): $@\n" if $@;
703       next;
704     }
705     unless ( keys %$info ) {
706       warn "no %info hash found in FS::part_pkg::$mod, skipping\n"
707         unless $mod =~ /^(passwdfile|null)$/; #hack but what the heck
708       next;
709     }
710     warn "got plan info from FS::part_pkg::$mod: $info\n" if $DEBUG;
711     if ( exists($info->{'disabled'}) && $info->{'disabled'} ) {
712       warn "skipping disabled plan FS::part_pkg::$mod" if $DEBUG;
713       next;
714     }
715     $info{$mod} = $info;
716   }
717 }
718
719 tie %plans, 'Tie::IxHash',
720   map { $_ => $info{$_} }
721   sort { $info{$a}->{'weight'} <=> $info{$b}->{'weight'} }
722   keys %info;
723
724 sub plan_info {
725   \%plans;
726 }
727
728 =back
729
730 =head1 NEW PLAN CLASSES
731
732 A module should be added in FS/FS/part_pkg/ (an example may be found in
733 eg/plan_template.pm)
734
735 =head1 BUGS
736
737 The delete method is unimplemented.
738
739 setup and recur semantics are not yet defined (and are implemented in
740 FS::cust_bill.  hmm.).
741
742 =head1 SEE ALSO
743
744 L<FS::Record>, L<FS::cust_pkg>, L<FS::type_pkgs>, L<FS::pkg_svc>, L<Safe>.
745 schema.html from the base documentation.
746
747 =cut
748
749 1;
750