mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 08:54:23 -05:00
Fix broken invoice processing
This commit is contained in:
@@ -70,26 +70,26 @@ class Invoice < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# processes the invoice into the database
|
# processes the invoice into the database
|
||||||
def self.process_invoice(invoice)
|
def self.process_invoice(i)
|
||||||
logger.info "Processing invoice #{invoice.id}"
|
logger.info "Processing invoice #{i.id}"
|
||||||
|
|
||||||
# Load the invoice into the database
|
# Load the invoice into the database
|
||||||
invoice = Invoice.find_or_create_by(id: invoice.id)
|
invoice = Invoice.find_or_create_by(id: i.id)
|
||||||
invoice.doc_number = invoice.doc_number
|
invoice.doc_number = i.doc_number
|
||||||
invoice.id = invoice.id
|
invoice.id = i.id
|
||||||
invoice.customer_id = invoice.customer_ref
|
invoice.customer_id = i.customer_ref
|
||||||
invoice.txn_date = invoice.txn_date
|
invoice.txn_date = i.txn_date
|
||||||
invoice.save!
|
invoice.save!
|
||||||
|
|
||||||
# Scan the private notes for hashtags and attach to the applicable issues
|
# Scan the private notes for hashtags and attach to the applicable issues
|
||||||
if not invoice.private_note.nil?
|
if not i.private_note.nil?
|
||||||
invoice.private_note.scan(/#(\w+)/).flatten.each { |issue|
|
i.private_note.scan(/#(\w+)/).flatten.each { |issue|
|
||||||
attach_to_issue(Issue.find_by_id(issue.to_i), invoice)
|
attach_to_issue(Issue.find_by_id(issue.to_i), invoice)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Scan the line items for hashtags and attach to the applicable issues
|
# Scan the line items for hashtags and attach to the applicable issues
|
||||||
invoice.line_items.each { |line|
|
i.line_items.each { |line|
|
||||||
if line.description
|
if line.description
|
||||||
line.description.scan(/#(\w+)/).flatten.each { |issue|
|
line.description.scan(/#(\w+)/).flatten.each { |issue|
|
||||||
attach_to_issue(Issue.find_by_id(issue.to_i), invoice)
|
attach_to_issue(Issue.find_by_id(issue.to_i), invoice)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ module IssuePatch
|
|||||||
next if item.nil?
|
next if item.nil?
|
||||||
|
|
||||||
# Create the new billable time entry and upload it
|
# Create the new billable time entry and upload it
|
||||||
time_entry.description = "#{tracker} ##{id} : #{subject} #{"(Partial @ #{done_ratio}%)" if not closed?}"
|
time_entry.description = "#{tracker} ##{id}: #{subject} #{"(Partial @ #{done_ratio}%)" if not closed?}"
|
||||||
time_entry.employee_id = assigned_to.employee_id
|
time_entry.employee_id = assigned_to.employee_id
|
||||||
time_entry.customer_id = customer_id
|
time_entry.customer_id = customer_id
|
||||||
time_entry.billable_status = "Billable"
|
time_entry.billable_status = "Billable"
|
||||||
|
|||||||
Reference in New Issue
Block a user