NetSuite: Automatically Create TAX Nexus for all Countries (252)

  1. This piece of code will create TAX Nexus for all these countries
  2. For USA and Canada States, please read this post
Iterator it = countryMapForNexusCreation.entrySet().iterator();
    int i = 1;
      while (it.hasNext()) {
          Map.Entry pair = (Map.Entry)it.next();
          //System.out.println(i + ": Code: "  + pair.getKey() + " = " + pair.getValue());
          createNexus((Country)pair.getKey(),(String)pair.getValue());
          it.remove(); // avoids a ConcurrentModificationException
          i++;
      }

public void createNexus(Country countryCode, String countryName) throws Exception{
		//this.login(true);
		//sub.setNexusList(nexusList);
		//getCountryList();
		
		Nexus nex = new Nexus();
		nex.setCountry(countryCode);
		
		nex.setDescription(countryName);
		
		// Invoke add() operation
		WriteResponse response = _port.add(nex);
		// Process the response
		if (response.getStatus().isIsSuccess()) {
			_console.info("\nNexus Created for :" + countryCode.getValue()
					+ "\n  key="
					+ ((RecordRef) response.getBaseRef()).getInternalId()
					+ "\n  entityId="
					+ nex.getDescription()
					);
		} else {
			_console.error(getStatusDetails(response.getStatus()));
		}
		
		
	}

Constant for country list or use the code here

