Contract Class
[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(DIPL_MainAccountUIBuilder))
]
class DIPL_MainAccountContract implements SysOperationValidatable
{
TransDate fromdate;
TransDate todate;
List mainAccountNum;
}
[
DataMemberAttribute("MainAccountList"),
AifCollectionTypeAttribute("MainAccountList", Types::String),
SysOperationLabelAttribute(literalStr("Main Account")),
SysOperationDisplayOrderAttribute('03')
]
public List parmMainAccount(List _mainAccountNum = mainAccountNum)
{
mainAccountNum = _mainAccountNum;
return mainAccountNum;
}
DataMemberAttribute('Fromd date'),
SysOperationLabelAttribute(literalStr("From date")),
SysOperationHelpTextAttribute(literalStr("From date")),
SysOperationDisplayOrderAttribute('01')
]
public TransDate parmFromdate(TransDate _fromdate = fromdate)
{
fromdate = _fromdate;
return fromdate;
}
/// <summary>
/// Validates the report parameters.
/// </summary>
/// <returns>
/// true if all of the parameters are valid; otherwise, false.
/// </returns>
public boolean validate()
{
boolean isValid = true;
if (fromDate && toDate && (fromDate > toDate))
{
isValid = checkFailed(strfmt("@SYS55013", date2StrUsr(fromDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));
}
return isValid;
}
UIBuilder
class DIPL_MainAccountUIBuilder extends SysOperationAutomaticUIBuilder
{
DIPL_MainAccountContract contract;
DialogField dialogFromdate;
DialogField dialogTodate;
DialogField dialogMainAccount;
SysLookupMultiSelectCtrl sysMainAccountCtrl;
SysLookupMultiSelectGrid sysMainAccountGrid;
container con;
}
public void build()
{
contract = this.dataContractObject() as DIPL_MainAccountContract;
dialogFromdate = this.addDialogField(methodStr(DIPL_MainAccountContract, parmFromdate), contract);
dialogTodate = this.addDialogField(methodStr(DIPL_MainAccountContract, parmTodate), contract);
}
public void getFromDialog()
{
super();
con = sysMainAccountCtrl.getSelectedFieldValues();
if (con)
{
contract.parmMainAccount(con2List(con));
}
}
public void MainAccountLookup(FormStringControl MainAccountLookup)
{
sysMainAccountGrid = SysLookupMultiSelectGrid::construct(MainAccountLookup,MainAccountLookup);
sysMainAccountGrid.parmQuery(this.mainAccountQuery());
sysMainAccountGrid.run();
sysMainAccountGrid.setSelected();
}
public Query mainAccountQuery()
{
Query query;
QueryBuildDataSource qbds;
query = new Query();
qbds = query.addDataSource(tableNum(MainAccount));
qbds.addSelectionField(fieldNum(MainAccount, MainAccountId));
return query;
}
public void postBuild()
{
super();
contract = this.dataContractObject() as DIPL_MainAccountContract;
}
Data Contract Class
[
SRSReportParameterAttribute(classStr(DIPL_MainAccountContract))
]
class DIPL_MainAccountDP extends SRSReportDataProviderBase
{
DIPL_MainAccountTmp dIPL_MainAccountTmp ;
GeneralJournalEntry generalJournalEntry;
GeneralJournalAccountEntry generalJournalAccountEntry;
LedgerJournalTrans ledgerJournalTrans;
MainAccount mainAccount;
Query q;
QueryRun qr;
QueryBuildDataSource ds;
QueryBuildDataSource ds1;
QueryBuildDataSource ds2;
QueryBuildRange range;
container con,con2;
int i;
str multiSelectString;
MainAccountNum mainAccountNum;
container values;
TransDate start;
TransDate end;
PeriodStart periodStartDate;
PeriodEnd periodEndDate;
// DIPL_MainAccountContract contract;
#avifiles
}
[
SRSReportDataSetAttribute(tableStr('DIPL_MainAccountTmp'))
]
public DIPL_MainAccountTmp getDIPLMainAccountTmp()
{
select dIPL_MainAccountTmp;
return dIPL_MainAccountTmp;
}
SRSReportParameterAttribute(classStr(DIPL_MainAccountContract))
]
class DIPL_MainAccountDP extends SRSReportDataProviderBase
{
DIPL_MainAccountTmp dIPL_MainAccountTmp ;
GeneralJournalEntry generalJournalEntry;
GeneralJournalAccountEntry generalJournalAccountEntry;
LedgerJournalTrans ledgerJournalTrans;
MainAccount mainAccount;
Query q;
QueryRun qr;
QueryBuildDataSource ds;
QueryBuildDataSource ds1;
QueryBuildDataSource ds2;
QueryBuildRange range;
container con,con2;
int i;
str multiSelectString;
MainAccountNum mainAccountNum;
container values;
TransDate start;
TransDate end;
PeriodStart periodStartDate;
PeriodEnd periodEndDate;
// DIPL_MainAccountContract contract;
#avifiles
}
[
SRSReportDataSetAttribute(tableStr('DIPL_MainAccountTmp'))
]
public DIPL_MainAccountTmp getDIPLMainAccountTmp()
{
select dIPL_MainAccountTmp;
return dIPL_MainAccountTmp;
}
public void insertDIPLMainAccountTmp()
{
while select ledgerJournalTrans
where ledgerJournalTrans.Voucher == generalJournalEntry.SubledgerVoucher
{
dIPL_MainAccountTmp.VocherNumber = generalJournalEntry.SubledgerVoucher;
dIPL_MainAccountTmp.MainAccount = mainAccountNum;
dIPL_MainAccountTmp.BillNumber = ledgerJournalTrans.Invoice;
dIPL_MainAccountTmp.TransactionDate = ledgerJournalTrans.TransDate;
dIPL_MainAccountTmp.Credit = ledgerJournalTrans.AmountCurCredit;
dIPL_MainAccountTmp.Debit = ledgerJournalTrans.AmountCurDebit;
dIPL_MainAccountTmp.Description = ledgerJournalTrans.Text;
dIPL_MainAccountTmp.OffSetDimension = DimensionAttributeValueCombination::find(ledgerJournalTrans.OffsetLedgerDimension).DisplayValue;// ProjTable::find(dimensionAttributeValueSetItemView.DisplayValue).Name;
dIPL_MainAccountTmp.ProjectName = DimensionAttributeValueCombination::find(ledgerJournalTrans.LedgerDimension).DisplayValue;// ProjTable::find(dimensionAttributeValueSetItemView.DisplayValue).Name;
dIPL_MainAccountTmp.insert();
}
}
[
SysEntryPointAttribute
]
public void processReport()
{
List parmMainAccount;
ListEnumerator mainaccountListIterator;
container conMain;
DIPL_MainAccountContract contract = this.parmDataContract() as DIPL_MainAccountContract;
SysOperationProgress progressBar = new SysOperationProgress();
parmMainAccount = new List(Types::String);
start = contract.parmFromdate();
end = contract.parmTodate();
parmMainAccount = contract.parmMainAccount();
periodStartDate = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), systemDateGet()).StartDate;
periodEndDate = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), systemDateGet()).EndDate;
if (parmMainAccount !=null)
{
mainaccountListIterator = parmMainAccount.getEnumerator();
while (mainaccountListIterator.moveNext())
{
conMain += mainaccountListIterator.current();
}
multiSelectString = con2Str(conMain,',');
con2 = str2con(multiSelectString,",");
for(i = 1;i<= conLen(con2) ;i++)
{
mainAccountNum = conPeek(con2,i);
q = new Query();
ds = q.addDataSource(tableNum(GeneralJournalAccountEntry));
ds1 = ds.addDataSource(tableNum(MainAccount));
ds1.addRange(fieldNum(MainAccount,MainAccountId)).value(SysQuery::value(mainAccountNum));
ds2 = ds.addDataSource(tableNum(GeneralJournalEntry));
ds2.addGroupByField(fieldNum(GeneralJournalEntry,SubledgerVoucher));
range = ds2.addRange(fieldNum(GeneralJournalEntry, AccountingDate));
if (start == dateNull() && end == dateNull())
{
range.value(queryRange(periodStartDate,periodEndDate));
}
else
{
range.value(queryRange(start,end));
}
ds1.relations(true);
ds2.relations(true);
ds1.fetchMode(QueryFetchMode::One2One);
ds2.fetchMode(QueryFetchMode::One2One);
qr = new QueryRun(q);
while (qr.next())
{
progressBar.setCaption(strfmt("Fetching the data"));
progressBar.setAnimation(#AviFindFile);
generalJournalEntry = qr.get(tableNum(GeneralJournalEntry));
this.insertDIPLMainAccountTmp();
progressBar.setText(strfmt("Processing... please wait"));
}
}
}
}