Skip to content

Bug Report: NetSuite::Support::Country ignores lowercase ISO country codes #619

@13-Sonal

Description

@13-Sonal

The NetSuite::Support::Country initializer only maps uppercase ISO country codes (e.g., "IN"), but fails silently for lowercase inputs (e.g., "in"), resulting in an invalid @id.

Steps to Reproduce:

NetSuite::Records::Address.new(
  addressee: "Test Company",
  country: "IN"
)
# => @id = "_india"

NetSuite::Records::Address.new(
  addressee: "Test Company",
  country: "in"
)
# => @id = "in" (invalid)

Image

Expected Behavior:
The country input should be normalized (e.g., upcase) before lookup, so both "IN" and "in" map to "_india".

Suggested Fix:
In NetSuite::Support::Country#initialize:

if iso_or_name.to_s.upcase =~ /^[A-Z]{2}/
  @id = iso_to_netsuite.fetch(iso_or_name.to_s.upcase)

Gem Version - netsuite (0.9.3)
Ruby Version - ruby 2.7.8p225 (2023-03-30 revision 1f4d455848)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions