mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 16:21:58 -04:00
Removed sync from migration
This commit is contained in:
@@ -14,42 +14,6 @@ class AddTxnDates < ActiveRecord::Migration[5.1]
|
|||||||
begin
|
begin
|
||||||
add_column :qbo_invoices, :txn_date, :date
|
add_column :qbo_invoices, :txn_date, :date
|
||||||
add_column :qbo_estimates, :txn_date, :date
|
add_column :qbo_estimates, :txn_date, :date
|
||||||
|
|
||||||
reversible do |direction|
|
|
||||||
direction.up {
|
|
||||||
break unless Qbo.first
|
|
||||||
|
|
||||||
QboEstimate.reset_column_information
|
|
||||||
QboInvoice.reset_column_information
|
|
||||||
|
|
||||||
say "Sync Estimates"
|
|
||||||
|
|
||||||
QboEstimate.sync
|
|
||||||
|
|
||||||
say "Sync Invoices"
|
|
||||||
|
|
||||||
qbo = Qbo.first
|
|
||||||
invoices = qbo.perform_authenticated_request do |access_token|
|
|
||||||
service = Quickbooks::Service::Invoice.new(company_id: qbo.realm_id, access_token: access_token)
|
|
||||||
service.all
|
|
||||||
end
|
|
||||||
|
|
||||||
return unless invoices
|
|
||||||
|
|
||||||
invoices.each { |invoice|
|
|
||||||
# Load the invoice into the database
|
|
||||||
qbo_invoice = QboInvoice.find_or_create_by(id: invoice.id)
|
|
||||||
qbo_invoice.doc_number = invoice.doc_number
|
|
||||||
qbo_invoice.id = invoice.id
|
|
||||||
qbo_invoice.customer_id = invoice.customer_ref
|
|
||||||
qbo_invoice.txn_date = invoice.txn_date
|
|
||||||
qbo_invoice.save!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
logger.error "AddTxnDates Failed"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user