mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 09:24:23 -05:00
Update issues_save_hook_listener.rb
This commit is contained in:
@@ -44,10 +44,6 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
# Add the line items to the estimate
|
# Add the line items to the estimate
|
||||||
estimate.line_items << line_item
|
estimate.line_items << line_item
|
||||||
|
|
||||||
# Save the etimate to the issue
|
|
||||||
#issue.qbo_estimate_id = estimate_base.service.create(estimate).id
|
|
||||||
#issue.save!
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -79,19 +75,27 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
|
|||||||
item_service = Qbo.get_base(:item).service
|
item_service = Qbo.get_base(:item).service
|
||||||
time_entry = Quickbooks::Model::TimeActivity.new
|
time_entry = Quickbooks::Model::TimeActivity.new
|
||||||
|
|
||||||
# Convert float spent time to hours and minutes
|
h = Hash.new
|
||||||
hours = spent_hours.to_i
|
|
||||||
minutesDecimal = (( spent_hours - hours) * 60)
|
spent_time.each do |entry|
|
||||||
minutes = minutesDecimal.to_i
|
h[entry.activity.name] = h[entry.activity.name] + entry.hours
|
||||||
|
|
||||||
# update time entries billed status
|
# update time entries billed status
|
||||||
spent_time.each do |entry|
|
|
||||||
entry.qbo_billed = true
|
entry.qbo_billed = true
|
||||||
entry.save
|
entry.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
h.each do |key, val|
|
||||||
|
item_id = Qbo.get_base(:item).service.query("SELECT Id FROM Item WHERE Name = '#{key}' ")
|
||||||
|
|
||||||
|
# Convert float spent time to hours and minutes
|
||||||
|
hours = val.to_i
|
||||||
|
minutesDecimal = (( spent_hours - hours) * 60)
|
||||||
|
minutes = minutesDecimal.to_i
|
||||||
|
|
||||||
item = item_service.fetch_by_id issue.qbo_item_id
|
item = item_service.fetch_by_id issue.qbo_item_id
|
||||||
time_entry.description = "#{issue.tracker} ##{issue.id}: #{issue.subject}"
|
time_entry.description = "#{issue.tracker} ##{issue.id}: #{issue.subject}"
|
||||||
|
# TODO entry.user.qbo_employee.id
|
||||||
time_entry.employee_id = employee_id
|
time_entry.employee_id = employee_id
|
||||||
time_entry.customer_id = issue.customer_id
|
time_entry.customer_id = issue.customer_id
|
||||||
time_entry.billable_status = "Billable"
|
time_entry.billable_status = "Billable"
|
||||||
@@ -100,10 +104,11 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
|
|||||||
time_entry.name_of = "Employee"
|
time_entry.name_of = "Employee"
|
||||||
time_entry.txn_date = Date.today
|
time_entry.txn_date = Date.today
|
||||||
time_entry.hourly_rate = item.unit_price
|
time_entry.hourly_rate = item.unit_price
|
||||||
time_entry.item_id = issue.qbo_item_id
|
time_entry.item_id = item_id #issue.qbo_item_id
|
||||||
time_entry.start_time = issue.start_date
|
time_entry.start_time = issue.start_date
|
||||||
time_entry.end_time = Time.now
|
time_entry.end_time = Time.now
|
||||||
time_service.create(time_entry)
|
time_service.create(time_entry)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user