timeoff-management / timeoff-management-application

Simple yet powerful absence management software for small and medium size business (community edition)
https://TimeOff.Management
MIT License
953 stars 589 forks source link

Error while running carry-over-allowance script: Unhandled rejection TypeError: user.promise_number_of_days_available_in_allowance is not a function #298

Open ktaranek opened 6 years ago

ktaranek commented 6 years ago

Hello!

I have encountered error while running carry-over-allowance script in my installation. The error says:

Unhandled rejection TypeError: user.promise_number_of_days_available_in_allowance is not a function

Here is the full output.

npm run-script carry-over-allowance

> TimeOff.Management@0.10.0 carry-over-allowance /srv/timeoff/timeoff-management
> node bin/calculate_carry_over_allowance_for_all_users.js

Executing (default): SELECT `id`, `email`, `password`, `name`, `lastname`, `activated`, `admin`, `auto_approve`, `start_date`, `end_date`, `createdAt`, `updatedAt`, `companyId`, `DepartmentId` FROM `Users` AS `User`;
Executing (default): SELECT `Leave`.`id`, `Leave`.`status`, `Leave`.`employee_comment`, `Leave`.`approver_comment`, `Leave`.`decided_at`, `Leave`.`date_start`, `Leave`.`day_part_start`, `Leave`.`date_end`, `Leave`.`day_part_end`, `Leave`.`createdAt`, `Leave`.`updatedAt`, `Leave`.`userId`, `Leave`.`approverId`, `Leave`.`leaveTypeId`, `leave_type`.`id` AS `leave_type.id`, `leave_type`.`name` AS `leave_type.name`, `leave_type`.`color` AS `leave_type.color`, `leave_type`.`use_allowance` AS `leave_type.use_allowance`, `leave_type`.`limit` AS `leave_type.limit`, `leave_type`.`sort_order` AS `leave_type.sort_order`, `leave_type`.`createdAt` AS `leave_type.createdAt`, `leave_type`.`updatedAt` AS `leave_type.updatedAt`, `leave_type`.`companyId` AS `leave_type.companyId`, `user`.`id` AS `user.id`, `user`.`email` AS `user.email`, `user`.`password` AS `user.password`, `user`.`name` AS `user.name`, `user`.`lastname` AS `user.lastname`, `user`.`activated` AS `user.activated`, `user`.`admin` AS `user.admin`, `user`.`auto_approve` AS `user.auto_approve`, `user`.`start_date` AS `user.start_date`, `user`.`end_date` AS `user.end_date`, `user`.`createdAt` AS `user.createdAt`, `user`.`updatedAt` AS `user.updatedAt`, `user`.`companyId` AS `user.companyId`, `user`.`DepartmentId` AS `user.DepartmentId`, `user.company`.`id` AS `user.company.id`, `user.company`.`name` AS `user.company.name`, `user.company`.`country` AS `user.company.country`, `user.company`.`start_of_new_year` AS `user.company.start_of_new_year`, `user.company`.`share_all_absences` AS `user.company.share_all_absences`, `user.company`.`ldap_auth_enabled` AS `user.company.ldap_auth_enabled`, `user.company`.`ldap_auth_config` AS `user.company.ldap_auth_config`, `user.company`.`date_format` AS `user.company.date_format`, `user.company`.`company_wide_message` AS `user.company.company_wide_message`, `user.company`.`mode` AS `user.company.mode`, `user.company`.`timezone` AS `user.company.timezone`, `user.company`.`createdAt` AS `user.company.createdAt`, `user.company`.`updatedAt` AS `user.company.updatedAt`, `user.company.bank_holidays`.`id` AS `user.company.bank_holidays.id`, `user.company.bank_holidays`.`name` AS `user.company.bank_holidays.name`, `user.company.bank_holidays`.`date` AS `user.company.bank_holidays.date`, `user.company.bank_holidays`.`createdAt` AS `user.company.bank_holidays.createdAt`, `user.company.bank_holidays`.`updatedAt` AS `user.company.bank_holidays.updatedAt`, `user.company.bank_holidays`.`companyId` AS `user.company.bank_holidays.companyId` FROM `Leaves` AS `Leave` LEFT OUTER JOIN `LeaveTypes` AS `leave_type` ON `Leave`.`leaveTypeId` = `leave_type`.`id` LEFT OUTER JOIN `Users` AS `user` ON `Leave`.`userId` = `user`.`id` LEFT OUTER JOIN `Companies` AS `user.company` ON `user`.`companyId` = `user.company`.`id` LEFT OUTER JOIN `BankHolidays` AS `user.company.bank_holidays` ON `user.company`.`id` = `user.company.bank_holidays`.`companyId` WHERE (`Leave`.`userId` = 1 AND (`Leave`.`status` IN (2, 1, 4) AND (`Leave`.`date_start` BETWEEN '2018-01-01' AND '2018-12-31 23:59' OR `Leave`.`date_end` BETWEEN '2018-01-01' AND '2018-12-31 23:59')));
Executing (default): SELECT `id`, `name`, `allowance`, `include_public_holidays`, `is_accrued_allowance`, `createdAt`, `updatedAt`, `companyId`, `bossId` FROM `Departments` AS `Department` WHERE `Department`.`id` = 4;
Executing (default): SELECT `id`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`, `created_at`, `updated_at`, `company_id`, `user_id` FROM `schedule` AS `Schedule` WHERE (`Schedule`.`user_id` = 1 OR `Schedule`.`company_id` = 1);
Executing (default): SELECT `User`.`id`, `User`.`email`, `User`.`password`, `User`.`name`, `User`.`lastname`, `User`.`activated`, `User`.`admin`, `User`.`auto_approve`, `User`.`start_date`, `User`.`end_date`, `User`.`createdAt`, `User`.`updatedAt`, `User`.`companyId`, `User`.`DepartmentId`, `company`.`id` AS `company.id`, `company`.`name` AS `company.name`, `company`.`country` AS `company.country`, `company`.`start_of_new_year` AS `company.start_of_new_year`, `company`.`share_all_absences` AS `company.share_all_absences`, `company`.`ldap_auth_enabled` AS `company.ldap_auth_enabled`, `company`.`ldap_auth_config` AS `company.ldap_auth_config`, `company`.`date_format` AS `company.date_format`, `company`.`company_wide_message` AS `company.company_wide_message`, `company`.`mode` AS `company.mode`, `company`.`timezone` AS `company.timezone`, `company`.`createdAt` AS `company.createdAt`, `company`.`updatedAt` AS `company.updatedAt`, `company.bank_holidays`.`id` AS `company.bank_holidays.id`, `company.bank_holidays`.`name` AS `company.bank_holidays.name`, `company.bank_holidays`.`date` AS `company.bank_holidays.date`, `company.bank_holidays`.`createdAt` AS `company.bank_holidays.createdAt`, `company.bank_holidays`.`updatedAt` AS `company.bank_holidays.updatedAt`, `company.bank_holidays`.`companyId` AS `company.bank_holidays.companyId` FROM `Users` AS `User` LEFT OUTER JOIN `Companies` AS `company` ON `User`.`companyId` = `company`.`id` LEFT OUTER JOIN `BankHolidays` AS `company.bank_holidays` ON `company`.`id` = `company.bank_holidays`.`companyId` WHERE `User`.`id` = 1;
Unhandled rejection TypeError: user.promise_number_of_days_available_in_allowance is not a function
    at user.reload_with_leave_details.then.user (/srv/timeoff/timeoff-management/bin/calculate_carry_over_allowance_for_all_users.js:31:29)
    at tryCatcher (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:756:18)
    at tryOnImmediate (timers.js:717:5)
    at processImmediate [as _immediateCallback] (timers.js:697:5)

Any ideas where should I look into? Thanks.

vpp commented 6 years ago

Oh

That might be a bug

Thank you for reporting

Sent from my iPhone

On 16 Jul 2018, at 16:11, ktaranek notifications@github.com wrote:

Hello!

I have encountered error while running carry-over-allowance script in my installation. The error says:

Unhandled rejection TypeError: user.promise_number_of_days_available_in_allowance is not a function

Here is the full output.

npm run-script carry-over-allowance

TimeOff.Management@0.10.0 carry-over-allowance /srv/timeoff/timeoff-management node bin/calculate_carry_over_allowance_for_all_users.js

Executing (default): SELECT id, email, password, name, lastname, activated, admin, auto_approve, start_date, end_date, createdAt, updatedAt, companyId, DepartmentId FROM Users AS User; Executing (default): SELECT Leave.id, Leave.status, Leave.employee_comment, Leave.approver_comment, Leave.decided_at, Leave.date_start, Leave.day_part_start, Leave.date_end, Leave.day_part_end, Leave.createdAt, Leave.updatedAt, Leave.userId, Leave.approverId, Leave.leaveTypeId, leave_type.id AS leave_type.id, leave_type.name AS leave_type.name, leave_type.color AS leave_type.color, leave_type.use_allowance AS leave_type.use_allowance, leave_type.limit AS leave_type.limit, leave_type.sort_order AS leave_type.sort_order, leave_type.createdAt AS leave_type.createdAt, leave_type.updatedAt AS leave_type.updatedAt, leave_type.companyId AS leave_type.companyId, user.id AS user.id, user.email AS user.email, user.password AS user.password, user.name AS user.name, user.lastname AS user.lastname, user.activated AS user.activated, user.admin AS user.admin, user.auto_approve AS user.auto_approve, user.start_date AS user.start_date, user.end_date AS user.end_date, user.createdAt AS user.createdAt, user.updatedAt AS user.updatedAt, user.companyId AS user.companyId, user.DepartmentId AS user.DepartmentId, user.company.id AS user.company.id, user.company.name AS user.company.name, user.company.country AS user.company.country, user.company.start_of_new_year AS user.company.start_of_new_year, user.company.share_all_absences AS user.company.share_all_absences, user.company.ldap_auth_enabled AS user.company.ldap_auth_enabled, user.company.ldap_auth_config AS user.company.ldap_auth_config, user.company.date_format AS user.company.date_format, user.company.company_wide_message AS user.company.company_wide_message, user.company.mode AS user.company.mode, user.company.timezone AS user.company.timezone, user.company.createdAt AS user.company.createdAt, user.company.updatedAt AS user.company.updatedAt, user.company.bank_holidays.id AS user.company.bank_holidays.id, user.company.bank_holidays.name AS user.company.bank_holidays.name, user.company.bank_holidays.date AS user.company.bank_holidays.date, user.company.bank_holidays.createdAt AS user.company.bank_holidays.createdAt, user.company.bank_holidays.updatedAt AS user.company.bank_holidays.updatedAt, user.company.bank_holidays.companyId AS user.company.bank_holidays.companyId FROM Leaves AS Leave LEFT OUTER JOIN LeaveTypes AS leave_type ON Leave.leaveTypeId = leave_type.id LEFT OUTER JOIN Users AS user ON Leave.userId = user.id LEFT OUTER JOIN Companies AS user.company ON user.companyId = user.company.id LEFT OUTER JOIN BankHolidays AS user.company.bank_holidays ON user.company.id = user.company.bank_holidays.companyId WHERE (Leave.userId = 1 AND (Leave.status IN (2, 1, 4) AND (Leave.date_start BETWEEN '2018-01-01' AND '2018-12-31 23:59' OR Leave.date_end BETWEEN '2018-01-01' AND '2018-12-31 23:59'))); Executing (default): SELECT id, name, allowance, include_public_holidays, is_accrued_allowance, createdAt, updatedAt, companyId, bossId FROM Departments AS Department WHERE Department.id = 4; Executing (default): SELECT id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, created_at, updated_at, company_id, user_id FROM schedule AS Schedule WHERE (Schedule.user_id = 1 OR Schedule.company_id = 1); Executing (default): SELECT User.id, User.email, User.password, User.name, User.lastname, User.activated, User.admin, User.auto_approve, User.start_date, User.end_date, User.createdAt, User.updatedAt, User.companyId, User.DepartmentId, company.id AS company.id, company.name AS company.name, company.country AS company.country, company.start_of_new_year AS company.start_of_new_year, company.share_all_absences AS company.share_all_absences, company.ldap_auth_enabled AS company.ldap_auth_enabled, company.ldap_auth_config AS company.ldap_auth_config, company.date_format AS company.date_format, company.company_wide_message AS company.company_wide_message, company.mode AS company.mode, company.timezone AS company.timezone, company.createdAt AS company.createdAt, company.updatedAt AS company.updatedAt, company.bank_holidays.id AS company.bank_holidays.id, company.bank_holidays.name AS company.bank_holidays.name, company.bank_holidays.date AS company.bank_holidays.date, company.bank_holidays.createdAt AS company.bank_holidays.createdAt, company.bank_holidays.updatedAt AS company.bank_holidays.updatedAt, company.bank_holidays.companyId AS company.bank_holidays.companyId FROM Users AS User LEFT OUTER JOIN Companies AS company ON User.companyId = company.id LEFT OUTER JOIN BankHolidays AS company.bank_holidays ON company.id = company.bank_holidays.companyId WHERE User.id = 1; Unhandled rejection TypeError: user.promise_number_of_days_available_in_allowance is not a function at user.reload_with_leave_details.then.user (/srv/timeoff/timeoff-management/bin/calculate_carry_over_allowance_for_all_users.js:31:29) at tryCatcher (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/util.js:26:23) at Promise._settlePromiseFromHandler (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/promise.js:510:31) at Promise._settlePromiseAt (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/promise.js:584:18) at Promise._settlePromises (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/promise.js:700:14) at Async._drainQueue (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/async.js:123:16) at Async._drainQueues (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/async.js:133:10) at Immediate.Async.drainQueues [as _onImmediate] (/srv/timeoff/timeoff-management/node_modules/bluebird/js/main/async.js:15:14) at runCallback (timers.js:756:18) at tryOnImmediate (timers.js:717:5) at processImmediate [as _immediateCallback] (timers.js:697:5) Any ideas where should I look into? Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

riyuk commented 6 years ago

if the field for "carried over" would be editable it wouldnt be a problem. we're thinking about using this tool but currently we can only do individual adjustments for every employee to insert the carried over of 2017.. 👎