Ajay Prajapati
Ajay Prajapati

Reputation: 1

How to get specific edger voucher data with date range?

I have created a simple .NET application to connect with Tally Prime. I am using tally connector package in the application.

I am able to the make call to APIs like getting company names, list of ledgers. Now I am trying to get ledger Voucher Report for specific ledger name with from and to date, which will return the voucher number, voucher type, opening, closing balance the same way it shows in tally prime.

Any help will be appreciated.

Thanks.

I tried calling GetVoucherAsync API, but I'm always getting no records, although there are records when I click on ledger Voucher in tally prime for that ledger with the date range.

VoucherRequestOptions voucherRequestOptions = new VoucherRequestOptions()
{     
FromDate = new DateTime(2023,1,1),     
ToDate = new DateTime(2024, 1, 1),     
Company = "Company Name" 
};

var voucher = tallyService.GetVoucherAsync(ledgerName, voucherRequestOptions ).Result;

var vouchers=tallyService.GetVouchersAsync(voucherRequestOptions).Result; 
foreach (var v in vouchers) 
{     
Console.WriteLine($"Voucher Number: 
{v.VoucherNumber}, Date: {v.Date}"); 
}

Not sure is this a correct way to get specific ledger voucher data with date range.

Upvotes: 0

Views: 92

Answers (1)

sai vineeth
sai vineeth

Reputation: 1045

you can refer voucher tests on how to query vouchers

you can only pass lookup options like masterid,guid,voucher number only when using GetVoucherAsync method and it will return only one voucher

if you want to get multiple vouchers based on ledger then


 var vchs = await _tallyService.GetVouchersAsync<Voucher>(new RequestOptions()
 {
     FromDate = new(2023, 1, 1),
     Filters = new List<Filter>() { new("TCLedgerFilter", "$$FilterCount:AllLedgerEntries:TCLedgerInternalFilter > 0"), new("TCLedgerInternalFilter", $"$LedgerName = \"{ledgerName}\"") { ExcludeinCollection=true} },

 });


you can pass any filters that tally supports

Upvotes: 0

Related Questions