Changeset 1757


Ignore:
Timestamp:
04/26/16 14:30:48 (8 years ago)
Author:
nanardon
Message:

arrival/departure: take non working day into account

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1754 r1757  
    241241                    my ($attr) = @_; 
    242242                    my $self = $attr->object; 
    243                     $self->_computeEndEmployment($self->base->config('employment_delay') || 0, 1); 
     243                    $self->_computeEndEmployment($self->base->config('employment_delay') || 0, 1, 1); 
    244244                }, 
    245245                label => l('Start of employment'), 
     
    359359                    my ($attr) = @_; 
    360360                    my $self = $attr->object; 
    361                     $self->_computeStartEmployment($self->base->config('employment_delay') || 0, 1); 
     361                    $self->_computeStartEmployment($self->base->config('employment_delay') || 0, 1, 1); 
    362362                }, 
    363363                label => l('Start of employment'), 
     
    15121512 
    15131513sub _computeStartEmployment { 
    1514     my ($self, $delay, $any) = @_; 
     1514    my ($self, $delay, $any, $workday) = @_; 
    15151515 
    15161516    $delay ||= 0; 
     
    15521552    $start ||= $nstart if ($any); 
    15531553 
     1554    if ($start) { 
     1555        if ($workday) { 
     1556            my $day_of_week = $start->day_of_week; 
     1557            $start->add(days => 
     1558                $day_of_week == 6 ? 2 : 
     1559                $day_of_week == 7 ? 1 : 0 
     1560            ); 
     1561        } 
     1562    } 
     1563 
    15541564    return $start ? $start->iso8601 : undef 
    15551565} 
    15561566 
    15571567sub _computeEndEmployment { 
    1558     my ($self, $delay, $any) = @_; 
     1568    my ($self, $delay, $any, $workday) = @_; 
    15591569 
    15601570    $delay ||= 0; 
     
    16021612    $end ||= $pend if($any); 
    16031613 
     1614    if ($end) { 
     1615        if ($workday) { 
     1616            my $day_of_week = $end->day_of_week; 
     1617            $end->subtract(days => 
     1618                $day_of_week == 7 ? 2 : 
     1619                $day_of_week == 6 ? 1 : 0 
     1620            ); 
     1621        } 
     1622    } 
     1623 
    16041624    return $end ? $end->iso8601 : undef 
    16051625} 
Note: See TracChangeset for help on using the changeset viewer.