Blog Listem

1 Aralık 2015 Salı

AX 2012 - Müşteri ve satıcı hesabı ekleme/güncelleme

Müşteri hesabı:
 
    CustTable                    custTable;
    DirParty                        dirParty;
    DirPartyPostalAddressView       dirPartyPostalAddressView;
    DirPartyContactInfoView         dirPartyContactInfo;
    CustGroup                       custGroup;
    DirPartyTable                   partyTable;
    DirPartyLocation                dirLocation;
    LogisticsPostalAddress          address;
    LogisticsLocation               logisticsLocation;

    ;
    select firstOnly forUpdate custTable
        where custTable.AccountNum == custAccount;
        //-------------------- custtable --------------------------
    if (custTable.RecId == 0)
    {
        custTable.initValue();
        custTable.AccountNum           = custAccount;
        custTable.CustGroup            = custGroupId;
        custTable.VATNum               = vatNum;
        custTable.IdentificationNumber = identificationNumber;
        custTable.TaxOfficeName_TR     = taxOfficeName_TR;
        custTable.Blocked              = custBlocked;
        custTable.insert(DirPartyType::Organization, custName);
    }
    else
    {
        custTable.CustGroup            = custGroupId;
        custTable.VATNum               = vatNum;
        custTable.TaxOfficeName_TR     = taxOfficeName_TR;
        custTable.IdentificationNumber = identificationNumber;
        custTable.Blocked              = custBlocked;
        custTable.update();
        update_recordSet partyTable setting name = custName, NameAlias = nameAlias
            where partyTable.RecId == custTable.Party;
    }
    //-------------------- adres -----------------------------
        dirParty = DirParty::constructFromCommon(custTable);
        select
firstonly dirPartyPostalAddressView
            where dirPartyPostalAddressView.Party == custTable.Party &&
                  dirPartyPostalAddressView.LocationName == "Adres";
        dirPartyPostalAddressView.LocationName      = "Adres";
        dirPartyPostalAddressView.City              = city;
        dirPartyPostalAddressView.State             = state;
        dirPartyPostalAddressView.Street            = street;
        dirPartyPostalAddressView.IsPrimary         = NoYes::Yes;
        dirPartyPostalAddressView.CountryRegionId   = countryRegionId;
        dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
        if (phone)
        {
            dirParty = DirParty::constructFromCommon(custTable);
            select dirPartyContactInfo
                where
firstonly dirPartyContactInfo.Party == custTable.Party &&
                      dirPartyContactInfo.LocationName == "Telefon";
            dirPartyContactInfo.LocationName    ="Telefon";
            dirPartyContactInfo.Locator         = phone;
            dirPartyContactInfo.IsPrimary       = NoYes::Yes;
            dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Phone;
            dirParty.createOrUpdateContactInfo(dirPartyContactInfo);
        }
        if (email)
        {
            select
firstonly dirPartyContactInfo
                where dirPartyContactInfo.Party == custTable.Party &&
                      dirPartyContactInfo.LocationName == "E-mail";
            dirPartyContactInfo.LocationName    ="E-mail";
            dirPartyContactInfo.Locator         = email;
            dirPartyContactInfo.IsPrimary       = NoYes::Yes;
            dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Email;
            dirParty.createOrUpdateContactInfo(dirPartyContactInfo);
        }


Satıcı hesabı eklemenin müşteri hesabı eklemekten tek farkı dirParty kaydının ayrıca oluşturulması . Eğer hesap organizasyon yerine bir kişi ise DirOrganization tablosu yerine DirPersonName tablosu kullanılıyor:


    VendTable                    vendTable;

    DirParty                        dirParty;
    DirPartyPostalAddressView       dirPartyPostalAddressView;
    DirPartyContactInfoView         dirPartyContactInfo;
    VendGroup                       vendGroup;
    DirPartyTable                   partyTable;
    DirPartyLocation                dirLocation;
    LogisticsPostalAddress          address;
    LogisticsLocation               logisticsLocation;
    DirOrganization                 organization;

    ;

    select firstOnly forUpdate vendTable
        where vendTable.AccountNum == vendAccount;
        //-------------------- vendTable --------------------------
    if (vendTable.RecId == 0)
    {
        organization.Name                    = vendName;
        organization.NameAlias               = nameAlias;
        organization.LanguageId              = CompanyInfo::languageId();
        organization.insert();

        vendTable.initValue();
        vendTable.party                = organization.recid;
        vendTable.AccountNum           = vendAccount;
        vendTable.vendGroup            = vendGroupId;
        vendTable.VATNum               = vatNum;
        vendTable.Blocked              = VendBlocked;
        vendTable.TaxOfficeName_TR     = taxOfficeName_TR;
        vendTable.insert();
    }
    else
    {
        vendTable.vendGroup            = vendGroupId;
        vendTable.VATNum               = vatNum;
        vendTable.Blocked              = VendBlocked;
        vendTable.update();
        update_recordSet organization setting name = vendName, NameAlias = nameAlias
            where organization.RecId == vendTable.Party;
    }

Hiç yorum yok:

Yorum Gönder