.//Create party for the vendor
public void createParty(VendorRequestCreate _vendorRequestCreate)
{
;
if(_vendorRequestCreate.DirPartyType == DirPartyBaseType::Person)
{
dirPerson.Name = _vendorRequestCreate.VendorName;
dirPerson.NameAlias = _vendorRequestCreate.FirstName;
dirPerson.NameSequence = dirNameSequence::find('First Last').RecId;
dirPerson.insert(); dirPersonName.FirstName = _vendorRequestCreate.FirstName;
dirPersonName.MiddleName = _vendorRequestCreate.MiddleName;
dirPersonName.LastName = _vendorRequestCreate.LastName;
dirPersonName.ValidFrom = DateTimeUtil::newDateTime(systemDateGet(),str2time ('00:00:00'),DateTimeUtil::getUserPreferredTimeZone());
dirPersonName.ValidTo = DateTimeUtil::maxValue();
dirPersonName.Person = dirPerson.RecId;
dirPersonName.insert(); dirParty = new DirParty(dirPerson);
}
else
{
dirOrganisation.Name = _vendorRequestCreate.VendorName;
dirOrganisation.NameAlias = _vendorRequestCreate.FirstName;
dirOrganisation.LanguageId = 'EN-US';
dirOrganisation.KnownAs = _vendorRequestCreate.VendorName;
dirOrganisation.PhoneticName = _vendorRequestCreate.VendorName;
dirOrganisation.insert(); dirParty = new DirParty(dirOrganisation);
} } .//Create vendor and associate with vendor
public void convertToVendor(VendorRequestCreate _vendorRequestCreate)
{
VendorRequestCreate vendorRequestCreate = VendorRequestCreate::find(_vendorRequestCreate.VendorNo,true);
; if(_vendorRequestCreate.DirPartyType == DirPartyBaseType::Person)
vendTable.Party = dirPerson.RecId;
else
vendTable.Party = dirOrganisation.RecId; ttsBegin;
vendTable.AccountNum = NumberSeq::newGetNum(VendParameters::numRefVendAccount()).num();
ttsCommit;
if(vendTable.AccountNum == '')
vendTable.AccountNum= int2str(_vendorRequestCreate.VendorNo); vendTable.Currency = _vendorRequestCreate.CurrencyCode;
vendTable.VendGroup = _vendorRequestCreate.VendGroupId;
vendTable.PaymTermId = _vendorRequestCreate.PaymTermId;
vendTable.DefaultDimension = _vendorRequestCreate.DefaultDimension;
vendTable.OneTimeVendor = _vendorRequestCreate.OneTimeSupplier;
vendTable.PaymMode = _vendorRequestCreate.PaymMode;
vendTable.BankAccount = _vendorRequestCreate.BankAccount;
vendTable.WI_Remarks = _vendorRequestCreate.Remarks;
vendTable.WI_DepartmentEmail = _vendorRequestCreate.DepartmentEmail;
vendTable.insert(); this.createPostalAddress(_vendorRequestCreate);
this.createCommAddress(_vendorRequestCreate);
this.createBankDetails(_vendorRequestCreate,vendTable.AccountNum);
this.createContact(_vendorRequestCreate,vendTable.Party); if(vendTable.RecId)
{
vendorRequestCreate.VendAccount = vendTable.AccountNum;
vendorRequestCreate.update();
info(strFmt('Vendor %1 has been successfully created',vendTable.AccountNum));
} } .//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);
} } .//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 != )
{
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 != )
{
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 != )
{
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 != )
{
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);
}
} .//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,,);
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;
} .
//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);
}
}

