Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle customer primary contact better #76

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lockstep_rails (0.3.83)
lockstep_rails (0.3.84)
rails

GEM
Expand Down
7 changes: 6 additions & 1 deletion app/models/lockstep/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Lockstep::Invoice < Lockstep::ApiRecord
load_schema(Schema::Invoice)

belongs_to :connection, class_name: 'Lockstep::Connection', foreign_key: :customer_id
belongs_to :customer_primary_contact, {:class_name=>"Lockstep::Contact", :included=>true}

scope :einvoices, -> { where(is_e_invoice: true).include_object(:customer, :lines, :attachments) }
scope :received_einvoices, -> { einvoices.where(invoice_type_code: 'AP Invoice') }
Expand All @@ -16,4 +15,10 @@ def download_pdf
response = resource.get "#{id}/pdf"
response.body
end

def customer_primary_contact
return nil unless attributes['customer_primary_contact'].present?

Lockstep::Contact.new attributes['customer_primary_contact']
end
end
1 change: 0 additions & 1 deletion app/platform_api/schema/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ def self.id_ref
belongs_to :connection, {:class_name=>"Lockstep::Connection", :primary_key=>:company_id, :foreign_key=>"customer_id"}
belongs_to :created_user, {:class_name=>"Lockstep::User", :primary_key=>:user_id, :foreign_key=>"created_user_id"}
belongs_to :modified_user, {:class_name=>"Lockstep::User", :primary_key=>:user_id, :foreign_key=>"modified_user_id"}
belongs_to :customer_primary_contact, {:class_name=>"Lockstep::Contact", :included=>true}

has_many :workflow_statuses, {:class_name=>"Schema::InvoiceWorkflowStatusHistory", :included=>true}
has_many :addresses, {:class_name=>"Schema::InvoiceAddress", :included=>true}
Expand Down
2 changes: 1 addition & 1 deletion lib/lockstep_rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module LockstepRails
VERSION = '0.3.83'
VERSION = '0.3.84'
end
Loading