Showing posts with label Address. Show all posts
Showing posts with label Address. Show all posts

Monday, 21 November 2016

job for create create addresses and role types by using customer account or vendor or prospect

job for create create addresses and role types by using customer account or vendor or prospect :


job: 


static void insertProspectAddress(Args _args)
{
    SysExcelApplication application;
    SysExcelWorkbooks   workbooks;
    SysExcelWorkbook    workbook;
    SysExcelWorksheets  worksheets;
    SysExcelWorksheet   worksheet;
    SysExcelCells       cells;
    COMVariantType      type;
    Name                name;
    FileName            filename;
    //InventPosting       InventPosting;
    int                 row =1;
    DimensionAttributeValueCombination DimensionAttributeValueCombination;

    LogisticsAddressZipCode          zipCode;
    LogisticsAddressZipCodeId        zipCodeId;
    LogisticsAddressCity             city;
    LogisticsAddressStateId          stateId;
    LogisticsAddressState            state;
    LogisticsAddresssCity            cityRecord;
    LogisticsAddressCountyName       countyName;
    LogisticsAddressCountyId         countyId;
    LogisticsAddressCounty           county;
    LogisticsAddressStreet           street;
    LogisticsAddressDistrictName     district;
    boolean                          badRecord;
    int                              i=1;
    int                              numProcessedRecords=0,numzipcodesinserted;
    LogisticsAddressCountryRegionId  _countryRegionId;
    LogisticsAddressDistrict         districtRecord;
    LogisticsAddressStreet_RU        streetRecord;
    smmBusRelAccount                 AccountNum;
    CustName                         CustName;
    MCGOneTimeAddress                MCGOneTimeAddress;
    smmBusRelTable                   smmBusRelTable;
    LogisticsLocationRoleName        LogisticsLocationRoleName;
    LogisticsLocationRoleType        LogisticsLocationRoleType;
    Phone                            phone;
    EMail                            eMail;
    TeleFax                          fax;
    URL                              url;
    ;

    application = SysExcelApplication::construct();

    workbooks = application.workbooks();

    //specify the file path that you want to read

    filename = "D:\\McLane Xpo\\Data\\Imported data\\Prospects\\AllProspectAddressJob.xlsx";//testingemail.xlsx";// //prospect addresses addresses only.xlsx";//

    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }


    ttsbegin;

    workbook   = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet  = worksheets.itemFromNum(1); //Here 3 is the worksheet Number
    cells      = worksheet.cells();

    do
    {

        row++;

        CustName = cells.item(row, 1).value().bStr();
        if(CustName == "")
            CustName = int2str(cells.item(row, 1).value().double());

        _countryRegionId = cells.item(row, 2).value().bStr();

        AccountNum = cells.item(row, 3).value().bStr();
        if(AccountNum == "")
            AccountNum = int2str(cells.item(row, 3).value().double());

        LogisticsLocationRoleName = cells.item(row, 4).value().bStr();

        eMail = cells.item(row, 6).value().bStr();
        phone = cells.item(row, 7).value().bStr();
        fax   = cells.item(row, 8).value().bStr();
        url   = cells.item(row, 14).value().bStr();

        city             = cells.item(row, 9).value().bStr();

        countyId         = cells.item(row, 10).value().bStr();

        stateId          = cells.item(row, 11).value().bStr();

        street = cells.item(row, 12).value().bStr();
        if(street == "")
            street = int2str(cells.item(row, 12).value().double());

        //district         = cells.item(row, 17).value().bStr();

        zipCodeId = cells.item(row, 13).value().bStr();
        if(zipCodeId == "")
            zipCodeId = int2str(cells.item(row, 13).value().double());



        smmBusRelTable = smmBusRelTable::find(AccountNum);
        if(smmBusRelTable)
        {
            LogisticsLocationRoleType = str2enum(LogisticsLocationRoleType,LogisticsLocationRoleName);
           //MCGOneTimeAddress::CreateOneTimeAddress("","",street,city,district,countyid,stateid,zipCodeid,_countryRegionId,"","",LogisticsLocationRoleType::Payment);
            MCGOneTimeAddress::mcLaneCreateOneTimeAddress(AccountNum,CustName,"",street,city,district,countyid,stateid,zipCodeid,_countryRegionId,phone,eMail,fax,url,LogisticsLocationRoleType);

            numzipcodesinserted++;
        }

        numProcessedRecords++;

    type = cells.item(row+1, 1).value().variantType();

    }
    while (type != COMVariantType::VT_EMPTY);
         info(strFmt("zip-%1 - rec-%2",numzipcodesinserted,numProcessedRecords));
        ttsCommit;
    application.quit();

}



