12 Aralık 2019 Perşembe

Stok yönetimi > Eldeki - Miktar ayarlama

Miktar ayarlama | Sayım geçmişi

Eldeki formunda bulunan Miktar ayarlama alanında sayılan miktara yazdığınız miktar, direkt olarak ilgili madde kartının stoğuna girer ya da stoktan düşürür.

Eldeki > Sayım geçmişi'nden de madde kartına ait sayım hareketlerini inceleyebilirsiniz.



Hareketlerine de Referansı Sayım olan bir kayıt oluşturur.
Yazacağımız miktar stoğumuzdaki miktardan az ise hareketlere azalan kada eksi(-) işaretli kayıt oluşturur, fazla ise artı(+) kayıt oluşturur.



Not: Dikkat edilmesi gerekir. Stokları doğrudan etkiler.

28 Kasım 2019 Perşembe

Aktif olmayan kullanıcıların gruplardan çıkarılması | Microsoft Dynamics Ax

Akfit olmayan kullanıcılar;

Aktifliği kaldırılmış olan(
UserInfo.enable == false
) kullanıcıların gruplardan kaldırılması için aşağıdaki kodu kullanabilirsiniz.

public void initValue()
{
    static void _removeDisableUserFromList(Args _args)
{
    UserGroupInfo       UserGroupInfo;
    UserGroupList       UserGroupList;
    UserInfo            UserInfo;
    UserGroupId         tmpGroupId;
    ;
    ttsbegin;
    while select forupdate UserGroupList
        join UserGroupInfo
        where UserGroupInfo.Id == UserGroupList.groupId
        //&& UserGroupInfo.id == "000-04"
    {
        while select  UserInfo
            where  UserInfo.id == UserGroupList.userId && UserInfo.enable == false
        {
            info(strfmt("%1; %2; %3", UserGroupList.groupId, UserGroupList.userId, UserInfo.name));
            UserGroupList.delete();
        }
    }
    ttscommit;

}

InventTrans | InventPostingTrans | LedgerTrans ilişkileri > Dynamics Ax

InventTrans | InventTransPosting | LedgerTrans ilişkileri 

- InventTrans (Madde hareketleri)
- InventTransPosting (Stok hareketi deftere nakil)
- LedgerTrans (Genel muhasebe hareketleri)

  1. Madde kartı kullanıldığında, InventTrans'a kayıt oluşur. (hareketleri için bu yazıyı okuyabilirsiniz)
  2. Oluşan hareket Sevk irsaliyesi kesildiğinde ilgili tablolara kayıt atar. (bu yazıyı inceleyebilirsiniz
  • InventTrans
  • VendPackingSlipJour
  • VendPackingSlipTrans
  • InventSum (Stoğa girer)
  • InventTransPosting (Kayıt LedgerTransta oluşmaz, Fiziksel deftere nakil olmuştur)

     3. Faturalandığında artık muhasebe kayıtları da oluşmuş olacaktır.
  • InventTrans
  • VendInvoiceJour
  • VendInvoiceTrans
  • LedgerTrans (Genel muhasebe hesaplarına kayıt atar)
  • TaxTrans (Vergilendirilmesi hesaplanır)
  • InventTransPosting(Mali olarak da nakil oluşturuldu)

Invent Trans & InventTransPosting & LedgerTrans arasındaki ilişki


 InventTrans  InventTransPosting LedgerTrans
 Voucher  Voucher  Voucher
 InventTransId  InventTransId
 DateFinancial  TransDate  TransDate

İrsaliye kesildi sonra nakil edildi.
Örnek olması için aşağıdaki bağlantıdan;

Stok haretlerini inceleyebilirsiniz.

Satınalma siparişi oluşturulması > Faturalanma Süreci | Dynamics Axapta

Satınalma siparişi oluşturulup > İrsaliye Kesildiğinde > Faturalandığında oluşan kayıtlar

Sipariş oluşturulduğunda madde kartı için Ax aşağıdaki tablolarda kayıt oluşturur.
  • PurchLine
  • InventTrans

Bu  kayıtlar için İrsaliye kesildiğinde;

  • InventTrans
  • VendPackingSlipJour
  • VendPackingSlipTrans
  • InventSum
  • InventTransPosting

İrsaliyelerin Faturası kesildiğinde; 

  • InventTrans
  • VendInvoiceJour
  • VendInvoiceTrans
  • LedgerTrans
  • TaxTrans
  • InventTransPosting

Tablolarında kayıt oluşur.

Hareketleri incelemek için bu yazıyı inceleyebilirsiniz.

Stok Yönetimi > Karantina Emirleri | Dynamics Axapta

Karantina Emirleri

Madde kartının Karantina Emirlerinde kayıt oluşturulması/oluşturulmaması için;

Madde ayrıntıları > Stok Modeli Grubu > Kurulum > Karantina Yönetimi alanı seçili(tikli) olduğunda ilgili kart nakil işlemleri sırasında Karantina Emirlerine başlatıldı durumunda kayıt oluşturur.


 Madde ayrıntıları > Stok Modeli Grubu > Kurulum > Karantina Yönetimi alanı tiksiz olursa,
Kantinaya kayıt oluşturmaz.

8 Kasım 2019 Cuma

Satınalma siparişlerini toplu aktarma | Sipariş satırı, Dynamics Ax

Satınalma sipariş satırlarını toplu aktar

Siparişlerin satırlarını toplu aktarmak için aşağıdaki kodu kullanabilirsiniz.

  void MAA_Excel_PurchLine()
{
    #Excel
    #AviFiles

    Dialog              dialog = new Dialog("Veri Aktarma");
    DialogField         dialogPath;
    FilenameFilter      filter = ['Excel files 2010','*.xlsx','Excel files 2003', '*.xls' ];
    FilenameOpen        filePath;
    SysExcelApplication application;
    SysExcelWorkBooks   workBooks;
    SysExcelWorkBook    workBook;
    SysExcelWorkSheets  workSheets;
    SysExcelWorkSheet   workSheet;
    SysExcelCells       cells;
    SysOperationProgress progress;
    Int                 NoofSheet,i,lastRow,sn;
  
    PurchLine            PurchLine;
    InventDim            tmpInventDim,tmpInventDimItem;
    inventBatch          inventBatch;
    InventSerial         InventSerial;

    SysExcelRange range;

    void findLastRow(SysExcelWorkSheet _workSheet)
    {
        #define.Star('*')
        #define.Space(' ')

        ;

        range = _workSheet.cells().range(#ExcelTotalRange);

        try
        {
            range = range.find(#Star, null, #xlFormulas, #xlWhole, #xlByRows, #xlPrevious);
        }
        catch (Exception::Error)
        {
            error("@SYS59926");
        }

        if (range)
        {
            lastRow = range.row();
        }
        else
        {
            lastRow = 0;
        }
    }
    ;

    dialog.filenameLookupFilter(filter);
    dialogPath  = dialog.addField(typeid(FilenameOpen));


    if (dialog.run())
    {
        if(dialog.closedOk())
        {
            filePath            = dialogPath.value();
            application         = SysExcelApplication::construct();
            application.visible(false);
            workBooks           = application.workbooks();
            workBooks.open(filePath,0,true);

            workSheets          = workBooks.item(1).worksheets();
            noOfSheet           = worksheets.count();
            progress = new SysOperationProgress();
            progress.setCaption("Vendor Importing");
            progress.setTotal(lastRow);
            progress.setAnimation(#AviTransfer);
            setprefix("Vendor Import");

            try
            {
                For( i = 1; i <= noOfSheet; i++)
                {
                    workSheet       = workSheets.itemFromNum(i);
                    if(workSheet)
                    {
                        findLastRow(workSheet);
                        for(sn = 2;sn <= lastrow;sn++)
                        {
                            ttsbegin;
                            cells                   = workSheet.cells();
                            cells = workSheet.cells();

                            PurchLine.clear();

                            PurchLine.PurchId                 = cells.item(sn,1).value().bStr();
                            PurchLine.VendAccount             = cells.item(sn,2).value().bStr();
                            PurchLine.ItemId                  = cells.item(sn,3).value().bStr();
                            PurchLine.PurchQty                = cells.item(sn,4).value().double();
                            PurchLine.PurchPrice              = cells.item(sn,5).value().currency();
                            PurchLine.LineAmount              = PurchLine.PurchQty * PurchLine.PurchPrice;
                            PurchLine.TaxItemGroup            = cells.item(sn,6).value().bStr();
                            PurchLine.VendGroup               = "272101";
                            PurchLine.TaxGroup                = "YURTICI";
                            PurchLine.CurrencyCode            =  "EUR";
                            PurchLine.ETGInventType           = InventTable::find(PurchLine.ItemId).ETGInventType;
                            PurchLine.PurchUnit               = InventTable::find(InventTableModule::find(PurchLine.ItemId, ModuleInventPurchSales::Purch).ItemId).purchUnitId();
                            PurchLine.PurchaseType            = PurchaseType::Purch;


                           //  tmpInventDimItem.clear();
                           //  tmpInventDimItem                 = purchLine.inventDim();
                           //  tmpInventDimItem                    = InventDim::findOrCreate(tmpInventDimItem);


                            if ( InventSite::exist(cells.item(sn,7).value().bStr()) )
                                tmpInventDimItem.InventSiteId       = cells.item(sn,7).value().bStr();

                            if ( InventLocation::exist(cells.item(sn,8).value().bStr()) )
                                tmpInventDimItem.InventLocationId   = cells.item(sn,8).value().bStr();

                                 purchLine.InventDimId             = cells.item(sn,9).value().bStr();




                            PurchLine.RemainPurchPhysical    = PurchLine.PurchQty;
                            PurchLine.RemainInventPhysical   = PurchLine.PurchQty;
                            PurchLine.QtyOrdered             = PurchLine.PurchQty;


                            if(Dimensions::exist(SysDimension::Department,cells.item(sn,10).value().bStr()) && cells.item(sn,10).value().bStr())
                            {
                                PurchLine.Dimension[1]   = cells.item(sn,10).value().bStr();
                                //  DRT MK - KDV hesaplaması için 
                            }
                            else if(cells.item(sn,10).value().bStr())
                                throw error(strfmt("%1 - %2 boyutu tanımlı değildir", SysDimension::Department, cells.item(sn,10).value().bStr()));

                            if(Dimensions::exist(SysDimension::Center,cells.item(sn,11).value().bStr()))
                                PurchLine.Dimension[2]   = cells.item(sn,11).value().bStr();
                            else if(cells.item(sn,11).value().bStr())
                                throw error(strfmt("%1 - %2 boyutu tanımlı değildir", SysDimension::Center, cells.item(sn,11).value().bStr()));

                            if(Dimensions::exist(SysDimension::Purpose,cells.item(sn,12).value().bStr()))
                                PurchLine.Dimension[3]   = cells.item(sn,12).value().bStr();
                            else if(cells.item(sn,12).value().bStr())
                                throw error(strfmt("%1 - %2 boyutu tanımlı değildir", SysDimension::Purpose, cells.item(sn,12).value().bStr()));

                            if(Dimensions::exist(SysDimension::Person,cells.item(sn,13).value().bStr()))
                                PurchLine.Dimension[4]   = cells.item(sn,13).value().bStr();
                            else if(cells.item(sn,13).value().bStr())
                                throw error(strfmt("%1 - %2 boyutu tanımlı değildir", SysDimension::Person, cells.item(sn,13).value().bStr()));

                            if(Dimensions::exist(SysDimension::Vehicle,cells.item(sn,14).value().bStr()))
                                PurchLine.Dimension[5]   = cells.item(sn,14).value().bStr();
                            else if(cells.item(sn,14).value().bStr())
                                throw error(strfmt("%1 - %2 boyutu tanımlı değildir", SysDimension::Vehicle, cells.item(sn,14).value().bStr()));



                            PurchLine.insert();
                            info("Aktarma tamamlandı");

                            ttscommit;
                        }
                    }
                }
            }
            catch
            {
                ttsabort;
                application.quit();
            }
        }
    }
}

Kullandığım exel şablonunu inceleyebilirsiniz. Excel Şablonu

Satınalma siparişlerini toplu aktarma | Sipariş başlığı, Dynamics Ax

Satınalma siparişleri toplu aktarma

Siparişlerin başlıklarını toplu aktarmak için aşağıdaki kodu kullanabilirsiniz.

  void MAA_Excel_PurchTable() // DRT_PasswordTable
{
    #Excel
    #AviFiles

    Dialog              dialog = new Dialog("Veri Aktarma");
    DialogField         dialogPath;
    FilenameFilter      filter = ['Excel files 2010','*.xlsx','Excel files 2003', '*.xls' ];
    FilenameOpen        filePath;
    SysExcelApplication application;
    SysExcelWorkBooks   workBooks;
    SysExcelWorkBook    workBook;
    SysExcelWorkSheets  workSheets;
    SysExcelWorkSheet   workSheet;
    SysExcelCells       cells;
    SysOperationProgress progress;
    Int                 NoofSheet,i,lastRow,sn;

    PurchTable            PurchTable;

    SysExcelRange range;

    void findLastRow(SysExcelWorkSheet _workSheet)
    {
        #define.Star('*')
        #define.Space(' ')

        ;

        range = _workSheet.cells().range(#ExcelTotalRange);

        try
        {
            range = range.find(#Star, null, #xlFormulas, #xlWhole, #xlByRows, #xlPrevious);
        }
        catch (Exception::Error)
        {
            error("@SYS59926");
        }

        if (range)
        {
            lastRow = range.row();
        }
        else
        {
            lastRow = 0;
        }
    }
    ;

    dialog.filenameLookupFilter(filter);
    dialogPath  = dialog.addField(typeid(FilenameOpen));


    if (dialog.run())
    {
        if(dialog.closedOk())
        {
            filePath            = dialogPath.value();
            application         = SysExcelApplication::construct();
            application.visible(false);
            workBooks           = application.workbooks();
            workBooks.open(filePath,0,true);

            workSheets          = workBooks.item(1).worksheets();
            noOfSheet           = worksheets.count();
            progress = new SysOperationProgress();
            progress.setCaption("Vendor Importing");
            progress.setTotal(lastRow);
            progress.setAnimation(#AviTransfer);
            setprefix("Vendor Import");

            try
            {
                For( i = 1; i <= noOfSheet; i++)
                {
                    workSheet       = workSheets.itemFromNum(i);
                    if(workSheet)
                    {
                        findLastRow(workSheet);
                        for(sn = 2;sn <= lastrow;sn++)
                        {
                            ttsbegin;
                            cells                   = workSheet.cells();
                            cells = workSheet.cells();


                            PurchTable.PurchId                 = cells.item(sn,1).value().bStr();
                            PurchTable.OrderAccount            = cells.item(sn,2).value().bStr();
                            PurchTable.InvoiceAccount          = cells.item(sn,4).value().bStr();
                            PurchTable.CurrencyCode            = cells.item(sn,5).value().bStr();
                            PurchTable.PaymMode                = cells.item(sn,10).value().bStr();
                            PurchTable.FixedDueDate            = cells.item(sn,9).value().date();
                            PurchTable.PostingProfile          = "320";
                            PurchTable.PurchPlacer             = "2524";
                            PurchTable.PurchName               = VendTable::find(PurchTable.OrderAccount).Name;
                            PurchTable.VendGroup               = VendTable::find(PurchTable.OrderAccount).VendGroup;
                            PurchTable.InventSiteId            = VendTable::find(PurchTable.OrderAccount).InventSiteId;
                            PurchTable.InventLocationId        = VendTable::find(PurchTable.OrderAccount).InventLocation;
                            PurchTable.PurchaseType            = PurchaseType::Purch;
                            PurchTable.DlvCountryRegionId      = VendTable::find(PurchTable.OrderAccount).CountryRegionId;
                            PurchTable.TaxGroup                = VendTable::find(PurchTable.OrderAccount).TaxGroup;
                            PurchTable.DeliveryAddress         = VendTable::find(PurchTable.OrderAccount).Address;
                            PurchTable.Email                   = VendTable::find(PurchTable.OrderAccount).Email;
                            PurchTable.LanguageId              = VendTable::find(PurchTable.OrderAccount).LanguageId;
                            PurchTable.DlvState                = VendTable::find(PurchTable.OrderAccount).State;
                            PurchTable.VATNum                  = VendTable::find(PurchTable.OrderAccount).VATNum;

                            PurchTable.insert();
                            info("Aktarma tamamlandı");

                            ttscommit;
                        }
                    }
                }
            }
            catch
            {
                ttsabort;
                application.quit();
            }
        }
    }
}     

Kullandığım exel şablonunu inceleyebilirsiniz. Excel Şablonu
Satırların aktarımı için bu yazıyı inceleybilirsiniz.

28 Ağustos 2019 Çarşamba

Satınalma taleplerinden sipariş oluşturma | Dynamics Ax

Satınalma taleplerinde girilen birim fiyatın sipariş oluşturulduğunda satınalma siparişinin birim fiyatına gelmesini PurchAutoCreate_PurchReq class'ında bulunan CreatePurchLine methodunu aşağıdaki gibi düzenlediğimizde birim fiyat talepteki olacaktır.

  if (reqLine.LineType == PurchReqLineType::Category || reqLine.PurchRFQCaseId)
        {
            searchPrice         = false;
            purchLine.PurchPrice    = reqLine.PurchPrice; // birim fiyat
            purchLine.LineDisc      = reqLine.LineDisc;
            purchLine.LinePercent   = reqLine.LinePercent;
            purchLine.PurchMarkup   = reqLine.PurchMarkup;
            purchLine.LineAmount    = purchLine.calcLineAmount();
        }
        else
        {
            searchPrice         = true;
        }
       
//        if (reqLine.ETGUnitCostPrice != 0) // maa
//         {
//           purchLine.PurchPrice = reqLine.ETGUnitCostPrice; // birim maliyet
//           searchPrice = false;
//         }
       

Üretim operasyonunu planlama projesi | Dynamics Ax

Üretim operasyonunda üretim ve iş merkezi bazlı sürelerin hesaplanması

Üretimde her bir iş emrinde harcanan süreyi ve sonrasında iş merkezi bazlı raporlanması için bir proje istenildi. 

Bunun için yapmamız gerekenlerden bir tanesi ProdId ile ilişkili bir tablo oluşturmak olacak.
Ben burada DRT_ProdOpReportTrans adında bir tablo oluşturdum ve ProdTable ile ilişkilerini aşağıdaki gibi düzenledim.




Her bir adımın sayılması için Sayı alanını, Üretimin başlangıç bitiş saatlerini, Üretimdeki duruşların girilmesi için Duruş kodu alanını ve iş merkezi alanını tabloya ekledim. Bunların dışında işlemlerin gerçekleşmesi hangi üretim üzerinde çalışılıyorsa onların bilgisi ve başlangıç bitiş saatleriyle hesaplama yapılacak olan Toplam Brüt, Duruş ve Toplam net süreleri ekledim.




Sayıyı 1 arttırmak için DRT_ProdOpReportTrans tablosunun methods'una aşağıdaki gibi kodları yazıyoruz.



1
public void initValue()
{
    super();

    this.Num = 1 + this.lastNum();
    this.TransDate = dateEndMth(systemdateget());

}
2
int lastNum()
{
    return (select maxof(Num) from DRT_ProdOpReportTrans).Num;
}
3
static Integer  Num(ProdId prodId)
{
    return (select maxof(Num) from DRT_ProdOpReportTrans
                index hint ProdIdx
                where DRT_ProdOpReportTrans.ProdId == prodId).Num;
}

Sonrasında oluşturmuş olduğumuz formun methods'una da aşağıdaki kodu yazıyoruz.


void Num()
{
    i = i+1;
}

Oluşturduğumuz formda yazacağımız kodların bölümler aşağıdaki gibi. incelemekte fayda var.



Saatin düzgün hesaplanmasını sağlamak için, Formun methods'una aşağıdaki gibi bir kod yazıyoruz.




public void init()
{
    super();

   if (DRT_ProdOpReportTrans.End == NoYes::No && DRT_ProdOpReportTrans.Start == NoYes::No)
   {
    DRT_ProdOpReportTrans.StopHour =  (DRT_ProdOpReportTrans.EndHour - DRT_ProdOpReportTrans.StartHour) / 3600;
   }

  else
   {
    DRT_ProdOpReportTrans.StopHour =  (DRT_ProdOpReportTrans.EndHour - DRT_ProdOpReportTrans.StartHour) * 0;
   }
}
DataSourcw'daki aktive'ıne aşağıdaki kodu yazarak kaydın durumuna göre alanların pasif ya da aktif olmasını sağlıyoruz.
public int active()
{
    int ret;
    DRT_ProdOpReportTrans   prodOpReportTrans;
    ProdTable               ProdTable;

    ret = super();

   if (DRT_ProdOpReportTrans.Num < DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId) || (DRT_ProdOpReportTrans.End == NoYes::Yes))
      {
        OpEnd.enabled(false);
        DRT_ProdOpReportTrans_ds.allowCreate(false);
        DRT_ProdOpReportTrans_ds.allowEdit(false);
      }

    else
      {
         OpEnd.enabled(true);
         DRT_ProdOpReportTrans_ds.allowCreate(true);
         DRT_ProdOpReportTrans_ds.allowEdit(true);
      }

   if (DRT_ProdOpReportTrans.Num < DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId) || (DRT_ProdOpReportTrans.End == NoYes::Yes || DRT_ProdOpReportTrans.Start == NoYes::Yes ))
      {
        OpEnd.enabled(false);
      }

     else
      {
         OpEnd.enabled(true);
         DRT_ProdOpReportTrans_ds.allowCreate(true);
      }

    while select firstonly prodOpReportTrans
            where DRT_ProdOpReportTrans.End == NoYes::Yes // DRT_ProdOpReportTrans.ProdId  == ProdTable.ProdId && DRT_ProdOpReportTrans.Num > 1
    {
      {
        DRT_ProdOpReportTrans_ds.allowEdit(false);

      }

     if (DRT_ProdOpReportTrans.Num > DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId) && DRT_ProdOpReportTrans.End == NoYes::Yes)

      {
        DRT_ProdOpReportTrans_ds.allowEdit(false);

     }
    else
     {
        DRT_ProdOpReportTrans_ds.allowEdit(true);

     }
   }
   if (DRT_ProdOpReportTrans.Num < DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId))
      {
        DRT_ProdOpReportTrans_ds.allowDelete(false);
      }

     else
      {
        DRT_ProdOpReportTrans_ds.allowDelete(true);
      }

   if (DRT_ProdOpReportTrans.Start == NoYes::Yes)
      {
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, End)).allowEdit(false);
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, StopId)).allowEdit(false);
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, EndHour)).allowEdit(false);
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, StartHour)).allowEdit(true);
      }

     else
      {
        DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, EndHour)).allowEdit(true);
      }

   if (DRT_ProdOpReportTrans.End == NoYes::Yes)
       {
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, Start)).allowEdit(false);
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, StartHour)).allowEdit(false);
       }

   if (DRT_ProdOpReportTrans.Start == NoYes::No && DRT_ProdOpReportTrans.End == NoYes::No)
       {
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, StopId)).allowEdit(true);
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, StartHour)).allowEdit(true);
       }

     else
       {
         DRT_ProdOpReportTrans_ds.object(fieldnum(DRT_ProdOpReportTrans, StopId)).allowEdit(false);
       }


    return ret;
}

Create böülümünde kayıt oluşturulurken ilgili alanların istenilen şekilde dolmasını sağlıyoruz.


public void create(boolean _append = false)
{
    DRT_ProdOpReportTrans   ProdOpReportTrans;
    ProdTable               ProdTable;
    super(_append);

    DRT_ProdOpReportTrans.TransDate =  systemdateget();
    DRT_ProdOpReportTrans.WrkCtrId  =  ProdRoute::findFirst(DRT_ProdOpReportTrans.ProdId).WrkCtrId;

    DRT_ProdOpReportTrans.Num          =  DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId) + 1;
    DRT_ProdOpReportTrans.QtySched     =  ProdTable::find(DRT_ProdOpReportTrans.ProdId).QtySched;
    DRT_ProdOpReportTrans.InventDimId  =  ProdTable::find(DRT_ProdOpReportTrans.ProdId).InventDimId;

    if  ((DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId)) < 1)
    {
      DRT_ProdOpReportTrans.Start     =  NoYes::Yes;
    }

    if  ((DRT_ProdOpReportTrans::Num(DRT_ProdOpReportTrans.ProdId)) > 1)
    {
      DRT_ProdOpReportTrans.Start     =  NoYes::No;
      DRT_ProdOpReportTrans.StartHour  = 0;
    }

}