How to using x++ creating Vendors [AX2012]的更多相关文章

  1. 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;

    一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...

  2. 如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites]

    如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites] 一.布局页面介绍[Abo ...

  3. 启用SQLite的Data Provider 运行WECOMPANYSITE时遇到ERROR CREATING CONTEXT 'SPRING.ROOT': ERROR THROWN BY A DEPENDENCY OF OBJECT 'SYSTEM.DATA.SQLITE'

    从网上下载的源码WeCompanySite,运行时报错 Error creating context 'spring.root': Error thrown by a dependency of ob ...

  4. Creating a Clean, Minimal-Footprint ASP.NET WebAPI Project with VS 2012 and ASP.NET MVC 4

    Creating a Clean, Minimal-Footprint ASP.NET WebAPI Project with VS 2012 and ASP.NET MVC 4 Building O ...

  5. Creating a SharePoint Sequential Workflow

    https://msdn.microsoft.com/en-us/library/office/hh824675(v=office.14).aspx Creating a SharePoint Seq ...

  6. [bigdata] 启动CM出现 “JDBC Driver class not found: com.mysql.jdbc.Driver” 以及“Error creating bean with name 'serverLogFetcherImpl'”问题的解决方法

    问题:“JDBC Driver class not found: com.mysql.jdbc.Driver”  通过以下命令启动cm [root@hadoop1 ~]# /etc/init.d/cl ...

  7. 【安卓】aidl.exe E 10744 10584 io_delegate.cpp:102] Error while creating directories: Invalid argument

    这几天在使用.aidl文件的时候eclipse的控制台总是爆出如下提示: aidl.exe E 10744 10584 io_delegate.cpp:102] Error while creatin ...

  8. Failed creating java D:/jre6/bin/client/jvm.dll

    Failed creating java D:/jre6/bin/client/jvm.dll 标记一下 坑爹啊! 我特么装了一个64位的eclipse 结果报错 目录下确实有这个文件. 我想说  6 ...

  9. Spring 异常:Error creating bean with name

    异常信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx' 我今 ...

随机推荐

  1. C#之面向对象初步

    1.构造函数定义一个类时,C#默认会实现一个隐式的构造函数,默认的构造函数不接受参数,负责把新对象分配到内存中并确保所有字段数据都设置为正确的默认值.然而,一旦自定义了构造函数,默认构造函数就被自动从 ...

  2. 【Shell脚本学习7】Shell脚本学习指南分享

    http://yunpan.cn/cyARvNiaiLhfR (提取码:2878)

  3. 【Mood-6】空气显示触摸屏、智能钱夹

    空气显示触摸屏 这款屏幕借助从设备中送出的空气和水在空中形成投影,可以用来展示计算机或平板中的图像.此外,它还可以实现人机互动.你只需在虚拟屏幕前挥动双手,就能完成一系列的隔空操作,如滑动.捏合.缩放 ...

  4. iOS - UI - UIStepper

    7.UIStepper //计数器控件   固定宽高 UIStepper * stepper = [[UIStepper alloc] initWithFrame:CGRectMake(100, 10 ...

  5. 小黄豆CRM软件安装

    小黄豆CRM软件(官方网址:http://www.xhdcrm.com,演示地址:http://demo.xhdcrm.com)是一款开源免费的客户关系管理系统,其客户跟进模块简单易用.安装环境是wi ...

  6. Oracle基础 事务

    一.事务 事务就是业务上的一个逻辑单元,它能够保证其中对数据所有的操作,要么全部成功,要么全部失败. 二.事务的特性: 1.原子性:事务是SQL中的最小执行单位,不能再进行分割.要么全部执行,要么全部 ...

  7. jQuery全选与反选,且解决点击只执行一次的问题

    <html> <head> <script src="jquery-1.11.1.min.js" type="text/javascript ...

  8. oracle数据操纵语言(DML)data manipulation language

    数据库操纵语言(DML)用于查询和操纵模式对象中的数据,它不隐式地提交当前事务. SELECTINSERTUPDATEDELETECALLEXPLAIN PLANLOCK TABLEMERGE使用算术 ...

  9. My Linux API

    @图形界面与命令行界面切换 Linux预设提供了六个命令窗口终端机让我们来登录.默认我们登录的就是第一个窗口,也就是tty1,这个六个窗口分别为tty1,tty2 … tty6,你可以按下Ctrl + ...

  10. 创建App IDs时选择App ID Prefix才能勾选push notifications