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:
Post a Comment