ValidateWrite'a yazdığımız kodlar belirlenen koşullarda kayıtlara güncelleme yaptırmaya izin verir, yoksa kayıt ettirmez.


public boolean validateWrite()
{
    boolean     ret;
;

    if (DRT_ProdOpReportTrans.TransDate < ProdTable::find(DRT_ProdOpReportTrans.ProdId).SchedStart)

        return checkfailed (strfmt(" %1 Üretimin başlangıç tarihinden önce olamaz! %2",
                             ProdTable::find(DRT_ProdOpReportTrans.ProdId).ProdId, ProdTable::find(DRT_ProdOpReportTrans.ProdId).SchedStart));

    ret = super();

    return ret;
}

Bu operasyonu da bitirmek için buton eklendi ve click method'unda aşağıdaki Formun methods'una yazdığımız kod çağrıldı

.
void OpEnd()
{
    Dialog                  d = new Dialog(strfmt("%1 üretimi bitirme", DRT_ProdOpReportTrans.ProdId));
    DialogField             dlgEndHour;
    DialogGroup             dlgGroup;
    boolean ret = true;
    ;

    dlgGroup = d.addGroup("Üretimi bitir");
    dlgGroup.widthMode(FormWidth::ColumnWidth);
    dlgGroup.heightMode(FormHeight::ColumnHeight);
    dlgEndHour  = d.addField(typeid(SchedFromTime), "Bitiş saati");
    dlgEndHour.value(DRT_ProdOpReportTrans.ProdId);

    if  ((dlgEndHour.value(DRT_ProdOpReportTrans::StartHour(DRT_ProdOpReportTrans.ProdId)) > DRT_ProdOpReportTrans::EndHour(DRT_ProdOpReportTrans.ProdId)))
     {
         ret = checkfailed  ("Üretimin başlangıç saatinden önce olamaz!");
     }

     else
    if (DRT_ProdOpReportTrans)
    {
        d.run();
        if (d.closedOk())
        {
            ttsbegin;
                DRT_ProdOpReportTrans.EndHour = dlgEndHour.value();
                DRT_ProdOpReportTrans.End     = NoYes::Yes;
                DRT_ProdOpReportTrans.Update();
            ttscommit;

            DRT_ProdOpReportTrans_ds.research(true);
        }
    }
    else
        throw warning ("Öncelikle bir satır seçmelisiniz!");


Böylelikle bir üretim için operasyon süreleri sonlandırılmış oldu. Harcanan süreleri hesaplamak için yapmamız gerekenler de aşağıdaki gibi.

Toplam brüt süreyi hesaplamak için Operasyonun başladığı saatten bittiği saate kadar olan süreyi çıkardığımızda sonucu elde etmiş oluruz.

Başlangıç saatlerini aşağıdaki kodla alabiliriz. Birden fazla başlama olabilir.



display real dispStartProdHour()
{
    DRT_ProdOpReportTrans DRT_ProdOpReportTrans;

    select sum(StartHour) from DRT_ProdOpReportTrans
    where DRT_ProdOpReportTrans.ProdId == this.ProdId  && DRT_ProdOpReportTrans.Start == Noyes::Yes;
    return DRT_ProdOpReportTrans.StartHour;
}

Bitiş saatini de aşağıdaki kodla alabiliriz.



display real dispEndProdHour()
{
    DRT_ProdOpReportTrans   DRT_ProdOpReportTrans;
    select sum(EndHour) from DRT_ProdOpReportTrans
        where DRT_ProdOpReportTrans.ProdId == this.ProdId && DRT_ProdOpReportTrans.End == NoYes::Yes;
        return DRT_ProdOpReportTrans.EndHour;
}

Bitiş saatinden başlangıç saatini çıkardığımızda bu operasyonda geçen Toplam brüt süreyi elde ederiz.



server display Hours TotalTime()
{
    DRT_ProdOpReportTrans   ProdOpReportTrans;
    Hours   hours = 0;
    ;

    while select ProdOpReportTrans
            index hint ProdLineIdx
            where ProdOpReportTrans.ProdId     == this.ProdId
      if(ProdOpReportTrans.End == NoYes::Yes || ProdOpReportTrans.Start == NoYes::Yes )
      {
        hours = (ProdOpReportTrans.dispEndProdHour() - ProdOpReportTrans.dispStartProdHour()) / str2Time('00:60');
      }

   return hours;
}



Maddenin hareket durumları (InventTrans) | Dynamics Ax

Madde üzerindeki hareketler


Satınalma siparişinde;

Örnek bir madde kartı üzerinden gidelim; etiket için oluşturulmuş ETI0338 madde kartını stoğa almak için öncelikle bir satın alma siparişi oluşturalım hareketlerini inceleyelim.

1'de miktarı 2200 olacak şekilde satın alma siparişi oluşturuldu. 2'de 200 adeti faturalandı ve 3'te 150 adeti sevk irsaliyesi kesildi.



Burada madde hareketinin(InventTrans) referansı(StatusReceipt) Satınalma siparişi  olarak geliyor.

1. Sipariş oluşturuldu.

  • Referansı: Satınalma siparişi,
  • Fiili tarih ve Mali tarih dolmuyor,
  • Giriş: Sipariş edilen,
  • Çıkış: Boş

2. 150 adet miktar sevk irsaliyesi kesildi sonrasında faturalandı. Faturalandıktan sonra 150 adet siparişteki tesisin stoğuna 150 adet miktar kadar girmiş oldu.

  • Referansı: Satınalma siparişi,
  • Fiili tarih ve Mali tarih doluyor,
  • Giriş: Satın alınan,
  • Çıkış: Boş
3. 2000 adet miktar sevk irsaliyesi kesildi(İrsaliye hareketini de incelemek için).

  • Referansı: Satınalma siparişi,
  • Fiili tarih dolu, Mali tarih boş oluyor,
  • Giriş: Alındı,
  • Çıkış: Boş
Not: Nakil işleminden sonra stoğa girer, Madde hareketlerindeki miktar pozitiftir(+).

Üretimde;

TIM1583 Madde kartının üretimini oluşturalım(Üretim tamamlanmadan incelemek için).


100 adet miktar üretim oluşturuldu.

  • Referansı: Üretim,
  • Fiili tarih boş, Mali tarih boş oluyor,
  • Giriş: Sipariş edilen,
  • Çıkış: Boş
Aynı madde kartını 48 adetlik farklı bir üretimde tamamlandıktan sonra maddenin üzerindeki hareketleri inceleyelim;

Not: Nakil işleminden sonra stoğa girer, Madde hareketlerindeki miktar pozitiftir(+).

48 adet miktar üretim oluşturuldu.

  • Referansı: Üretim,
  • Fiili tarih dolu, Mali tarih dolu oluyor,
  • Giriş: Satın alınan,
  • Çıkış: Boş

Ax otomatik olarak karantina emri oluşturuyor, sonlandırılınca;

  • Referansı: Karantina emri,
  • Fiili tarih dolu, Mali tarih dolu oluyor,
  • Giriş: Boş,
  • Çıkış: Satılan,

Satışta;

24, 24 ayrı satırlarda sipariş oluşturuldu(Faturalanmışla faturalanmamış arasındaki farkı görmek için).

Not: Nakil işleminden sonra stoktan düşer, Madde hareketlerindeki miktar negatiftir(-).

Faturalanmamış(Sadece sipariş oluşturulmuş)
  • Referansı: Satış siparişi,
  • Fiili tarih boş, Mali tarih boş oluyor,
  • Giriş: Boş,
  • Çıkış: Siparişte
Faturalamış,
  • Referansı: Satış siparişi,
  • Fiili tarih dolu, Mali tarih dolu oluyor,
  • Giriş: Boş,
  • Çıkış: Satılan




Hareket günlüğünde;

Stok yönetimi > Günlükler > Madde hareketi > Hareket

Not: Nakil işleminden sonra stoktan düşer, Madde hareketlerindeki miktar negatiftir(-).

Harekete oluşturduğumuz günlüğü nakil etmeden;
  • Referansı: Hareket,
  • Fiili tarih boş, Mali tarih boş oluyor,
  • Giriş: Fiziksel rezerve miktar,
  • Çıkış: Boş,


Harekete oluşturduğumuz günlüğü nakil ettikten sonra;
  • Referansı: Hareket,
  • Fiili tarih dolu, Mali tarih dolu oluyor,
  • Giriş: Boş,
  • Çıkış: Satılan,


Maddenin hareketleri neticesinde oluşan değerler tesise göre Eldeki(InventSum) hesaplanır.




27 Ağustos 2019 Salı

InventTrans'a update işleminden sonra yeniden hesaplama yapılmalı (ReCalc) | Dynamics Ax

İnventTrans'ta update işlemi yaptıktan sonra InventSum'ı Eldeki'nin doğru çalışması için hesaplatmak gerekiyor. Tek bir kayıtta çalıştıracaksanız;

static void MAA_ReCalc_InventSumReCalcItem(Args _args)
{
    InventSumRecalcItem InventSumRecalcItem;
    ;
    InventSumRecalcItem = new InventSumRecalcItem("GUB0021", true, checkfix::Fix );
    InventSumRecalcItem.updatenow();
}
Bütün madde kartlarında çalıştırmak için;

static void MAA_ReCalc_IInventSumRecalcAllItems(Args _args)
{  
 InventTable InventTable;
   InventSumRecalcItem InventSumRecalcItem;
   ;
 
   while select InventTable
     where (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
   {
     InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
     InventSumRecalcItem.updatenow();
   }
}

26 Ağustos 2019 Pazartesi

Enum'a göre display alan | Dynamics Ax

Enum değerine göre display alanın aşağıdaki gibi örnek bir kodla değiştiğini görebilirsiniz
display name LastTransAccountName ()
{
    ;
    if(this.LastTransACType == LedgerJournalACType::Cust)
        return custTable::find(this.LastTransAccount).Name;

    if(this.LastTransACType == LedgerJournalACType::Vend)
        return VendTable::find(this.LastTransAccount).Name;

    if(this.LastTransACType == LedgerJournalACType::Bank)
        return BankAccountTable::find(this.LastTransAccount).Name;

     if(this.LastTransACType == LedgerJournalACType::Ledger) // maa
        return BankAccountTable::find(this.LastTransAccount).Name;

    return "";

}

Örnek rapor | Dynamics Ax

Tarih itibariyle çek durum sorgusu

Örneğin sizden çeklerin durumunu tarih filtreli şekilde hesaplayıp raporlanmasını istenildiğinde.
Bir tablo oluşturup girilen tarihe göre hesaplama yaptırabilirsiniz.


DRT_ETGChequeHistoryByDates adında bir tablo oluşturuyoruz ve istenilen alanları ekliyoruz.
Sonrasında bunu oluşturduğumuz formun datasource'una ekliyoruz. Resimde olduğu gibi tarihi filtreleyebileceğimiz tarih alanı ve hesaplama yapabileceğimiz butonu ekliyoruz.


Formun methods'una hesaplama yaptıracağımız kodu yazıyoruz.




void calculate()
{
    LedgerJournalTrans      LTrans,LTrans2;
    LedgerJournalTable      LTable;
    DRT_ETGChequeHistoryByDates ETGchequeHistoryByDate;
    BankChequeTable         BankChequeTable;
    int                     chequeNum = 0;
    ETGBankChequeHistory    ChequeHistory;
    ;
    ttsbegin;
    delete_from ETGchequeHistoryByDate;

    while select BankChequeTable
        where BankChequeTable.AmountMST != 0
    {
        select maxof(ChequeTransNum) from LTrans
            where LTrans.BankChequeNum      == BankChequeTable.ChequeNum
                   && LTrans.TransDate          <= fromDate.dateValue()
                exists join LTable
                    where LTable.JournalNum == LTrans.JournalNum
                    &&    LTable.Posted;



        if (Ltrans && Ltrans.ChequeTransNum >= 0)
        {
            select firstonly LTrans2
                where LTrans2.BankChequeNum      == BankChequeTable.ChequeNum
                &&    LTrans2.ChequeTransNum     == LTrans.ChequeTransNum
                &&    LTrans2.TransDate          <=  fromDate.dateValue();

            ETGchequeHistoryByDate.clear();
            ETGchequeHistoryByDate.ChequeNum               = BankChequeTable.ChequeNum;
            ETGchequeHistoryByDate.CiroPayment             = BankChequeTable.ETGCiroPayment;
            ETGchequeHistoryByDate.LastTransACTypeOffset   = LTrans2.OffsetAccountType;
            ETGchequeHistoryByDate.LastTransAccountOffset  = LTrans2.OffsetAccount;


            select firstonly ChequeHistory
                where ChequeHistory.ChequeNum           == BankChequeTable.ChequeNum
                &&    ChequeHistory.RefJournalVoucher   == LTrans2.Voucher
                &&    ChequeHistory.TransDate           <=  fromDate.dateValue() ;



           if (ChequeHistory)
                {
                    ETGchequeHistoryByDate.LastTransACType       = LTrans2.AccountType;
                    ETGchequeHistoryByDate.LastTransAccount      = ChequeHistory.LastTransAccountNum ;//LTrans2.AccountNum;
                }

            else
                {
                     if(CompanyInfo::Find().DataAreaId == "TRS")
                     {
                      ETGchequeHistoryByDate.LastTransAccount    = LTrans2.OffsetAccount;//BankChequeTable.LastTransAccount; //Çek Tablosundan almak için
                      ETGchequeHistoryByDate.LastTransACType     = LTrans2.OffsetAccountType;//BankChequeTable.LastTransACType; //Çek Tablosundan almak için
                    }

                    else
                    {
                      ETGchequeHistoryByDate.LastTransAccount    = BankChequeTable.LastTransAccount; //Çek Tablosundan almak için
                      ETGchequeHistoryByDate.LastTransACType     = BankChequeTable.LastTransACType;//BankChequeTable.LastTransACType; //Çek Tablosundan almak için
                    }
               }

                    ETGchequeHistoryByDate.DocumentStatus      = LTrans2.TransactionTxtType;
                    ETGchequeHistoryByDate.ChequePrintedNum    = BankChequeTable.ChequePrintedNum;
                    ETGchequeHistoryByDate.DueDate             = BankChequeTable.DueDate;
                    ETGchequeHistoryByDate.FromDate            = fromdate.dateValue();
                    ETGchequeHistoryByDate.AmountMST           = BankChequeTable.AmountMST;
                    ETGchequeHistoryByDate.AccountID           = BankChequeTable.AccountID;
                    ETGchequeHistoryByDate.CurrencyCode        = BankChequeTable.CurrencyCode;
                    ETGchequeHistoryByDate.AmountCur           = BankChequeTable.AmountCur;
                    ETGchequeHistoryByDate.ETGChequeType       = BankChequeTable.ETGChequeType;
                    ETGchequeHistoryByDate.Customer            = BankChequeTable.Customer;

                    ETGchequeHistoryByDate.Drawer                   = BankChequeTable.Drawer; //MAA
                    ETGchequeHistoryByDate.ETGCentralBankBranchCode = BankChequeTable.ETGCentralBankBranchCode;
                    ETGchequeHistoryByDate.ETGCentralBankCode       = BankChequeTable.ETGCentralBankCode;


                     ETGchequeHistoryByDate.insert();

                     if (     BankChequeTable.ChequeNum == "CEK_030248" // Gelmesini istemediniz çek varsa bu şekilde belirtebilirsiniz.
                           || BankChequeTable.ChequeNum == "CEK_028932"
                           || BankChequeTable.ChequeNum == "CEK_029017"
                           || BankChequeTable.ChequeNum == "CEK_029088"
                           || BankChequeTable.ChequeNum == "CEK_029064"
                           || BankChequeTable.ChequeNum == "CEK_028922"
                           || BankChequeTable.ChequeNum == "CEK_029059"
                           || BankChequeTable.ChequeNum == "CEK_029151"
                           || BankChequeTable.ChequeNum == "CEK_029162")
                  {
                     ETGchequeHistoryByDate.delete();
                  }

       }
       else
       continue;

    }


    ttscommit;

    DRT_ETGChequeHistoryByDates_ds.executeQuery();
    info("Hesaplama Tamamlandı");

}

Sonrasında bu hesaplamayı buton ile çağırmak için, eklediğimiz butonun click'ine aşağıdaki kodu yazıyoruz.
Rapor bu şekilde ilgili tablolardan kayıtları alıyor ve raporu oluşturuyor.

void clicked()
{
    element.calculate();
}

Kasa borç bakiye tanımlama | Dynamics Ax

Kasa hesaplarının eksi(-)'ye düşmemesi için,

Genel muhasebe hesabı
100.01.001
100.02.001
100.03.001
100.04.001

Genel Muhasebe > Hesap planı ayrıntıları
Bakiye kontrolü alanı : Borç olarak seçildiğinde kasayı eksi(-)'ye düşürmeyecektir.



24 Haziran 2019 Pazartesi

InventItemPrice tablosuna kayıt hk.

Direkt olarak deftere nakil ederken;

Örn:



Şeklinde hata alırsanız;

Aşağıdaki alanların tikini kaldırın.



21 Haziran 2019 Cuma

Veri tabanı günlüğü > logları aktifleştirme | Dynamics Ax

 Logları aktifleştirme

Veri tabanı günlüğünde logları aktifleştirmek için aşağıdaki adımlardan bunu yapabilirsiniz.
Uygulama Tümleştirme Çerçevesi > Administration > Kurulum > Veritabanı günlükleri




İleri ve son dedikten sonra hangi şirketi seçtiyseniz ilgili şirket için aktifleşecektir.

31 Mayıs 2019 Cuma

ChangeCompany X++

Changecompany kullanımı; bir şirket üzerindeyken belirlediğiniz farklı şirketlerden de data çekmenizde yardımcı olur. Aşağıdaki örneği inceleyebilirsiniz.


static void MAA__EInvoiceActiveCustVendParties_2(Args _args) 
{
    EInvoiceActiveCustVendParties   EInvoiceActiveCustVendParties;
    CustTable                       custTable;
    VendTable                       vendTable;

    ttsBegin;

    ChangeCompany("TRS")
    {
        EInvoiceActiveCustVendParties = null;

        while select forUpdate EInvoiceActiveCustVendParties
        {
            custTable = CustTable::find(EInvoiceActiveCustVendParties.CustAccount);
            if(custTable.TaxNumberType_TR == TaxNumberType_TR::TCIdentityID)
            {
                EInvoiceActiveCustVendParties.FirstName = custTable.FirstName;
                EInvoiceActiveCustVendParties.LastName  = custTable.LastName;
                EInvoiceActiveCustVendParties.Update();
            }

            vendTable = VendTable::find(EInvoiceActiveCustVendParties.VendAccount);
            if(vendTable.TaxNumberType_TR == TaxNumberType_TR::TCIdentityID)
            {
                EInvoiceActiveCustVendParties.FirstName = vendTable.FirstName;
                EInvoiceActiveCustVendParties.LastName  = vendTable.LastName;
                EInvoiceActiveCustVendParties.Update();
            }
        }
    }

    ChangeCompany("TAS")
    {
        EInvoiceActiveCustVendParties = null;

        while select forUpdate EInvoiceActiveCustVendParties
        {
            custTable = CustTable::find(EInvoiceActiveCustVendParties.CustAccount);
            if(custTable.TaxNumberType_TR == TaxNumberType_TR::TCIdentityID)
            {
                EInvoiceActiveCustVendParties.FirstName = custTable.FirstName;
                EInvoiceActiveCustVendParties.LastName  = custTable.LastName;
                EInvoiceActiveCustVendParties.Update();
            }

            vendTable = VendTable::find(EInvoiceActiveCustVendParties.VendAccount);
            if(vendTable.TaxNumberType_TR == TaxNumberType_TR::TCIdentityID)
            {
                EInvoiceActiveCustVendParties.FirstName = vendTable.FirstName;
                EInvoiceActiveCustVendParties.LastName  = vendTable.LastName;
                EInvoiceActiveCustVendParties.Update();
            }
        }
    }

    ttsCommit;
}

29 Mayıs 2019 Çarşamba

Temel E-Fatura | Ticari E-Fatura

Temel kesilen faturaların sistemden reddi yapılamıyordu. 05.03.2019 tarihinden itibaren firmalar temel e-faturalar e-fatura iptal portalından , iptal talebinde bulunarak alıcı firmanın onayı ile fatura reddedilmiş/ yani iptal edilmiş oluyor. Müşterilere düzenlediğimiz faturaları yanlış düzenlersek yada iptal kararı verirsek e-fatura iptal portalından “iptal” talebinde bulunulur, müşteri reddini yapabilir.

Satıcılar tarafında ise firmalar iptal talebinde bulunacak e-imza ile reddedeceğiz. GİB’den onaylanan iptallerde, Uyumsoft’a bildirilmediği için Uyumsoft portal üzerindeki faturanın durumu eski haliyle kalacak.Sisteme giriş için bazı ayarların yapılması gerekiyor.

İptal portalı | https://portal.efatura.gov.tr/FaturaIptal/

Ayarlara aşağıdaki linkten ulaşabilirsiniz. http://efatura.gov.tr/dosyalar/kilavuzlar/%C4%B0mzalama_Araci_Kullanim_Kilavuzu.pdf

Temel Fatura
Temel e-fatura seçimi yapıp faturanızı karşı tarafa bu şekilde gönderirseniz, faturanız karşı tarafın onayını beklemeden otomatik olarak (onaylanmış/kabul edilmiş) olarak algılanır.

Ticari Fatura
Ticari e-fatura gönderdiğinizde, karşı tarafa onay ve red seçenekleri sunulur. Bu durumda firma faturayı inceleyip onaylayabilir ya da ikinci bir seçenek olarak red yanıtı verebilir.

28 Mayıs 2019 Salı

Müşteri > BankChequeTable

Aşağıdaki kodu çalıştırdığınızda müşterinin çekleriyle ilgili problem olduğunda veriler doğru girildiyse problemin gitmesini sağlar.

static void Bank_custTable (Args _args)
{
    BankChequeTable     BankChequeTable;
    CustTable           custTable;
    ;

    ttsbegin;

    while select forupdate custTable
        where custTable.Blocked != CustVendorBlocked::All
           && custTable.CreditMax > 1
    {
        select forupdate  sum(AmountMST) from BankChequeTable
            where BankChequeTable.Customer               == custTable.AccountNum
            &&    BankChequeTable.DocumentStatus         != LedgerTransTxt::RejectedToCust
            &&    BankChequeTable.DocumentStatus         != LedgerTransTxt::PaidCust
            &&    BankChequeTable.ETGCiroPayment         == NoYes::No;

        if(custTable.RiskAmount != BankChequeTable.AmountMST )
        {
            custTable.RiskAmount = BankChequeTable.AmountMST;
            custTable.update();
        }
    }

    ttscommit;
}

Müşteri kredi limitlerinin yeniden hesaplanması

Aşağıdaki kod müşteri kredi limitlerini yeniden hesaplar.


static void Sales_CreditLimits(Args _args) 
{
    #OCCRetryCount
    SalesTable              salesTable;
    SalesId                 fromSalesId;
    ;

    if (_showProgess && !updateOne)
    {
        this.progressInit("@SYS59119", 0, #AviFormLetter);
        progress.setText(strfmt("@SYS26577"));
    }

    try
    {
        ttsbegin;

        update_recordset salesTable
            setting estimate = 0
            where salesTable.SalesStatus == SalesStatus::Invoiced   &&
                  salesTable.Estimate    != 0;

        while (queryRun.next())
        {
            salesTable = queryRun.get(tablenum(SalesTable));

            if (_showProgess && !updateOne)
            {
                if (fromSalesId)
                    this.progressUpdate(strfmt("@SYS59131", strfmt('%1 - %2',fromSalesId, salesTable.SalesId)));
                else
                    this.progressUpdate(strfmt("@SYS59131", salesTable.SalesId));

                fromSalesId = salesTable.SalesId;
            }

            if (salesTable.setEstimate())
                salesTable.doUpdate();
        }

        ttscommit;
    }
    catch (Exception::Error)
    {
        info("@SYS78886");
    }

    catch (Exception::Deadlock)
    {
        queryRun.reset();
        retry;
    }

    catch (Exception::UpdateConflict)
    {
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::UpdateConflictNotRecovered;
            }
            else
            {
                queryRun.reset();
                retry;
            }
        }
        else
        {
            throw Exception::UpdateConflict;
        }
    }
}

6 Mayıs 2019 Pazartesi

Madde kartlrında Boyutların zorunluluğu | Dynamics Ax

Madde kartlrında Boyutların zorunluluğu

Madde kartında bulunan Madde grubu alanına göre boyutların zorunlu hale gelmesinde aşağıdaki kodu PurchTabe formunun datasource'unda bulunan PurcLine'ın methods'una yazdığınızda buradaki kontroller çalışacaktır.
Böylece madde grubunda belirlediğiniz zorunlu alanlar formda boş geçilmeyecektir. Aynı kodu SalesTable için de yazabilirsiniz.
void checkDimension()
{
    ItemGroupMandSetupTable     itemGroupMandSetupTable;
    ;

    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 1)).allowEdit(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 1)).mandatory(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 2)).allowEdit(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 2)).mandatory(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 3)).allowEdit(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 3)).mandatory(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 4)).allowEdit(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 4)).mandatory(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 5)).allowEdit(false);
    PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 5)).mandatory(false);

    while select itemGroupMandSetupTable
        where ItemGroupMandSetupTable.InventItemGroupId == InventTable::find(PurchLine.ItemId).ItemGroupId
    {
        if(itemGroupMandSetupTable.DimensionCode == SysDimension::Department)
        {
            if(!PurchLine.Dimension[1])
            {
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 1)).allowEdit(true);
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 1)).mandatory(true);
            }
        }

        if(itemGroupMandSetupTable.DimensionCode == SysDimension::Center)
        {
            if(!PurchLine.Dimension[2])
            {
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 2)).allowEdit(true);
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 2)).mandatory(true);
            }
        }

        if(itemGroupMandSetupTable.DimensionCode == SysDimension::Purpose)
        {
            if(!PurchLine.Dimension[3])
            {
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 3)).allowEdit(true);
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 3)).mandatory(true);
            }
        }

        if(itemGroupMandSetupTable.DimensionCode == SysDimension::Person)
        {
            if(!PurchLine.Dimension[4])
            {
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 4)).allowEdit(true);
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 4)).mandatory(true);
            }
        }
        if(itemGroupMandSetupTable.DimensionCode == SysDimension::Vehicle)
        {
            if(!PurchLine.Dimension[5])
            {
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 5)).allowEdit(true);
                PurchLine_ds.object(fieldid2ext(fieldnum(PurchLine, Dimension), 5)).mandatory(true);
            }
        }
    }
}

