1.
3.
//Create postal
address
public void
createPostalAddress(VendorRequestCreate
_vendorRequestCreate)
{
VendorRequestAddress vendorRequestAddress;
DirPartyPostalAddressView
dirPartyPostalAddressView;
;
select Addressing, LogisticsAddressCity,
LogisticsAddressCountryRegionId, LogisticsAddressStateId,
LogisticsAddressZipCodeId from
vendorRequestAddress
where
vendorRequestAddress.WI_VendorRequestCreate == _vendorRequestCreate.RecId;
// Create postal address
if(dirPerson.RecId || dirOrganisation.RecId)
{
dirPartyPostalAddressView.LocationName = 'Primary
business';
dirPartyPostalAddressView.Address =
vendorRequestAddress.Addressing;
dirPartyPostalAddressView.City =
vendorRequestAddress.LogisticsAddressCity;
dirPartyPostalAddressView.ZipCode =
vendorRequestAddress.LogisticsAddressZipCodeId;
dirPartyPostalAddressView.State =
vendorRequestAddress.LogisticsAddressStateId;
dirPartyPostalAddressView.Street =
vendorRequestAddress.Addressing;
//dirPartyPostalAddressView.Street = 'Dover Street';
//dirPartyPostalAddressView.StreetNumber = '123';
dirPartyPostalAddressView.CountryRegionId =
vendorRequestAddress.LogisticsAddressCountryRegionId;
dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
}
}
4.
//Create
communication details
public void createCommAddress(VendorRequestCreate _vendorRequestCreate)
{
VendorRequestCommunication vendorRequestCommunication;
;
select Phone1, Phone2, Email, Fax from vendorRequestCommunication
where
vendorRequestCommunication.WI_VendorRequestCreate ==
_vendorRequestCreate.RecId;
//Phone 1
if(vendorRequestCommunication.Phone1 != '' && vendTable.Party != 0)
{
logisticsLocation.clear();
logisticsLocation =
LogisticsLocation::create('Phone',
NoYes::No);
dirPartyContactInfoView.LocationName = 'Primay
Phone 1';
dirPartyContactInfoView.Locator =
vendorRequestCommunication.Phone1;
dirPartyContactInfoView.Type =
LogisticsElectronicAddressMethodType::Phone;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
}
//Phone 2
if(vendorRequestCommunication.Phone2 != '' && vendTable.Party != 0)
{
logisticsLocation.clear();
logisticsLocation =
LogisticsLocation::create('Phone',
NoYes::No);
dirPartyContactInfoView.LocationName = 'Primay
Phone 2';
dirPartyContactInfoView.Locator =
vendorRequestCommunication.Phone2;
dirPartyContactInfoView.Type =
LogisticsElectronicAddressMethodType::Phone;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::No;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
}
//Email
if(vendorRequestCommunication.Email != '' && vendTable.Party != 0)
{
logisticsLocation.clear();
logisticsLocation =
LogisticsLocation::create('Phone',
NoYes::No);
dirPartyContactInfoView.LocationName = 'Primay
Email';
dirPartyContactInfoView.Locator =
vendorRequestCommunication.Email;
dirPartyContactInfoView.Type = LogisticsElectronicAddressMethodType::Email;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
}
//Fax
if(vendorRequestCommunication.Fax != '' && vendTable.Party != 0)
{
logisticsLocation.clear();
logisticsLocation =
LogisticsLocation::create('Phone',
NoYes::No);
dirPartyContactInfoView.LocationName = 'Primay
Fax';
dirPartyContactInfoView.Locator =
vendorRequestCommunication.Fax;
dirPartyContactInfoView.Type =
LogisticsElectronicAddressMethodType::Fax;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
}
}
5.
//Create bank
details for the vendor
private void
createBankDetails(WI_VendorRequestCreate _vendorRequestCreate,
VendAccount _vendAcc)
{
VendBankAccount
vendBankAccount;
LogisticsLocation
lLogisticsLocation;
LogisticsPostalAddress
logisticsPostalAddress;
;
ttsBegin;
lLogisticsLocation.Description
= _vendorRequestCreate.FirstName;
lLogisticsLocation.insert();
logisticsPostalAddress.Street
= _vendorRequestCreate.VendBankAddress;
logisticsPostalAddress.Address
= _vendorRequestCreate.VendBankAddress;
logisticsPostalAddress.Location
= lLogisticsLocation.RecId;
logisticsPostalAddress.insert();
vendBankAccount.AccountID
= subStr(_vendorRequestCreate.BankAccount,1,10);
vendBankAccount.Name
= _vendorRequestCreate.BankAccount;
vendBankAccount.AccountNum
= _vendorRequestCreate.BankAccountNum;
vendBankAccount.VendAccount
= _vendAcc;
vendBankAccount.CurrencyCode
= _vendorRequestCreate.CurrencyCode;
vendBankAccount.BankGroupID
= BankAccountTable::find(vendBankAccount.AccountID).BankGroupId;
vendBankAccount.Location
= lLogisticsLocation.RecId;
vendBankAccount.WI_BeneficiaryName
= _vendorRequestCreate.BeneficiaryName;
vendBankAccount.initFromBankGroup(BankGroup::find(vendBankAccount.BankGroupID));
vendBankAccount.insert();
ttsCommit;
}
6.
//Create contact for
the vendor
private void
createContact(VendorRequestCreate
_vendorRequestCreate,
RefRecId _partyId)
{
ContactPerson
contactPerson;
DirPersonName
lDirPersonName;
DirPerson lDirPerson;
DirParty lDirParty;
LogisticsLocation
lLogisticsLocation;
DirPartyContactInfoView
lDirPartyContactInfoView;
;
//Create party for Contact
lDirPerson.Name
= _vendorRequestCreate.ContactPersonName;
lDirPerson.NameAlias
= _vendorRequestCreate.ContactPersonName;
lDirPerson.NameSequence
= dirNameSequence::find('First Last').RecId;
lDirPerson.insert();
lDirPersonName.FirstName
= _vendorRequestCreate.ContactPersonName;
//lDirPersonName.MiddleName =
_vendorRequestCreate.ContactPersonName;
//lDirPersonName.LastName =
_vendorRequestCreate.LastName;
lDirPersonName.ValidFrom
= DateTimeUtil::newDateTime(systemDateGet(),str2time ('00:00:00'),DateTimeUtil::getUserPreferredTimeZone());
lDirPersonName.ValidTo
= DateTimeUtil::maxValue();
lDirPersonName.Person
= lDirPerson.RecId;
lDirPersonName.insert();
lDirParty
= new DirParty(lDirPerson);
//Create contact and associate with party
contactPerson.ContactForParty
= vendTable.Party;
contactPerson.Party
= lDirPerson.RecId;
contactPerson.insert();
//Create contact number
if(_vendorRequestCreate.ContactPersonNo != '')
{
lLogisticsLocation.clear();
lLogisticsLocation = LogisticsLocation::create('Phone', NoYes::No);
lDirPartyContactInfoView.LocationName = 'Primay
Phone';
lDirPartyContactInfoView.Locator =
_vendorRequestCreate.ContactPersonNo;
lDirPartyContactInfoView.Type =
LogisticsElectronicAddressMethodType::Phone;
lDirPartyContactInfoView.Party = contactPerson.Party;
lDirPartyContactInfoView.IsPrimary = NoYes::Yes;
lDirParty.createOrUpdateContactInfo(lDirPartyContactInfoView);
}
}