class Quickbooks::Model::TaxService
Constants
- REST_RESOURCE
Public Class Methods
from_json(response)
click to toggle source
# File lib/quickbooks/model/tax_service.rb, line 19 def self.from_json(response) result = JSON.parse(response) if result.present? ts = Quickbooks::Model::TaxService.new ts.tax_code = result['TaxCode'] ts.tax_code_id = result['TaxCodeId'] result['TaxRateDetails'].each do |item| attrs = item.keys.inject({}){|mem, k| mem[k.underscore] = item[k]; mem} ts.tax_rate_details << Quickbooks::Model::TaxRateDetailLine.new(attrs) end return ts else return nil end end
new(options = {})
click to toggle source
Calls superclass method
Quickbooks::Model::BaseModel::new
# File lib/quickbooks/model/tax_service.rb, line 14 def initialize(options = {}) self.tax_rate_details = options['tax_rate_details'] || [] super end
Public Instance Methods
check_details_item()
click to toggle source
# File lib/quickbooks/model/tax_service.rb, line 35 def check_details_item if tax_rate_details.blank? errors.add(:tax_rate_details, "must have at least one item") else tax_rate_details.each do |line| unless line.valid? errors.add(:base, line.errors.full_messages.join(', ')) end end names = tax_rate_details.map(&:tax_rate_name).uniq if names.size < tax_rate_details.size errors.add(:tax_rate_name, "Duplicate Tax Rate Name") end end end