class ItemTransfer
{
ItemsRequest itemsRequest;
InventJournalTable inventJournalTable;
InventJournalTrans inventjournalTrans;
}
______________
void new(ItemsRequest localItemRequest)
{
FormDataSource fds;
;
fds = localItemRequest.dataSource();
// populates the inventJournalTable table
inventJournalTable = this.populateInventJournalTable();
itemsRequest = fds.getFirst();
while(itemsRequest)
{
// populates the inventJournalTrans table
inventjournalTrans = this.populateInventJournalTrans(inventJournalTable.JournalId);
itemsRequest = fds.getNext();
}
this.createAndPostJournal();// to post the journal
}
_______________
///
/// Populates the buffer of the
///
///
/// Buffer of the
///
Public InventJournalTable populateInventJournalTable()
{
InventJournalTable journalTable;
InventJournalTableData journalTableData;
journalTable.clear();
journalTable.JournalNameId = ProjParameters::find().TransferJournal;
journalTableData = JournalTableData::newTable(journalTable);
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.Reservation = ItemReservation::Automatic;
journalTable.JournalType = InventJournalType::Transfer;
journalTableData.initFromJournalName(journalTableData.JournalStatic().findJournalName(journalTable.journalNameId));
//journalTable.Description = InventDescription.valueStr();
journalTable.insert();
return journalTable;
}
______________
public InventJournalTrans populateInventJournalTrans(InventJournalId _InventJournalId)
{
InventJournalTrans localInventJournalTrans;
InventSum inventSum;
InventQty inventQty;
InventDim fromInventDim,toInventDim;
InventJournalTransData journalTransData;
;
localInventJournalTrans.JournalId = _InventJournalId;
localInventJournalTrans.JournalType = InventJournalType::Transfer;
localInventJournalTrans.TransDate = itemsRequest.TransDate;//systemdateget();
localInventJournalTrans.ItemId = itemsRequest.ItemId;//inventSum.ItemId;
localInventJournalTrans.Qty = itemsRequest.Qty;//InventQty.realValue();
// Dimensions from which the transfer performs
fromInventDim.InventSiteId = itemsRequest.FromSite;
fromInventDim.InventLocationId = itemsRequest.FromWarehouse;
/*select firstonly inventSum where inventSum.Itemid == itemsRequest.itemid;
localInventJournalTrans.InventDimid = InventDim::find(inventSum.InventDimId).inventDimId;*/
localInventJournalTrans.InventDimid = InventDim::findOrCreate(fromInventDim).inventDimId;
localInventJournalTrans.initFromInventTable(InventTable::find(itemsRequest.ItemId), False, False);
// Dimensions To which the transfer performs
toInventDim.InventSiteId = itemsRequest.ToSite;
toInventDim.InventLocationId = itemsRequest.ToWarehouse;
toInventDim.inventSiteId = itemsRequest.ToSite;//InventSite.valueStr();
toInventDim.InventLocationId = itemsRequest.ToWarehouse;//InventWareHouse.valueStr();
localInventJournalTrans.ToInventDimId = InventDim::findOrCreate(toInventDim).inventDimId;
localInventJournalTrans.insert();
return localInventJournalTrans;
}
_______________
///
/// Creates and posts the Inventory Transfer Journal.
///
///
/// If there is any exception then the Inventory Journal data is deleted.
///
public void createAndPostJournal()
{
JournalCheckPost journalCheckPost;
;
/*ttsbegin;
//populates the inventJournalTable table
//inventJournalTable = this.populateInventJournalTable();
//populates the inventJournalTrans table
inventjournalTrans = this.populateInventJournalTrans(inventJournalTable.JournalId);
ttsCommit;*/
if (BOX::yesNo('Do you want to post the Journal ? ', DialogButton::Yes) == DialogButton::Yes)
{
// Call the static method to create the journal check post class
if(InventJournalCheckpost::newPostJournal(inventJournalTable).validate())
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
if(journalCheckPost.validate())
{
try
{
journalCheckPost.run();
}
catch
{
// Deletes the InventJournalTable table, the InventJournalTrans will auto delete because of the Delete actions.
InventJournalTable.delete();
}
}
}
}
__