Class: Suretax::Api::RequestItem

Inherits:
Object
  • Object
show all
Includes:
Concerns::Validatable
Defined in:
lib/suretax/api/request_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Validatable

#errors, included

Constructor Details

#initialize(args = {}) ⇒ RequestItem

Returns a new instance of RequestItem.



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/suretax/api/request_item.rb', line 56

def initialize(args = {})
  args.each_pair do |key, value|
    send("#{key}=", value.to_s)
  end

  @tax_exemption_codes = []
  args[:tax_exemption_codes]&.each do |code|
    @tax_exemption_codes << code.to_s
  end

  validate!
end

Instance Attribute Details

#aux_revenueObject

Returns the value of attribute aux_revenue.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def aux_revenue
  @aux_revenue
end

#aux_revenue_typeObject

Returns the value of attribute aux_revenue_type.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def aux_revenue_type
  @aux_revenue_type
end

#bill_to_numberObject

Returns the value of attribute bill_to_number.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def bill_to_number
  @bill_to_number
end

#common_carrierObject

Returns the value of attribute common_carrier.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def common_carrier
  @common_carrier
end

#customer_numberObject

Returns the value of attribute customer_number.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def customer_number
  @customer_number
end

#dest_country_codeObject

Returns the value of attribute dest_country_code.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def dest_country_code
  @dest_country_code
end

#freight_on_boardObject

Returns the value of attribute freight_on_board.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def freight_on_board
  @freight_on_board
end

#geocodeObject

Returns the value of attribute geocode.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def geocode
  @geocode
end

#invoice_numberObject

Returns the value of attribute invoice_number.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def invoice_number
  @invoice_number
end

#line_numberObject

Returns the value of attribute line_number.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def line_number
  @line_number
end

#mail_orderObject

Returns the value of attribute mail_order.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def mail_order
  @mail_order
end

#order_approval_plus_fourObject

Returns the value of attribute order_approval_plus_four.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def order_approval_plus_four
  @order_approval_plus_four
end

#order_approval_zipcodeObject

Returns the value of attribute order_approval_zipcode.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def order_approval_zipcode
  @order_approval_zipcode
end

#order_placement_plus_fourObject

Returns the value of attribute order_placement_plus_four.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def order_placement_plus_four
  @order_placement_plus_four
end

#order_placement_zipcodeObject

Returns the value of attribute order_placement_zipcode.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def order_placement_zipcode
  @order_placement_zipcode
end

#orig_numberObject

Returns the value of attribute orig_number.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def orig_number
  @orig_number
end

#origin_country_codeObject

Returns the value of attribute origin_country_code.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def origin_country_code
  @origin_country_code
end

#p_to_p_plus_fourObject

Returns the value of attribute p_to_p_plus_four.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def p_to_p_plus_four
  @p_to_p_plus_four
end

#p_to_p_zipcodeObject

Returns the value of attribute p_to_p_zipcode.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def p_to_p_zipcode
  @p_to_p_zipcode
end

#plus_fourObject

Returns the value of attribute plus_four.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def plus_four
  @plus_four
end

#regulatory_codeObject

Returns the value of attribute regulatory_code.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def regulatory_code
  @regulatory_code
end

#revenueObject

Returns the value of attribute revenue.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def revenue
  @revenue
end

#sales_type_codeObject

Returns the value of attribute sales_type_code.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def sales_type_code
  @sales_type_code
end

#secondsObject

Returns the value of attribute seconds.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def seconds
  @seconds
end

#ship_from_plus_fourObject

Returns the value of attribute ship_from_plus_four.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def ship_from_plus_four
  @ship_from_plus_four
end

#ship_from_pobObject

Returns the value of attribute ship_from_pob.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def ship_from_pob
  @ship_from_pob
end

#ship_from_zipcodeObject

Returns the value of attribute ship_from_zipcode.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def ship_from_zipcode
  @ship_from_zipcode
end

#tax_exemption_codesObject

Returns the value of attribute tax_exemption_codes.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def tax_exemption_codes
  @tax_exemption_codes
end

#tax_included_codeObject

Returns the value of attribute tax_included_code.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def tax_included_code
  @tax_included_code
end

#tax_situs_ruleObject

Returns the value of attribute tax_situs_rule.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def tax_situs_rule
  @tax_situs_rule
end

#term_numberObject

Returns the value of attribute term_number.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def term_number
  @term_number
end

#trans_dateObject

Returns the value of attribute trans_date.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def trans_date
  @trans_date
end

#trans_type_codeObject

Returns the value of attribute trans_type_code.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def trans_type_code
  @trans_type_code
end

#unit_typeObject

Returns the value of attribute unit_type.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def unit_type
  @unit_type
end

#unitsObject

Returns the value of attribute units.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def units
  @units
end

#user_defined_fieldObject

Returns the value of attribute user_defined_field.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def user_defined_field
  @user_defined_field
end

#zipcodeObject

Returns the value of attribute zipcode.



6
7
8
# File 'lib/suretax/api/request_item.rb', line 6

def zipcode
  @zipcode
end

Instance Method Details

#blank(value) ⇒ Object



115
116
117
# File 'lib/suretax/api/request_item.rb', line 115

def blank(value)
  value.respond_to?(:empty?) ? !!value.empty? : !value
end

#paramsObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/suretax/api/request_item.rb', line 69

def params
  {
    "LineNumber"           => line_number,
    "InvoiceNumber"        => invoice_number,
    "CustomerNumber"       => customer_number,
    "OrigNumber"           => orig_number      || "",
    "TermNumber"           => term_number      || "",
    "BillToNumber"         => bill_to_number   || "",
    "Zipcode"              => zipcode,
    "Plus4"                => plus_four,
    "P2PZipcode"           => p_to_p_zipcode   || "",
    "P2PPlus4"             => p_to_p_plus_four || "",
    "TransDate"            => trans_date       || Date.today.strftime("%m-%d-%Y"),
    "Revenue"              => revenue.to_f,
    "Units"                => units.to_i,
    "UnitType"             => presence(unit_type) || "00",
    "Seconds"              => seconds.to_i,
    "TaxIncludedCode"      => tax_included_code,
    "TaxSitusRule"         => tax_situs_rule,
    "TransTypeCode"        => trans_type_code,
    "SalesTypeCode"        => sales_type_code,
    "RegulatoryCode"       => regulatory_code,
    "TaxExemptionCodeList" => tax_exemption_codes,
    "UDF"                   => user_defined_field || "",
    "ShipFromZipCode"       => ship_from_zipcode || "",
    "ShipFromPlus4"         => ship_from_plus_four || "",
    "OrderPlacementZipcode" => order_placement_zipcode || "",
    "OrderPlacementPlus4"   => order_approval_plus_four || "",
    "OrderApprovalZipcode"  => order_approval_zipcode || "",
    "OrderApprovalPlus4"    => order_approval_plus_four || "",
    "Geocode"               => geocode || "",
    "AuxRevenue"            => presence(aux_revenue) || "0.00",
    "AuxRevenueType"        => presence(aux_revenue_type) || "01",
    "FreightOnBoard"        => freight_on_board || "",
    "ShipFromPOB"           => presence(ship_from_pob) || "1",
    "MailOrder"             => presence(mail_order) || "1",
    "CommonCarrier"         => presence(common_carrier) || "1",
    "OriginCountryCode"     => origin_country_code || "",
    "DestCountryCode"       => dest_country_code || ""
  }
end

#presence(value) ⇒ Object



111
112
113
# File 'lib/suretax/api/request_item.rb', line 111

def presence(value)
  value unless blank(value)
end