CyberCraftInc / vacation_system

Cyber Craft Vacation System
0 stars 0 forks source link

Implement calculation of available vacations #49

Closed eleidan closed 8 years ago

eleidan commented 8 years ago

Add employment_date column to users table

Update RoR User model The User#days_since_employment instance method provides number of days since the date of employment. The User#accumulated_days_of_all_types instance method provides number of accumulated available vacations of all types. The User#accumulated_days(kind) instance method provides number of accumulated available vacations of particular type. The User#used_days(kind) instance method provides number of all used vacations since employment date.

Update RoR User model factory Initialize the date of employment.

Update RoR VacationRequest model The VacationRequest#used scope filters used vacations.

Update RoR AvailableVacation model The AvailableVacation#accumulate_more_days instance method updates available_days property by adding more available days if the record is not up-to-date.

Update RoR AvailableVacationsController The index action method updates number of available days for all the records before sending them to the client.

Add module for calculations The AvailableVacations module provides configuration data needed for vacations related calculations.

Update RoR Holiday model with helpers The Holiday.dates class method provides array of all the holidays dates. The Holiday#dates instance method provides array of holiday dates. The Holiday.dates class method actually aggregates results of the instance method invocations on the list of all holidays records.

Add filter into VacationRequestsController The VacationRequestsController#update_available_vacations method is hooked with after_action. The method initiates recalculation of available vacations for the same type as the finished vacation. The new functionality is covered with tests.

Update RoR VacationRequest model The VacationRequest#duration method provides of the vacation taking into consideration holidays and weekends. That is, if there are any weekneds or holidays that vacation date range overlaps with, they will be properly subtracted. The VacationRequest#duration method is covered with tests.

Update BB App.Views.VacationRequestForm The form shows in badges only integer part of number of available days.

Fix BB App.Views.VacationRequestsList The decision logic for showing the Cancel button now works properly.

Update rubocop configuration Disable rule for the guard style checking

Add deployment related section to README.md