private static final Map<Country, String> countryMapForNexusCreation;
    static
    {
    	countryMapForNexusCreation = new HashMap<Country, String>();
    	
    	countryMapForNexusCreation.put(Country._afghanistan,"Afghanistan");
    	countryMapForNexusCreation.put(Country._alandIslands,"Aland Islands");
    	countryMapForNexusCreation.put(Country._albania,"Albania");
    	countryMapForNexusCreation.put(Country._algeria,"Algeria");
    	countryMapForNexusCreation.put(Country._americanSamoa,"American Samoa");
    	countryMapForNexusCreation.put(Country._andorra,"Andorra");
    	countryMapForNexusCreation.put(Country._angola,"Angola");
    	countryMapForNexusCreation.put(Country._anguilla,"Anguilla");
    	countryMapForNexusCreation.put(Country._antarctica,"Antarctica");
    	countryMapForNexusCreation.put(Country._antiguaAndBarbuda,"Antigua and Barbuda");
    	countryMapForNexusCreation.put(Country._argentina,"Argentina");
    	countryMapForNexusCreation.put(Country._armenia,"Armenia");
    	countryMapForNexusCreation.put(Country._aruba,"Aruba");
    	countryMapForNexusCreation.put(Country._australia,"Australia");
    	countryMapForNexusCreation.put(Country._austria,"Austria");
    	countryMapForNexusCreation.put(Country._azerbaijan,"Azerbaijan");
    	countryMapForNexusCreation.put(Country._bahamas,"Bahamas");
    	countryMapForNexusCreation.put(Country._bahrain,"Bahrain");
    	countryMapForNexusCreation.put(Country._bangladesh,"Bangladesh");
    	countryMapForNexusCreation.put(Country._barbados,"Barbados");
    	countryMapForNexusCreation.put(Country._belarus,"Belarus");
    	countryMapForNexusCreation.put(Country._belgium,"Belgium");
    	countryMapForNexusCreation.put(Country._belize,"Belize");
    	countryMapForNexusCreation.put(Country._benin,"Benin");
    	countryMapForNexusCreation.put(Country._bermuda,"Bermuda");
    	countryMapForNexusCreation.put(Country._bhutan,"Bhutan");
    	countryMapForNexusCreation.put(Country._bolivia,"Bolivia");
    	countryMapForNexusCreation.put(Country._bonaireSaintEustatiusAndSaba,"Bonaire, Saint Eustatius, and Saba");
    	countryMapForNexusCreation.put(Country._bosniaAndHerzegovina,"Bosnia and Herzegovina");
    	countryMapForNexusCreation.put(Country._botswana,"Botswana");
    	countryMapForNexusCreation.put(Country._bouvetIsland,"Bouvet Island");
    	countryMapForNexusCreation.put(Country._brazil,"Brazil");
    	countryMapForNexusCreation.put(Country._britishIndianOceanTerritory,"British Indian Ocean Territory");
    	countryMapForNexusCreation.put(Country._bruneiDarussalam,"Brunei Darussalam");
    	countryMapForNexusCreation.put(Country._bulgaria,"Bulgaria");
    	countryMapForNexusCreation.put(Country._burkinaFaso,"Burkina Faso");
    	countryMapForNexusCreation.put(Country._burundi,"Burundi");
    	countryMapForNexusCreation.put(Country._cambodia,"Cambodia");
    	countryMapForNexusCreation.put(Country._cameroon,"Cameroon");
    	countryMapForNexusCreation.put(Country._canada,"Canada");
    	countryMapForNexusCreation.put(Country._canaryIslands,"Canary Islands");
    	countryMapForNexusCreation.put(Country._capeVerde,"Cape Verde");
    	countryMapForNexusCreation.put(Country._caymanIslands,"Cayman Islands");
    	countryMapForNexusCreation.put(Country._centralAfricanRepublic,"Central African Republic");
    	countryMapForNexusCreation.put(Country._ceutaAndMelilla,"Ceuta and Melilla");
    	countryMapForNexusCreation.put(Country._chad,"Chad");
    	countryMapForNexusCreation.put(Country._chile,"Chile");
    	countryMapForNexusCreation.put(Country._china,"China");
    	countryMapForNexusCreation.put(Country._christmasIsland,"Christmas Island");
    	countryMapForNexusCreation.put(Country._cocosKeelingIslands,"Cocos (Keeling) Islands");
    	countryMapForNexusCreation.put(Country._colombia,"Colombia");
    	countryMapForNexusCreation.put(Country._comoros,"Comoros");
    	countryMapForNexusCreation.put(Country._congoDemocraticPeoplesRepublic,"Congo, Democratic People's Republic");
    	countryMapForNexusCreation.put(Country._congoRepublicOf,"Congo,  Republic of");
    	countryMapForNexusCreation.put(Country._cookIslands,"Cook Islands");
    	countryMapForNexusCreation.put(Country._costaRica,"Costa Rica");
    	countryMapForNexusCreation.put(Country._coteDIvoire,"Cote d'Ivoire");
    	countryMapForNexusCreation.put(Country._croatiaHrvatska,"Croatia/Hrvatska");
    	countryMapForNexusCreation.put(Country._cuba,"Cuba");
    	countryMapForNexusCreation.put(Country._curacao,"Curacao");
    	countryMapForNexusCreation.put(Country._cyprus,"Cyprus");
    	countryMapForNexusCreation.put(Country._czechRepublic,"Czech Republic");
    	countryMapForNexusCreation.put(Country._denmark,"Denmark");
    	countryMapForNexusCreation.put(Country._djibouti,"Djibouti");
    	countryMapForNexusCreation.put(Country._dominica,"Dominica");
    	countryMapForNexusCreation.put(Country._dominicanRepublic,"Dominican Republic");
    	countryMapForNexusCreation.put(Country._eastTimor,"East Timor");
    	countryMapForNexusCreation.put(Country._ecuador,"Ecuador");
    	countryMapForNexusCreation.put(Country._egypt,"Egypt");
    	countryMapForNexusCreation.put(Country._elSalvador,"El Salvador");
    	countryMapForNexusCreation.put(Country._equatorialGuinea,"Equatorial Guinea");
    	countryMapForNexusCreation.put(Country._eritrea,"Eritrea");
    	countryMapForNexusCreation.put(Country._estonia,"Estonia");
    	countryMapForNexusCreation.put(Country._ethiopia,"Ethiopia");
    	countryMapForNexusCreation.put(Country._falklandIslands,"Falkland Islands");
    	countryMapForNexusCreation.put(Country._faroeIslands,"Faroe Islands");
    	countryMapForNexusCreation.put(Country._fiji,"Fiji");
    	countryMapForNexusCreation.put(Country._finland,"Finland");
    	countryMapForNexusCreation.put(Country._france,"France");
    	countryMapForNexusCreation.put(Country._frenchGuiana,"French Guiana");
    	countryMapForNexusCreation.put(Country._frenchPolynesia,"French Polynesia");
    	countryMapForNexusCreation.put(Country._frenchSouthernTerritories,"French Southern Territories");
    	countryMapForNexusCreation.put(Country._gabon,"Gabon");
    	countryMapForNexusCreation.put(Country._gambia,"Gambia");
    	countryMapForNexusCreation.put(Country._georgia,"Georgia");
    	countryMapForNexusCreation.put(Country._germany,"Germany");
    	countryMapForNexusCreation.put(Country._ghana,"Ghana");
    	countryMapForNexusCreation.put(Country._gibraltar,"Gibraltar");
    	countryMapForNexusCreation.put(Country._greece,"Greece");
    	countryMapForNexusCreation.put(Country._greenland,"Greenland");
    	countryMapForNexusCreation.put(Country._grenada,"Grenada");
    	countryMapForNexusCreation.put(Country._guadeloupe,"Guadeloupe");
    	countryMapForNexusCreation.put(Country._guam,"Guam");
    	countryMapForNexusCreation.put(Country._guatemala,"Guatemala");
    	countryMapForNexusCreation.put(Country._guernsey,"Guernsey");
    	countryMapForNexusCreation.put(Country._guinea,"Guinea");
    	countryMapForNexusCreation.put(Country._guineaBissau,"Guinea-Bissau");
    	countryMapForNexusCreation.put(Country._guyana,"Guyana");
    	countryMapForNexusCreation.put(Country._haiti,"Haiti");
    	countryMapForNexusCreation.put(Country._heardAndMcDonaldIslands,"Heard and McDonald Islands");
    	countryMapForNexusCreation.put(Country._holySeeCityVaticanState,"Holy See (City Vatican State)");
    	countryMapForNexusCreation.put(Country._honduras,"Honduras");
    	countryMapForNexusCreation.put(Country._hongKong,"Hong Kong");
    	countryMapForNexusCreation.put(Country._hungary,"Hungary");
    	countryMapForNexusCreation.put(Country._iceland,"Iceland");
    	countryMapForNexusCreation.put(Country._india,"India");
    	countryMapForNexusCreation.put(Country._indonesia,"Indonesia");
    	countryMapForNexusCreation.put(Country._iranIslamicRepublicOf,"Iran (Islamic Republic of)");
    	countryMapForNexusCreation.put(Country._iraq,"Iraq");
    	countryMapForNexusCreation.put(Country._ireland,"Ireland");
    	countryMapForNexusCreation.put(Country._isleOfMan,"Isle of Man");
    	countryMapForNexusCreation.put(Country._israel,"Israel");
    	countryMapForNexusCreation.put(Country._italy,"Italy");
    	countryMapForNexusCreation.put(Country._jamaica,"Jamaica");
    	countryMapForNexusCreation.put(Country._japan,"Japan");
    	countryMapForNexusCreation.put(Country._jersey,"Jersey");
    	countryMapForNexusCreation.put(Country._jordan,"Jordan");
    	countryMapForNexusCreation.put(Country._kazakhstan,"Kazakhstan");
    	countryMapForNexusCreation.put(Country._kenya,"Kenya");
    	countryMapForNexusCreation.put(Country._kiribati,"Kiribati");
    	countryMapForNexusCreation.put(Country._koreaDemocraticPeoplesRepublic,"Korea,  Democratic People's Republic");
    	countryMapForNexusCreation.put(Country._koreaRepublicOf,"Korea,  Republic of");
    	countryMapForNexusCreation.put(Country._kosovo,"Kosovo");
    	countryMapForNexusCreation.put(Country._kuwait,"Kuwait");
    	countryMapForNexusCreation.put(Country._kyrgyzstan,"Kyrgyzstan");
    	countryMapForNexusCreation.put(Country._laoPeoplesDemocraticRepublic,"Lao People's Democratic Republic");
    	countryMapForNexusCreation.put(Country._latvia,"Latvia");
    	countryMapForNexusCreation.put(Country._lebanon,"Lebanon");
    	countryMapForNexusCreation.put(Country._lesotho,"Lesotho");
    	countryMapForNexusCreation.put(Country._liberia,"Liberia");
    	countryMapForNexusCreation.put(Country._libya,"Libyan Arab Jamahiriya");
    	countryMapForNexusCreation.put(Country._liechtenstein,"Liechtenstein");
    	countryMapForNexusCreation.put(Country._lithuania,"Lithuania");
    	countryMapForNexusCreation.put(Country._luxembourg,"Luxembourg");
    	countryMapForNexusCreation.put(Country._macau,"Macau");
    	countryMapForNexusCreation.put(Country._macedonia,"Macedonia");
    	countryMapForNexusCreation.put(Country._madagascar,"Madagascar");
    	countryMapForNexusCreation.put(Country._malawi,"Malawi");
    	countryMapForNexusCreation.put(Country._malaysia,"Malaysia");
    	countryMapForNexusCreation.put(Country._maldives,"Maldives");
    	countryMapForNexusCreation.put(Country._mali,"Mali");
    	countryMapForNexusCreation.put(Country._malta,"Malta");
    	countryMapForNexusCreation.put(Country._marshallIslands,"Marshall Islands");
    	countryMapForNexusCreation.put(Country._martinique,"Martinique");
    	countryMapForNexusCreation.put(Country._mauritania,"Mauritania");
    	countryMapForNexusCreation.put(Country._mauritius,"Mauritius");
    	countryMapForNexusCreation.put(Country._mayotte,"Mayotte");
    	countryMapForNexusCreation.put(Country._mexico,"Mexico");
    	countryMapForNexusCreation.put(Country._micronesiaFederalStateOf,"Micronesia,  Federal State of");
    	countryMapForNexusCreation.put(Country._moldovaRepublicOf,"Moldova, Republic of");
    	countryMapForNexusCreation.put(Country._monaco,"Monaco");
    	countryMapForNexusCreation.put(Country._mongolia,"Mongolia");
    	countryMapForNexusCreation.put(Country._montenegro,"Montenegro");
    	countryMapForNexusCreation.put(Country._montserrat,"Montserrat");
    	countryMapForNexusCreation.put(Country._morocco,"Morocco");
    	countryMapForNexusCreation.put(Country._mozambique,"Mozambique");
    	countryMapForNexusCreation.put(Country._myanmar,"Myanmar");
    	countryMapForNexusCreation.put(Country._namibia,"Namibia");
    	countryMapForNexusCreation.put(Country._nauru,"Nauru");
    	countryMapForNexusCreation.put(Country._nepal,"Nepal");
    	countryMapForNexusCreation.put(Country._netherlands,"Netherlands");
    	countryMapForNexusCreation.put(Country._newCaledonia,"New Caledonia");
    	countryMapForNexusCreation.put(Country._newZealand,"New Zealand");
    	countryMapForNexusCreation.put(Country._nicaragua,"Nicaragua");
    	countryMapForNexusCreation.put(Country._niger,"Niger");
    	countryMapForNexusCreation.put(Country._nigeria,"Nigeria");
    	countryMapForNexusCreation.put(Country._niue,"Niue");
    	countryMapForNexusCreation.put(Country._norfolkIsland,"Norfolk Island");
    	countryMapForNexusCreation.put(Country._northernMarianaIslands,"Northern Mariana Islands");
    	countryMapForNexusCreation.put(Country._norway,"Norway");
    	countryMapForNexusCreation.put(Country._oman,"Oman");
    	countryMapForNexusCreation.put(Country._pakistan,"Pakistan");
    	countryMapForNexusCreation.put(Country._palau,"Palau");
    	countryMapForNexusCreation.put(Country._palestinianTerritories,"Palestinian Territories");
    	countryMapForNexusCreation.put(Country._panama,"Panama");
    	countryMapForNexusCreation.put(Country._papuaNewGuinea,"Papua New Guinea");
    	countryMapForNexusCreation.put(Country._paraguay,"Paraguay");
    	countryMapForNexusCreation.put(Country._peru,"Peru");
    	countryMapForNexusCreation.put(Country._philippines,"Philippines");
    	countryMapForNexusCreation.put(Country._pitcairnIsland,"Pitcairn Island");
    	countryMapForNexusCreation.put(Country._poland,"Poland");
    	countryMapForNexusCreation.put(Country._portugal,"Portugal");
    	countryMapForNexusCreation.put(Country._puertoRico,"Puerto Rico");
    	countryMapForNexusCreation.put(Country._qatar,"Qatar");
    	countryMapForNexusCreation.put(Country._reunionIsland,"Reunion Island");
    	countryMapForNexusCreation.put(Country._romania,"Romania");
    	countryMapForNexusCreation.put(Country._russianFederation,"Russian Federation");
    	countryMapForNexusCreation.put(Country._rwanda,"Rwanda");
    	countryMapForNexusCreation.put(Country._saintBarthelemy,"Saint Barthélemy");
    	countryMapForNexusCreation.put(Country._saintHelena,"Saint Helena");
    	countryMapForNexusCreation.put(Country._saintKittsAndNevis,"Saint Kitts and Nevis");
    	countryMapForNexusCreation.put(Country._saintLucia,"Saint Lucia");
    	countryMapForNexusCreation.put(Country._saintMartin,"Saint Martin");
    	countryMapForNexusCreation.put(Country._saintVincentAndTheGrenadines,"Saint Vincent and the Grenadines");
    	countryMapForNexusCreation.put(Country._samoa,"Samoa");
    	countryMapForNexusCreation.put(Country._sanMarino,"San Marino");
    	countryMapForNexusCreation.put(Country._saoTomeAndPrincipe,"Sao Tome and Principe");
    	countryMapForNexusCreation.put(Country._saudiArabia,"Saudi Arabia");
    	countryMapForNexusCreation.put(Country._senegal,"Senegal");
    	countryMapForNexusCreation.put(Country._serbia,"Serbia");
    	countryMapForNexusCreation.put(Country._seychelles,"Seychelles");
    	countryMapForNexusCreation.put(Country._sierraLeone,"Sierra Leone");
    	countryMapForNexusCreation.put(Country._singapore,"Singapore");
    	countryMapForNexusCreation.put(Country._sintMaarten,"Sint Maarten");
    	countryMapForNexusCreation.put(Country._slovakRepublic,"Slovak Republic");
    	countryMapForNexusCreation.put(Country._slovenia,"Slovenia");
    	countryMapForNexusCreation.put(Country._solomonIslands,"Solomon Islands");
    	countryMapForNexusCreation.put(Country._somalia,"Somalia");
    	countryMapForNexusCreation.put(Country._southAfrica,"South Africa");
    	countryMapForNexusCreation.put(Country._southGeorgia,"South Georgia");
    	countryMapForNexusCreation.put(Country._southSudan,"South Sudan");
    	countryMapForNexusCreation.put(Country._spain,"Spain");
    	countryMapForNexusCreation.put(Country._sriLanka,"Sri Lanka");
    	countryMapForNexusCreation.put(Country._stPierreAndMiquelon,"St. Pierre and Miquelon");
    	countryMapForNexusCreation.put(Country._sudan,"Sudan");
    	countryMapForNexusCreation.put(Country._suriname,"Suriname");
    	countryMapForNexusCreation.put(Country._svalbardAndJanMayenIslands,"Svalbard and Jan Mayen Islands");
    	countryMapForNexusCreation.put(Country._swaziland,"Swaziland");
    	countryMapForNexusCreation.put(Country._sweden,"Sweden");
    	countryMapForNexusCreation.put(Country._switzerland,"Switzerland");
    	countryMapForNexusCreation.put(Country._syrianArabRepublic,"Syrian Arab Republic");
    	countryMapForNexusCreation.put(Country._taiwan,"Taiwan");
    	countryMapForNexusCreation.put(Country._tajikistan,"Tajikistan");
    	countryMapForNexusCreation.put(Country._tanzania,"Tanzania");
    	countryMapForNexusCreation.put(Country._thailand,"Thailand");
    	countryMapForNexusCreation.put(Country._togo,"Togo");
    	countryMapForNexusCreation.put(Country._tokelau,"Tokelau");
    	countryMapForNexusCreation.put(Country._tonga,"Tonga");
    	countryMapForNexusCreation.put(Country._trinidadAndTobago,"Trinidad and Tobago");
    	countryMapForNexusCreation.put(Country._tunisia,"Tunisia");
    	countryMapForNexusCreation.put(Country._turkey,"Turkey");
    	countryMapForNexusCreation.put(Country._turkmenistan,"Turkmenistan");
    	countryMapForNexusCreation.put(Country._turksAndCaicosIslands,"Turks and Caicos Islands");
    	countryMapForNexusCreation.put(Country._tuvalu,"Tuvalu");
    	countryMapForNexusCreation.put(Country._uganda,"Uganda");
    	countryMapForNexusCreation.put(Country._ukraine,"Ukraine");
    	countryMapForNexusCreation.put(Country._unitedArabEmirates,"United Arab Emirates");
    	countryMapForNexusCreation.put(Country._unitedKingdomGB,"United Kingdom (GB)");
    	countryMapForNexusCreation.put(Country._unitedStates,"United States");
    	countryMapForNexusCreation.put(Country._uruguay,"Uruguay");
    	countryMapForNexusCreation.put(Country._uSMinorOutlyingIslands,"US Minor Outlying Islands");
    	countryMapForNexusCreation.put(Country._uzbekistan,"Uzbekistan");
    	countryMapForNexusCreation.put(Country._vanuatu,"Vanuatu");
    	countryMapForNexusCreation.put(Country._venezuela,"Venezuela");
    	countryMapForNexusCreation.put(Country._vietnam,"Vietnam");
    	countryMapForNexusCreation.put(Country._virginIslandsBritish,"Virgin Islands (British)");
    	countryMapForNexusCreation.put(Country._virginIslandsUSA,"Virgin Islands (USA)");
    	countryMapForNexusCreation.put(Country._wallisAndFutunaIslands,"Wallis and Futuna Islands");
    	countryMapForNexusCreation.put(Country._westernSahara,"Western Sahara");
    	countryMapForNexusCreation.put(Country._yemen,"Yemen");
    	countryMapForNexusCreation.put(Country._zambia,"Zambia");
    	countryMapForNexusCreation.put(Country._zimbabwe,"Zimbabwe");
    	
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>