Flavio suggested working out a directory structure for DT::B, so here it
is for your perusal.

DateTime::Business
        This is a base module as well as the directory for all Business
modules. I figure this module would be central to all else. It sets up
the basic business calendar. Feed it the regular schedule of the
business. Blocks out days its closed (such as Christmas and other public
holidays) as well as other half-days or non recurring days.

   The module would hold a hash of spansets:
   {
      open => SpanSet( spans_were_open ),
      public_holidays => [
         { name => Christmas, 
           spanset => Recurrence( Dec 25 ),
           open => undef, close => undef
         },
         { name => Melbourne Cup,
           spanset => Recurrence( First Tues in November ),
           open => { hour => 9, minute => 0},
           close => { hour => 17, minute => 0},
         }
      ],
      company_holidays => [
         { name => Christmas Break, 
           spanset => Recurrence( Mon before Christmas to Mon after ) }
      ],
      closed => [
         { name => Fumigating, spanset => 9am - 12pm Fri 12th June 2003}
   }

We'd construct it by creating the general 'open' spanset. 

Then we define public holidays and mark if/when we're open on those
days.

We then construct Company Holidays (which I assume we're closed for,
otherwise what good is a company holiday! If I'm wrong, tell me).

Then we can add days when we're closed for arbitrary reasons. 

All these modifications are remembered for their own sake and don't
modify the 'open'.

We can then extract data:

What happened on Jan 12, 2003?
        $business_object->diary( year=>2003, month=>1, day=>12 );
        # open => 9am,
        # close => 10.30am,
        # open => 12pm,
        # close => 5pm

Huh? We were closed at 11am?
        $business_object->status( 
                DateTime->new( year=>2003, month=>1, day=>12, hour=>11)
        );
        # closed

Why were we closed?
        $business_object->detail( 
                DateTime->new( year=>2003, month=>1, day=>12, hour=>11)
        );
        # closed 10.30am start Fumigation
        # opened at 12pm end Fumigation

Ahh .. we were being fumigated! Does this happen regularly?
        $business_object->find( name => 'Fumigation' );
        # DateTime::SpanSet

Now remember all that for later ok?
        $business_object->save_as( $filename );
        # or
        custom_save($business_object->freeze);

Send accounts a copy of general company activity for the past fornight
        $new_business_object = 
                $business_object->extract( $datetime_span );

How long were we actually open in the last fortnight?
        $datetime_duration = $new_business_object->flatten->duration
        # 'flatten' returns a single spanset representing our
        # open times without any data. We can then call 'duration' on
        # this spanset as well as do anything else that can be done
        # to a spanset.




OK, so that's the base object. The rest is a little sketchier

DateTime::Business::Moment - this is basically a datetime except that it
works with a calendar that has holes in it (ie the Business Calendar)

$now = DateTime::Business::Moment->now();
$now->status; #closed
$datetime = $now->next_open;
$datetime = $now->next_close;
($datetime, $status) = $now->next; # open or close

$now->forward('open');  # Move forward to next open
$now->backward('open'); # Move backward to previous open

$now->add( days => 1 );  # Next business day
$now->add( hours => 1 ); # Will wrap to tomorrow if there's 
                         # not an entire hour left today

Also, implement other datetime functionality. This is just a quick
sketch 




DateTime::Business::Employee - Very similar to the base object except
we're talking about when he/she was/wasn't at work.

DateTime::Business::Employee::Pay - Defines pay rates for various
activities (such as getting a 1.5 loading on weekends, double on public
holidays and 0 on leave-without-pay). We can then extract gross amounts
needed for pay-slips.


MAYBE ALSO: DateTime::Business::Employee::Tax::Australia which allows us
to calculate the tax rate for the above module.



DateTime::Business::Project - Not really datetime related but a record
of a project that was carried out. This exists so an employee can be
ties to a project for accounting purposes.



All the modules will be able to tie in together such that we might be
able to get a list of employees working at a particular Moment.



Comments welcome
Cheers!
Rick

Reply via email to