Closed sanketgroup closed 2 years ago
Yes we can
Ctally.GetLedgerDynamic("Ledgname",fromDate:"01042020",toDate:"31032021"); //gets all ledger fields
//as usual you can specify comp name & list of fields to be fetched
List<string> fields = new List<string>(){ "Name", "Parent", "OpeningBalance" ,"Closing Balance"};
Ctally.GetLedgerDynamic("Ledgname",fromDate:"01042020",toDate:"31032021",Nativelist:fields );
//gets only req fields other fields are empty or null in object
Will this return all ledgers with closing balance or it is for just one single ledger. I am looking to get list of ledgers with closing balance.
This method will return only single ledger if you want all ledgers there is no predefined method you need to create one
public async Task<List<Ledger>> GetLedgersDynamic(string company = null,
string fromDate = null,
string toDate = null,
List<string> Nativelist = null)
{
Nativelist ??= new() { "Address", "InterestCollection", "*" };
StaticVariables sv = new() { SVCompany = company,SVFromDate=fromDate,SVToDate=toDate };
string xml = await GetNativeCollectionXML(rName: "Ledgers",
colType: "Ledger",
Sv: sv,
NativeFields: Nativelist,
);
List<Ledger> ledgers = GetObjfromXml<LedgerEnvelope>(xml).Body.Data.Collection.Ledgers;
return ledgers;
}
//Whereever you want ledgers call like this
List<string> fields = new List<string>(){ "Name", "Parent", "OpeningBalance" ,"Closing Balance"};
List<Ledger> ledgers = GetLedgersDynamic(fromDate:"01042020",toDate:"31032021",Nativelist:fields );
It is not good to get all ledgers at once If there are thousands of ledgers then tally will not respond or stop working or request timeout
Following ODBC query returns Ledger List with ClosingBalance without any stress on Tally. It works efficiently even with 40000 ledgers.
Select $Name,$CLOSINGBALANCE, $Parent from Ledger
The issue with the query is, it show the current ClosingBalance, Cannot pass period.
In Tally, we get this report by going into Balance Sheet > F10 > Trial Balance > F5 (Ledgerwise), this return list of ledgers with all required field and period.
Following ODBC query returns Ledger List with ClosingBalance without any stress on Tally. It works efficiently even with 40000 ledgers.
Select $Name,$CLOSINGBALANCE, $Parent from Ledger
The issue with the query is, it show the current ClosingBalance, Cannot pass period.In Tally, we get this report by going into Balance Sheet > F10 > Trial Balance > F5 (Ledgerwise), this return list of ledgers with all required field and period.
If you want to get all ledgers with specific fields I given solution
Coming to ODBC tables they show data pertaining to period currently opened in Tally(You know this) because data is already loaded and kept in memory you will not have any issues Coming to XML API every time we sent a request It process and collects data If asks to collect large data you will get issues
Error occurred during import of large number of ledgers in Stack overflow
I recommend to use GetledgerDynamic method looping through Ctally.Ledgers
if (await tally.Check())
{
await tally.FetchAllTallyData();
foreach (var Ledgername in tally.Ledgers)
{
Ledger ledger = await tally.GetLedgerDynamic(Ledgername);
//Worker with ledger here
}
}
Removed closing balance from all models If you want get closing balance of any item then refer #19
Hello Is it possible to get a Closing balance list (with parent column) for a particular date?
Thanks