Discussion:
LedgerJournalEngine
(too old to reply)
Adam
2009-02-23 17:24:06 UTC
Permalink
Hello,

I'm trying to create invoice journals from data imported from a CSV file.
My current approach is to initialize LedgerJournalTable and
LedgerJournalTrans records with the values from my file but I'm running into
some problems when creating journals where the account or offset account is a
project. I think I'm not initializing values properly on the linked records
(LedgerJournalTrans_Project).

It looks like AX uses the LedgerJournalEngine class to create all of this
data. Does anyone have a simple code example of how to use this class to
properly create journals? I think most of the work is already done for me,
I'm just having trouble figuring out exactly how to use that class. Any
suggestions would be a huge help!

Thanks,
Adam
Adam
2009-02-25 00:05:01 UTC
Permalink
OK, after a lot of debugging and trial and error, here's what I came up with.
If anyone knows how to use this thing, please let me know if I'm going about
this the right way. Everything seems to be working correctly from what I can
tell:

......................................................................................

LedgerJournalEngine ledgerEngine;
LedgerJournalTable ledgerTable;
LedgerJournalTrans ledgerTrans;
LedgerJournalTrans_Asset ledgerTransAsset;
LedgerJournalTrans_Project ledgerTransProj;
;
ledgerTable.clear();
ledgerTable.initValue();
ledgerTable.journalName = importOrder.journalName;
ledgerTable.name = importOrder.name;
ledgerTable.currencyCode = importOrder.currencyCode;
ledgerTable.insert();

while select importLine
{
// setup the journal line
ledgerEngine = new LedgerJournalEngine_VendInvoice();
ledgerEngine.newJournalActive(ledgerTable);
ledgerTrans.initValue();
ledgerEngine.initValue(ledgerTrans);
ledgerEngine.initValueAsset(ledgerTransAsset);
ledgerEngine.active(ledgerTrans);

// set the account type
ledgerTrans.AccountType = importLine.AccountType;
ledgerEngine.accountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);

// set the account number
ledgerTrans.accountNum = importLine.AccountNum;
ledgerEngine.accountNumModified(ledgerTrans, ledgerTransProj);
ledgerEngine.accountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);

if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);

// set the offset account type
ledgerTrans.offsetAccountType = importLine.offsetAccountType;
ledgerTrans.offsetAccountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);

// set the offset account number
ledgerTrans.offsetAccount = importLine.offsetAccount;
ledgerEngine.offsetAccountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
ledgerEngine.initFromOffsetAccount(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);

if(ledgerTrans.isFixedAssetTransaction())
{
// link the ledgerTransAsset record to the ledgerTrans record
ledgerTransAsset.refRecId = ledgerTrans.recId;

// set the fixed asset transaction type
ledgerTransAsset.TransType = importLine.assetTransType;
ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);

// set the fixed asset value model
ledgerTransAsset.BookId = importLine.assetBookId;
ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);

if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);

ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);

ttsbegin;
ledgerTransAsset.write();
ttscommit;
}

if(ledgerTrans.isProjectTransaction())
{
ledgerTransProj.RefRecId = ledgerTrans.RecId;
ttsbegin;
ledgerTransProj.write();
ttscommit;
}

// set the credit amount
if(importLine.creditAmount)
{
ledgerTrans.amountCurCredit = importLine.creditAmount;
ledgerEngine.amountCurCreditModified(ledgerTrans, ledgerTransProj);
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);

if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
{
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
}
}

// set the debit amount
if(importLine.debitAmount)
{
ledgerTrans.amountCurDebit = importLine.debitAmount;
ledgerEngine.amountCurDebitModified(ledgerTrans, ledgerTransProj);
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);

if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
{
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
}
}

// set the currency
ledgerTrans.currencyCode = importLine.currencyCode;
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.currencyModified(ledgerTrans);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);

// set the invoice date
ledgerTrans.TransDate = importLine.TransDate;
ledgerEngine.transDateModified(ledgerTrans);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);

