static void Job12(Args _args)
{
LedgerJournalTrans ledgerJournalTrans; //Table
LedgerJournalTable ledgerJournalTable; //Table
ledgerJournalname ledgerJournalname; //Table
NumberSeq numberSeq; //Class
NumberSequenceTable numSeqTable; //Table
DimensionDefault DimensionDefault; //EDT
DimensionDynamicAccount ledgerDim, offsetledgerDim; //EDT
container cont1,cont2,ledgerDimension,offSetAcctPattern;
int cnt;
ledgerJournalTable = LedgerJournalTable::find("00619");
try
{
ttsbegin;
ledgerJournalTrans.clear();
ledgerJournalTrans.initValue();
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.TransDate = today();
ledgerJournalName = ledgerJournalName::find(ledgerJournalTable.JournalName);
select firstOnly numSeqTable
where numSeqTable.RecId == ledgerJournalName.NumberSequenceTable;
if (numSeqTable)
{
numberseq = numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
ledgerJournalTrans.voucher = numberseq.voucher();
}
ledgerJournalTrans.AccountType = LedgerJournalACType::Vend;
ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
// Main account dimensions
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','001','Department','022'];
cnt =2;
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','110130',2];
cont1+=cont2;
ledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['110130','110130'];
ledgerDim = AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.LedgerDimension = ledgerDim;
}
else
{
ledgerDim = DimensionStorage::getDynamicAccount( '10001',ledgerJournalTrans.AccountType);
ledgerJournalTrans.LedgerDimension = ledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.DefaultDimension = DimensionDefault;
}
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','001','Department','023'];
cnt =2;
if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','110130',2];
cont1+=cont2;
offsetledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['110130','110130'];
offsetledgerDim = AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
}
else
{
offsetledgerDim = DimensionStorage::getDynamicAccount( '10001',ledgerJournalTrans.AccountType);
ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.OffsetDefaultDimension = DimensionDefault;
}
//ledgerJournalTrans.LedgerDimension = ledgerDim;
//ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
ledgerJournalTrans.Txt = "Test";
ledgerJournalTrans.CurrencyCode = "USD";
ledgerJournalTrans.AmountCurDebit = 500;
if (ledgerJournalTrans.validateWrite())
{
ledgerJournalTrans.insert();
}
ttscommit;
}
catch(Exception::Error)
{
info(strFmt('Catched an error in row: %1',ledgerJournalTrans.OffsetDefaultDimension));
}
info(strFmt('journal inserted %1',ledgerJournalTable.JournalNum));
}
{
LedgerJournalTrans ledgerJournalTrans; //Table
LedgerJournalTable ledgerJournalTable; //Table
ledgerJournalname ledgerJournalname; //Table
NumberSeq numberSeq; //Class
NumberSequenceTable numSeqTable; //Table
DimensionDefault DimensionDefault; //EDT
DimensionDynamicAccount ledgerDim, offsetledgerDim; //EDT
container cont1,cont2,ledgerDimension,offSetAcctPattern;
int cnt;
ledgerJournalTable = LedgerJournalTable::find("00619");
try
{
ttsbegin;
ledgerJournalTrans.clear();
ledgerJournalTrans.initValue();
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.TransDate = today();
ledgerJournalName = ledgerJournalName::find(ledgerJournalTable.JournalName);
select firstOnly numSeqTable
where numSeqTable.RecId == ledgerJournalName.NumberSequenceTable;
if (numSeqTable)
{
numberseq = numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
ledgerJournalTrans.voucher = numberseq.voucher();
}
ledgerJournalTrans.AccountType = LedgerJournalACType::Vend;
ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
// Main account dimensions
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','001','Department','022'];
cnt =2;
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','110130',2];
cont1+=cont2;
ledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['110130','110130'];
ledgerDim = AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.LedgerDimension = ledgerDim;
}
else
{
ledgerDim = DimensionStorage::getDynamicAccount( '10001',ledgerJournalTrans.AccountType);
ledgerJournalTrans.LedgerDimension = ledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.DefaultDimension = DimensionDefault;
}
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','001','Department','023'];
cnt =2;
if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','110130',2];
cont1+=cont2;
offsetledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['110130','110130'];
offsetledgerDim = AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
}
else
{
offsetledgerDim = DimensionStorage::getDynamicAccount( '10001',ledgerJournalTrans.AccountType);
ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.OffsetDefaultDimension = DimensionDefault;
}
//ledgerJournalTrans.LedgerDimension = ledgerDim;
//ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
ledgerJournalTrans.Txt = "Test";
ledgerJournalTrans.CurrencyCode = "USD";
ledgerJournalTrans.AmountCurDebit = 500;
if (ledgerJournalTrans.validateWrite())
{
ledgerJournalTrans.insert();
}
ttscommit;
}
catch(Exception::Error)
{
info(strFmt('Catched an error in row: %1',ledgerJournalTrans.OffsetDefaultDimension));
}
info(strFmt('journal inserted %1',ledgerJournalTable.JournalNum));
}
No comments:
Post a Comment