CustName name;
DirParty dirParty;
CustTable custTable;
CustBankAccount custBankAccount;
ttsBegin;
custBankAccount.clear();
custBankAccount.initValue();
custBankAccount.CustAccount = 'CUST-000123';
custBankAccount.AccountID = 'BANK-ACCT-001';
custBankAccount.Name = 'Wells Fargo Bank';
custBankAccount.AccountNum = '9876543210';
custBankAccount.BankGroupId = 'CORP-BANK';
custBankAccount.RegistrationNum = 'REG-998877';
custBankAccount.BankCodeType = 'RoutingNumber';
custBankAccount.SWIFTNo = 'WFBIUS6S';
custBankAccount.BankIBAN = 'US64SVBKUS6S1234567890';
custBankAccount.CurrencyCode = 'USD';
LogisticsPostalAddress logisticsPostalAddress;
LogisticsLocation logisticsLocation;
LogisticsAddressStreet street;
street = '123 Market Street' + '\n' + 'Suite 45B' + '\n' + 'Business Plaza';
logisticsLocation = LogisticsLocation::find(custBankAccount.Location, true);
if (!logisticsLocation.RecId)
{
logisticsLocation.clear();
}
logisticsLocation.IsPostalAddress = NoYes::Yes;
logisticsLocation.Description = 'Primary Bank Address';
logisticsLocation.write();
logisticsPostalAddress = LogisticsPostalAddress::findByLocation(logisticsLocation.RecId, true);
if (!logisticsPostalAddress.RecId)
{
logisticsPostalAddress.clear();
}
logisticsPostalAddress.CountryRegionId = 'US';
logisticsPostalAddress.State = 'CA';
logisticsPostalAddress.County = 'Santa Clara';
logisticsPostalAddress.City = 'San Jose';
logisticsPostalAddress.ZipCode = '95113';
logisticsPostalAddress.DistrictName = 'Downtown';
logisticsPostalAddress.Street = street;
logisticsPostalAddress.Location = logisticsLocation.RecId;
if (logisticsPostalAddress.RecId)
{
logisticsPostalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
}
logisticsPostalAddress.formatAddressInstance();
logisticsPostalAddress.write();
custBankAccount.Location = logisticsLocation.RecId;
custBankAccount.defaultRow();
// Validate and Insert
if (custBankAccount.validateWrite())
{
custBankAccount.insert();
custTable = CustTable::find(custBankAccount.CustAccount, true);
if (custTable.RecId && custTable.BankAccount != custBankAccount.AccountID)
{
ttsBegin;
custTable.BankAccount = custBankAccount.AccountID;
custTable.update();
ttsCommit;
}
}
ttsCommit;