Added Estimate date

This commit is contained in:
2022-02-20 17:19:56 -05:00
parent 70e6038215
commit 8c735d3921
2 changed files with 31 additions and 1 deletions

View File

@@ -62,5 +62,35 @@ class QboEstimate < ActiveRecord::Base
estimate = base.fetch_by_id(id) estimate = base.fetch_by_id(id)
return base.pdf(estimate) return base.pdf(estimate)
end end
# Magic Method
# Maps Get/Set methods to QBO estimate object
def method_missing(sym, *arguments)
# Check to see if the method exists
if Quickbooks::Model::Estimate.method_defined?(sym)
# download details if required
pull unless @details
method_name = sym.to_s
# Setter
if method_name[-1, 1] == "="
@details.method(method_name).call(arguments[0])
# Getter
else
return @details.method(method_name).call
end
end
end
private
# pull the details
def pull
begin
raise Exception unless self.id
@details = Qbo.get_base(:estimate).fetch_by_id(self.id)
rescue Exception => e
@details = Quickbooks::Model::Estimate.new
end
end
end end

View File

@@ -2,7 +2,7 @@
<% @customer.qbo_estimates.each do |estimate| %> <% @customer.qbo_estimates.each do |estimate| %>
<div class="row"> <div class="row">
<b><%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %> </b> <b><%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %></b> <%= estimate.txn_date %>
</div> </div>
<% end %> <% end %>