void insertarTipoCambio(TransDate _fechadesde,
amount _tipoCambio)
{
ExchangeRate exchangeRate;
//TmpExchangeRate currentTmpExchangeRate = this.cursor();
ExchangeRateCurrencyPair selectedCurrencyPair;
ExchangeRateType ExchangeRateType = ExchangeRateType::findByName('Tipo de cambio');
;
select forUpdate firstOnly selectedCurrencyPair
where selectedCurrencyPair.ExchangeRateType == ExchangeRateType.RecId &&
selectedCurrencyPair.FromCurrencyCode == 'USD' &&
selectedCurrencyPair.ToCurrencyCode == 'MXN';
if(selectedCurrencyPair)
{
select forUpdate firstOnly * from exchangeRate
where exchangeRate.ValidFrom == _fechadesde &&
exchangeRate.ExchangeRateCurrencyPair == selectedCurrencyPair.RecId;
//exchangeRate = exchangeRate::findByDate(selectedCurrencyPair.RecId,_fechadesde,true);
//exchangeRate = ExchangeRate::find(currentTmpExchangeRate.ExchangeRateRecId, true);
ttsbegin;
exchangeRate.ExchangeRate = ExchangeRateHelper::prepareExchangeRateForStorage_Static(
_tipoCambio,
selectedCurrencyPair.ExchangeRateDisplayFactor);
if (exchangeRate)
{
exchangeRate.update();
}
else
{
// Insert into the ExchangeRate table
exchangeRate.ExchangeRateCurrencyPair = selectedCurrencyPair.RecId;
exchangeRate.ValidFrom = _fechadesde;
exchangeRate.insert();
//currentTmpExchangeRate.ExchangeRateRecId = exchangeRate.RecId;
}
ttsCommit;
info("Tipo de cambio actualizado ",con2Str([_fechadesde,_tipoCambio]));
}
}
Dynamics Ax X++
miércoles, 1 de julio de 2015
viernes, 30 de mayo de 2014
Ax 2012 Obtener Costo de articulo por fecha
static void Job2(Args _args)
{
inventPriceMap inventPriceMap;
;
inventPriceMap = inventtable::find('1000004').inventCostPriceMap(InventDim::find('2523000000008').inventdimid ,null,null,today());
inventPriceMap.Price();
inventPriceMap.PriceUnit();
//etccc
}
{
inventPriceMap inventPriceMap;
;
inventPriceMap = inventtable::find('1000004').inventCostPriceMap(InventDim::find('2523000000008').inventdimid ,null,null,today());
inventPriceMap.Price();
inventPriceMap.PriceUnit();
//etccc
}
miércoles, 21 de mayo de 2014
Ax 2012 consumir webservice para crear empleados en c#
string carpeta = @"carpeta";
string archivo = @"archivo excel";
HcmWorkerImportServiceClient proxy = new HcmWorkerImportServiceClient();
CallContext context = new CallContext();
context.Company = "Company";
string firstName, lastName, personelNumber, jobTitle;
int records;
firstName = "";
lastName = "";
personelNumber = "";
jobTitle = "";
records = 0;
//Create COM Objects. Create a COM object for everything that is referenced
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(carpeta+archivo);
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
//iterate over the rows and columns and print to the console as it appears in the file
//excel is not zero based!!
for (int i = 1; i <= rowCount; i++)
{
string str=Convert.ToString(xlRange.Cells[i, 4].Value2());
if (str == null || i == 1)
{
continue;
}
firstName = xlRange.Cells[i, 1].Value2() == null ? "" : xlRange.Cells[i, 1].Value2().ToString(); //a
lastName = xlRange.Cells[i, 2].Value2() == null ? "" : xlRange.Cells[i, 2].Value2().ToString(); //b
string company = xlRange.Cells[i, 6].Value2() == null ? "" : xlRange.Cells[i, 6].Value2().ToString();//f
personelNumber = xlRange.Cells[i, 4].Value2() == null ? "" : xlRange.Cells[i, 4].Value2().ToString();//d
//personelNumber = "te1" + personelNumber;
jobTitle = xlRange.Cells[i, 5].Value2() == null ? "" : xlRange.Cells[i, 5].Value2().ToString();//e
string calle = xlRange.Cells[i, 10].Value2() == null ? "" : xlRange.Cells[i, 10].Value2().ToString();//j
string calle2 = xlRange.Cells[i, 11].Value2() == null ? "" : xlRange.Cells[i, 11].Value2().ToString();//k
string city = xlRange.Cells[i, 12].Value2() == null ? "" : xlRange.Cells[i, 12].Value2().ToString();//l
string state = xlRange.Cells[i, 13].Value2() == null ? "" : xlRange.Cells[i, 13].Value2().ToString();//m
string zipcode = xlRange.Cells[i, 14].Value2() == null ? "" : xlRange.Cells[i, 14].Value2().ToString();//n
string phone = xlRange.Cells[i, 15].Value2() == null ? "" : xlRange.Cells[i, 15].Value2().ToString();//o
string email = xlRange.Cells[i, 18].Value2() == null ? "" : xlRange.Cells[i, 18].Value2().ToString();//r
string phonework = xlRange.Cells[i, 16].Value2() == null ? "" : xlRange.Cells[i, 16].Value2().ToString();//p
string phonecell = xlRange.Cells[i, 17].Value2() == null ? "" : xlRange.Cells[i, 17].Value2().ToString();//q
string Departamento = xlRange.Cells[i, 8].Value2() == null ? "" : xlRange.Cells[i, 8].Value2().ToString();//h
string location = xlRange.Cells[i, 19].Value2() == null ? "" : xlRange.Cells[i, 19].Value2().ToString();//s
AxdHcmWorkerImport worker = new AxdHcmWorkerImport();
AxdEntity_HcmWorker hcmWorkerTable = new AxdEntity_HcmWorker();
AxdEntity_DirPerson_DirPerson party = new AxdEntity_DirPerson_DirPerson();
party.NameAlias = firstName + " " + lastName;//a and b
party.ProfessionalTitle = jobTitle;//e
//party.PartyNumber = "EMP-123";
//party.Gender = AxdEnum_Gender.Female;
//party.MaritalStatus = AxdEnum_DirPersonMaritalStatus.Married;
AxdEntity_DirPersonName personName = new AxdEntity_DirPersonName();
personName.FirstName = firstName;//a
personName.LastName = lastName;//b
party.DirPersonName = personName;
///// postal
AxdEntity_DirPartyPostalAddressView postalview = new AxdEntity_DirPartyPostalAddressView();
postalview.Street = calle + ", " + calle2;//j and k
postalview.City = city; // l
postalview.State = state;//m
postalview.ZipCode = zipcode;//n
postalview.CountryRegionId = "USA";
//postalview.StreetNumber = "123";
postalview.RecIdSpecified = false;
postalview.Roles = "Home";
/////
party.DirPartyPostalAddressView = new AxdEntity_DirPartyPostalAddressView[] { postalview };
////contact info
///// postal
/*
AxdEntity_DirPartyContactInfoView emailInfo = new AxdEntity_DirPartyContactInfoView();
emailInfo.Type = AxdEnum_LogisticsElectronicAddressMethodType.Email;
emailInfo.Roles = "Invoice";
emailInfo.Locator = "anybody@mail.org";
emailInfo.IsPrimary = AxdEnum_NoYes.No;
emailInfo.LocatorExtension = "";
emailInfo.LocationName = "Primary Email";
*/
/*
AxdEntity_DirPartyContactInfoView phoneInfo = new AxdEntity_DirPartyContactInfoView();
phoneInfo.Type = AxdEnum_LogisticsElectronicAddressMethodType.Phone;
phoneInfo.Roles = "Business";
phoneInfo.Locator = "999";
phoneInfo.IsPrimary = AxdEnum_NoYes.Yes;
phoneInfo.LocatorExtension = "456";
phoneInfo.LocationName = "Primary Phone";
//phoneInfo.IsPrivateSpecified = true;
//phoneInfo.IsLocationOwner = AxdEnum_NoYes.Yes;
phoneInfo.IsPrivate = AxdEnum_NoYes.Yes;
party.DirPartyContactInfoView = new AxdEntity_DirPartyContactInfoView[] { phoneInfo };
* */
/////////////////
hcmWorkerTable.DirPerson = party;
hcmWorkerTable.PersonnelNumber = personelNumber;//d;
AxdEntity_HcmEmployment personEmployment = new AxdEntity_HcmEmployment();
personEmployment.EmploymentType = AxdEnum_HcmEmploymentType.Employee;
personEmployment.LegalEntity = company;//f
AxdType_DimensionAttributeValueSet dimset = new AxdType_DimensionAttributeValueSet();
AxdType_DimensionAttributeValue dimva1 = new AxdType_DimensionAttributeValue();
dimva1.Name = "Department";
dimva1.Value = Departamento;
AxdType_DimensionAttributeValue dimva2 = new AxdType_DimensionAttributeValue();
//dimva2.Name = "LocationSite";
dimva2.Name = "Location";
dimva2.Value = location;
dimset.Values = new AxdType_DimensionAttributeValue[] { dimva1, dimva2 };
personEmployment.DefaultDimension = dimset;
hcmWorkerTable.HcmEmployment = new AxdEntity_HcmEmployment[1] { personEmployment };
worker.HcmWorker = new AxdEntity_HcmWorker[1] { hcmWorkerTable };
try
{
proxy.create(context, worker);
StreamWriter log = new StreamWriter(carpeta + "\\Log.txt", true);
log.WriteLine(company+" "+personelNumber + " " +"Created");
log.Flush();
log.Close();
System.Console.WriteLine(company + " " + personelNumber + " " + "Created");
records++;
}
catch(Exception e)
{
StreamWriter log = new StreamWriter(carpeta +"\\Log.txt", true);
log.WriteLine(DateTime.Now.ToString() + " Error");
log.WriteLine(company + " " + personelNumber + " " + e.Message);
log.Flush();
log.Close();
//throw;
}
}
//cleanup
GC.Collect();
GC.WaitForPendingFinalizers();
//rule of thumb for releasing com objects:
// never use two dots, all COM objects must be referenced and released individually
// ex: [somthing].[something].[something] is bad
//release com objects to fully kill excel process from running in the background
Marshal.ReleaseComObject(xlRange);
Marshal.ReleaseComObject(xlWorksheet);
//close and release
xlWorkbook.Close();
Marshal.ReleaseComObject(xlWorkbook);
//quit and release
xlApp.Quit();
Marshal.ReleaseComObject(xlApp);
Console.WriteLine("Records Inserted" + records);
Console.ReadKey();
string archivo = @"archivo excel";
HcmWorkerImportServiceClient proxy = new HcmWorkerImportServiceClient();
CallContext context = new CallContext();
context.Company = "Company";
string firstName, lastName, personelNumber, jobTitle;
int records;
firstName = "";
lastName = "";
personelNumber = "";
jobTitle = "";
records = 0;
//Create COM Objects. Create a COM object for everything that is referenced
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(carpeta+archivo);
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
//iterate over the rows and columns and print to the console as it appears in the file
//excel is not zero based!!
for (int i = 1; i <= rowCount; i++)
{
string str=Convert.ToString(xlRange.Cells[i, 4].Value2());
if (str == null || i == 1)
{
continue;
}
firstName = xlRange.Cells[i, 1].Value2() == null ? "" : xlRange.Cells[i, 1].Value2().ToString(); //a
lastName = xlRange.Cells[i, 2].Value2() == null ? "" : xlRange.Cells[i, 2].Value2().ToString(); //b
string company = xlRange.Cells[i, 6].Value2() == null ? "" : xlRange.Cells[i, 6].Value2().ToString();//f
personelNumber = xlRange.Cells[i, 4].Value2() == null ? "" : xlRange.Cells[i, 4].Value2().ToString();//d
//personelNumber = "te1" + personelNumber;
jobTitle = xlRange.Cells[i, 5].Value2() == null ? "" : xlRange.Cells[i, 5].Value2().ToString();//e
string calle = xlRange.Cells[i, 10].Value2() == null ? "" : xlRange.Cells[i, 10].Value2().ToString();//j
string calle2 = xlRange.Cells[i, 11].Value2() == null ? "" : xlRange.Cells[i, 11].Value2().ToString();//k
string city = xlRange.Cells[i, 12].Value2() == null ? "" : xlRange.Cells[i, 12].Value2().ToString();//l
string state = xlRange.Cells[i, 13].Value2() == null ? "" : xlRange.Cells[i, 13].Value2().ToString();//m
string zipcode = xlRange.Cells[i, 14].Value2() == null ? "" : xlRange.Cells[i, 14].Value2().ToString();//n
string phone = xlRange.Cells[i, 15].Value2() == null ? "" : xlRange.Cells[i, 15].Value2().ToString();//o
string email = xlRange.Cells[i, 18].Value2() == null ? "" : xlRange.Cells[i, 18].Value2().ToString();//r
string phonework = xlRange.Cells[i, 16].Value2() == null ? "" : xlRange.Cells[i, 16].Value2().ToString();//p
string phonecell = xlRange.Cells[i, 17].Value2() == null ? "" : xlRange.Cells[i, 17].Value2().ToString();//q
string Departamento = xlRange.Cells[i, 8].Value2() == null ? "" : xlRange.Cells[i, 8].Value2().ToString();//h
string location = xlRange.Cells[i, 19].Value2() == null ? "" : xlRange.Cells[i, 19].Value2().ToString();//s
AxdHcmWorkerImport worker = new AxdHcmWorkerImport();
AxdEntity_HcmWorker hcmWorkerTable = new AxdEntity_HcmWorker();
AxdEntity_DirPerson_DirPerson party = new AxdEntity_DirPerson_DirPerson();
party.NameAlias = firstName + " " + lastName;//a and b
party.ProfessionalTitle = jobTitle;//e
//party.PartyNumber = "EMP-123";
//party.Gender = AxdEnum_Gender.Female;
//party.MaritalStatus = AxdEnum_DirPersonMaritalStatus.Married;
AxdEntity_DirPersonName personName = new AxdEntity_DirPersonName();
personName.FirstName = firstName;//a
personName.LastName = lastName;//b
party.DirPersonName = personName;
///// postal
AxdEntity_DirPartyPostalAddressView postalview = new AxdEntity_DirPartyPostalAddressView();
postalview.Street = calle + ", " + calle2;//j and k
postalview.City = city; // l
postalview.State = state;//m
postalview.ZipCode = zipcode;//n
postalview.CountryRegionId = "USA";
//postalview.StreetNumber = "123";
postalview.RecIdSpecified = false;
postalview.Roles = "Home";
/////
party.DirPartyPostalAddressView = new AxdEntity_DirPartyPostalAddressView[] { postalview };
////contact info
///// postal
/*
AxdEntity_DirPartyContactInfoView emailInfo = new AxdEntity_DirPartyContactInfoView();
emailInfo.Type = AxdEnum_LogisticsElectronicAddressMethodType.Email;
emailInfo.Roles = "Invoice";
emailInfo.Locator = "anybody@mail.org";
emailInfo.IsPrimary = AxdEnum_NoYes.No;
emailInfo.LocatorExtension = "";
emailInfo.LocationName = "Primary Email";
*/
/*
AxdEntity_DirPartyContactInfoView phoneInfo = new AxdEntity_DirPartyContactInfoView();
phoneInfo.Type = AxdEnum_LogisticsElectronicAddressMethodType.Phone;
phoneInfo.Roles = "Business";
phoneInfo.Locator = "999";
phoneInfo.IsPrimary = AxdEnum_NoYes.Yes;
phoneInfo.LocatorExtension = "456";
phoneInfo.LocationName = "Primary Phone";
//phoneInfo.IsPrivateSpecified = true;
//phoneInfo.IsLocationOwner = AxdEnum_NoYes.Yes;
phoneInfo.IsPrivate = AxdEnum_NoYes.Yes;
party.DirPartyContactInfoView = new AxdEntity_DirPartyContactInfoView[] { phoneInfo };
* */
/////////////////
hcmWorkerTable.DirPerson = party;
hcmWorkerTable.PersonnelNumber = personelNumber;//d;
AxdEntity_HcmEmployment personEmployment = new AxdEntity_HcmEmployment();
personEmployment.EmploymentType = AxdEnum_HcmEmploymentType.Employee;
personEmployment.LegalEntity = company;//f
AxdType_DimensionAttributeValueSet dimset = new AxdType_DimensionAttributeValueSet();
AxdType_DimensionAttributeValue dimva1 = new AxdType_DimensionAttributeValue();
dimva1.Name = "Department";
dimva1.Value = Departamento;
AxdType_DimensionAttributeValue dimva2 = new AxdType_DimensionAttributeValue();
//dimva2.Name = "LocationSite";
dimva2.Name = "Location";
dimva2.Value = location;
dimset.Values = new AxdType_DimensionAttributeValue[] { dimva1, dimva2 };
personEmployment.DefaultDimension = dimset;
hcmWorkerTable.HcmEmployment = new AxdEntity_HcmEmployment[1] { personEmployment };
worker.HcmWorker = new AxdEntity_HcmWorker[1] { hcmWorkerTable };
try
{
proxy.create(context, worker);
StreamWriter log = new StreamWriter(carpeta + "\\Log.txt", true);
log.WriteLine(company+" "+personelNumber + " " +"Created");
log.Flush();
log.Close();
System.Console.WriteLine(company + " " + personelNumber + " " + "Created");
records++;
}
catch(Exception e)
{
StreamWriter log = new StreamWriter(carpeta +"\\Log.txt", true);
log.WriteLine(DateTime.Now.ToString() + " Error");
log.WriteLine(company + " " + personelNumber + " " + e.Message);
log.Flush();
log.Close();
//throw;
}
}
//cleanup
GC.Collect();
GC.WaitForPendingFinalizers();
//rule of thumb for releasing com objects:
// never use two dots, all COM objects must be referenced and released individually
// ex: [somthing].[something].[something] is bad
//release com objects to fully kill excel process from running in the background
Marshal.ReleaseComObject(xlRange);
Marshal.ReleaseComObject(xlWorksheet);
//close and release
xlWorkbook.Close();
Marshal.ReleaseComObject(xlWorkbook);
//quit and release
xlApp.Quit();
Marshal.ReleaseComObject(xlApp);
Console.WriteLine("Records Inserted" + records);
Console.ReadKey();
miércoles, 26 de febrero de 2014
Ax 2012 Ir al registro desde un info
void MostrarInfoOV()
{
;
info("OV"+' '+SalesTable.SalesId,' ',SysInfoAction_TableField::newBuffer(SalesTable));
}
{
;
info("OV"+' '+SalesTable.SalesId,' ',SysInfoAction_TableField::newBuffer(SalesTable));
}
Ax 2012 Crear Orden de Venta con precios manuales
//////encabezado
NumberSeq NumberSeq;
SalesId sid;
;
NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId() , true);
NumberSeq.used();
sid=NumberSeq.num();
salesTable.SalesId = sid;
salesTable.initValue();
salesTable.CustAccount = CustTable.AccountNum;
salesTable.initFromCustTable();
salesTable.CurrencyCode = CurrencyCode;
if (!salesTable.validateWrite())
{
throw Exception::Error;
}
salesTable.insert();
///lineas
salesLine.clear();
salesLine.SalesId =salesTable.SalesId;
salesLine.ItemId =GsRemSalesLineTmp.ItemId;
salesLine.initName();
salesLine.initFromItemOrCategory(salesLine.ItemId, salesLine.SalesCategory, salesLine.Name);
salesLine.initFromSalesTable(salesTable);
salesLine.SalesQty =GsRemSalesLineTmp.SalesQty;
salesLine.SalesPrice =GsRemSalesLineTmp.SalesPrice;
salesLine.SalesUnit =GsRemSalesLineTmp.SalesUnit;
salesLine.CurrencyCode =GsRemSalesLineTmp.CurrencyCode;
salesLine.LineAmount =salesLine.calcLineAmountForced();
salesLine.setPriceDiscChangePolicy(PriceDiscSystemSource::ManualEntry);
salesLine.createLine(true, true, false, true, true, false);
///lo que esta es rojo es el tip
NumberSeq NumberSeq;
SalesId sid;
;
NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId() , true);
NumberSeq.used();
sid=NumberSeq.num();
salesTable.SalesId = sid;
salesTable.initValue();
salesTable.CustAccount = CustTable.AccountNum;
salesTable.initFromCustTable();
salesTable.CurrencyCode = CurrencyCode;
if (!salesTable.validateWrite())
{
throw Exception::Error;
}
salesTable.insert();
///lineas
salesLine.clear();
salesLine.SalesId =salesTable.SalesId;
salesLine.ItemId =GsRemSalesLineTmp.ItemId;
salesLine.initName();
salesLine.initFromItemOrCategory(salesLine.ItemId, salesLine.SalesCategory, salesLine.Name);
salesLine.initFromSalesTable(salesTable);
salesLine.SalesQty =GsRemSalesLineTmp.SalesQty;
salesLine.SalesPrice =GsRemSalesLineTmp.SalesPrice;
salesLine.SalesUnit =GsRemSalesLineTmp.SalesUnit;
salesLine.CurrencyCode =GsRemSalesLineTmp.CurrencyCode;
salesLine.LineAmount =salesLine.calcLineAmountForced();
salesLine.setPriceDiscChangePolicy(PriceDiscSystemSource::ManualEntry);
salesLine.createLine(true, true, false, true, true, false);
///lo que esta es rojo es el tip
miércoles, 19 de febrero de 2014
Ax 2012 Obtener impuesto de una linea
Tax::calcTaxAmount(this.TaxGroup,
this.TaxItemGroup,
this.InvoiceDate,
this.CurrencyCode,
this.LineAmount,
TaxModuleType::Sales,
this.Qty,
this.SalesUnit,
this.ItemId,
TaxDirection::OutgoingTax);
this.TaxItemGroup,
this.InvoiceDate,
this.CurrencyCode,
this.LineAmount,
TaxModuleType::Sales,
this.Qty,
this.SalesUnit,
this.ItemId,
TaxDirection::OutgoingTax);
jueves, 6 de febrero de 2014
Ax 2012 Copiar Cliente
static server void CopiarCliente(CustTable _CustTable)
{
CustTable newCusttable;
DirPartyTable DirPartyTable;
DirPartyPostalAddressView DirPartyPostalAddressView;
DirPartyPostalAddressView DirPartyPostalAddressViewNew;
LogisticsPostalAddressView LogisticsPostalAddressView;
#define.F('F')
#define.R('R')
DirParty DirParty;
DirParty DirPartyOld;
DirPartyContactInfoView DirPartyContactInfoView;
DirPartyContactInfoView DirPartyContactInfoViewNew;
LogisticsElectronicAddress LogisticsElectronicAddress;
;
if(_CustTable)
{
try
{
ttsBegin;
newCusttable.clear();
newCusttable.data(_CustTable);
newCusttable.Party =0;
newCusttable.initFromCustGroup(CustGroup::find(_CustTable.CustGroup));
newCusttable.AccountNum =strReplace(_CustTable.AccountNum,#F,#R) ;
newCusttable.insert();
///////
DirParty =DirParty::constructFromPartyRecId(newCusttable.Party);
DirPartyOld =DirParty::constructFromPartyRecId(_CustTable.Party);
//////Agregar nombre
DirPartyTable =DirPartyTable::findRec(newCusttable.Party,true);
DirPartyTable.initFromDirParty(DirPartyOld);
ttsBegin;
DirPartyTable.update();
ttsCommit;
///agregar direcciones
while select * from DirPartyPostalAddressView
where DirPartyPostalAddressView.Party==_CustTable.Party
{
///inicializar la vista con la direccion
LogisticsPostalAddressView.initFromPartyPostalAddressView(DirPartyPostalAddressView);
///inicializar la direccion
DirPartyPostalAddressViewNew.initFromPostalAddressView(LogisticsPostalAddressView);
//insertar la direccion
DirParty.createOrUpdatePostalAddress(DirPartyPostalAddressViewNew);
}
DirParty =DirParty::constructFromPartyRecId(newCusttable.Party);
///agregar Contacto
while select * from DirPartyContactInfoView
where DirPartyContactInfoView.Party==_CustTable.Party
{
///inicializar la vista con la direccion
LogisticsElectronicAddress=LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
DirPartyContactInfoViewNew.Locator = LogisticsElectronicAddress.Locator;
DirPartyContactInfoViewNew.Type = LogisticsElectronicAddress.Type;
DirPartyContactInfoViewNew.LocatorExtension = LogisticsElectronicAddress.LocatorExtension;
DirPartyContactInfoViewNew.CountryRegionCode = LogisticsElectronicAddress.CountryRegionCode;
DirPartyContactInfoViewNew.IsPrimary = LogisticsElectronicAddress.IsPrimary;
DirPartyContactInfoViewNew.IsPrivate = LogisticsElectronicAddress.IsPrivate;
DirPartyContactInfoViewNew.IsMobilePhone = LogisticsElectronicAddress.IsMobilePhone;
DirPartyContactInfoViewNew.IsInstantMessage = LogisticsElectronicAddress.IsInstantMessage;
//DirPartyContactInfoViewNew.LocationName = LogisticsElectronicAddress.LocationName;
//LogisticsElectronicAddress =LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
//DirPartyContactInfoViewNew.initFromElectronicAddress(LogisticsElectronicAddress);
//insertar la direccion
DirParty.createOrUpdateContactInfo(DirPartyContactInfoViewNew);
}
ttsCommit;
}
catch
{
throw(error("Error"));
}
}
}
{
CustTable newCusttable;
DirPartyTable DirPartyTable;
DirPartyPostalAddressView DirPartyPostalAddressView;
DirPartyPostalAddressView DirPartyPostalAddressViewNew;
LogisticsPostalAddressView LogisticsPostalAddressView;
#define.F('F')
#define.R('R')
DirParty DirParty;
DirParty DirPartyOld;
DirPartyContactInfoView DirPartyContactInfoView;
DirPartyContactInfoView DirPartyContactInfoViewNew;
LogisticsElectronicAddress LogisticsElectronicAddress;
;
if(_CustTable)
{
try
{
ttsBegin;
newCusttable.clear();
newCusttable.data(_CustTable);
newCusttable.Party =0;
newCusttable.initFromCustGroup(CustGroup::find(_CustTable.CustGroup));
newCusttable.AccountNum =strReplace(_CustTable.AccountNum,#F,#R) ;
newCusttable.insert();
///////
DirParty =DirParty::constructFromPartyRecId(newCusttable.Party);
DirPartyOld =DirParty::constructFromPartyRecId(_CustTable.Party);
//////Agregar nombre
DirPartyTable =DirPartyTable::findRec(newCusttable.Party,true);
DirPartyTable.initFromDirParty(DirPartyOld);
ttsBegin;
DirPartyTable.update();
ttsCommit;
///agregar direcciones
while select * from DirPartyPostalAddressView
where DirPartyPostalAddressView.Party==_CustTable.Party
{
///inicializar la vista con la direccion
LogisticsPostalAddressView.initFromPartyPostalAddressView(DirPartyPostalAddressView);
///inicializar la direccion
DirPartyPostalAddressViewNew.initFromPostalAddressView(LogisticsPostalAddressView);
//insertar la direccion
DirParty.createOrUpdatePostalAddress(DirPartyPostalAddressViewNew);
}
DirParty =DirParty::constructFromPartyRecId(newCusttable.Party);
///agregar Contacto
while select * from DirPartyContactInfoView
where DirPartyContactInfoView.Party==_CustTable.Party
{
///inicializar la vista con la direccion
LogisticsElectronicAddress=LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
DirPartyContactInfoViewNew.Locator = LogisticsElectronicAddress.Locator;
DirPartyContactInfoViewNew.Type = LogisticsElectronicAddress.Type;
DirPartyContactInfoViewNew.LocatorExtension = LogisticsElectronicAddress.LocatorExtension;
DirPartyContactInfoViewNew.CountryRegionCode = LogisticsElectronicAddress.CountryRegionCode;
DirPartyContactInfoViewNew.IsPrimary = LogisticsElectronicAddress.IsPrimary;
DirPartyContactInfoViewNew.IsPrivate = LogisticsElectronicAddress.IsPrivate;
DirPartyContactInfoViewNew.IsMobilePhone = LogisticsElectronicAddress.IsMobilePhone;
DirPartyContactInfoViewNew.IsInstantMessage = LogisticsElectronicAddress.IsInstantMessage;
//DirPartyContactInfoViewNew.LocationName = LogisticsElectronicAddress.LocationName;
//LogisticsElectronicAddress =LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
//DirPartyContactInfoViewNew.initFromElectronicAddress(LogisticsElectronicAddress);
//insertar la direccion
DirParty.createOrUpdateContactInfo(DirPartyContactInfoViewNew);
}
ttsCommit;
}
catch
{
throw(error("Error"));
}
}
}
Suscribirse a:
Entradas (Atom)