0

I need to find how is the SourceBaseAmountCur being computed, in my case I am getting an error in Amount Origin on the SST window where it doesn't show 0 when it needs to be.

I am coming from General Ledger > Journals > General Journal > (select a record, going to Lines) > then SST window. Then, the Amount Origin field.

The Amount Origin is a display field:

display TaxBaseCur displaySourceBaseAmountCur(TmpTaxWorkTrans _tmpTaxWorkTrans)
{
       return taxTmpWorkTransForm.getSourceBaseAmountCur(_tmpTaxWorkTrans);
}

As seen on the code above, it already passes a TmpTaxWorkTrans record. Going to that method on the class TaxTmpWorkTransForm this is the method:

public TaxAmountCur getSourceBaseAmountCur(TmpTaxWorkTrans _tmpTaxWorkTrans = null, TmpTaxRegulation _tmpTaxRegulation = null)
{
       if (_tmpTaxRegulation)
       {
          return _tmpTaxRegulation.SourceBaseAmountCur;
       }
      else
      {
          return _tmpTaxWorkTrans.SourceBaseAmountCur * _tmpTaxWorkTrans.taxChangeDisplaySign(accountTypeMap);
      }
}

I found this article: https://dynamicsuser.net/ax/f/technical/92855/how-tmptaxworktrans-populated and I started from there Class\Tax\insertIntersection and unfortunately I couldn't find what I was looking for, been debugging for days.

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71

1 Answers1

1

An important distinction is tax calculation for a posted vs non-posted journal. It appears you are looking at non-posted journals.

I don't have great data to test this with, but I just hacked this POC job together in 20 minutes, but it should have enough "bits" that you can run with it and get the information you need.

static void Job3(Args _args)
{
    TaxCalculation          taxCalculation;
    LedgerJournalTrans      ledgerJournalTrans;
    TmpTaxWorkTrans         tmpTaxWorkTrans;
    TaxAmountCur            taxAmountCur;

    ledgerJournalTrans = LedgerJournalTrans::findRecId(5637293082, false); // Use your own journal line

    // The reason we call the below stuff is `element.getShowTax()` and is called from `\Forms\LedgerJournalTransDaily\Designs\Design\[ActionPane:ActionPane]\[ActionPaneTab:ActionPaneTab]\[ButtonGroup:ButtonGroup]\MenuItemButton:TaxTransSource\Methods\clicked`

    // This is from `\Classes\LedgerJournalEngine\getShowTax`
    taxCalculation = LedgerJournalTrans::getTaxInstance(ledgerJournalTrans.JournalNum, ledgerJournalTrans.Voucher, ledgerJournalTrans.Invoice, true, null, false, ledgerJournalTrans.TransDate);
    taxCalculation.sourceSingleLine(true, false);

    // This is from `\Classes\TaxTmpWorkTransForm\initTax`
    tmpTaxWorkTrans.setTmpData(taxCalculation.tmpTaxWorkTrans());

    // This is the temporary table that is populated
    while select tmpTaxWorkTrans
    {
        // This is from `\Classes\TaxTmpWorkTransForm\getSourceBaseAmountCur`
        taxAmountCur = (tmpTaxWorkTrans.SourceTaxAmountCur * tmpTaxWorkTrans.taxChangeDisplaySign(null)); // I pass null because the map doesn't appear used...investigate?

        // This just outputs some data
        info(strFmt("%1: %2", tmpTaxWorkTrans.TaxCode, taxAmountCur));
    }
}
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
  • HI Alex thank you for your reply! So basically, what I've understood from your code, that the method getTaxInstance from ledgerjournaltrans is the method I should look into further? however, I'm looking for how is the SourceTaxAmountCur being populated before it is being inserted into the tmpTaxWorkTrans tmp table. – Migs Zuniga Nov 11 '19 at 06:43
  • @MigsZuniga - Well it's those two lines that does the calculation and populates the `TmpTaxWorkTrans` table, then the `setTmpData()` call just lets you access/reference it. When you click the "Sales Tax" button, it just generates that tax data on the fly, so if you open a journal and look at the tax value, then copy the `RecId` of the `LedgerJournalTrans` record you were on, then run the job, ideally the `info(...)` will pump out the same numbers you saw. Then you can debug with the job more quickly to understand the calc. – Alex Kwitny Nov 11 '19 at 21:00