mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-10-03 20:40:43 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3b9441f25 | ||
|
|
852d2119a0 | ||
|
|
041a6441fe | ||
|
|
0e54316eac | ||
|
|
250442db9d |
No files matched your search
@@ -173,7 +173,34 @@
|
||||
if event.is_a?(Issue)
|
||||
event.estimated_hours.to_f
|
||||
elsif event.is_a?(CustomerAppointment)
|
||||
if event.respond_to?(:estimated_hours) && event.estimated_hours.present?
|
||||
if event.duration.to_i > 1
|
||||
# Get the total hours (fallback to duration * 8 if estimated_hours is blank)
|
||||
app_total_hours = if event.respond_to?(:estimated_hours) && event.estimated_hours.present?
|
||||
event.estimated_hours.to_f
|
||||
else
|
||||
event.duration.to_f * 8.0
|
||||
end
|
||||
|
||||
start_date = (event.respond_to?(:date) && event.date.present? ? event.date : event.start_date).to_date
|
||||
|
||||
# Count how many working days occurred before the current calendar 'day'
|
||||
working_day_index = 0
|
||||
date_cursor = start_date
|
||||
|
||||
while date_cursor < day
|
||||
is_weekend = non_working_days.include?(date_cursor.cwday.to_s)
|
||||
is_holiday = all_holidays.any? { |h| h.occurs_on?(date_cursor) }
|
||||
working_day_index += 1 unless is_weekend || is_holiday
|
||||
date_cursor += 1
|
||||
end
|
||||
|
||||
# Subtract previous days' hours (8h/day) from the total
|
||||
hours_already_allocated = working_day_index * 8.0
|
||||
remaining_hours = app_total_hours - hours_already_allocated
|
||||
|
||||
# Allocate up to 8 hours for today, but don't go below 0
|
||||
[[remaining_hours, 8.0].min, 0.0].max
|
||||
elsif event.respond_to?(:estimated_hours) && event.estimated_hours.present?
|
||||
event.estimated_hours.to_f
|
||||
else
|
||||
event.duration.to_f
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
<p>
|
||||
<% customer = context[:customer] %>
|
||||
<%= link_to l(:label_add_appointment), new_customer_appointment_path(customer_id: customer.id), target: :_blank, id: :appointment_link %>
|
||||
</p>\
|
||||
</p>
|
||||
<% end %>
|
||||
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_calendar do
|
||||
name 'Redmine QBO Calendar plugin'
|
||||
author 'Rick Barrette'
|
||||
description 'A plugin for Redmine to extend the capabilitys of the Redmine QuickBooks Online plugin to create customer appointments for the Redmine Calendar'
|
||||
version '2026.9.0'
|
||||
version '2026.9.2'
|
||||
url 'https://github.com/rickbarrette/redmine_qbo_calendar'
|
||||
author_url 'https://barrettefabrication.com'
|
||||
requires_redmine version_or_higher: '7.0.0'
|
||||
|
||||
@@ -13,14 +13,14 @@ module RedmineQboCalendar
|
||||
|
||||
class ViewHookListener < Redmine::Hook::ViewListener
|
||||
|
||||
# Load the javascript and stylesheet assets
|
||||
def view_layouts_base_html_head(context = {})
|
||||
safe_join([
|
||||
javascript_include_tag("customer_appointments", plugin: :redmine_qbo_calendar),
|
||||
stylesheet_link_tag('customer_appointments', plugin: :redmine_qbo_calendar),
|
||||
javascript_include_tag('https://kit.fontawesome.com/4be4394b21.js', crossorigin: 'anonymous')
|
||||
])
|
||||
end
|
||||
# Load the javascript and stylesheet assets
|
||||
def view_layouts_base_html_head(context = {})
|
||||
safe_join([
|
||||
javascript_include_tag("customer_appointments", plugin: :redmine_qbo_calendar),
|
||||
stylesheet_link_tag('customer_appointments', plugin: :redmine_qbo_calendar),
|
||||
javascript_include_tag('https://kit.fontawesome.com/4be4394b21.js', crossorigin: 'anonymous')
|
||||
])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user