Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Tuesday, February 20, 2024

Project intercompany invoice sales tax calculation bug in 10.0.37

 While Microsoft working on this issue, let me show you how you can fix it in the current code running on 10.0.37 or lower.

Scenario

When using the project intercompany customer invoice form in Project management and accounting module , you can create a customer invoice to bill to an intercompany customer. As the customer is intercompany, there is a legal entity (LE) associated with that customer. When posting the intercompany customer invoice, a pending vendor invoice is created in the customer’s LE with the same lines from the customer invoice.





You can see calculated Sales taxes via Sales tax button













Issue

If you try to add more lines, it will be added with line number 1, and sales taxes won't be added with this newly added line. Note: If you delete any line here and then you add more, it works fine.

This bug leads to missed taxes transactions in all TaxUncommitted, TmpTaxWorkTrans, and eventually in TaxTrans tables

Fix

Create an extension class with the following code



[ExtensionOf(classStr(ProjIntercompanyCustomerInvoiceCreator))]
final class myProjIntercompanyCustomerInvoiceCreator_Extension
{
    
    public CustInvoiceTable createInvoice()
    {
        // we need to increase the next line number to avoid duplicates in case when new lines added to initially created ones
        lineNum             = this.myGetNextLineNum();

        custInvoiceTable    = next createInvoice();

        if(origTransList.elements())
        {
            TaxUncommitted::deleteForDocumentHeader(tableNum(CustInvoiceTable), custInvoiceTable.RecId);
        }
        
        return custInvoiceTable;
    }


    public LineNum myGetNextLineNum()
    {
        CustInvoiceLine custInvoiceLine;
        
        select maxof(lineNum) from custInvoiceLine
            where custInvoiceLine.ParentRecId == custInvoiceTable.RecId;

        return custInvoiceLine.LineNum + 1;
    }

}

Wednesday, June 29, 2022

Union query for Project transactions

Union query may be a very efficient and useful option when you need to fetch similar data fields from different tables. A good example of this may be the case when you to gather information about project related transactions as they can be of different types, like, expenses, fees, items, etc. 

Say, we need to render some report collecting all these different types of transaction that can be posted against a given project and group them by a given financial dimension value in Project group. Let's see how Union query can help us.

In order to better understand the goal, you can take a look to the standard form ProjInvoiceJournal which perfectly explains how all these table relate to each other. 

Most of them contain the same set of fields, and we simply need to get some of them into one view to populate by the report data provider.

So, at the first step, let's create all necessary queries for the source Project transaction related tables. Pick up the first and create a simple query as depicted. 

Then create a view based on this query. 

Then pick up the next and do the same.

Complete these two steps for all necessary transaction types.

Now you can create a Union query and add all your views together as they have the same set of fields.

If you need to distinguish them later who is who, say, in computed column methods, you can use  unionAllBranchId field, but this is out of the current focus.

Finally you can elaborate it by adding a new view based on the latter with a simple SUM aggregation for Amount field.

Basically, you achieve your goal with no coding.

I am not going into details about the whole project, which you can get by this URL https://github.com/wojzeh/tmxProjectSalesPerSegment. Ping me, if you have any questions.


Related topics: 

Computed column for union values from multiple outer joined data sources in view

Friday, April 5, 2019

AX2012-D365 Bug: TrvWorkflowExpLines query misses fields

The issue appears once you post project or inter-company expenses.

Once you approved and never opened Accounting distribution form for an expense, Project activity number field will be empty, or, for the Inter-company case, even the project information will be lost.






This is how TrvWorkflowExpLines query should look like to overcome the issue.


Wednesday, June 6, 2018

How to add a new report for a business document in D365

