mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Update customer.rb
This commit is contained in:
@@ -15,6 +15,8 @@ class Customer < ActiveRecord::Base
|
|||||||
has_many :qbo_purchases
|
has_many :qbo_purchases
|
||||||
has_many :vehicles
|
has_many :vehicles
|
||||||
|
|
||||||
|
before_save :qbo
|
||||||
|
|
||||||
attr_accessible :name
|
attr_accessible :name
|
||||||
validates_presence_of :id, :name
|
validates_presence_of :id, :name
|
||||||
|
|
||||||
@@ -50,6 +52,14 @@ class Customer < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Updates the customer's primary phone number
|
||||||
|
def primary_phone=(n)
|
||||||
|
Quickbooks::Model::TelephoneNumber.new
|
||||||
|
pn.free_form_number = n
|
||||||
|
@details.primary_phone = pn
|
||||||
|
push
|
||||||
|
end
|
||||||
|
|
||||||
# returns the customer's mobile phone
|
# returns the customer's mobile phone
|
||||||
def mobile_phone
|
def mobile_phone
|
||||||
begin
|
begin
|
||||||
@@ -59,6 +69,14 @@ class Customer < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Updates the custome's mobile phone number
|
||||||
|
def mobile_phone=(n)
|
||||||
|
Quickbooks::Model::TelephoneNumber.new
|
||||||
|
pn.free_form_number = n
|
||||||
|
@details.mobile_phone = pn
|
||||||
|
push
|
||||||
|
end
|
||||||
|
|
||||||
# returns the customer's notes
|
# returns the customer's notes
|
||||||
def notes
|
def notes
|
||||||
return @details.notes if @details
|
return @details.notes if @details
|
||||||
@@ -68,7 +86,7 @@ class Customer < ActiveRecord::Base
|
|||||||
def notes=(s)
|
def notes=(s)
|
||||||
customer = get_customer(self.id)
|
customer = get_customer(self.id)
|
||||||
customer.notes = s
|
customer.notes = s
|
||||||
get_base.update(customer)
|
push
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns the bases QBO service for customers
|
# returns the bases QBO service for customers
|
||||||
@@ -105,6 +123,23 @@ class Customer < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def push
|
||||||
|
begin
|
||||||
|
get_base.update(@details)
|
||||||
|
rescue
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def qbo
|
||||||
|
if new_record?
|
||||||
|
customer = Quickbooks::Model::Customer.new
|
||||||
|
customer.display_name = self.name
|
||||||
|
@details = get_base.create(customer)
|
||||||
|
self.id = @details.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# init details
|
# init details
|
||||||
def get_details
|
def get_details
|
||||||
t= Thread.new {
|
t= Thread.new {
|
||||||
|
|||||||
Reference in New Issue
Block a user