diff --git a/HISTORY.md b/HISTORY.md index c01f6d46b..ac317b1b2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,7 @@ ### Added -* +* Update Estimate record fields/record refs for 2021.2. `balance`, `bill_address`, `bill_is_residential`, and `is_multi_ship_to` were all removed as fields as either being incorrect, outdated, or a search-only field. (#496) * ### Fixed @@ -29,4 +29,4 @@ * Fix accessing custom field values returned in advanced search results (#480) * Fixing bug where single-selection custom multi select fields would incorrectly be parsed 3377c971d0cb727d81f4b4bc6e30edfbdfaccfd1 * Fixed some field definitions on serialized assembly item -* Properly extract external_id from advanced search results (#478) \ No newline at end of file +* Properly extract external_id from advanced search results (#478) diff --git a/lib/netsuite/records/estimate.rb b/lib/netsuite/records/estimate.rb index d131964dd..41e11631b 100644 --- a/lib/netsuite/records/estimate.rb +++ b/lib/netsuite/records/estimate.rb @@ -9,24 +9,105 @@ class Estimate actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search - fields :alt_handling_cost, :alt_sales_total, :alt_shipping_cost, :balance, - :bill_address, :billing_schedule, :bill_is_residential, - :created_date, :currency_name, :discount_rate, :email, :end_date, - :est_gross_profit, :exchange_rate, :handling_cost, :handling_tax1_rate, :is_taxable, - :last_modified_date, :memo, :message, :other_ref_num, :ship_date, :shipping_cost, - :shipping_tax1_rate, :source, :start_date, :status, :sync_partner_teams, :sync_sales_teams, - :to_be_emailed, :to_be_faxed, :to_be_printed, :total_cost_estimate, :tran_date, :tran_id, - :linked_tracking_numbers, :is_multi_ship_to + fields :alt_handling_cost, + :alt_sales_total, + :alt_shipping_cost, + :can_have_stackable, + :contrib_pct, + :created_date, + :currency_name, + :discount_rate, + :discount_total, + :due_date, + :email, + :end_date, + :est_gross_profit, + :est_gross_profit_percent, + :exchange_rate, + :expected_close_date, + :fax, + :fob, + :handling_cost, + :handling_tax1_rate, + :handling_tax2_rate, + :include_in_forecast, + :is_taxable, + :last_modified_date, + :linked_tracking_numbers, + :memo, + :message, + :one_time, + :other_ref_num, + :probability, + :recur_annually, + :recur_monthly, + :recur_quarterly, + :recur_weekly, + :ship_date, + :ship_is_residential, + :shipping_cost, + :shipping_tax1_rate, + :shipping_tax2_rate, + :source, + :start_date, + :status, + :sub_total, + :sync_partner_teams, + :sync_sales_teams, + :tax2_total, + :tax_details_override, + :tax_point_date, + :tax_rate, + :tax_reg_override, + :tax_total, + :title, + :to_be_emailed, + :to_be_faxed, + :to_be_printed, + :total, + :total_cost_estimate, + :tracking_numbers, + :tran_date, + :tran_id, + :vat_reg_num, + :visible_to_customer - field :shipping_address, Address field :billing_address, Address - - field :item_list, EstimateItemList field :custom_field_list, CustomFieldList + field :item_list, EstimateItemList + field :promotions_list, PromotionsList + field :shipping_address, Address - record_refs :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item, :entity, - :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :opportunity, :partner, - :promo_code, :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :terms + record_refs :bill_address_list, + :billing_schedule, + :klass, + :created_from, + :currency, + :custom_form, + :department, + :discount_item, + :entity, + :entity_status, + :entity_tax_reg_num, + :forecast_type, + :handling_tax_code, + :job, + :lead_source, + :location, + :message_sel, + :nexus, + :opportunity, + :partner, + :promo_code, + :sales_group, + :sales_rep, + :ship_address_list, + :ship_method, + :shipping_tax_code, + :subsidiary, + :subsidiary_tax_reg_num, + :tax_item, + :terms attr_reader :internal_id attr_accessor :external_id diff --git a/spec/netsuite/records/estimate_spec.rb b/spec/netsuite/records/estimate_spec.rb index 9c6546696..7731e827a 100644 --- a/spec/netsuite/records/estimate_spec.rb +++ b/spec/netsuite/records/estimate_spec.rb @@ -7,27 +7,117 @@ it 'has all the right fields' do [ - :alt_handling_cost, :alt_shipping_cost, - :balance, :bill_address, :created_date, :currency_name, - :discount_rate, :email, :end_date, :est_gross_profit, + :alt_handling_cost, + :alt_sales_total, + :alt_shipping_cost, + :can_have_stackable, + :contrib_pct, + :created_date, + :currency_name, + :discount_rate, + :discount_total, + :due_date, + :email, + :end_date, + :est_gross_profit, + :est_gross_profit_percent, :exchange_rate, - :handling_cost, :handling_tax1_rate, :is_taxable, - :last_modified_date, :memo, :message, :other_ref_num, - :shipping_cost, :shipping_tax1_rate, - :source, :start_date, :status, :sync_partner_teams, - :sync_sales_teams, :to_be_emailed, :to_be_faxed, :to_be_printed, - :total_cost_estimate, :tran_date, :tran_id + :expected_close_date, + :fax, + :fob, + :handling_cost, + :handling_tax1_rate, + :handling_tax2_rate, + :include_in_forecast, + :is_taxable, + :last_modified_date, + :linked_tracking_numbers, + :memo, + :message, + :one_time, + :other_ref_num, + :probability, + :recur_annually, + :recur_monthly, + :recur_quarterly, + :recur_weekly, + :ship_date, + :ship_is_residential, + :shipping_cost, + :shipping_tax1_rate, + :shipping_tax2_rate, + :source, + :start_date, + :status, + :sub_total, + :sync_partner_teams, + :sync_sales_teams, + :tax2_total, + :tax_details_override, + :tax_point_date, + :tax_rate, + :tax_reg_override, + :tax_total, + :title, + :to_be_emailed, + :to_be_faxed, + :to_be_printed, + :total, + :total_cost_estimate, + :tracking_numbers, + :tran_date, + :tran_id, + :vat_reg_num, + :visible_to_customer, ].each do |field| expect(estimate).to have_field(field) end end + it 'has all the right fields with specific classes' do + { + billing_address: NetSuite::Records::Address, + custom_field_list: NetSuite::Records::CustomFieldList, + item_list: NetSuite::Records::EstimateItemList, + promotions_list: NetSuite::Records::PromotionsList, + shipping_address: NetSuite::Records::Address, + }.each do |field, klass| + expect(estimate).to have_field(field, klass) + end + end + it 'has all the right record refs' do [ - :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item, - :entity, :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, - :opportunity, :partner, :promo_code, :sales_group, :sales_rep, - :ship_method, :shipping_tax_code, :subsidiary + :bill_address_list, + :billing_schedule, + :klass, + :created_from, + :currency, + :custom_form, + :department, + :discount_item, + :entity, + :entity_status, + :entity_tax_reg_num, + :forecast_type, + :handling_tax_code, + :job, + :lead_source, + :location, + :message_sel, + :nexus, + :opportunity, + :partner, + :promo_code, + :sales_group, + :sales_rep, + :ship_address_list, + :ship_method, + :shipping_tax_code, + :subsidiary, + :subsidiary_tax_reg_num, + :tax_item, + :terms, ].each do |record_ref| expect(estimate).to have_record_ref(record_ref) end diff --git a/spec/support/field_matcher.rb b/spec/support/field_matcher.rb index 0233b84a3..a748a0e34 100644 --- a/spec/support/field_matcher.rb +++ b/spec/support/field_matcher.rb @@ -1,17 +1,19 @@ -RSpec::Matchers.define :have_field do |attribute| +RSpec::Matchers.define :have_field do |attribute, klass| match do |model| - field_can_be_set_and_retrieved?(model, attribute) && field_can_be_set_on_instantiation?(model, attribute) + klass = klass || Object + + field_can_be_set_and_retrieved?(model, attribute, klass) && field_can_be_set_on_instantiation?(model, attribute, klass) end - def field_can_be_set_and_retrieved?(model, attribute) - obj = Object.new + def field_can_be_set_and_retrieved?(model, attribute, klass) + obj = klass.new model.send("#{attribute}=".to_sym, obj) model.send(attribute) == obj end - def field_can_be_set_on_instantiation?(model, attribute) - obj = Object.new + def field_can_be_set_on_instantiation?(model, attribute, klass) + obj = klass.new new_model = model.class.new(attribute => obj) new_model.send(attribute) == obj end