NetSuite: How to associate Tax Nexus to all subsidiaries

NetSuite by default doesnot allow you to associate all the tax nexus to all the subsidiaries. You have to manually do add the tax nexus one by one to the subsidiaries. Here is how you can get this done using web services.

  1. Export the Subsidiary list and their internal IDs using a Saved Search
  2. Export the Nexus List and their internal IDs using a Saved Search
  3. Replace this in the code below and run it

Quick and dirty code. Obviously to be run only once.

public void updateTaxNexusAll() throws Exception{
Integer arrSubsidiaryInteralID [] = {1,17,23,19,21,5,16,22,24,35,18,20,36,27,28,8,33,14,10,12,37,30,6,13,25,26,29,9,34,15,11,31};

// SANDBOX
// Integer arrSubsidiaryInteralID [] = {1,5,18,3,2,7,9,10,17,8,15,6,12,4,11};
for(int subInternalID=0;subInternalID< arrSubsidiaryInteralID.length ; subInternalID++){
//Integer PRODarrNexusIDs [] = {1,5,6,7,8,9,10,11,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,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,109,110,112,113,114,115,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149};

//Export the Internal IDs of all your Tax Nexus using a Saved Search
Integer arrNexusIDs [] = {5}; //Second Update

//SANDBOX
//Integer arrNexusIDs [] = {5,3,4,7,1,8,2};
for(int nexusInternalID=0 ; nexusInternalID < arrNexusIDs.length ; nexusInternalID++){
updateTaxNexus(arrSubsidiaryInteralID[subInternalID], arrNexusIDs[nexusInternalID]);
System.out.println("Subsidiary " + arrSubsidiaryInteralID[subInternalID] + " : Nexus Added " + arrNexusIDs[nexusInternalID]);

}
}
System.out.println("ALL SUBS UPDATED");
}

public void getAllNexusInternalIDs() throws Exception{
this.login(true);
NexusSearch nexusSearch = new NexusSearch();
SearchResult result = _port.search( nexusSearch );
if (result.getStatus().isIsSuccess()) {
_console.write("Active Nexus count: " + result.getTotalRecords());

// Page Size is 1000 by default
// if there are anymore pages to retrieve.
// searchMore(result);
} else {
_console.error(getStatusDetails(result.getStatus()));
}
}
public void updateTaxNexus(int subInternalID, int nexusInternalID) throws Exception{
// This operation requires a valid session
this.login(true);

RecordRef nexusAndorra = new RecordRef();
nexusAndorra.setInternalId(String.valueOf(nexusInternalID));
nexusAndorra.setType(RecordType.nexus);
// CompanuLimited / 2
// nexusAndorra

//RecordRef subsidiary = new RecordRef();
//subsidiary.setInternalId(String.valueOf(subInternalID));
//subsidiary.setType(RecordType.subsidiary);

//subsidiary.
//List all Nexus
//nexusList.
//Nexus nexus = new Nexus();
//nexus.setInternalId("5");

SubsidiaryNexus subNexus = new SubsidiaryNexus();
subNexus.setNexusId(nexusAndorra);
SubsidiaryNexus subNexusArr[] = new SubsidiaryNexus[1];
subNexusArr[0]=subNexus;

SubsidiaryNexusList subNexusList = new SubsidiaryNexusList();
subNexusList.setNexus(subNexusArr);

//sub.setNexusList(nexusList);
Subsidiary sub = new Subsidiary();
sub.setInternalId(String.valueOf(subInternalID));
sub.setNexusList(subNexusList);

// Invoke add() operation
WriteResponse response = _port.update(sub);

// Process the response
if (response.getStatus().isIsSuccess()) {
_console.info("\nThe following Subsidiary was updated successfully:"
+ "\n  key="
+ ((RecordRef) response.getBaseRef()).getInternalId()
+ "\n  entityId="
+ sub.getName()
);
} else {
_console.error(getStatusDetails(response.getStatus()));
}

}

 


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>