class: 


class MCGOneTimeAddress
{
}



public static LogisticsLocationRecId mcLaneCreateOneTimeAddress(
                                        smmBusRelAccount             smmBusRelAccount,
                                        CustName                     custName,
                                        LogisticsAddressStreetNumber streetNumber,
                                        AddressStreet                street,
                                        AddressCity                  city,
                                        LogisticsAddressDistrictName districtName,
                                        AddressCountyId              county,
                                        AddressStateId               state,
                                        AddressZipCodeId             zip,
                                        AddressCountryRegionId       country,
                                        Phone                        phone,
                                        EMail                        eMail,
                                        TeleFax                      fax,
                                        URL                          url,
                                        LogisticsLocationRoleType    logisticsLocationRoleType
                                        )
{
    boolean                     validInsert    = false;
    LogisticsPostalAddress      postalAddress;
    smmBusRelTable              smmBusRelTable;
    container                   roleContainer;
    DirPartyPostalAddressView   addressView;
    LogisticsLocation           location;
    LogisticsPostalAddressEntity postalAddressEntity;
    LogisticsPostalAddressView  logisticsPostalAddressView;
    DirPartyLocationEntity      partyLocationEntity;
    LogisticsLocationRecId      logisticsLocationRecId;

    // If there aren't any address fields, don't try to create the address.
    if (street == "" && city == "" && zip == "" && county == "" && country == "" && eMail == "" && phone == "")
    {
        return logisticsLocationRecId;
    }

    smmBusRelTable     = smmBusRelTable::find(smmBusRelAccount);
    roleContainer = [LogisticsLocationRole::findBytype(logisticsLocationRoleType).RecId];
    if (smmBusRelTable)
    {
        addressView.StreetNumber = streetNumber;
        addressView.Street = street;
        addressView.City = city;
        addressView.ZipCode = zip;
        addressView.State = state;
        addressView.County = county;
        addressView.CountryRegionId = country;
        addressView.DistrictName = districtName;
        addressView.IsPrimary = NoYes::No;
        addressView.Party = smmBusRelTable.Party;//new CustomerEntity(custTable, DirUtility::getCurrentDateTime()).getPartyRecId();

        // Create LogisticsPostalAddress and LogisticsLocation
        postalAddressEntity = LogisticsPostalAddressEntity::construct();
        logisticsPostalAddressView.initFromPartyPostalAddressView(addressView);
        postalAddress = postalAddressEntity.createPostalAddress(logisticsPostalAddressView);

        if (postalAddress.RecId > 0)
        {
            partyLocationEntity = DirPartyLocationEntity::construct(addressView.Party);
            partyLocationEntity.parmLocation(postalAddress.Location);

            // Create party links
            partyLocationEntity.createPartyLocationAssociation(roleContainer, addressView.IsPrimary, addressView.IsPrivate);
        }

        select forUpdate RecId from location where location.RecId == postalAddress.Location;
        location.Description = custName;
        location.update();

        logisticsLocationRecId = location.RecId;

        // Create LogisticsElectronicAddresses
        if (eMail != "" ||phone != "" ||fax != "" ||url != "" )
        {
            MCGOneTimeAddress::CreateLogisticsElectronicAddress(logisticsLocationRecId,  eMail,phone,fax,url);
        }

        /*
        if (eMail != "")
        {
            MCGOneTimeAddress::CreateLogisticsElectronicAddress(logisticsLocationRecId, LogisticsElectronicAddressMethodType::Email, eMail);
        }

        if (phone != "")
        {
            MCGOneTimeAddress::CreateLogisticsElectronicAddress(logisticsLocationRecId, LogisticsElectronicAddressMethodType::Phone, phone);
        }
        if (fax != "")
        {
            MCGOneTimeAddress::CreateLogisticsElectronicAddress(logisticsLocationRecId, LogisticsElectronicAddressMethodType::Fax, fax);
        }
        if (url != "")
        {
            MCGOneTimeAddress::CreateLogisticsElectronicAddress(logisticsLocationRecId, LogisticsElectronicAddressMethodType::URL, url);
        }*/
    }

    return logisticsLocationRecId;
}




