Create hours journal from the Proj Listpage(posted transactions), using List,passing container
void clicked()
{
Args args;
MenuFunction menuFunction;
container con;
Str1260 listOfRecId;
ProjPostTransView projPostTransView;
args = new Args();
for(projPostTransView = ProjPostTransView_1_ds.getFirst(true) ? ProjPostTransView_1_ds.getFirst(true) : ProjPostTransView_1_ds.cursor(); projPostTransView; projPostTransView = ProjPostTransView_1_ds.getNext())
{
if(ProjTable::find(projPostTransView.ProjId).ParentId == '')
{
// storing recid of selected field in container
con = conIns(con,1,projPostTransView.TransId);
// converting container to string with comma separated
listOfRecId = con2Str(con,',');
}
}
args.parm(listOfRecId);
if ( args.parm())
{
//Menu item GenerateJournalLInes from project
menuFunction = new MenuFunction(menuitemActionStr(ALE_GenerateLinesFromProj), MenuItemType::Action);
menuFunction.run(args);
}
ProjPostTransView_1_ds.reread();
ProjPostTransView_1_ds.refresh();
}
................................................................
class ALE_GenerateJournalLinesFromProjPostedTr extends RunBase
{
ProjPostTransView projPostTransView;
ProjJournalTrans projJournalTransCheck;
List listOfRecid;
}
...........................................................................
public static void main(Args args)
{
Str1260 listOfRecId;
ProjPostTransView projPostTransViewLoc;
List myListString = new List(Types::String);
ALE_GenerateJournalLinesFromProjPostedTr generateJournalLinesFromProjPostedTr = new ALE_GenerateJournalLinesFromProjPostedTr();
listOfRecId = args.parm();
myListString = Global::strSplit(listOfRecId,',');
generateJournalLinesFromProjPostedTr.getListOfRecId(myListString);
generateJournalLinesFromProjPostedTr.run();
}
..............................................................................
public void run()
{
ALE_GenerateJournalLinesFromProjPostedTr generateJournalLinesFromProjPostedTr = new ALE_GenerateJournalLinesFromProjPostedTr();
try
{
generateJournalLinesFromProjPostedTr.createJournalLine(listOfRecId);
}
catch(Exception::Deadlock)
{
error('Caught an exception');
retry;
}
}
............................................................
public void getListOfRecId(List listOfRecIds)
{
listOfRecid = listOfRecIds;
}
....................................................................
private void createJournalLine(List _listOfRecId)
{
ProjJournalTable projJournalTableLoc1,projJournalTable;
ProjJournalTrans projJournalTrans;
ProjJournalTableData projJournalTableData;
ProjJournalTransData projJournalTransData;
int linescount;
ProjTable projTable;
ProjPostTransView projPostTransViewLoc;
Str1260 listOfRecIdLoc;
ProjTransIdBase projPostTransViewRecId;
//projPostTransViewLoc = projPostTransViewV;
List listRecIdLoc = new List(Types::String);
ListIterator listIterator;
ttsBegin;
listRecIdLoc = _listOfRecId;
projJournalTableData = JournalTableData::newTable(projJournalTable);
projJournalTransData = projJournalTableData.journalStatic().newJournalTransData(projJournalTrans, projJournalTableData);
// Init JournalTable -- header
projJournalTable.clear();
projJournalTable.JournalId = projJournalTableData.nextJournalId();
projJournalTable.JournalType = ProjJournalType::Hour;
projJournalTable.JournalNameId = 'Hybrid';
projJournalTable.initFromProjJournalName(ProjJournalName::find(projJournalTable.JournalNameId));
projJournalTable.insert();
// Init JournalTrans -- lines
listIterator = new ListIterator(listRecIdLoc);
while(listIterator.more())
{
projPostTransViewRecId = listIterator.value();
select projPostTransViewLoc where projPostTransViewLoc.TransId == projPostTransViewRecId;
while select projTable where projTable.ParentId == projPostTransViewLoc.ProjId
{
projJournalTableData.initFromJournalName(projJournalTableData.journalStatic().findJournalName(projJournalTable.JournalNameId));
projJournalTrans.clear();
projJournalTransData.initFromJournalTable();
//projJournalTableData = JournalTableData::newTable(projJournalTableRevenueJournal);
//projJournalTransData = projJournalTableData.journalStatic().newJournalTransData(projJournalTrans,projJournalTableData);
projJournalTrans.JournalId = projJournalTable.JournalId;
projJournalTrans.initValue();
projJournalTrans.ProjId = projTable.ProjId;
projJournalTrans.Worker = HcmWorker::findByPersonnelNumber('Blank').RecId;
projJournalTrans.initFromProjTable( ProjTable::find(projPostTransViewLoc.ProjId));
projJournalTrans.TransDate = projPostTransViewLoc.TransDate;
projJournalTrans.LinePropertyId = ProjJournalName::find(projJournalTable.JournalNameId).ALE_LinePropertyId ;
projJournalTrans.ProjTransDate = projJournalTrans.TransDate;
projJournalTrans.Ale_WorkerName = projPostTransViewLoc.WorkerName;//HcmWorker::find(projJournalTrans.Worker).name();// Added by somendra
projJournalTrans.TransId = '';
projJournalTrans.CategoryId = 'C-HYBRID-PRO';
//projJournalTrans.setHourCostPrice();
projJournalTrans.Qty = projPostTransViewLoc.Qty;
if(projPostTransViewLoc.TotalCostAmountCur == 0)
{
projJournalTrans.CostPrice = (projPostTransViewLoc.TotalSalesAmountCur * projTable.Ale_HybridPercentage)/100;
}
else
{
projJournalTrans.CostPrice = (projPostTransViewLoc.TotalCostAmountCur * projTable.Ale_HybridPercentage)/100;
}
linescount++;
projJournalTransData.create();
}
listIterator.next();
}// List
if(projJournalTrans.RecId)
{
select forUpdate projJournalTableLoc1 where projJournalTableLoc1.JournalId == projJournalTable.JournalId;
projJournalTableLoc1.ProjQty = projJournalTable.ProjQty ;
projJournalTableLoc1.NumOfLines = projJournalTable.NumOfLines ;
projJournalTableLoc1.update();
info(strFmt('%1 - %2 Journal lines has been created',projJournalTable.JournalId,linescount));
}
ttsCommit;
}
.....................................................
void clicked()
{
Args args;
MenuFunction menuFunction;
container con;
Str1260 listOfRecId;
ProjPostTransView projPostTransView;
args = new Args();
for(projPostTransView = ProjPostTransView_1_ds.getFirst(true) ? ProjPostTransView_1_ds.getFirst(true) : ProjPostTransView_1_ds.cursor(); projPostTransView; projPostTransView = ProjPostTransView_1_ds.getNext())
{
if(ProjTable::find(projPostTransView.ProjId).ParentId == '')
{
// storing recid of selected field in container
con = conIns(con,1,projPostTransView.TransId);
// converting container to string with comma separated
listOfRecId = con2Str(con,',');
}
}
args.parm(listOfRecId);
if ( args.parm())
{
//Menu item GenerateJournalLInes from project
menuFunction = new MenuFunction(menuitemActionStr(ALE_GenerateLinesFromProj), MenuItemType::Action);
menuFunction.run(args);
}
ProjPostTransView_1_ds.reread();
ProjPostTransView_1_ds.refresh();
}
................................................................
class ALE_GenerateJournalLinesFromProjPostedTr extends RunBase
{
ProjPostTransView projPostTransView;
ProjJournalTrans projJournalTransCheck;
List listOfRecid;
}
...........................................................................
public static void main(Args args)
{
Str1260 listOfRecId;
ProjPostTransView projPostTransViewLoc;
List myListString = new List(Types::String);
ALE_GenerateJournalLinesFromProjPostedTr generateJournalLinesFromProjPostedTr = new ALE_GenerateJournalLinesFromProjPostedTr();
listOfRecId = args.parm();
myListString = Global::strSplit(listOfRecId,',');
generateJournalLinesFromProjPostedTr.getListOfRecId(myListString);
generateJournalLinesFromProjPostedTr.run();
}
..............................................................................
public void run()
{
ALE_GenerateJournalLinesFromProjPostedTr generateJournalLinesFromProjPostedTr = new ALE_GenerateJournalLinesFromProjPostedTr();
try
{
generateJournalLinesFromProjPostedTr.createJournalLine(listOfRecId);
}
catch(Exception::Deadlock)
{
error('Caught an exception');
retry;
}
}
............................................................
public void getListOfRecId(List listOfRecIds)
{
listOfRecid = listOfRecIds;
}
....................................................................
private void createJournalLine(List _listOfRecId)
{
ProjJournalTable projJournalTableLoc1,projJournalTable;
ProjJournalTrans projJournalTrans;
ProjJournalTableData projJournalTableData;
ProjJournalTransData projJournalTransData;
int linescount;
ProjTable projTable;
ProjPostTransView projPostTransViewLoc;
Str1260 listOfRecIdLoc;
ProjTransIdBase projPostTransViewRecId;
//projPostTransViewLoc = projPostTransViewV;
List listRecIdLoc = new List(Types::String);
ListIterator listIterator;
ttsBegin;
listRecIdLoc = _listOfRecId;
projJournalTableData = JournalTableData::newTable(projJournalTable);
projJournalTransData = projJournalTableData.journalStatic().newJournalTransData(projJournalTrans, projJournalTableData);
// Init JournalTable -- header
projJournalTable.clear();
projJournalTable.JournalId = projJournalTableData.nextJournalId();
projJournalTable.JournalType = ProjJournalType::Hour;
projJournalTable.JournalNameId = 'Hybrid';
projJournalTable.initFromProjJournalName(ProjJournalName::find(projJournalTable.JournalNameId));
projJournalTable.insert();
// Init JournalTrans -- lines
listIterator = new ListIterator(listRecIdLoc);
while(listIterator.more())
{
projPostTransViewRecId = listIterator.value();
select projPostTransViewLoc where projPostTransViewLoc.TransId == projPostTransViewRecId;
while select projTable where projTable.ParentId == projPostTransViewLoc.ProjId
{
projJournalTableData.initFromJournalName(projJournalTableData.journalStatic().findJournalName(projJournalTable.JournalNameId));
projJournalTrans.clear();
projJournalTransData.initFromJournalTable();
//projJournalTableData = JournalTableData::newTable(projJournalTableRevenueJournal);
//projJournalTransData = projJournalTableData.journalStatic().newJournalTransData(projJournalTrans,projJournalTableData);
projJournalTrans.JournalId = projJournalTable.JournalId;
projJournalTrans.initValue();
projJournalTrans.ProjId = projTable.ProjId;
projJournalTrans.Worker = HcmWorker::findByPersonnelNumber('Blank').RecId;
projJournalTrans.initFromProjTable( ProjTable::find(projPostTransViewLoc.ProjId));
projJournalTrans.TransDate = projPostTransViewLoc.TransDate;
projJournalTrans.LinePropertyId = ProjJournalName::find(projJournalTable.JournalNameId).ALE_LinePropertyId ;
projJournalTrans.ProjTransDate = projJournalTrans.TransDate;
projJournalTrans.Ale_WorkerName = projPostTransViewLoc.WorkerName;//HcmWorker::find(projJournalTrans.Worker).name();// Added by somendra
projJournalTrans.TransId = '';
projJournalTrans.CategoryId = 'C-HYBRID-PRO';
//projJournalTrans.setHourCostPrice();
projJournalTrans.Qty = projPostTransViewLoc.Qty;
if(projPostTransViewLoc.TotalCostAmountCur == 0)
{
projJournalTrans.CostPrice = (projPostTransViewLoc.TotalSalesAmountCur * projTable.Ale_HybridPercentage)/100;
}
else
{
projJournalTrans.CostPrice = (projPostTransViewLoc.TotalCostAmountCur * projTable.Ale_HybridPercentage)/100;
}
linescount++;
projJournalTransData.create();
}
listIterator.next();
}// List
if(projJournalTrans.RecId)
{
select forUpdate projJournalTableLoc1 where projJournalTableLoc1.JournalId == projJournalTable.JournalId;
projJournalTableLoc1.ProjQty = projJournalTable.ProjQty ;
projJournalTableLoc1.NumOfLines = projJournalTable.NumOfLines ;
projJournalTableLoc1.update();
info(strFmt('%1 - %2 Journal lines has been created',projJournalTable.JournalId,linescount));
}
ttsCommit;
}
.....................................................