static void
CON_PeriodicJournal_Multiplelines(Args _args)
{
LedgerJournalTrans
ledgerJournalTrans,LedgerJournaltrans1;
LedgerJournalTable
ledgerJournalTable;
ledgerJournalname
ledgerJournalname;
NumberSeq
numberSeq;
NumberSequenceTable
numSeqTable;
container
cont1,cont2,ledgerDimension,offSetAcctPattern;
DimensionDynamicAccount
ledgerDim, offsetledgerDim;
ledgerJournalCheckPost
ledgerJournalCheckPost;
int cnt;
DimensionDefault
DimensionDefault;
LedgerJournalPeriodicCopy
LedgerJournalPeriodicCopy;
CopyMove
CopyMove;
LedgerJournalId
periodicLedgerJournalId,genjourLedgerJournalId;
LedgerJournalACType
periodicACType,periodicOffSetACType;
DimensionDynamicAccount
periodicAccount,periodicoffsetAccount ;
AmountCurCredit
credit;
RecId RecId;
// find
ledgerjournalname record
select firstonly
ledgerjournalname where
LedgerJournalName.JournalName =='PerJrn';
//create ledger journal table
ledgerjournaltable.journalname
= ledgerjournalname.journalname ;
ledgerjournaltable.initfromledgerjournalname();
ledgerjournaltable.name
= " May Periodic Journal";
ledgerJournalTable.insert();
//Header Created
/////Line 1 Created
//ledgerJournalTable =
LedgerJournalTable::find("00553");
try
{
ttsbegin;
ledgerJournalTrans.clear();
ledgerJournalTrans.initValue();
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.TransDate = today();
ledgerJournalName =
ledgerJournalName::find(ledgerJournalTable.JournalName);
periodicLedgerJournalId =
ledgerJournalTrans.JournalNum ;
select
firstOnly numSeqTable
where
numSeqTable.RecId ==
ledgerJournalName.NumberSequenceTable;
if
(numSeqTable)
{
numberseq =
numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
ledgerJournalTrans.voucher =
numberseq.voucher();
}
//ledgerJournalTrans.Voucher = voucher;
ledgerJournalTrans.AccountType = LedgerJournalACType::Vend;
ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
//
Main account dimensions
periodicACType =
ledgerJournalTrans.AccountType;
periodicOffSetACType =
ledgerJournalTrans.OffsetAccountType;
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','082','Department','023'];
cnt =2;
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','112100',2];
cont1+=cont2;
ledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['112100','112100'];
ledgerDim =
AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.LedgerDimension
= ledgerDim;
}
else
{
ledgerDim =
DimensionStorage::getDynamicAccount( '000021',ledgerJournalTrans.AccountType);
ledgerJournalTrans.LedgerDimension = ledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault =
AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.DefaultDimension
= DimensionDefault;
}
periodicAccount = ledgerDim;
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','082','Department','023'];
cnt =2;
if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','112140',2];
cont1+=cont2;
offsetledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['112140','112140'];
offsetledgerDim =
AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.OffsetLedgerDimension
= offsetledgerDim;
}
else
{
offsetledgerDim =
DimensionStorage::getDynamicAccount( '000021',ledgerJournalTrans.AccountType);
ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault =
AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.OffsetDefaultDimension = DimensionDefault;
}
periodicoffsetAccount =
offsetledgerDim;
ledgerJournalTrans.CurrencyCode
= "USD";
ledgerJournalTrans.AmountCurCredit = 6000;
ledgerJournalTrans.FreqCode = PeriodUnit::Month;
ledgerJournalTrans.FreqValue = 1;
credit =
ledgerJournalTrans.AmountCurCredit;
if
(ledgerJournalTrans.validateWrite())
{
ledgerJournalTrans.insert();
}
ttscommit;
}
catch(Exception::Error)
{
info(strFmt('Catched an error in row: %1',ledgerJournalTrans.OffsetDefaultDimension));
}
info(strFmt('Periodic journal inserted %1',ledgerJournalTable.JournalNum));
////Line 2
Created
try
{
ttsbegin;
ledgerJournalTrans.clear();
ledgerJournalTrans.initValue();
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.TransDate = today();
ledgerJournalName =
ledgerJournalName::find(ledgerJournalTable.JournalName);
periodicLedgerJournalId =
ledgerJournalTrans.JournalNum ;
select
firstOnly numSeqTable
where
numSeqTable.RecId ==
ledgerJournalName.NumberSequenceTable;
if
(numSeqTable)
{
numberseq =
numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
ledgerJournalTrans.voucher =
numberseq.voucher();
}
//ledgerJournalTrans.Voucher = voucher;
ledgerJournalTrans.AccountType = LedgerJournalACType::Vend;
ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
//
Main account dimensions
periodicACType =
ledgerJournalTrans.AccountType;
periodicOffSetACType = ledgerJournalTrans.OffsetAccountType;
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','082','Department','023'];
cnt =2;
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','112100',2];
cont1+=cont2;
ledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['112100','112100'];
ledgerDim =
AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.LedgerDimension = ledgerDim;
}
else
{
ledgerDim =
DimensionStorage::getDynamicAccount( '000021',ledgerJournalTrans.AccountType);
ledgerJournalTrans.LedgerDimension
= ledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault =
AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.DefaultDimension = DimensionDefault;
}
periodicAccount = ledgerDim;
cont1=conNull();
cont2=conNull();
ledgerDimension =conNull();
cont2 += ['BusinessUnit','082','Department','023'];
cnt =2;
if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
cont1+=['MainAccount','112140',2];
cont1+=cont2;
offsetledgerDim=AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim==0)
{
offSetAcctPattern = ['112140','112140'];
offsetledgerDim =
AxdDimensionUtil::getLedgerAccountId(offSetAcctPattern);
}
ledgerJournalTrans.OffsetLedgerDimension
= offsetledgerDim;
}
else
{
offsetledgerDim =
DimensionStorage::getDynamicAccount( '000021',ledgerJournalTrans.AccountType);
ledgerJournalTrans.OffsetLedgerDimension = offsetledgerDim;
ledgerDimension +=cnt;
ledgerDimension +=cont2;
DimensionDefault =
AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.OffsetDefaultDimension = DimensionDefault;
}
periodicoffsetAccount =
offsetledgerDim;
ledgerJournalTrans.CurrencyCode
= "USD";
ledgerJournalTrans.AmountCurCredit
= 4000;
ledgerJournalTrans.FreqCode = PeriodUnit::Month;
ledgerJournalTrans.FreqValue = 1;
credit =
ledgerJournalTrans.AmountCurCredit;
if
(ledgerJournalTrans.validateWrite())
{
ledgerJournalTrans.insert();
}
ttscommit;
}
catch(Exception::Error)
{
info(strFmt('Catched an error in row: %1',ledgerJournalTrans.OffsetDefaultDimension));
}
Periodic journal lines Created:
//info(strFmt('Periodic
journal inserted %1',ledgerJournalTable.JournalNum));
ledgerJournalTable.clear();
//General Ledger create
select firstonly
ledgerjournalname where
LedgerJournalName.JournalName =='GenJrn';
//create ledger journal table
ledgerjournaltable.journalname
= ledgerjournalname.journalname ;
ledgerjournaltable.initfromledgerjournalname();
ledgerjournaltable.name
= " General Journal";
genjourLedgerJournalId= ledgerjournaltable.JournalNum;
ledgerJournalTable.insert();
info(strFmt("General journal is %1",ledgerjournaltable.JournalNum));
//General Journal Header Is Created as below:
//ledgerJournalTrans1.clear();
//ledgerJournalTrans1.initValue();
//if(genjourLedgerJournalId)
//{
//ledgerJournalTrans
=
ledgerJournalTrans::find(periodicLedgerJournalId,ledgerJournalTrans.Voucher,true);
while select
ledgerJournalTrans where
ledgerJournalTrans.JournalNum==periodicLedgerJournalId
{
ttsBegin;
ledgerJournalTrans1.initValue();
ledgerJournalTrans1.data(ledgerJournalTrans);
ledgerJournalTrans1.JournalNum=ledgerjournaltable.JournalNum;
//ledgerJournalTrans1.initValue();
select
firstOnly numSeqTable
where
numSeqTable.RecId == ledgerJournalName.NumberSequenceTable;
if
(numSeqTable)
{
numberseq =
numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
ledgerJournalTrans1.voucher =
numberseq.voucher();
}
if(!ledgerJournalTrans1.validateWrite())
{
throw
error("ERROR");
}
else
{
ledgerJournalTrans1.insert();
}
ttsCommit;
}
General journal lines Created
//Post Journal
ledgerJournalCheckPost =
ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournaltable,Noyes::Yes);
LedgerJournalCheckPost.run();
//Lastdate
updated
while select
forUpdate ledgerJournalTrans where ledgerJournalTrans.JournalNum==periodicLedgerJournalId
{
ttsBegin;
ledgerJournalTrans.LastTransferred=today();
ledgerJournalTrans.update();
ttsCommit;
}
}
Info Message
(02:10:22 pm) Periodic journal inserted
00737
Info Message
(02:10:22 pm) General journal is 00738
Info Message
(02:10:22 pm) Number of vouchers posted to
the journal: 2
No comments:
Post a Comment