// set the invoice id
ledgerTrans.invoice = importLine.invoiceId;
ledgerEngine.invoiceModified(ledgerTrans, ledgerTransProj);
ledgerEngine.paymentModified(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);

// set the tax group
ledgerTrans.taxGroup = importLine.TaxGroup;
ledgerEngine.correctTaxAmount(ledgerTrans, 0);
ledgerEngine.paymentModified(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);

// set the item tax group
ledgerTrans.taxItemGroup = importLine.taxItemGroup;
ledgerEngine.correctTaxAmount(ledgerTrans, 0);
ledgerEngine.paymentModified(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);

// set other fields that don't require ledgerEngine.modified() methods
...

ledgerTrans.write();
ledgerEngine.write(ledgerTrans);

if(ledgerTrans.isFixedAssetTransaction())
{
// link the ledgerTransAsset record to the ledgerTrans record
ledgerTransAsset.refRecId = ledgerTrans.recId;

// set the fixed asset transaction type
ledgerTransAsset.TransType = importLine.assetTransType;
ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);

// set the fixed asset value model
ledgerTransAsset.BookId = importLine.assetBookId;
ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);

if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);

ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);

ttsbegin;
ledgerTransAsset.write();
ttscommit;
}

if(ledgerTrans.isProjectTransaction())
{
ledgerTransProj.RefRecId = ledgerTrans.RecId;
ttsbegin;
ledgerTransProj.write();
ttscommit;
}
}
......................................................................................

Some of these methods, I wasn't too sure if I needed to call, like the
clearTaxAmountCache(...) and cashDiscCodeModified(...) but as I was having
troubles getting things to behave properly after I imported my lines, I found
these methods being called in the modified field methods in the
LedgerJournalTransVendInvoice form. I know it's a lot to look over but if
anyone has experience using the ledgerJournalEngine class, please glance over
this and see if I'm missing anything or adding any extra unnecessary steps.

Thanks,
Adam
Leonel Galán
2009-04-23 19:24:43 UTC
Permalink
Post by Adam
OK, after a lot of debugging and trial and error, here's what I came up with.
 If anyone knows how to use this thing, please let me know if I'm going about