public static void CreateLogisticsElectronicAddress(int64 parentLocationId,
                                        EMail                        eMail,
                                        Phone                        phone,
                                        TeleFax                      fax,
                                        URL                          url)//, LogisticsElectronicAddressMethodType methodType, LogisticsElectronicAddressLocator locator)
{
    LogisticsLocation location;
    LogisticsElectronicAddress electronicAddress;
    location.initValue();
    location.ParentLocation = parentLocationId;
    location.IsPostalAddress = NoYes::No;
    location.insert();

    if(eMail)
    {
        electronicAddress.initValue();
        electronicAddress.Type = LogisticsElectronicAddressMethodType::Email;
        electronicAddress.Location = location.RecId;
        electronicAddress.Locator = eMail;
        electronicAddress.insert();
    }
    if(phone)
    {
        electronicAddress.initValue();
        electronicAddress.Type = LogisticsElectronicAddressMethodType::Phone;
        electronicAddress.Location = location.RecId;
        electronicAddress.Locator = phone;
        electronicAddress.insert();
    }
    if(fax)
    {
        electronicAddress.initValue();
        electronicAddress.Type = LogisticsElectronicAddressMethodType::Fax;
        electronicAddress.Location = location.RecId;
        electronicAddress.Locator = fax;
        electronicAddress.insert();
    }
    if(url)
    {
        electronicAddress.initValue();
        electronicAddress.Type = LogisticsElectronicAddressMethodType::URL;
        electronicAddress.Location = location.RecId;
        electronicAddress.Locator = url;
        electronicAddress.insert();
    }

    //info(strFmt("%1 - %2 -%3",location.RecId,electronicAddress.RecId,electronicAddress,electronicAddress.Locator));
}



reference: retailordermanager class 





Tuesday, 8 October 2013

LogisticsElectronicAddress phone ,fax details:

static void phonefax(Args _args)
{
    InventLocation inventLocation;
    InventSite inventSite;
    LogisticsEntityPostalAddressView logisticsEntityPostalAddressView;
    LogisticsLocation logisticsLocation;
    LogisticsElectronicAddress logisticsElectronicAddress;
    int64 siteid;
    select * from inventSite where inventSite.SiteId == "1";
    select * from logisticsEntityPostalAddressView where logisticsEntityPostalAddressView.Entity == inventSite.RecId;
                                               // && logisticsEntityPostalAddressView.IsPrimary == NoYes::Yes;
     //info(strFmt("%1",logisticsEntityPostalAddressView.Address));
    select * from logisticsLocation where logisticsLocation.RecId == logisticsEntityPostalAddressView.Location;
    siteid = logisticsLocation.RecId + 1;
     while select logisticsElectronicAddress where logisticsElectronicAddress.Location == siteid
                                                       && logisticsElectronicAddress.Type == 1//LogisticsElectronicAddressMethodType::Phone//1
     //                                                  && logisticsElectronicAddress.IsPrimary == NoYes::No//LogisticsElectronicAddressTypes::Phone
    {

    info(strFmt("%1 %2 %3",logisticsElectronicAddress.Type,logisticsElectronicAddress.LocatorExtension,logisticsElectronicAddress.Locator));
    info("hi");
    }
        info("bye");

}

Tuesday, 16 July 2013

contact information (vend and purch)

while select PurchTable{
// if(purchTable.PurchId == VendPurchOrderJourloc.PurchaseOrderId)
purchID = VendPurchOrderJour::findbyPurchaseOrderId(PurchPurchaseOrderHeader.PurchaseOrderId).PurchId;
PurchRecid = purchTable::find(purchID).RecId;
// c = purchTable::find(purchID).OrderAccount;
PurchDim = purchTable::find(purchID).DefaultDimension;
// TableId = PurchReqLine::findByPurchId(purchID).PurchReqTable;
// c = PurchReqTable::find(TableId).PurchReqId;
// PurchPurchaseOrderHeader.PurchReqId = c;
select VendTable where VendTable.AccountNum == purchTable::find(purchID).OrderAccount;//purchTable.OrderAccount;
select DirPartyTable where DirPartyTable.RecId == VendTable.Party;
while select DirPartyLocation where DirPartyLocation.Party == DirPartyTable.RecId
&& DirPartyLocation.IsPrimary == NoYes::Yes
{
while select LogisticsElectronicAddress where LogisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone
&& LogisticsElectronicAddress.Location == DirPartyLocation.Location
{
purchPurchaseOrderHeader.Phone = LogisticsElectronicAddress.Locator;
}
while select LogisticsElectronicAddress where LogisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email
&& LogisticsElectronicAddress.Location == DirPartyLocation.Location
{
purchPurchaseOrderHeader.Email = LogisticsElectronicAddress.Locator;
}
while select LogisticsElectronicAddress where LogisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Fax
&& LogisticsElectronicAddress.Location == DirPartyLocation.Location
{
purchPurchaseOrderHeader.Fax = LogisticsElectronicAddress.Locator;
}
}