My colleague Rod showed it to me when I needed to add a new report to Project Invoice Proposal with billing rules to be present in Print management settings.


    /// <summary>
    /// Subscribes to print mgmt report format publisher to populate custom reports
    /// </summary>
    [SubscribesTo(classstr(PrintMgmtReportFormatPublisher), delegatestr(PrintMgmtReportFormatPublisher, notifyPopulate))]
    public static void notifyPopulate()
    {
        #PrintMgmtSetup

        void addFormat(PrintMgmtDocumentType _type, PrintMgmtReportFormatName _name, PrintMgmtReportFormatCountryRegionId _countryRegionId = #NoCountryRegionId)
        {
            myPrintMgtDocType_ProjInvReport_Handler::addPrintMgmtReportFormat(_type, _name, _name, _countryRegionId);
        }

        addFormat(PrintMgmtDocumentType::myProjInvoiceWithBR, ssrsReportStr(myPSAContractLineInvoice, Report));
    }

    /// <summary>
    /// Adds a report format to the printMgtReportFormat table
    /// </summary>
    /// <param name = "_type">PrintMgmtDocumentType value</param>
    /// <param name = "_name">Name of the report (ie. reportname.Report)</param>
    /// <param name = "_description">Description of the report (ie. reportname.Report)</param>
    /// <param name = "_countryRegionId">Country or default (#NoCountryRegionId)</param>
    /// <param name = "_system">True if this is a system report</param>
    /// <param name = "_ssrs">SSRS report or another type</param>
    private static void addPrintMgmtReportFormat(
        PrintMgmtDocumentType _type,
        PrintMgmtReportFormatName _name,
        PrintMgmtReportFormatDescription _description,
        PrintMgmtReportFormatCountryRegionId _countryRegionId,
        PrintMgmtReportFormatSystem _system = false,
        PrintMgmtSSRS _ssrs = PrintMgmtSSRS::SSRS)
    {
        PrintMgmtReportFormat printMgmtReportFormat;

        select firstonly printMgmtReportFormat
            where printMgmtReportFormat.DocumentType == _type
                && printMgmtReportFormat.Description == _description
                && printMgmtReportFormat.CountryRegionId == _countryRegionId;

        if (!printMgmtReportFormat)
        {
            // Add the new format
            printMgmtReportFormat.clear();
            printMgmtReportFormat.DocumentType = _type;
            printMgmtReportFormat.Name = _name;
            printMgmtReportFormat.Description = _description;
            printMgmtReportFormat.CountryRegionId = _countryRegionId;
            printMgmtReportFormat.System = _system;
            printMgmtReportFormat.ssrs = _ssrs;
            printMgmtReportFormat.insert();
        }
    }

Then I can pick it up in Print management settings in Project module.





It may be a good idea to delete records from PrintMgmtReportFormat table; all its records will be recreated the next time you open Print management form.


Tuesday, November 29, 2016

How to see beginning balance journals from your projects

There is a bug in AX 2012 R2/R3.

Beginning balance journals do not create transactions in ProjJournalTrans table; therefore, they won't be selected via the standard query.



This is a small fix to show beginning balance journals from the projects forms.

In ProjJournalFormTable class we need to redo datasourceLinkActivePre() method as follows:

public void datasourceLinkActivePre()
{
    QueryBuildDataSource    qbds;
    ProjTable               callerRecord;

    if (formRun                 &&
        formRun.args()          &&
        formRun.args().record() &&
        formRun.args().dataset() == tableNum(ProjTable))
    {
        callerRecord = formRun.args().record() as ProjTable;

        // if this is a beginning balance table we have no transactions in ProjJournalTrans
        // therefore, we need to update the query so that all related journals will be shown.
        if(journalTypeId == 2) // beginning balance
        {
            SysQuery::findOrCreateRange(journalTable_ds.query().dataSourceTable(tableNum(ProjJournalTable)), fieldNum(ProjJournalTable, JournalType)).value(SysQuery::value(ProjJournalType::BegBalance));
            SysQuery::findOrCreateRange(journalTable_ds.query().dataSourceTable(tableNum(ProjJournalTable)), fieldNum(ProjJournalTable, ProjId)).value(SysQuery::value(callerRecord.ProjId));
        }
        else
        {
        // End
            qbds = journalTable_ds.query().dataSourceNo(1).addDataSource(tableNum(ProjJournalTrans));

            qbds.joinMode(JoinMode::ExistsJoin);

            qbds.addRange(fieldNum(ProjJournalTrans, ProjId)).value(callerRecord.ProjId);
            qbds.relations(true);
        }
    }

    super();
}

Friday, October 24, 2014

How to iterate project group members: Tables, EDT, etc

Based on S. Kuskov's suggestion and Vania Kashperuk's article, I put down this simple job that iterates Tables and Extended Data Types groups members in a given shared project.
static void tmxIterateProjectGroupMembers(Args _args)
{
    #aot
    #properties
    Str                         projectName = "tmxEDI999";
    ProjectNode                 projectNode;
    ProjectGroupNode            ddProjectGroupNode;
    ProjectGroupNode            edtProjectGroupNode;
    ProjectGroupNode            tblProjectGroupNode;
    ProjectListNode             projectListNode;
    TreeNode                    memberTreeNode;              
    TreeNode                    projectTreeNode;
    TreeNodeIterator            projectIterator;
    
    if(projectName)
    {
        // find all shared projects
        projectListNode = SysTreeNode::getSharedProject();
        // find project with a given name
        projectNode = projectListNode.AOTfindChild(projectName);
        // open it in a separate window in AOT
        projectTreeNode = projectNode.getRunNode();
        // this is the key point after which we can iterate group members
        projectNode = projectNode.loadForInspection();
        // get nested nodes for appropriate names
        ddProjectGroupNode = projectNode.AOTfindChild('DataDictionary');
        edtProjectGroupNode = ddProjectGroupNode.AOTfindChild('Extended Data Types');
        tblProjectGroupNode = ddProjectGroupNode.AOTfindChild('Tables');
        
        // tables
        projectIterator = tblProjectGroupNode.AOTiterator();
        memberTreeNode = projectIterator.next();

        while(memberTreeNode)
        {
            info(strFmt("%1 %2", memberTreeNode.AOTname(), memberTreeNode.treeNodeName()));
            memberTreeNode = projectIterator.next();
        }

        // extended data types
        projectIterator = edtProjectGroupNode.AOTiterator();
        memberTreeNode = projectIterator.next();

        while(memberTreeNode)
        {
            info(strFmt("%1 %2", memberTreeNode.AOTname(), memberTreeNode.treeNodeName()));
            memberTreeNode = projectIterator.next();
        }
    }
}
The key method is loadForInspection. Happy iterating!

Thursday, September 29, 2011

visualize your resume!

I want to tell you about a new online project that allows you to visualize your resume. The project is still in beta version; nevertheless, it can perform some magic.

vizualize.me

It is well known that a picture paints a thousand words. It does not matter how many words are in your CV, but I am sure that you will be impressed as might be your eventual employer.

Right after signing up it is possible to import your profile directly from LinkedIn, de facto the most popular social network for professionals.

Now the project will generate your new good-looking resume automatically: by converting text into diagrams, schemes, maps, etc.



It is up to you what to include in each part of it.



Then you can ice the cake by choosing a theme you like or formatting text and diagrams.

Finally, you publish your new resume by one click.



Good luck in job landing!

Tuesday, December 1, 2009

How to add all descendant classes to a new project

I bumped into the problem of a class compilation with no licence for X++ source code.

Forward compile option is not enough to make my changes working. Thus I need to export-import all descendant classes as well as the class I changed - FormLetter in my case.

I therefore have to add all these classes to my project. Natural laziness saved me again from this manual work.

I hope this short job inspired by system class SysCompilerOutput and miklenew's job from AXForum will help you in similar situations.






// add to a new project all descendant classes for forward compilation
public static void SISCreateCompileForwardProject(Args _args)
{
#AOT
str project = 'SIS_CompileForward';
SysCompilerOutput sysCompilerOutput;
Dictionary dictionary = new Dictionary();
DictClass dictClass = new DictClass(className2Id("Formletter"));
int numOfClasses = dictionary.classCnt();
ProjectNode sharedProjects;
ProjectNode newProject;

void addToProjectForwardClass(DictClass _dictClass, Dictionary _dictionary, int _numOfClasses)
{
ClassNode classNode;
DictClass dictClassLoop;
DictClass childClass;
int i;
;
if (_dictClass)
{
classNode = infolog.findNode(#ClassesPath + #AOTDelimiter + _dictClass.name());

if (classNode)
{
newProject.addUtilNode(UtilElementType::Class, classNode.name());

for (i=1; i <= _numOfClasses; i++)
{
dictClassLoop = _dictionary.classObject(_dictionary.classCnt2Id(i));

if (dictClassLoop.extend() == _dictClass.id())
{
childClass = new DictClass(dictClassLoop.id());
addToProjectForwardClass(childClass, _dictionary, _numOfClasses);
}
}
}
}
}
;

sharedProjects = infolog.projectRootNode().AOTfindChild('Shared');
sharedProjects.AOTAdd(project);
newProject = sharedProjects.AOTfindChild(project);
newProject.loadForInspection();
newProject = newProject.getRunNode();
addToProjectForwardClass(dictClass, dictionary, numOfClasses);
newProject.AOTsave();


}