Project-Hour Journal D365FO
code you can create Project-Hour
Journal
public void createProjectHourJournal()
{
ProjJournalTableData JournalTableData;
ProjJournalTransData journalTransData;
ProjJournalTable journalTable,
journalTableUpdate;
ProjJournalTrans journalTrans;
ProjectJournalContract _projectJournal
ProjTable projTable;
ProjInvoiceTable projInvoiceTable;
NumberSeq numberSeq;
ProjJournalCheckPost jourPost;
ProjQtyEmpl qty;
JournalNumOfLines numOfLines;
ProjCategory projCategory;
LedgerJournalName ledgerJournalName;
ProjectJournalTransContract projecJournalTrans;
ProjJournalName projJournalName;
if(_projectJournal!=null)
{
select projJournalName
where projJournalName.isFSJournal==NoYes::Yes;
projecJournalTrans=_projectJournal.getProjectJournalTrans(0);
ttsBegin;
journalTableData
= JournalTableData::newTable(journalTable);
journalTransData
= journalTableData.journalStatic().newJournalTransData(journalTrans, journalTableData);
projTable = ProjTable::find(projecJournalTrans.ProjectId);
//
Init JournalTable
projCategory=ProjCategory::find(projecJournalTrans.ProjectCateId);
journalTable.JournalId =
journalTableData.nextJournalId();
journalTable.JournalType = ProjJournalType::Hour;
journalTable.ProjId=projecJournalTrans.ProjectId;
journalTable.ProjQty=projecJournalTrans.QtyUsed;
journalTable.CategoryId=projecJournalTrans.ProjectCateId;
journalTable.ProjTransDate=systemDateGet();
//journalTable.LinePropertyId
journalTable.initFromProjJournalName(projJournalName);
journalTable.insert();
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTrans.clear();
journalTransData.initFromJournalTable();
projInvoiceTable =
projTable.projInvoice();
journalTrans.setTransDate();
journalTrans.ProjTransDate =
systemDateGet();
journalTrans.ProjId =
projTable.ProjId;
journalTrans.Qty =
projecJournalTrans.QtyUsed;
journalTrans.CategoryId =
projCategory.CategoryId;
journalTrans.Worker = HcmWorkerLookup::currentWorker();
journalTrans.ActivityNumber
= projecJournalTrans.ActivityId;
journalTrans.Txt =
_projectJournal.FreeTxt;
if(projInvoiceTable.CurrencyId)
{
journalTrans.CurrencyId
= projInvoiceTable.CurrencyId;
}
else
{
journalTrans.CurrencyId
= Ledger::accountingCurrency(CompanyInfo::current());
}
journalTrans.DefaultDimension =
projTable.DefaultDimension;
journalTrans.TaxGroupId = ProjParameters::taxGroupInvoice(projTable.ProjId);
if (journalTrans.Worker)
{
journalTrans.setHourPrices();
journalTrans.setPeriodDate();
}
numberSeq
= NumberSeq::newGetVoucherFromId(journalTable.VoucherNumberSequenceTable, false);
journalTrans.Voucher =
numberSeq.voucher();
journalTransData.create();
ttsCommit;
}
}
Comments
Post a Comment