22 Nisan 2019 Pazartesi

Brüt ağırlık hesaplama | Dynamics Ax

Ağırlık hesaplama

Madde ayrıntılarındaki bir ürünün net ağırlık + dara ağırlığını satış siparişinde miktarıyla çarpıp brüt ağırlığını aşağıdaki kod ile hesaplatabilirsiniz.

Aşağıdaki kod madde kartının üzerindeki net ağırlık + dara ağırlığını hesaplar:
display ItemGrossWeight grossWeight()
{
    return this.NetWeight + this.TaraWeight;
}

Herhangi bir satış raporunda kullanabilirsiniz.

display ItemGrossWeight grossWeight() //maa 22.04.2019
{
    return InventTable::find(this.ItemId).grossWeight() * this.SalesQty / 1000; // 1000'e böldüğümüzde ton olarak sonucu alırız.
}

4 Nisan 2019 Perşembe

Kayıt düzeyi güvenliği kodla ekleme yapma | Dynamics Axapta

Kayıt düzeyi güvenliği


Kayıt düzeyi güvenliğine excel ile kayıtları ekleyebilirsiniz. Aşağıdaki formdaki gibi kayıtlar eklenmiş olacak.



void MAA_SysRecordLevelSecurity_Excel()
{
    #Excel
    #AviFiles

    Dialog              dialog = new Dialog("Veri Aktarma");
    DialogField         dialogPath;
    FilenameFilter      filter = ['Excel files 2010','*.xlsx','Excel files 2003', '*.xls' ];
    FilenameOpen        filePath;
    SysExcelApplication application;
    SysExcelWorkBooks   workBooks;
    SysExcelWorkBook    workBook;
    SysExcelWorkSheets  workSheets;
    SysExcelWorkSheet   workSheet;
    SysExcelCells       cells;
    SysOperationProgress progress;
    Int                 NoofSheet,i,lastRow,sn;

    SysRecordLevelSecurity   SysRecordLevelSecurity;

    SysExcelRange range;

    void findLastRow(SysExcelWorkSheet _workSheet)
    {
        #define.Star('*')
        #define.Space(' ')

        ;

        range = _workSheet.cells().range(#ExcelTotalRange);

        try
        {
            range = range.find(#Star, null, #xlFormulas, #xlWhole, #xlByRows, #xlPrevious);
        }
        catch (Exception::Error)
        {
            error("@SYS59926");
        }

        if (range)
        {
            lastRow = range.row();
        }
        else
        {
            lastRow = 0;
        }
    }
    ;

    dialog.filenameLookupFilter(filter);
    dialogPath  = dialog.addField(typeid(FilenameOpen));


    if (dialog.run())
    {
        if(dialog.closedOk())
        {
            filePath            = dialogPath.value();
            application         = SysExcelApplication::construct();
            application.visible(false);
            workBooks           = application.workbooks();
            workBooks.open(filePath,0,true);

            workSheets          = workBooks.item(1).worksheets();
            noOfSheet           = worksheets.count();
            progress = new SysOperationProgress();
            progress.setCaption("Vendor Importing");
            progress.setTotal(lastRow);
            progress.setAnimation(#AviTransfer);
            setprefix("Vendor Import");

            try
            {
                For( i = 1; i <= noOfSheet; i++)
                {
                    workSheet       = workSheets.itemFromNum(i);
                    if(workSheet)
                    {
                        findLastRow(workSheet);
                        for(sn = 2;sn <= lastrow;sn++)
                        {
                            ttsbegin;
                            cells                   = workSheet.cells();

                          //  SoftwareTable.clear();
                            cells = workSheet.cells();

                            SysRecordLevelSecurity.tabId       = cells.item(sn,1).value().double();
                            SysRecordLevelSecurity.groupId     = cells.item(sn,2).value().bStr();
                            SysRecordLevelSecurity.companyId   = cells.item(sn,3).value().bStr();

                            info("Aktarma tamamlandı");
                            SysRecordLevelSecurity.insert();

                            ttscommit;
                        }
                    }
                }
            }
            catch
            {
                ttsabort;
                application.quit();
            }
        }
    }
}

Eşlemede "LimitKrediLimiti" Değer Bulunamadı | İş akışının durdurulması

İş akışı hatası


Eşlemede "LimitKrediLimiti" Değer Bulunamadı! hatası iş akışları kurulurken hiyearşik olarak devam eden adımın durdurma koşulunda kullanıcının pozisyonunun onay sınırı için ayarlanacak veri girilmemiştir.



Temel > Kurulum > Limit tipleri(HRPLimitTypeTable) Bu tabloya verileri girdiğinizde problem gidecektir.

21 Ocak 2019 Pazartesi

İş akışlarının ilerlememesi | Dynamics Ax

İş akışlarınız ilerlemiyorsa muhtemelen gereksiz kayıtlar kalmış ve ilgili tablolar şişmiş olabilir(gönderilmiş formdan silinmiş vs.). Aşağıdaki kod oluşan bu gereksiz kayıtları siler. İş akışlarınız çalışmaya devam eder.


static void workflowUndefinedRecords(Args args)
{
    Common                      buffer;
    SysDictTable                dictTable;
    SysWorkflowTable            workflowTable;
    WorkflowMessageTable        workflowMessageTable;
    WorkflowWorkItemTable       workflowWorkItemTable;
    WorkflowTrackingStatusTable trackingStatus;
    boolean                     deleteifNotExist = true;
    ;
    ttsbegin;
    deleteifNotExist = Box::yesNo('Hatalı bulunan iş akış kayıtları silinsin mi?',DialogButton::No) == DialogButton::Yes ? true : false;

    setPrefix('SysWorkflowTable');
    while select forupdate workflowTable
    {
        changecompany(workflowTable.ContextCompanyId)
        {
            dictTable = new SysDictTable(workflowTable.ContextTableId);
            buffer = dictTable.makeRecord();
            select buffer where buffer.RecId == workflowTable.ContextRecId;

            if (!buffer)
            {
                 info(strfmt('%1 tablosunda %2 kaydı yok. Şirket:%3',tableId2pname(workflowTable.ContextTableId),workflowTable.ContextRecId,workflowTable.ContextCompanyId));

                if(deleteifNotExist)
                {
                    trackingStatus = WorkflowTrackingStatusTable::findByCorrelation(workflowTable.RootCorrelationId,true);
                    trackingStatus.delete();

                    workflowTable.delete();
                    info(strfmt('%1 iş akış öğesi silindi',workflowTable.RootCorrelationId));
                }
            }

        }
   }
   setPrefix('WorkflowMessageTable');
   while select forupdate workflowMessageTable
    where workflowMessageTable.MessageLifeCycleState == WorkflowMessageLifeCycleState::Queued
    {
        changecompany(workflowMessageTable.WorkflowContextCompanyId)
        {
            dictTable = new SysDictTable(workflowMessageTable.WorkflowContextTableId);
            buffer = dictTable.makeRecord();
            select buffer where buffer.RecId == workflowMessageTable.WorkflowContextRecId;

            if (!buffer)
            {
                 info(strfmt('%1 tablosunda %2 kaydı yok. Şirket:%3',tableId2pname(workflowMessageTable.workflowContextTableId),workflowMessageTable.workflowContextRecId,workflowMessageTable.workflowContextCompanyId));

                if(deleteifNotExist)
                {
                    trackingStatus = WorkflowTrackingStatusTable::findByCorrelation(workflowMessageTable.RootCorrelationId,true);
                    trackingStatus.delete();

                    workflowMessageTable.delete();
                    info(strfmt('%1 iş akış öğesi silindi',workflowMessageTable.RootCorrelationId));
                }
            }

        }

    }
   setPrefix('WorkflowMessageTable&StatusTable');
   while select forupdate workflowMessageTable
   // where workflowMessageTable.MessageLifeCycleState == WorkflowMessageLifeCycleState::Queued
         notexists join trackingStatus
            where trackingStatus.CorrelationId == workflowMessageTable.WorkflowCorrelationId
    {
        changecompany(workflowMessageTable.WorkflowContextCompanyId)
        {

            info(strfmt('WorkMessage %1 için TrackingStatus kaydı yok. statü:%2',workflowMessageTable.WorkflowCorrelationId,workflowMessageTable.MessageLifeCycleState));

                if(deleteifNotExist)
                {
                    workflowMessageTable.delete();
                    info(strfmt('%1 iş akış öğesi silindi',workflowMessageTable.WorkflowCorrelationId));
                }
        }
   }
   setPrefix('WorkflowWorkItemTable');
   while select forupdate workflowWorkItemTable
    {
        changecompany(workflowWorkItemTable.CompanyId)
        {
            dictTable = new SysDictTable(workflowWorkItemTable.RefTableId);
            buffer = dictTable.makeRecord();
            select buffer where buffer.RecId == workflowWorkItemTable.RefRecId;
            if (!buffer)
            {
                 info(strfmt('%1 tablosunda %2 kaydı yok. Şirket:%3',tableId2pname(workflowWorkItemTable.refTableId),workflowWorkItemTable.refRecId,workflowWorkItemTable.CompanyId));

                if(deleteifNotExist)
                {
                    trackingStatus = WorkflowTrackingStatusTable::findByCorrelation(workflowWorkItemTable.CorrelationId,true);
                    trackingStatus.delete();

                    workflowWorkItemTable.delete();
                    info(strfmt('%1 iş akış öğesi silindi',workflowWorkItemTable.CorrelationId));
                }
            }

        }
   }
   setPrefix('WorkflowWorkItemTable&StatusTable');
   while select forupdate workflowWorkItemTable
        notexists join trackingStatus
            where trackingStatus.CorrelationId == workflowWorkItemTable.CorrelationId
    {
        changecompany(workflowWorkItemTable.CompanyId)
        {

            info(strfmt('WorkItem %1 için TrackingStatus kaydı yok. statü:%2',workflowWorkItemTable.CorrelationId,workflowWorkItemTable.Status));

                if(deleteifNotExist)
                {
                    workflowWorkItemTable.delete();
                    info(strfmt('%1 iş akış öğesi silindi',workflowWorkItemTable.CorrelationId));
                }
        }
   }
   setPrefix('WorkflowtrackingStatusTable');
    while select forupdate trackingStatus
    {
        changecompany(trackingStatus.ContextCompanyId)
        {
            dictTable = new SysDictTable(trackingStatus.ContextTableId);
            buffer = dictTable.makeRecord();
            select buffer where buffer.RecId == trackingStatus.ContextRecId;

            if (!buffer)
            {
                 info(strfmt('%1 tablosunda %2 kaydı yok. Şirket:%3',tableId2pname(trackingStatus.ContextTableId),trackingStatus.ContextRecId,trackingStatus.ContextCompanyId));

                if(deleteifNotExist)
                {
                   trackingStatus.delete();
                   info(strfmt('%1 iş akış öğesi silindi',trackingStatus.RootCorrelationId));
                }
            }

        }
   }

   ttscommit;
}


Total ciro

static void MAA_SalesTableTotal(Args _args) { SalesTable SalesTable; utcDateTime dateTime; dateTime ...