this the right way.  Everything seems to be working correctly from what I can
........................................................................... ...........
LedgerJournalEngineledgerEngine;
LedgerJournalTable ledgerTable;
LedgerJournalTrans ledgerTrans;
LedgerJournalTrans_Asset ledgerTransAsset;
LedgerJournalTrans_Project ledgerTransProj;
;
ledgerTable.clear();
ledgerTable.initValue();
ledgerTable.journalName = importOrder.journalName;
ledgerTable.name = importOrder.name;
ledgerTable.currencyCode = importOrder.currencyCode;
ledgerTable.insert();
while select importLine
{
   // setup the journal line
   ledgerEngine = new LedgerJournalEngine_VendInvoice();
   ledgerEngine.newJournalActive(ledgerTable);
   ledgerTrans.initValue();
   ledgerEngine.initValue(ledgerTrans);
   ledgerEngine.initValueAsset(ledgerTransAsset);
   ledgerEngine.active(ledgerTrans);
   // set the account type
   ledgerTrans.AccountType = importLine.AccountType;
   ledgerEngine.accountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   // set the account number
   ledgerTrans.accountNum = importLine.AccountNum;
   ledgerEngine.accountNumModified(ledgerTrans, ledgerTransProj);
   ledgerEngine.accountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
      ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
   // set the offset account type
   ledgerTrans.offsetAccountType = importLine.offsetAccountType;
   ledgerTrans.offsetAccountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   // set the offset account number
   ledgerTrans.offsetAccount = importLine.offsetAccount;
   ledgerEngine.offsetAccountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   ledgerEngine.initFromOffsetAccount(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   ledgerEngine.clearTaxAmountCache(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   if(ledgerTrans.isFixedAssetTransaction())
   {
      // link the ledgerTransAsset record to the ledgerTrans record
      ledgerTransAsset.refRecId = ledgerTrans.recId;
      // set the fixed asset transaction type
      ledgerTransAsset.TransType = importLine.assetTransType;
      ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);
      // set the fixed asset value model
      ledgerTransAsset.BookId = importLine.assetBookId;
      ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
         ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);
      ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
      ttsbegin;
      ledgerTransAsset.write();
      ttscommit;
   }    
   if(ledgerTrans.isProjectTransaction())
   {
      ledgerTransProj.RefRecId = ledgerTrans.RecId;
      ttsbegin;
      ledgerTransProj.write();
      ttscommit;
   }
   // set the credit amount
   if(importLine.creditAmount)
   {
      ledgerTrans.amountCurCredit = importLine.creditAmount;
      ledgerEngine.amountCurCreditModified(ledgerTrans, ledgerTransProj);
      ledgerEngine.clearTaxAmountCache(ledgerTrans);
      ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
         ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
      {
          ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
          ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
      }
   }
   // set the debit amount
   if(importLine.debitAmount)
   {
      ledgerTrans.amountCurDebit = importLine.debitAmount;
      ledgerEngine.amountCurDebitModified(ledgerTrans, ledgerTransProj);
      ledgerEngine.clearTaxAmountCache(ledgerTrans);
      ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
         ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
      {
          ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
          ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
      }
   }
   // set the currency
   ledgerTrans.currencyCode = importLine.currencyCode;
   ledgerEngine.clearTaxAmountCache(ledgerTrans);
   ledgerEngine.currencyModified(ledgerTrans);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set the invoice date
   ledgerTrans.TransDate = importLine.TransDate;
   ledgerEngine.transDateModified(ledgerTrans);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set the invoice id
   ledgerTrans.invoice = importLine.invoiceId;
   ledgerEngine.invoiceModified(ledgerTrans, ledgerTransProj);
   ledgerEngine.paymentModified(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   // set the tax group
   ledgerTrans.taxGroup = importLine.TaxGroup;
   ledgerEngine.correctTaxAmount(ledgerTrans, 0);
   ledgerEngine.paymentModified(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set the item tax group
   ledgerTrans.taxItemGroup = importLine.taxItemGroup;
   ledgerEngine.correctTaxAmount(ledgerTrans, 0);
   ledgerEngine.paymentModified(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set other fields that don't require ledgerEngine.modified() methods
   ...
   ledgerTrans.write();
   ledgerEngine.write(ledgerTrans);
   if(ledgerTrans.isFixedAssetTransaction())
   {
      // link the ledgerTransAsset record to the ledgerTrans record
      ledgerTransAsset.refRecId = ledgerTrans.recId;
      // set the fixed asset transaction type
      ledgerTransAsset.TransType = importLine.assetTransType;
      ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);
      // set the fixed asset value model
      ledgerTransAsset.BookId = importLine.assetBookId;
      ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
         ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);
      ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
      ttsbegin;
      ledgerTransAsset.write();
      ttscommit;
   }    
   if(ledgerTrans.isProjectTransaction())
   {
      ledgerTransProj.RefRecId = ledgerTrans.RecId;
      ttsbegin;
      ledgerTransProj.write();
      ttscommit;
   }}
........................................................................... ...........
Some of these methods, I wasn't too sure if I needed to call, like the
clearTaxAmountCache(...) and cashDiscCodeModified(...) but as I was having
troubles getting things to behave properly after I imported my lines, I found
these methods being called in the modified field methods in the
LedgerJournalTransVendInvoice form.  I know it's a lot to look over but if
anyone has experience using theledgerJournalEngineclass, please glance over
this and see if I'm missing anything or adding any extra unnecessary steps.
Thanks,
Adam
After calling ledgerJournalEngine.initValue(ledgerJournalTrans); an
error occurs:

Message (<time>)
System does not support setup 'continuous' of number sequence <number
sequence name>.
Number selection is canceled.

I'm not sure why this is happening. Thanks in advance for your help.
Leonel Galán
2009-04-23 22:44:44 UTC
Permalink
Post by Leonel Galán
Post by Adam
OK, after a lot of debugging and trial and error, here's what I came up with.
 If anyone knows how to use this thing, please let me know if I'm going about
this the right way.  Everything seems to be working correctly from what I can
........................................................................... ...........
LedgerJournalEngineledgerEngine;
LedgerJournalTable ledgerTable;
LedgerJournalTrans ledgerTrans;
LedgerJournalTrans_Asset ledgerTransAsset;
LedgerJournalTrans_Project ledgerTransProj;
;
ledgerTable.clear();
ledgerTable.initValue();
ledgerTable.journalName = importOrder.journalName;
ledgerTable.name = importOrder.name;
ledgerTable.currencyCode = importOrder.currencyCode;
ledgerTable.insert();
while select importLine
{
   // setup the journal line
   ledgerEngine = new LedgerJournalEngine_VendInvoice();
   ledgerEngine.newJournalActive(ledgerTable);
   ledgerTrans.initValue();
   ledgerEngine.initValue(ledgerTrans);
   ledgerEngine.initValueAsset(ledgerTransAsset);
   ledgerEngine.active(ledgerTrans);
   // set the account type
   ledgerTrans.AccountType = importLine.AccountType;
   ledgerEngine.accountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   // set the account number
   ledgerTrans.accountNum = importLine.AccountNum;
   ledgerEngine.accountNumModified(ledgerTrans, ledgerTransProj);
   ledgerEngine.accountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
      ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
   // set the offset account type
   ledgerTrans.offsetAccountType = importLine.offsetAccountType;
   ledgerTrans.offsetAccountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   // set the offset account number
   ledgerTrans.offsetAccount = importLine.offsetAccount;
   ledgerEngine.offsetAccountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   ledgerEngine.initFromOffsetAccount(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
   ledgerEngine.clearTaxAmountCache(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   if(ledgerTrans.isFixedAssetTransaction())
   {
      // link the ledgerTransAsset record to the ledgerTrans record
      ledgerTransAsset.refRecId = ledgerTrans.recId;
      // set the fixed asset transaction type
      ledgerTransAsset.TransType = importLine.assetTransType;
      ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);
      // set the fixed asset value model
      ledgerTransAsset.BookId = importLine.assetBookId;
      ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
         ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);
      ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
      ttsbegin;
      ledgerTransAsset.write();
      ttscommit;
   }    
   if(ledgerTrans.isProjectTransaction())
   {
      ledgerTransProj.RefRecId = ledgerTrans.RecId;
      ttsbegin;
      ledgerTransProj.write();
      ttscommit;
   }
   // set the credit amount
   if(importLine.creditAmount)
   {
      ledgerTrans.amountCurCredit = importLine.creditAmount;
      ledgerEngine.amountCurCreditModified(ledgerTrans, ledgerTransProj);
      ledgerEngine.clearTaxAmountCache(ledgerTrans);
      ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
         ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
      {
          ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
          ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
      }
   }
   // set the debit amount
   if(importLine.debitAmount)
   {
      ledgerTrans.amountCurDebit = importLine.debitAmount;
      ledgerEngine.amountCurDebitModified(ledgerTrans, ledgerTransProj);
      ledgerEngine.clearTaxAmountCache(ledgerTrans);
      ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
         ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
      {
          ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
          ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
      }
   }
   // set the currency
   ledgerTrans.currencyCode = importLine.currencyCode;
   ledgerEngine.clearTaxAmountCache(ledgerTrans);
   ledgerEngine.currencyModified(ledgerTrans);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set the invoice date
   ledgerTrans.TransDate = importLine.TransDate;
   ledgerEngine.transDateModified(ledgerTrans);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set the invoice id
   ledgerTrans.invoice = importLine.invoiceId;
   ledgerEngine.invoiceModified(ledgerTrans, ledgerTransProj);
   ledgerEngine.paymentModified(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   // set the tax group
   ledgerTrans.taxGroup = importLine.TaxGroup;
   ledgerEngine.correctTaxAmount(ledgerTrans, 0);
   ledgerEngine.paymentModified(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set the item tax group
   ledgerTrans.taxItemGroup = importLine.taxItemGroup;
   ledgerEngine.correctTaxAmount(ledgerTrans, 0);
   ledgerEngine.paymentModified(ledgerTrans);
   ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
   ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
   // set other fields that don't require ledgerEngine.modified() methods
   ...
   ledgerTrans.write();
   ledgerEngine.write(ledgerTrans);
   if(ledgerTrans.isFixedAssetTransaction())
   {
      // link the ledgerTransAsset record to the ledgerTrans record
      ledgerTransAsset.refRecId = ledgerTrans.recId;
      // set the fixed asset transaction type
      ledgerTransAsset.TransType = importLine.assetTransType;
      ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);
      // set the fixed asset value model
      ledgerTransAsset.BookId = importLine.assetBookId;
      ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);
      if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
         ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);
      ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
      ttsbegin;
      ledgerTransAsset.write();
      ttscommit;
   }    
   if(ledgerTrans.isProjectTransaction())
   {
      ledgerTransProj.RefRecId = ledgerTrans.RecId;
      ttsbegin;
      ledgerTransProj.write();
      ttscommit;
   }}
