SRSReportQueryAttribute(queryStr(TSBankAccountStatementNew)),
SRSReportParameterAttribute(classstr(TSBankAccountStatementNewContract))
]
class TSBankAccountStatementNewDP extends SrsReportDataProviderPreProcessTempDB
{
AmountCur currentBalance;
TransDate fromDate;
TransDate toDate;
CompanyBankAccount bankAccount;
TSBankAccountStatementTmpNew bankAccountStatementTmp;
AmountCur PrevBalance;
//real currentBalance;
/// Calculates the opening balance from fromDate.
/// </summary>
/// <returns>
/// The opening balance.
/// </returns>
private AmountCur calculateOpeningBalanceForBankAccount()
{
BankAccountTrans bankAccountTrans;
where bankAccountTrans.AccountId == bankAccount
&& bankAccountTrans.TransDate < fromDate;
}
/// Adds the records to the <c>BankAccountStatementTmp</c> table.
/// </summary>
private void createTSBankAccountStatementTmpNew()
{
BankAccountTable bankAccountTable;
BankAccountTrans bankAccountTrans;
LedgerJournalTrans ledgerJournalTrans;
(
FromDate,
ToDate,
CurrentBalance,
BankTransType,
TransDate,
Voucher,
DepositNum,
PaymReference,
PaymentMode,
AmountCur,
AmountCorrect,
AmountMST,
AmountMSTSecond,
AccountID,
Name,
CurrencyCode
//TSDescription
)
select
fromDate,
toDate,
currentBalance,
BankTransType,
TransDate,
Voucher,
DepositNum,
PaymReference,
PaymentMode,
AmountCur,
AmountCorrect,
AmountMST,
AmountReportingCurrency
from bankAccountTrans
where bankAccountTrans.AccountId == bankAccount
&& bankAccountTrans.TransDate >= fromDate
&& bankAccountTrans.TransDate <= toDate
join
AccountID,
Name,
CurrencyCode
from bankAccountTable
where bankAccountTable.AccountID == bankAccount;
// Txt from ledgerJournalTrans
// where //bankAccountStatementTmp.TSDescription == ledgerJournalTrans.Txt;
//LedgerJournalTrans.PaymentAccount == bankAccount;
//bankAccountStatementTmp.TSDescription = ledgerJournalTable.Name;
//bankAccountStatementTmp.insert();
if (bankAccountStatementTmp.RecId == 0)
{
bankAccountTable = BankAccountTable::find(bankAccount);
bankAccountStatementTmp.AccountID = bankAccountTable.AccountID;
bankAccountStatementTmp.Name = bankAccountTable.Name;
bankAccountStatementTmp.CurrencyCode = bankAccountTable.CurrencyCode;
bankAccountStatementTmp.CurrentBalance = currentBalance;
}
else
{
if(bankAccountStatementTmp)
{
ttsbegin;
while select forupdate bankAccountStatementTmp
{
select * from bankAccountTrans where BankAccountTrans.AccountId == BankAccountTable.AccountID;
if(bankAccountStatementTmp.AmountCur>=0)
{
bankAccountStatementTmp.TSDebit = bankAccountTrans.AmountCur;
}
else
{
bankAccountStatementTmp.TSCredit = bankAccountTrans.AmountCur;
}
}
PrevBalance = bankAccountStatementTmp.TSCorrectedAmountCur;
{
bankAccountStatementTmp.TSCorrectedAmountCur = PrevBalance - bankAccountStatementTmp.TSCredit;
}
else
{
bankAccountStatementTmp.TSCorrectedAmountCur = PrevBalance + bankAccountStatementTmp.TSDebit;
}
}
}
/// Retrieves the temporary table for SQL Server Reporting Services reports.
/// </summary>
/// <returns>
/// The <c>BankAccountStatementTmp</c> temporary table.
/// </returns>
[SrsReportDataSetAttribute(tablestr(TSBankAccountStatementTmpNew))]
public TSBankAccountStatementTmpNew getTSBankAccountStatementTmpNew()
{
select bankAccountStatementTmp;
}
/// Processes the business logic that is used to populate a <c>BankAccountStatementTmp</c> temporary
/// table.
/// </summary>
public void processReport()
{
TSBankAccountStatementNewContract contract = this.parmDataContract() as TSBankAccountStatementNewContract;
toDate = contract.parmToDate() ? contract.parmToDate() : dateMax();
}