This article describes the creation of Project Expense Journals through X++ in D365 or AX7.
LedgerJournalName objLedgerJournalName;
LedgerJournalTable header,jourTable1;
LedgerJournalTrans trans;
LedgerJournalTrans_Project ledgerJournalTrans_Project;
LedgerJournalTrans_ProjectTaxExtensionIN ledgerJourTrans_ProjTaxExtensionIN;
ProjTableTaxExtensionIN projTableTaxExtensionIN;
ProjJournalCheckPost jourPost;
ledgerJournalCheckPost ledgerJournalCheckPost;
ProjTable
projTable;
NumberSequenceTable numberSequenceTable;
Voucher
voucher;
UserInfo
UserInfo;
DirPerson ObjDirPerson;
Select* from objLedgerJournalName where objLedgerJournalName.JournalName=="PrjJrn";
header.JournalName
=objLedgerJournalName.JournalName;
header.initFromLedgerJournalName();
header.Name
=
header.ledgerJournalName().Name;
header.JournalType =ledgerJournalType::Cost;
header.LedgerJournalInclTax =NoYes::No;
header.insert();
trans.clear();
trans.JournalNum =
header.JournalNum;
trans.DefaultDimension = projTable::find("ProjectId").DefaultDimension;
trans.AccountType =
LedgerJournalACTypE::Project;
numberSequenceTable =NumberSequenceTable::find(LedgerJournalName::find(header.JournalName).NumberSequenceTable);
voucher =NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
trans.Voucher =
voucher;
trans.CurrencyCode =
VendTable::find("VendorAccount").Currency;
trans.Qty =
0;
trans.TransDate =
01/10/2018;
trans.Invoice =
"1/125";
trans.Approved =
NoYes::Yes;
UserInfo.clear();
select * from UserInfo where UserInfo.name =="ApprovedBy ";
if(UserInfo.name != '')
{
select * from ObjDirPerson where ObjDirPerson.NameAlias == UserInfo.name;
if(ObjDirPerson.RecId != 0)
{
trans.Approver = HcmWorker::findByPerson(ObjDirPerson.RecId).RecId;
}
}
trans.Txt =
"Expense Journal";
trans.AmountCurDebit =
100.00;
trans.PostingProfile =
"INVOICE";
trans.Due =
mkdate(01,10,2018);
trans.DefaultDimension =
ProjTable::find("Project Id").DefaultDimension;
trans.AccountType =
LedgerJournalACType::Project;
trans.LedgerDimension =
LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber("ProjectId",LedgerJournalACType::Project);
trans.OffsetAccountType =
LedgerJournalACType::Vend;
trans.OffsetLedgerDimension
=
LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber("VendorAccount",LedgerJournalACType::Vend);
trans.ExchRate =
100;
trans.TaxGroup =
TaxGroupHeading::find("VendorVATCode").TaxGroup;
trans.TaxItemGroup =
TaxItemGroupHeading::find("VATCode").TaxItemGroup;
trans.insert();
ledgerJournalTrans_Project.initValue();
ledgerJourTrans_ProjTaxExtensionIN.clear();
projTableTaxExtensionIN.clear();
ledgerJourTrans_ProjTaxExtensionIN
= ledgerJournalTrans_Project.ledgerJournalTrans_ProjectTaxExtensionIN();
projTableTaxExtensionIN
= ProjTableTaxExtensionIN::findByProjTable(ProjTable::find("ProjectId").Recid);
ledgerJourTrans_ProjTaxExtensionIN.CompanyLocation
=
projTableTaxExtensionIN.CompanyLocation;
ledgerJourTrans_ProjTaxExtensionIN.TaxInformation =
projTableTaxExtensionIN.TaxInformation;
ledgerJourTrans_ProjTaxExtensionIN.ExciseType =
projTableTaxExtensionIN.ExciseType;
ledgerJourTrans_ProjTaxExtensionIN.CustomsTariffCodeTable=
projTableTaxExtensionIN.CustomsTariffCodeTable;
ledgerJourTrans_ProjTaxExtensionIN.ExciseRecordType =
projTableTaxExtensionIN.ExciseRecordType;
ledgerJourTrans_ProjTaxExtensionIN.ExciseTariffCodes =
projTableTaxExtensionIN.ExciseTariffCodes;
ledgerJourTrans_ProjTaxExtensionIN.SalesTaxFormTypes =
projTableTaxExtensionIN.SalesTaxFormTypes;
ledgerJourTrans_ProjTaxExtensionIN.ServiceCodeTable =
projTableTaxExtensionIN.ServiceCodeTable;
ledgerJourTrans_ProjTaxExtensionIN.TaxInventVATCommodityCodeId
= projTableTaxExtensionIN.TaxInventVATCommodityCodeId;
ledgerJourTrans_ProjTaxExtensionIN.DirectSettlement =
projTableTaxExtensionIN.DirectSettlement;
ledgerJournalTrans_Project.packLedgerJournalTrans_Project_IN(ledgerJourTrans_ProjTaxExtensionIN);
ledgerJournalTrans_Project.CategoryId
= Objdev_PurchaseImportData1.ProjCategoryId;
ledgerJournalTrans_Project.Qty
= 1;
ledgerJournalTrans_Project.CostPrice
=
Objdev_PurchaseImportData1.NetAmount;
ledgerJournalTrans_Project.SalesPrice
=
Objdev_PurchaseImportData1.NetAmount;
ledgerJournalTrans_Project.SalesCurrencyId
= VendTable::find(Objdev_PurchaseImportData1.SupplierAccount).Currency;
ledgerJournalTrans_Project.LinePropertyId
=
Objdev_PurchaseImportData1.LinePropertyId;
ledgerJournalTrans_Project.ProjId
=
Objdev_PurchaseImportData1.JobNumber;
ledgerJournalTrans_Project.RefRecId
=
trans.RecId;
ledgerJournalTrans_Project.insert();
ledgerJournalCheckPost
= ledgerJournalCheckPost::newLedgerJournalTable(header,NoYes::Yes);
ledgerJournalCheckPost.run();
info(strFmt("Journal number:'%1' for file '%2' created successfully.",header.JournalNum,Objdev_ProcessMaster1.FileName));
1 comments:
Write commentsThanks for sharing good information.
ReplyD365 Ax Technical online training
Microsoft Dynamics AX Technical Training
EmoticonEmoticon