........................................................................... ...........
Some of these methods, I wasn't too sure if I needed to call, like the
clearTaxAmountCache(...) and cashDiscCodeModified(...) but as I was having
troubles getting things to behave properly after I imported my lines, I found
these methods being called in the modified field methods in the
LedgerJournalTransVendInvoice form.  I know it's a lot to look over but if
anyone has experience using theledgerJournalEngineclass, please glance over
this and see if I'm missing anything or adding any extra unnecessary steps.
Thanks,
Adam
After calling ledgerJournalEngine.initValue(ledgerJournalTrans); an
Message (<time>)
System does not support setup 'continuous' of number sequence <number
sequence name>.
Number selection is canceled.
I'm not sure why this is happening. Thanks in advance for your help.
I'm trying to create (and add lines) to a project expenses journal, so
the voucher number sequence must be continuous (while configuring a
Journal of this type a number sequence with the continious setup is
required).

The error is thrown by NumberSeq.checkSetUpNum because appl.ttsLevel
== 1 (!makeDecisionLater && appl.ttsLevel() == 1 &&
numberSequenceTable.Continuous == NoYes::Yes) and the stack trace is:

[s] \Classes\NumberSeq
\checkSetUpNum
4
[s] \Classes\NumberSeq
\getNumInternal
24
[s] \Classes\NumberSeq
\runNumber
11
[s] \Classes\NumberSeq
\voucher
9
[c] \Classes\JournalVoucherNum
\getNew
11
[c] \Classes\LedgerJournalEngine
\newVoucher
15
[c] \Classes\LedgerJournalEngine
\initValue
16
[c] \Classes\LedgerJournalEngine_ProjectCost
\initValue 5
[c] \Classes\FormButtonControl
\Clicked
38

Thanks again, all help is appreciated.
Richard
2010-08-18 09:48:03 UTC
Permalink
Hi,
Post by Leonel Galán
Message (<time>)
System does not support setup 'continuous' of number sequence <number
sequence name>.
Number selection is canceled.
I got that once and solved it by placing the issuing of the sequence number
in a transaction.

For example:

NumberSeq numberSeq =
NumberSeq::newGetVoucherFromCode(ledgerJournalName.VoucherSeries);
;

ttsbegin;
voucher = numberSeq.voucher();
ttscommit;

Hope that helps,

Belal Marzouk
2009-05-10 12:58:07 UTC
Permalink
What about Inventory Transfer

The following code generates this warning: "From warehouse must be 11." and
this error: "Update has been canceled.". Please note I deal with contoso demo
data and AX 2009 SP1

static void InventoryTransfer(Args _args)
{
InventTransferTable InventTransferTable;
NumberSequenceReference NumberSequenceReference;
NumberSeq numberSeq;
InventTransferLine InventTransferLine;
str item='1000';
real qty_ship = 7.0;
;
InventTransferTable.initValue();
NumberSequenceReference = InventParameters::numRefTransferId();
numberSeq =
numberSeq::newGetNumFromCode(NumberSequenceReference.NumberSequence, true);

InventTransferTable.TransferId = numberSeq.num();
InventTransferTable.InventLocationIdFrom = '11';

InventTransferTable.modifiedField(fieldNum(InventTransferTable,
InventLocationIdFrom));
InventTransferTable.InventLocationIdTo = '12';
InventTransferTable.modifiedField(fieldNum(InventTransferTable,
InventLocationIdTo));
InventTransferTable.insert();

inventTransferLine.clear();
inventTransferLine.initFromInventTransferTable(InventTransferTable,
NoYes::Yes);
inventTransferLine.ItemId = item; ///
inventTransferLine.initFromInventTable(InventTable::find(item));
inventTransferLine.QtyTransfer = qty_ship;
inventTransferLine.QtyRemainReceive = qty_ship;
inventTransferLine.QtyRemainShip = qty_ship;
inventTransferLine.QtyShipNow = 0;
inventTransferLine.QtyReceiveNow = 0;

inventTransferLine.insert();


}
Post by Adam
OK, after a lot of debugging and trial and error, here's what I came up with.
If anyone knows how to use this thing, please let me know if I'm going about
this the right way. Everything seems to be working correctly from what I can
......................................................................................
LedgerJournalEngine ledgerEngine;
LedgerJournalTable ledgerTable;
LedgerJournalTrans ledgerTrans;
LedgerJournalTrans_Asset ledgerTransAsset;
LedgerJournalTrans_Project ledgerTransProj;
;
ledgerTable.clear();
ledgerTable.initValue();
ledgerTable.journalName = importOrder.journalName;
ledgerTable.name = importOrder.name;
ledgerTable.currencyCode = importOrder.currencyCode;
ledgerTable.insert();
while select importLine
{
// setup the journal line
ledgerEngine = new LedgerJournalEngine_VendInvoice();
ledgerEngine.newJournalActive(ledgerTable);
ledgerTrans.initValue();
ledgerEngine.initValue(ledgerTrans);
ledgerEngine.initValueAsset(ledgerTransAsset);
ledgerEngine.active(ledgerTrans);
// set the account type
ledgerTrans.AccountType = importLine.AccountType;
ledgerEngine.accountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
// set the account number
ledgerTrans.accountNum = importLine.AccountNum;
ledgerEngine.accountNumModified(ledgerTrans, ledgerTransProj);
ledgerEngine.accountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
// set the offset account type
ledgerTrans.offsetAccountType = importLine.offsetAccountType;
ledgerTrans.offsetAccountTypeModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
// set the offset account number
ledgerTrans.offsetAccount = importLine.offsetAccount;
ledgerEngine.offsetAccountModified(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
ledgerEngine.initFromOffsetAccount(ledgerTrans, ledgerTransProj,
ledgerTransAsset);
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
if(ledgerTrans.isFixedAssetTransaction())
{
// link the ledgerTransAsset record to the ledgerTrans record
ledgerTransAsset.refRecId = ledgerTrans.recId;
// set the fixed asset transaction type
ledgerTransAsset.TransType = importLine.assetTransType;
ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);
// set the fixed asset value model
ledgerTransAsset.BookId = importLine.assetBookId;
ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);
if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);
ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
ttsbegin;
ledgerTransAsset.write();
ttscommit;
}
if(ledgerTrans.isProjectTransaction())
{
ledgerTransProj.RefRecId = ledgerTrans.RecId;
ttsbegin;
ledgerTransProj.write();
ttscommit;
}
// set the credit amount
if(importLine.creditAmount)
{
ledgerTrans.amountCurCredit = importLine.creditAmount;
ledgerEngine.amountCurCreditModified(ledgerTrans, ledgerTransProj);
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
{
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
}
}
// set the debit amount
if(importLine.debitAmount)
{
ledgerTrans.amountCurDebit = importLine.debitAmount;
ledgerEngine.amountCurDebitModified(ledgerTrans, ledgerTransProj);
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
if(ledgerTrans.AccountType == LedgerJournalACType::Project ||
ledgerTrans.OffsetAccountType == LedgerJournalACType::Project &&
ledgerTrans.offsetAccount))
{
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
ledgerEngine.projCostPriceModified(ledgerTrans, ledgerTransProj);
}
}
// set the currency
ledgerTrans.currencyCode = importLine.currencyCode;
ledgerEngine.clearTaxAmountCache(ledgerTrans);
ledgerEngine.currencyModified(ledgerTrans);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
// set the invoice date
ledgerTrans.TransDate = importLine.TransDate;
ledgerEngine.transDateModified(ledgerTrans);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
// set the invoice id
ledgerTrans.invoice = importLine.invoiceId;
ledgerEngine.invoiceModified(ledgerTrans, ledgerTransProj);
ledgerEngine.paymentModified(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
// set the tax group
ledgerTrans.taxGroup = importLine.TaxGroup;
ledgerEngine.correctTaxAmount(ledgerTrans, 0);
ledgerEngine.paymentModified(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
// set the item tax group
ledgerTrans.taxItemGroup = importLine.taxItemGroup;
ledgerEngine.correctTaxAmount(ledgerTrans, 0);
ledgerEngine.paymentModified(ledgerTrans);
ledgerEngine.cashDiscCodeModified(ledgerTrans, ledgerTransAsset);
ledgerEngine.setProjCostSalesPrice(ledgerTrans, ledgerTransProj);
// set other fields that don't require ledgerEngine.modified() methods
...
ledgerTrans.write();
ledgerEngine.write(ledgerTrans);
if(ledgerTrans.isFixedAssetTransaction())
{
// link the ledgerTransAsset record to the ledgerTrans record
ledgerTransAsset.refRecId = ledgerTrans.recId;
// set the fixed asset transaction type
ledgerTransAsset.TransType = importLine.assetTransType;
ledgerEngine.assetTransTypeModified(ledgerTrans, ledgerTransAsset);
// set the fixed asset value model
ledgerTransAsset.BookId = importLine.assetBookId;
ledgerEngine.assetBookIdModified(ledgerTrans, ledgerTransAsset);
if(ledgerTrans.AccountType == LedgerJournalACType::FixedAssets)
ledgerEngine.initFromAssetTable(ledgerTrans, ledgerTransAsset);
ledgerEngine.setAssetDepStartDate(ledgerTrans, ledgerTransAsset);
ttsbegin;
ledgerTransAsset.write();
ttscommit;
}
if(ledgerTrans.isProjectTransaction())
{
ledgerTransProj.RefRecId = ledgerTrans.RecId;
ttsbegin;
ledgerTransProj.write();
ttscommit;
}
}
......................................................................................
Some of these methods, I wasn't too sure if I needed to call, like the
clearTaxAmountCache(...) and cashDiscCodeModified(...) but as I was having
troubles getting things to behave properly after I imported my lines, I found
these methods being called in the modified field methods in the
LedgerJournalTransVendInvoice form. I know it's a lot to look over but if
anyone has experience using the ledgerJournalEngine class, please glance over
this and see if I'm missing anything or adding any extra unnecessary steps.
Thanks,
Adam
Loading...