วันอาทิตย์ที่ 2 กันยายน พ.ศ. 2555

Create JournalMovement


Boolean CreateJournalMovement()
{

InventJournalTable journalTable;
InventJournalTrans journalTrans;
JournalTableData journalTableData;

InventJournalId journalId;
InventJournalName journalName;

;
ttsbegin;
//journalName = InventJournalName::find([MyJournalName]);
journalName = InventJournalName::find("M-FG");

journalTable.clear();

journalTable.JournalNameId=journalName.JournalNameId;
//rint journalTable.JournalNameId;
//ause;


journalTableData = JournalTableData::newTable(journalTable);
journalTableData.initFromJournalName(journalTableData.JournalStatic().findJournalName(journalTable.journalNameId));

journalTable.JournalId = journalTableData.nextJournalId();
   print journalTable.JournalId;
journalTable.Reservation = ItemReservation::Automatic;
journalTable.insert();


//=== Journal Trans ===//
journalTrans.clear();
journalTrans.JournalId = journalTable.JournalId;
journalTrans.JournalType = journalName.JournalType;
journalTrans.LedgerAccountIdOffset = journalName.LedgerAccountIdOffset;

   print journalTrans.JournalId;
   print journalTrans.JournalType;
   print journalTrans.LedgerAccountIdOffset;
   pause;
 
 //  BBCN0001

//journalTrans.ItemId = [MyItemId];
journalTrans.ItemId = "BBCN0001";

//journalTrans.initFromInventTable(InventTable::find([MyItemId]),False,False);
journalTrans.initFromInventTable(InventTable::find("BBCN0001"),False,False);



//ournalTrans.InventDimId = [MyInventDimId];
journalTrans.InventDimId = "DM-0000001";

journalTrans.TransDate = SystemDateGet();
//journalTrans.Qty = [MyQty];
journalTrans.Qty = 1000;
//journalTrans.PriceUnit = [MyPriceUnit];
journalTrans.PriceUnit = 1000;
//journalTrans.CostPrice = [MyCostPrice];
journalTrans.CostPrice = 999;
journalTrans.CostAmount = journalTrans.calcCostAmount();

print journalTrans.CostAmount;
pause;


journalTrans.insert();
ttscommit;

 info("Create journal movement is done.");

return true;

}

Reference http://oromux.wordpress.com/2008/07/02/ax-create-journal-movement-via-x/
Thanks....

ไม่มีความคิดเห็น:

แสดงความคิดเห็น