Pages

Banner 468 x 60px

 

Wednesday, November 22, 2017

Upload Inventory Movement Finish Good using x++

0 comments
Upload Inventory Movement Finish Good using x++ :

static void OA_SayimMaliyetli(Args _args)
{
    InventJournalTable InventJournalTable;
    InventJournalTrans InventJournalTrans;
    InventDim InventDim;

    FileNameFilter  filter;
    Dialog          dialog;
    DialogField     field;
    FilenameOpen    filenameOpen;

    InventClosing InventClosing;
    Date finalDate;
    InventTrans InventTrans;
    ItemCostPrice ItemCostPrice;


    COMVariant  COMVariant;
    SysExcelApplication app;
    SysExcelWorkbooks   Workbooks;
    SysExcelWorkbook    Workbook;
    SysExcelWorksheets  Worksheets;
    SysExcelWorksheet   Worksheet;
    SysExcelCells       Cells;
    SysExcelCell        Cell;
    int                 i,j;
    #excel

    ;

    ItemCostPrice = 0;

    while select firstonly InventClosing
        order by  TransDate desc
    {
        finalDate = InventClosing.TransDate;
    }

    filter = ["*.xlsx","*.xls"];

    dialog = new Dialog("Dosya seçiniz ");
    field  = dialog.addField(typeId(FilenameOpen));
    // dialog.filenameLookupFilter(filter);
    dialog.run();

    if (dialog.closedOK())
    {

         app = SysExcelApplication::construct();
         Workbooks = app.Workbooks();
         COMVariant = new COMVariant();
         COMVariant.bStr(field.value());
         Workbook = Workbooks.Add(COMVariant);
         Worksheets = Workbook.worksheets();
         Worksheet = Worksheets.itemFromNum(1);
         Cells = Worksheet.Cells();
            InventJournalTable.initFromInventJournalName(InventJournalName::find("HSYM"));
            InventJournalTable.Description = "Sayim Duzeltmesi";
            InventJournalTable.JournalType = InventJournalType::Movement;
            InventJournalTable.insert();
         i = 3;
         j = 0;

         while (Cells.item(i,1).value().variantType() != COMVariantType::VT_EMPTY)
         {
                InventJournalTrans.initFromInventJournalTable(InventJournalTable);
                InventJournalTrans.initValue();
                InventJournalTrans.TransDate = Cells.item(i,1).value().date() ;
                InventJournalTrans.ItemId =  Cells.item(i,2).value().bStr();
                InventJournalTrans.Qty = 1 * Cells.item(i,3).value().double();
                InventJournalTrans.TalepMiktar = -1 * InventJournalTrans.Qty;

                InventDim.inventBatchId = Cells.item(i,6).value().bStr();
                InventDim.InventLocationId = Cells.item(i,4).value().bStr();
                InventDim.wMSLocationId = Cells.item(i,5).value().bStr();
                InventJournalTrans.InventDimId = InventDim::findOrCreate(InventDim).inventDimId;

                InventDim.clear();
                InventDim.inventBatchId = Cells.item(i,9).value().bStr();
                InventDim.InventLocationId = Cells.item(i,7).value().bStr();
                InventDim.wMSLocationId = Cells.item(i,8).value().bStr();
                InventJournalTrans.ToInventDimId = InventDim::findOrCreate(InventDim).inventDimId;

                if (InventJournalTrans.Qty > 0) {

                    while select firstonly InventTrans
                        order by DateFinancial desc
                        where InventTrans.ItemId == InventJournalTrans.ItemId
                        && InventTrans.StatusReceipt == StatusReceipt::Purchased
                        && InventTrans.DateFinancial <= finalDate
                        {
                            ItemCostPrice = InventTrans.costPrice();
                        }


                    InventJournalTrans.CostPrice = ItemCostPrice;
                    InventJournalTrans.CostAmount = InventJournalTrans.CostPrice * InventJournalTrans.Qty;
                }

                InventJournalTrans.insert();
                InventJournalTrans.clear();
                i++;
         }

    }

    info ("bitti");


}

0 comments:

A financial dimension value is based on the record and has been used on a transaction. You cannot delete the record

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH