For posting general journal we can use this table and
classes
1. LedgerJournalTable
2. LedgerJournalTrans
3. ledgerJournalCheckPost(class)
mandatory fields are offset account,ledger
account,amount,journal name,journal number… etc
createFreeTextInvoicesAndPost(default class where
one method is there-“ createGeneralJournalAndPost ”-through this method we can
post the ledger journal through code)
[SysEntryPointAttribute(true)]
public str
createGeneralJournalAndPost(Amount
_amount,
CustAccount _cutomer,
str
_businessUnit,
ItemId _itemId,
str
_batchId,
str
_qty,
str
_costPrice,
str
_billCode,
str
_department,
str
_costCenter,
str
_employee,
str
_NEW_OR_CANCEL_IND,
str
_company,
RecId _InvTableRecId,
LedgerDimensionDefaultAccount _defaultAccount)
{
AxLedgerJournalTable
journalTable;
AxLedgerJournalTrans
journalTransCredit,journalTransDebit;
container acctPattern;
container offSetAcctPattern;
LedgerJournalTable
ledgerJournalTable,ledgerJournalTableUpdate;
ledgerJournalCheckPost
ledgerJournalCheckPost;
LedgerJournalTable
ledgerjournalTableDelete;
LedgerJournalTrans
journalTransDelete;
SalesParameters
SalesParameters;//JournalNameId;
DimAttributeCustTable
DimAttributeCustTable;
DimensionAttributeValueCombination valueCombination;
CustInvoiceTable
custInvoiceTable;
CustParameters CustParameters;
System.Exception ex;
str errorStr;
LedgerJournalId journalId;
LedgerJournalPost
LedgerJournalPost;
Args
args = new Args();
;
changeCompany(_company)
{
try
{
SalesParameters = SalesParameters::find();
journalTable = new
AxLedgerJournalTable();
journalTransCredit = new
AxLedgerJournalTrans();
journalTable.parmJournalName(SalesParameters.JournalNameId);
//journalTable.parmDefaultDimension(this.retDefaultDimension(_businessUnit,_department,_costCenter,_employee));
journalTable.save();
ledgerJournalTable = journalTable.ledgerJournalTable();
select valueCombination where valueCombination.DisplayValue ==
_cutomer
&& valueCombination.LedgerDimensionType ==
LedgerDimensionType::Account
&& !valueCombination.MainAccount
&&
!valueCombination.AccountStructure;
journalTransCredit.parmJournalNum(ledgerJournalTable.JournalNum);
journalTransCredit.parmTransDate(systemDateGet());
journalTransCredit.parmAmountCurCredit(_amount);
journalTransCredit.parmAccountType(LedgerJournalACType::Cust);
journalTransCredit.parmLedgerDimension(valueCombination.RecId);
journalTransCredit.parmDefaultDimension(_defaultAccount);
CustParameters = CustParameters::find();
if(_NEW_OR_CANCEL_IND == "C")
{
journalTransCredit.parmPostingProfile(CustParameters.PrepaymentPostingProfile);
}
else if(_NEW_OR_CANCEL_IND
== "N")
{
journalTransCredit.parmPostingProfile(CustParameters.PostingProfile);
}
journalTransCredit.save();
journalTransDebit = new
AxLedgerJournalTrans();
journalTransDebit.parmJournalNum(ledgerJournalTable.JournalNum);
journalTransDebit.parmTransDate(systemDateGet());
journalTransDebit.parmAmountCurDebit(_amount);
journalTransDebit.parmAccountType(LedgerJournalACType::Cust);
journalTransDebit.parmLedgerDimension(valueCombination.RecId);
journalTransDebit.parmDefaultDimension(_defaultAccount);
if(_NEW_OR_CANCEL_IND == "C")
{
journalTransDebit.parmPostingProfile(CustParameters.PostingProfile);
}
else if(_NEW_OR_CANCEL_IND
== "N")
{
journalTransDebit.parmPostingProfile(CustParameters.PrepaymentPostingProfile);
}
journalTransDebit.save();
ledgerJournalCheckPost
=
LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,Noyes::Yes);
ledgerJournalCheckPost.run();
return journalTransDebit.parmVoucher() + "," + journalTable.parmJournalNum();
}
catch(Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
errorStr = "Error while Posting the
General Journal Entry.";// +
ex.ToString();
delete_from journalTransDelete where journalTransDelete.JournalNum ==
journalId;
delete_from ledgerjournalTableDelete where ledgerjournalTableDelete.JournalNum ==
journalId;
//this.updateErrorInventMovement(sqlConGlobal,kRODBCParameters,itemIdStr,wareHouseStr,batchIdStr,businessUnitStr,costPriceStr,errorStr);
this.insertErrorLogDetails(errorStr,_businessUnit,_itemId,_batchId,_qty,_costPrice,_billCode,_company);
return "";
}
}
}
my code:
example:
in my form I wrote the journal posting method in
form methods as
//[SysEntryPointAttribute(true)]
public void
createGeneralJournalAndPost(Amount _shipnow)
{
AxLedgerJournalTable
journalTable;
AxLedgerJournalTrans
journalTransCredit,journalTransDebit;
container acctPattern;
container offSetAcctPattern;
LedgerJournalTable
ledgerJournalTable,ledgerJournalTableUpdate;
ledgerJournalCheckPost
ledgerJournalCheckPost;
LedgerJournalTable
ledgerjournalTableDelete;
LedgerJournalTrans
journalTransDelete;
SalesParameters
SalesParameters;//JournalNameId;
DimAttributeCustTable DimAttributeCustTable;
DimensionAttributeValueCombination valueCombination;
CustInvoiceTable
custInvoiceTable;
LedgerParameters
LedgerParameters;
System.Exception ex;
str errorStr;
LedgerJournalId journalId;
LedgerJournalPost
LedgerJournalPost;
InventParameters
InventParameters;
Amount markvalue;
InventTransferTable InventTransferTable1;
str s;
markvalue = InventTransferTable.markupvalue(_shipnow);
journalTable = new
AxLedgerJournalTable();
journalTransCredit = new
AxLedgerJournalTrans();
InventParameters = InventParameters::find();
journalTable.parmJournalName(InventParameters.JournalNameId);
//
journalTable.parmTransferRecId(InventTransferTable.RecId);
journalTable.parmDefaultDimension(InventTransferTable.DefaultDimension);
journalTable.save();
ledgerJournalTable = journalTable.ledgerJournalTable();
ttsBegin;
select forUpdate
ledgerJournalTableUpdate where ledgerJournalTableUpdate.JournalNum ==
ledgerJournalTable.JournalNum;
ledgerJournalTableUpdate.TransferRefRecId = InventTransferTable.RecId;
ledgerJournalTableUpdate.update();
ttsCommit;
journalTransCredit.parmJournalNum(ledgerJournalTable.JournalNum);
journalTransCredit.parmTransDate(systemDateGet());
journalTransCredit.parmAmountCurCredit(round(markvalue,2));
journalTransCredit.parmAccountType(LedgerJournalACType::Ledger);
journalTransCredit.parmLedgerDimension(InventParameters.RevenueDimension);
journalTransCredit.parmDefaultDimension(InventTransferTable.DefaultDimension);
LedgerParameters = LedgerParameters::find();
journalTransCredit.parmOffsetLedgerDimension(InventParameters.LedgerDimension);
journalTransCredit.save();
ledgerJournalCheckPost
=
LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,Noyes::Yes);
ledgerJournalCheckPost.run();
//if (this.showInfo())
//info(strFmt("%1,%2-%3",journalTable.parmJournalNum(),journalTransCredit.parmVoucher(),SysInfoAction_TableField::newBuffer(LedgerJournalTable)));
info(strfmt("%1",
journalTable.parmJournalNum()),'',SysInfoAction_TableField::newBuffer(LedgerJournalTable));
//////////////////this above line I wrote for
showing show button
}
//}
When the general journal posted info box opened
Here we click on show button its go to current journal
record.
For this functionality we can follow this procedure
Create one int64 field in ledgerjournal table(ex: TransferRefRecId)
And give the relation in ledgerjournal table to what ever
table ur using that table(ex:I used the InventTransferTable)
(Then I am giving the relation as ledgerjournaltable. TransferRefRecId
== InventTransferTable.recid)
After that where the journal posting method u write this
following code
info(strfmt("%1", journalTable.parmJournalNum()),'',SysInfoAction_TableField::newBuffer( LedgerJournalTable));