public void postInventMovementJournal()
{
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
CustSalesInvoiceTableOCPMANU custSalesInvoiceTableOCPMANU,custSalesInvoiceTableOCPMANUExt;
InventDim inventDimCreate;
journalTableData = JournalTableData::newTable(movementjournalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(movementjournalTrans,journalTableData);
// Init JournalTable
movementjournalTable.clear();
movementjournalTable.initValue();
movementjournalTable.JournalId = journalTableData.nextJournalId();
movementjournalTable.JournalType = InventJournalType::Movement; //This is a movement journal type
select firstonly * from custSalesInvoiceTableOCPMANUExt
where custSalesInvoiceTableOCPMANUExt.ExecutionId == executionId
&& custSalesInvoiceTableOCPMANUExt.DefinitionGroup == definitionGroupName; // Journal name configured in staging table will be available to create new movement journal
movementjournalTable.JournalNameId = custSalesInvoiceTableOCPMANUExt.InventJournalNameMovement;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(movementjournalTable.JournalNameId));
mainAccountNumOffset = DimensionStorage::getMainAccountFromLedgerDimension(InventJournalName::find(movementjournalTable.JournalNameId).LedgerDimension).MainAccountId;
movementjournalTable.LedgerDimension = DimensionStorage::getDefaultAccountForMainAccountNum(mainAccountNumOffset);
// loop through custSalesInvoiceTableOCPMANU table for movement journal
while select * from custSalesInvoiceTableOCPMANU
where custSalesInvoiceTableOCPMANU.ExecutionId == executionId
&& custSalesInvoiceTableOCPMANU.DefinitionGroup == definitionGroupName
{
// Create InventDim based on custom table data
inventDimCreate.InventSiteId = custSalesInvoiceTableOCPMANU.InventSiteId;
inventDimCreate.InventLocationId = custSalesInvoiceTableOCPMANU.InventLocationId;
inventDimCreate.wmsLocationId = custSalesInvoiceTableOCPMANU.wmsLocationId;
inventDimCreate = InventDim::findOrCreate(inventDimCreate);
// Init movementjournalTrans
movementjournalTrans.clear();
movementjournalTrans.initValue();
journalTransData.initFromJournalTable();
movementjournalTrans.ItemId = custSalesInvoiceTableOCPMANU.ItemId;
movementjournalTrans.initFromInventTable(InventTable::find(movementjournalTrans.ItemId));
movementjournalTrans.InventDimId = inventDimCreate.InventDimId;
movementjournalTrans.DefaultDimension = movementjournalTrans.mergeDimension(movementjournalTrans.DefaultDimension, movementjournalTrans.inventDim().inventLocation().DefaultDimension);
movementjournalTrans.Qty = custSalesInvoiceTableOCPMANU.SalesQty ; //post only that much qty. which are going to ship/receive for order
movementjournalTrans.CostAmount = movementjournalTrans.calcCostAmount();
movementjournalTrans.LineNum = InventJournalTrans::lastLineNum(movementjournalTable.JournalId)+1;
movementjournalTrans.TransDate = custSalesInvoiceTableOCPMANU.InvoiceDate;
journalTransData.create();
}
// post the movement journal
if(movementjournalTrans.RecId)
{
movementjournalTable.insert();
this.recalculateNumOfLines(movementjournalTable);
setPrefix(strFmt("@OCP3312",movementjournalTable.JournalId));
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(movementjournalTable).validate())
{
InventJournalCheckPost::newPostJournal(movementjournalTable).run();
}
}
}
{
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
CustSalesInvoiceTableOCPMANU custSalesInvoiceTableOCPMANU,custSalesInvoiceTableOCPMANUExt;
InventDim inventDimCreate;
journalTableData = JournalTableData::newTable(movementjournalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(movementjournalTrans,journalTableData);
// Init JournalTable
movementjournalTable.clear();
movementjournalTable.initValue();
movementjournalTable.JournalId = journalTableData.nextJournalId();
movementjournalTable.JournalType = InventJournalType::Movement; //This is a movement journal type
select firstonly * from custSalesInvoiceTableOCPMANUExt
where custSalesInvoiceTableOCPMANUExt.ExecutionId == executionId
&& custSalesInvoiceTableOCPMANUExt.DefinitionGroup == definitionGroupName; // Journal name configured in staging table will be available to create new movement journal
movementjournalTable.JournalNameId = custSalesInvoiceTableOCPMANUExt.InventJournalNameMovement;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(movementjournalTable.JournalNameId));
mainAccountNumOffset = DimensionStorage::getMainAccountFromLedgerDimension(InventJournalName::find(movementjournalTable.JournalNameId).LedgerDimension).MainAccountId;
movementjournalTable.LedgerDimension = DimensionStorage::getDefaultAccountForMainAccountNum(mainAccountNumOffset);
// loop through custSalesInvoiceTableOCPMANU table for movement journal
while select * from custSalesInvoiceTableOCPMANU
where custSalesInvoiceTableOCPMANU.ExecutionId == executionId
&& custSalesInvoiceTableOCPMANU.DefinitionGroup == definitionGroupName
{
// Create InventDim based on custom table data
inventDimCreate.InventSiteId = custSalesInvoiceTableOCPMANU.InventSiteId;
inventDimCreate.InventLocationId = custSalesInvoiceTableOCPMANU.InventLocationId;
inventDimCreate.wmsLocationId = custSalesInvoiceTableOCPMANU.wmsLocationId;
inventDimCreate = InventDim::findOrCreate(inventDimCreate);
// Init movementjournalTrans
movementjournalTrans.clear();
movementjournalTrans.initValue();
journalTransData.initFromJournalTable();
movementjournalTrans.ItemId = custSalesInvoiceTableOCPMANU.ItemId;
movementjournalTrans.initFromInventTable(InventTable::find(movementjournalTrans.ItemId));
movementjournalTrans.InventDimId = inventDimCreate.InventDimId;
movementjournalTrans.DefaultDimension = movementjournalTrans.mergeDimension(movementjournalTrans.DefaultDimension, movementjournalTrans.inventDim().inventLocation().DefaultDimension);
movementjournalTrans.Qty = custSalesInvoiceTableOCPMANU.SalesQty ; //post only that much qty. which are going to ship/receive for order
movementjournalTrans.CostAmount = movementjournalTrans.calcCostAmount();
movementjournalTrans.LineNum = InventJournalTrans::lastLineNum(movementjournalTable.JournalId)+1;
movementjournalTrans.TransDate = custSalesInvoiceTableOCPMANU.InvoiceDate;
journalTransData.create();
}
// post the movement journal
if(movementjournalTrans.RecId)
{
movementjournalTable.insert();
this.recalculateNumOfLines(movementjournalTable);
setPrefix(strFmt("@OCP3312",movementjournalTable.JournalId));
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(movementjournalTable).validate())
{
InventJournalCheckPost::newPostJournal(movementjournalTable).run();
}
}
}
Comments
Post a Comment