Changeset 1950 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 02/14/17 21:39:12 (7 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Employment.pm
r1949 r1950 343 343 my $res = $self->SUPER::set_fields(%data); 344 344 345 $self->applyToUser or return;346 return $res;347 }348 349 =head2 applyToUser()350 351 Set user's attributes if need from this employement.352 353 =cut354 355 sub applyToUser {356 my ($self) = @_;357 358 345 my $user = $self->base->get_object('user', $self->get_attributes('user')) or do { 359 346 $self->base->log(LA_ERR, "Cannot fetch user %s to apply employment", $self->get_attributes('user')); … … 361 348 }; 362 349 363 $user->base->log(LA_DEBUG, "Applying Employement %s to user %s", $self->id, $user->id); 364 365 my $currentemployment = $user->get_attributes('currentEmployment') || ''; 366 367 if (!$currentemployment) { 368 return $user->_resetEmployment 369 } elsif ($currentemployment eq $self->id) { 370 # No sync to do if this employment is not currently applied 371 return $user->applyCurrentEmployment; 372 } else { 373 return $user->computeEmploymentDate; 374 } 350 $user->applyCurrentEmployment; 351 352 return $res; 375 353 } 376 354 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1949 r1950 1530 1530 my ($self) = @_; 1531 1531 1532 # Get current employment name 1532 1533 my $currentempl = $self->get_attributes('currentEmployment') || ''; 1533 1534 … … 1540 1541 1541 1542 if (my $currentemployment = $self->base->get_object('employment', $currentempl)) { 1543 1544 # If an employement apply we set the value to the user object 1545 1542 1546 $self->computeEmploymentDate; 1543 1547 … … 1574 1578 } 1575 1579 } else { 1580 # No current employment, resetting values: 1581 1576 1582 return $self->_resetEmployment; 1577 1583 } 1578 1584 1579 1585 } 1586 1587 # Reset attribute value set by employment 1588 # except maangerContact and expire 1580 1589 1581 1590 sub _resetEmployment { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Employment.pm
r1824 r1950 60 60 my $ouser = $self->{_base}->get_object('user', $user) or next; 61 61 62 my $job = $self->{_base}->get_object('employment', $employment); 63 $job->applyToUser; 62 $ouser->applyCurrentEmployment; 64 63 $self->{_base}->commit; 65 64 }
Note: See TracChangeset
for help on using the changeset viewer.