mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d6c114d52b | |||
| 87b8daf283 | |||
| 719abe20a6 | |||
| 4a5b83265d | |||
| 8d103d3fc6 | |||
| 9310f207a3 | |||
| 000b67b329 | |||
| ebee9395ba | |||
| 2cd6731f0c | |||
| ebdbd25082 | |||
| 18ada91fcd | |||
| 1cf3926585 | |||
| e776deeece | |||
| 8c2f30949a | |||
| 015a989f72 | |||
| 0d4d5a6136 | |||
| 0364989fe1 | |||
| fb47eaba0e | |||
| 725d511be5 | |||
| fd85f296de | |||
| 9549bb8fe2 | |||
| 6a1c8b0551 |
@@ -4,9 +4,13 @@ A plugin for Redmine to connect to Quickbooks Online
|
||||
|
||||
The goal of this project is to allow Redmine to connect with Quickbooks Online to create `Time Activity Entries` for completed work when an Issue is closed.
|
||||
|
||||
`Note: Although the core functionality is complete, this project is still under heavy development. I am still working on refining everthing and adding other features. Tags should be stable`
|
||||
#### Disclaimer
|
||||
|
||||
`Note: I am currently using this in a live production enviroment with no issues`
|
||||
OAuth2 is hacked into place with version 0.8.0 & working but I'm sure I missed a few things
|
||||
|
||||
Note: Although the core functionality is complete, this project is still under heavy development. I am still working on refining everthing and adding other features. Tags should be stable
|
||||
|
||||
Also worth metioning I am currently using this in a live production enviroment with no issues
|
||||
|
||||
#### Features
|
||||
* Issues can be assigned to a `Customer` via drop down in the edit Issue form
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#The MIT License (MIT)
|
||||
#
|
||||
#Copyright (c) 2017 rick barrette
|
||||
#Copyright (c) 2020 rick barrette
|
||||
#
|
||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
@@ -66,7 +66,7 @@ class QboController < ApplicationController
|
||||
qbo.company_id = params[:realmId]
|
||||
|
||||
access_token = OAuth2::AccessToken.new(oauth2_client, resp.token, refresh_token: resp.refresh_token)
|
||||
qbo.token = access_token
|
||||
qbo.token = access_token.to_hash
|
||||
qbo.expire = 1.hour.from_now.utc
|
||||
|
||||
if qbo.save!
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
class Qbo < ActiveRecord::Base
|
||||
unloadable
|
||||
validates_presence_of :qb_token, :qb_secret, :company_id, :token_expires_at, :reconnect_token_at
|
||||
serialize :token
|
||||
|
||||
OAUTH_CONSUMER_KEY = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey']
|
||||
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret']
|
||||
@@ -32,19 +33,24 @@ class Qbo < ActiveRecord::Base
|
||||
# Get a quickbooks base service object for type
|
||||
# @params type of base
|
||||
def self.get_base(type)
|
||||
# lets getnourbold access token from the database
|
||||
oauth2_client = get_client
|
||||
qbo = self.first
|
||||
access_token = OAuth2::AccessToken.new(oauth2_client, qbo.qb_token , refresh_token: qbo.qb_secret)
|
||||
access_token = OAuth2::AccessToken.from_hash(oauth2_client, qbo.token)
|
||||
|
||||
# check to see if we need to refest the token
|
||||
#if qbo.expire.to_date.past?
|
||||
# new_access_token_object = access_token.refresh!
|
||||
# qbo.token = new_access_token_object
|
||||
# qbo.expire = 1.hour.from_now.utc
|
||||
# qbo.save!
|
||||
# access_token = new_access_token_object
|
||||
#end
|
||||
# check to see if we need to refresh the acesstoken
|
||||
if qbo.expire.to_time.utc.past?
|
||||
puts "Updating access token"
|
||||
new_access_token_object = access_token.refresh!
|
||||
qbo.token = new_access_token_object.to_hash
|
||||
qbo.expire = 1.hour.from_now.utc
|
||||
qbo.save!
|
||||
access_token = new_access_token_object
|
||||
else
|
||||
puts "Using current token"
|
||||
end
|
||||
|
||||
# build the reqiested service
|
||||
case type
|
||||
when :item
|
||||
return Quickbooks::Service::Item.new(:company_id => qbo.company_id, :access_token => access_token)
|
||||
@@ -58,6 +64,8 @@ class Qbo < ActiveRecord::Base
|
||||
return Quickbooks::Service::Estimate.new(:company_id => qbo.company_id, :access_token => access_token)
|
||||
when :account
|
||||
return Quickbooks::Service::Account.new(:company_id => qbo.company_id, :access_token => access_token)
|
||||
when :employee
|
||||
return Quickbooks::Service:: Employee.new(:company_id => qbo.company_id, :access_token => access_token)
|
||||
else
|
||||
return access_token
|
||||
end
|
||||
|
||||
@@ -12,6 +12,6 @@ class UpdateQbosToken < ActiveRecord::Migration
|
||||
|
||||
def change
|
||||
add_column :qbos, :token, :text
|
||||
add_column :qbos, :expire, :date
|
||||
add_column :qbos, :expire, :datetime
|
||||
end
|
||||
end
|
||||
|
||||
2
init.rb
2
init.rb
@@ -31,7 +31,7 @@ Redmine::Plugin.register :redmine_qbo do
|
||||
name 'Redmine Quickbooks Online plugin'
|
||||
author 'Rick Barrette'
|
||||
description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues'
|
||||
version '0.8.0'
|
||||
version '0.8.1'
|
||||
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||
author_url 'http://rickbarrette.org'
|
||||
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
||||
|
||||
Reference in New Issue
Block a user