How can i solve this issue
public class TTBankTransactionForm extends FormRun
{
/// <summary>
///
/// </summary>
///
//public str getAccountName(int64 MainAccountId)
//{
// MainAccount mainAccount;
// str _mainAccountId = int642Str(MainAccountId);
// select firstonly * from mainAccount where mainAccount.MainAccountId == _mainAccountId;
// return mainAccount.Name;
//}
public void init()
{
super();
MainAccountDialog myDialog = MainAccountDialog ::construct();
if (myDialog.prompt())
{
BankTransactionTable reportTmp;
delete_from reportTmp;
date startDate = mydialog.getStartDate();
date endDate = mydialog.getEndDate();
container selectedMainAccounts = mydialog.getSelectedMainAccountRecIds();
str selectedMainAccountsStr;
for (int i = 1; i <= conLen(selectedMainAccounts); i++)
{
if (selectedMainAccountsStr == "")
{
selectedMainAccountsStr = strFmt('"%1"', conPeek(selectedMainAccounts, i));
}
else
{
selectedMainAccountsStr += strFmt(', "%1"', conPeek(selectedMainAccounts, i));
}
}
//container selectedVouchers = mydialog.getSelectedSubledgerVouchers();
//container SelectedLedgerDimension = myDialog.getSelectedLedgerDimensionIds();
//str SelectedLedgerDimensionStr;
//for (int i = 1; i <= conLen(SelectedLedgerDimension); i++)
//{
// if (SelectedLedgerDimensionStr == "")
// {
// SelectedLedgerDimensionStr = strFmt('"%1"', conPeek(SelectedLedgerDimension, i));
// }
// else
// {
// SelectedLedgerDimensionStr += strFmt(', "%1"', conPeek(SelectedLedgerDimension, i));
// }
//}
//str selectedVouchersStr;
//for (int i = 1; i <= conLen(selectedVouchers); i++)
//{
// if (selectedVouchersStr == "")
// {
// selectedVouchersStr = strFmt('"%1"', conPeek(selectedVouchers, i));
// }
// else
// {
// selectedVouchersStr += strFmt(', "%1"', conPeek(selectedVouchers, i));
// }
//}
Query query = new Query();
QueryBuildDataSource qbdsGeneralJournalEntry, qbdsLedgerJournalTrans, qbdsGeneralJournalAccountEntry;
qbdsGeneralJournalEntry = query.addDataSource(tablenum(GeneralJournalEntry));
qbdsLedgerJournalTrans = qbdsGeneralJournalEntry.addDataSource(tablenum(LedgerJournalTrans ));
qbdsLedgerJournalTrans.relations(false);
qbdsLedgerJournalTrans.joinMode(joinmode::OuterJoin);
qbdsLedgerJournalTrans.fetchMode(QueryFetchMode::One2One);
qbdsLedgerJournalTrans.addLink(fieldnum(GeneralJournalEntry,SubledgerVoucher),fieldnum(LedgerJournalTrans,Voucher));
//qbdsLedgerJournalTrans.addRange(fieldnum(LedgerJournalTrans, PaymMode )).value("1");
qbdsGeneralJournalAccountEntry = qbdsGeneralJournalEntry.addDataSource(tablenum(GeneralJournalAccountEntry ));
qbdsGeneralJournalAccountEntry.relations(false);
qbdsGeneralJournalAccountEntry.joinMode(joinmode::OuterJoin);
qbdsGeneralJournalAccountEntry.fetchMode(QueryFetchMode::One2One);
qbdsGeneralJournalAccountEntry.addLink(
fieldnum(GeneralJournalEntry, RecId),
fieldnum(GeneralJournalAccountEntry, GeneralJournalEntry)
);
if (startDate && endDate)
{
qbdsGeneralJournalEntry.addRange(fieldnum(GeneralJournalEntry, AccountingDate)).value(strFmt("%1..%2", startDate,endDate));
}
//if (selectedVouchers != conNull() && conLen(selectedVouchers) > 0 && !(conLen(selectedVouchers) == 1 && conPeek(selectedVouchers, 1) == ""))
//{
// qbdsGeneralJournalEntry.addRange(fieldnum(GeneralJournalEntry, SubledgerVoucher)).value(selectedVouchersStr);
//}
//qbdsGeneralJournalAccountEntry.addRange(fieldnum(GeneralJournalAccountEntry, LedgerAccount)).value(selectedMainAccountsStr);
if (selectedMainAccounts != conNull() && conLen(selectedMainAccounts) > 0 && !(conLen(selectedMainAccounts) == 1 && conPeek(selectedMainAccounts, 1) == ""))
{
qbdsGeneralJournalAccountEntry.addRange(fieldnum(GeneralJournalAccountEntry, MainAccount)).value(selectedMainAccountsStr);
}
//if (SelectedLedgerDimension != conNull() && conLen(SelectedLedgerDimension) > 0 && !(conLen(SelectedLedgerDimension) == 1 && conPeek(SelectedLedgerDimension, 1) == ""))
//{
// qbdsLedgerJournalTrans.addRange(fieldnum(LedgerJournalTrans, LedgerDimension)).value(SelectedLedgerDimensionStr);
//}
//qbdsGeneralJournalEntry.addRange(fieldnum(GeneralJournalEntry, RecId)).value("5637147002");
QueryRun queryRun = new QueryRun(query);
while (queryRun.next())
{
GeneralJournalEntry generalJournalEntry = queryRun.get(tablenum(GeneralJournalEntry));
LedgerJournalTrans ledgerJournalTrans = queryRun.get(tablenum(LedgerJournalTrans));
GeneralJournalAccountEntry generalJournalAccountEntry = queryRun.get(tablenum(GeneralJournalAccountEntry));
MainAccount mainAccount = ledgerJournalTrans.findMainAccount();
real openingBalance = mainAccount.calculateBalance(
mkDate(01, 01, 1990 ), // Start date
ledgerJournalTrans.TransDate -1 , // End date
FiscalPeriodType::Operating
);
//reportTmp.JournalNumber = generalJournalEntry.JournalNumber;
reportTmp.Voucher = generalJournalEntry.SubledgerVoucher;
reportTmp.AccountingDate = generalJournalEntry.AccountingDate;
reportTmp.Debit = ledgerJournalTrans.AmountCurDebit;
reportTmp.Credit = ledgerJournalTrans.AmountCurCredit;
//reportTmp.OffsetAccountType = enum2Str(ledgerJournalTrans.OffsetAccountType);
//reportTmp.OffsetLedgerDimension = ledgerJournalTrans.OffsetLedgerDimension;
reportTmp.Description = generalJournalAccountEntry.Text;
//reportTmp.LedgerAccount = generalJournalAccountEntry.LedgerAccount;
//reportTmp.MainAccount = mainAccount.MainAccountId;
reportTmp.AccountName = mainAccount.Name;
reportTmp.Amount = generalJournalAccountEntry.AccountingCurrencyAmount;
reportTmp.Opening = openingBalance;
reportTmp.Balance = openingBalance + generalJournalAccountEntry.AccountingCurrencyAmount;
reportTmp.insert();
}
}
FormDataSource dataSource = this.dataSource('BankTransactionTable');
if (dataSource)
{
dataSource.executeQuery();
}
}
}```
Dialog ```class MainAccountDialog extends RunBase
{
// Main Account fields
container selectedMainAccounts;
container selectedMainAccountNames;
container selectedMainAccountRecIds;
SysLookupMultiSelectCtrl mainAccountMultiSelect;
FormBuildStringControl mainAccountCtrl;
// Date fields (kept for structure compatibility)
date startDate;
date endDate;
DialogField startDateField;
DialogField endDateField;
#define.CurrentVersion(1)
#localMacro.CurrentList
startDate, endDate
#endmacro
public Object dialog()
{
DialogRunbase dialog;
DialogGroup dialogGroup;
FormBuildControl formBuildControl;
dialog = super();
dialog.allowUpdateOnSelectCtrl(true);
// Add date range fields (kept for structure)
startDateField = dialog.addField(extendedTypeStr(DocumentDate), "Start Date");
endDateField = dialog.addField(extendedTypeStr(DocumentDate), "End Date");
// Add Main Account filter group
dialogGroup = dialog.addGroup("Select Main Account Filters");
formBuildControl = dialog.formBuildDesign().control(dialogGroup.formBuildGroup().id());
mainAccountCtrl = formBuildControl.addControl(FormControlType::String, identifierStr(MainAccount));
mainAccountCtrl.label("Select Main Accounts");
return dialog;
}
public void dialogPostRun(DialogRunbase dialog)
{
FormRun formRun;
FormStringControl fsCtrlMainAccount;
Query query;
QueryBuildDataSource qbds;
super(dialog);
formRun = dialog.dialogForm().formRun();
if (formRun)
{
// Setup Main Account multi-select
query = new Query();
qbds = query.addDataSource(tableNum(MainAccount));
qbds.addSelectionField(fieldNum(MainAccount, RecId));
qbds.addSelectionField(fieldNum(MainAccount, MainAccountId));
qbds.addSelectionField(fieldNum(MainAccount, Name));
qbds.addSortField(fieldNum(MainAccount, Name));
qbds.addGroupByField(fieldNum(MainAccount, Name));
qbds.addGroupByField(fieldNum(MainAccount, MainAccountId));
qbds.addGroupByField(fieldNum(MainAccount, RecId));
fsCtrlMainAccount = formRun.design().control(mainAccountCtrl.id());
mainAccountMultiSelect = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlMainAccount, query);
mainAccountMultiSelect.set(selectedMainAccounts);
}
}
public boolean getFromDialog()
{
boolean ret;
ret = super();
// Get the values from the dialog fields (kept for structure)
startDate = startDateField.value();
endDate = endDateField.value();
// Get Main Account selections
selectedMainAccounts = mainAccountMultiSelect.get();
selectedMainAccountNames = this.getMainAccountNames(selectedMainAccounts);
selectedMainAccountRecIds = this.getMainAccountRecIds(selectedMainAccounts);
return ret;
}
public container getMainAccountNames(container _mainAccounts)
{
MainAccount mainAccount;
container mainAccountNames;
int i;
str accountId;
mainAccountNames = conNull();
for (i = 1; i <= conLen(_mainAccounts); i++)
{
accountId = conPeek(_mainAccounts, i);
select firstOnly Name from mainAccount
where mainAccount.MainAccountId == accountId;
mainAccountNames += [mainAccount.Name];
}
return mainAccountNames;
}
public container getMainAccountRecIds(container _mainAccounts)
{
MainAccount mainAccount;
container mainAccountRecIds;
int i;
str accountId;
mainAccountRecIds = conNull();
for (i = 1; i <= conLen(_mainAccounts); i++)
{
accountId = conPeek(_mainAccounts, i);
select firstOnly RecId from mainAccount
where mainAccount.MainAccountId == accountId;
mainAccountRecIds += [mainAccount.RecId];
}
return mainAccountRecIds;
}
public static MainAccountDialog construct()
{
return new MainAccountDialog();
}
// Getter methods for Main Account
public container getSelectedMainAccounts()
{
return selectedMainAccounts;
}
public container getSelectedMainAccountNames()
{
return selectedMainAccountNames;
}
public container getSelectedMainAccountRecIds()
{
return selectedMainAccountRecIds;
}
// Getter methods for Date Range (kept for structure)
public TransDate getStartDate()
{
return startDate;
}
public TransDate getEndDate()
{
return endDate;
}
// Pack/unpack methods
public container pack()
{
return [#CurrentVersion, #CurrentList];
}
public boolean unpack(container packedClass)
{
Version version = RunBase::getVersion(packedClass);
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
}