Contract Class with Param Methods :-
[DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(CIC_CreditReportUIBuilder)),
SysOperationGroupAttribute('Date', "@SYS7402", '1',FormArrangeMethod::Vertical)
]
public class CIC_CreditReportContract implements SysOperationValidatable, SysOperationInitializable
{
TransDate fromDate;
TransDate toDate;
List agentBroker, policy, profitCenter, userId, businessTypeId, requestor;
}
======================================================================
public void initialize()
{
this.parmFromDate(systemdateget());
this.parmToDate(nextyr(systemdateget() - 1));
}
=======================================================================
[
DataMemberAttribute('FromDate'),
SysOperationLabelAttribute(literalstr("@SYS4083")),
SysOperationHelpTextAttribute(literalstr("From date")),
SysOperationGroupMemberAttribute('Date'),
SysOperationDisplayOrderAttribute('1')
]
public TransDate parmFromDate(TransDate _fromDate = fromDate)
{
fromDate = _fromDate;
return fromDate;
}
========================================================================
[
DataMemberAttribute('ToDate'),
SysOperationLabelAttribute(literalstr("@SYS8828")),
SysOperationHelpTextAttribute(literalstr("To date")),
SysOperationGroupMemberAttribute('Date'),
SysOperationDisplayOrderAttribute('2')
]
public TransDate parmToDate(TransDate _toDate = toDate)
{
toDate = _toDate;
return toDate;
}
======================================================================
[
DataMemberAttribute('Approver'),
AifCollectionTypeAttribute("Approver", Types::String),
SysOperationLabelAttribute(literalstr('Approver')),
SysOperationHelpTextAttribute(literalstr('Workflow Approver')),
SysOperationGroupMemberAttribute('Date'),
SysOperationDisplayOrderAttribute('4')
]
public List parmUserId(List _userId = userId)
{
userId = _userId;
return userId;
}
=======================================================================
[
DataMemberAttribute('ProfitCenter'),
AifCollectionTypeAttribute("ProfitCenter", Types::String),
SysOperationLabelAttribute(literalstr('ProfitCenter')),
SysOperationHelpTextAttribute(literalstr('ProfitCenter')),
SysOperationGroupMemberAttribute('Date'),
SysOperationDisplayOrderAttribute('5')
]
public List parmProfitCenter(List _profitCenter = profitCenter)
{
profitCenter = _profitCenter;
return profitCenter;
}
========================================================================
public boolean validate()
{boolean ret = true;
if (!fromDate)
{
fromDate = systemdateget();
}
if (!toDate)
{
toDate = systemdateget();
}
if (toDate < fromDate)
{
ret = checkFailed("@SYS16982");
}
return ret;
}
=======================================================================
UI Builder Class
public class CIC_CreditReportUIBuilder extends SrsReportDataContractUIBuilder
{
CIC_CreditReportContract creditReportContract;
}
=======================================================================
public void getFromDialog()
{
creditReportContract contract = this.dataContractObject();
super();
}
======================================================================
public void initializeFields()
{
creditReportContract contract = this.dataContractObject();
}
=======================================================================
private void lookupApprover(FormStringControl _formStringControl)
{
SysLookupMultiSelectGrid msCtrlApprover;
msCtrlApprover = SysLookupMultiSelectGrid::construct(_formStringControl, _formStringControl);
msCtrlApprover.parmQuery(this.approverQuery());
msCtrlApprover.run();
}
=======================================================================
private Query approverQuery()
{
Query query;
query = new query();
query.addDataSource(tableNum(UserInfo));
query.dataSourceTable(tableNum(UserInfo)).addSelectionField(fieldNum(UserInfo,Id));
query.dataSourceTable(tableNum(UserInfo)).addSelectionField(fieldNum(UserInfo,Name));
return query;
}
========================================================================
private void lookupProfitCenter(FormStringControl _formStringControl)
{
SysLookupMultiSelectGrid msCtrlProfitCenter;
msCtrlProfitCenter = SysLookupMultiSelectGrid::construct(_formStringControl, _formStringControl);
msCtrlProfitCenter.parmQuery(this.profitCenterQuery());
msCtrlProfitCenter.run();
}
========================================================================
private Query profitCenterQuery()
{
Query query;
QueryBuildDataSource qbds, qbds1;
DimensionAttribute dimAttr;
define.DimensionName("ProfitCenter")
query = new query();
dimAttr = DimensionAttribute::findByName("Profitcenter");
qbds = query.addDataSource(tableNum(DimensionFinancialTag));
qbds.addSelectionField(fieldNum(DimensionFinancialTag,Value));
qbds.addSelectionField(fieldNum(DimensionFinancialTag,Description));
qbds1 = qbds.addDataSource(tableNum(DimensionAttributeDirCategory));
qbds1.addLink(fieldNum(DimensionFinancialTag,FinancialTagCategory),fieldnum(DimensionAttributeDirCategory,RecId));
qbds1.addRange(fieldNum(DimensionAttributeDirCategory, DimensionAttribute)).value(queryvalue(dimAttr.recid));
qbds1.addSelectionField(fieldNum(DimensionAttributeDirCategory,DimensionAttribute));
return query;
}
=======================================================================
public void build()
{
Dialog dialogObject = this.dialog();
creditReportContract = this.dataContractObject();
dialogObject.addGroup('Date');
this.addDialogField(methodstr(CIC_CreditReportContract,parmFromDate),creditReportContract);
this.addDialogField(methodstr(CIC_CreditReportContract,parmToDate),creditReportContract);
dialogObject.addGroup('Customer');
this.addDialogField(methodstr(CIC_CreditReportContract,parmUserId),creditReportContract);
this.addDialogField(methodstr(CIC_CreditReportContract,parmProfitCenter),creditReportContract);
}
=======================================================================
public void postBuild()
{
DialogField dialogFromDate;
DialogField dialogToDate;
DialogField dialogApprover;
DialogField dialogProfitCenter;
super();
dialogApprover = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(CIC_CreditReportContract,parmUserId));
dialogProfitCenter = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(CIC_CreditReportContract,parmProfitCenter));
dialogApprover.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(CIC_CreditReportUIBuilder, lookupApprover), this);
dialogProfitCenter.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(CIC_CreditReportUIBuilder, lookupProfitCenter), this);
}
=======================================================================
public void postRun()
{
creditReportContract contract = this.dataContractObject();
}
=======================================================================
RDP Class
[
SRSReportQueryAttribute(querystr(CICGBCreditReport)),
SRSReportParameterAttribute(classstr(CIC_CreditReportContract))
]
class CIC_CreditReportDP extends SRSReportDataProviderBase
{
CICGBCreditCommittal cicGBCreditCommittal;
CICCreditReportTmp cicCreditReportTmp;
DirPerson dirPerson;
CustTrans custTrans;
VendTable vendTable;
FromDate fromDate;
ToDate toDate;
List intermediary,
profitCenter,
userId;
ListIterator literator;
define.FromDate('FromDate')
define.ToDate('ToDate')
}
======================================================================
[
SRSReportDataSetAttribute('CICCreditReportTmp')
]
public CICCreditReportTmp getcicCreditReportTmp()
{
select cicCreditReportTmp;
return cicCreditReportTmp;
}
=======================================================================
private void insertIntoTempTable()
{
cicCreditReportTmp.PolicyNumber = cicGBCreditCommittal.Policy;
cicCreditReportTmp.Endorsement = cicGBCreditCommittal.Endorsement;
cicCreditReportTmp.ClientName = cicGBCreditCommittal.CustomerName;
cicCreditReportTmp.CreditAmount = cicGBCreditCommittal.PremiumAmount;
cicCreditReportTmp.CreditDays = cicGBCreditCommittal.CreditDays;
cicCreditReportTmp.UnderwritersNarration = cicGBCreditCommittal.OperationRemarks;
cicCreditReportTmp.FinanceRemarks = cicGBCreditCommittal.FinanceRemarks;
cicCreditReportTmp.CreditStatus = cicGBCreditCommittal.CreditApprovalStatus;
cicCreditReportTmp.RecNo = cicGBCreditCommittal.VoucherNo;
cicCreditReportTmp.AmountPaid = cicGBCreditCommittal.VoucherAmount;
cicCreditReportTmp.Approver = cicGBCreditCommittal.Approver;
cicCreditReportTmp.Requestor = cicGBCreditCommittal.Requestor;
cicCreditReportTmp.RequestDate = cicGBCreditCommittal.RequestDate;
cicCreditReportTmp.OverDueDays = date2num(cicGBCreditCommittal.DueDate) - date2num(systemDateGet());
cicCreditReportTmp.OutsCreditAmount = custTrans.remainAmountMST();
cicCreditReportTmp.IntermediaryCode = custTrans.CICAgentBroker;
cicCreditReportTmp.Channel = custTrans.CICChannelDesc;
cicCreditReportTmp.RecDate = custTrans.TransDate;
cicCreditReportTmp.IntermediaryName = vendTable.name();
cicCreditReportTmp.Profitcenter = custTrans.CICProfitcenter;
if (businessTypeId)
{
cicCreditReportTmp.BusinessType = cicBusinessType.Name;
}
else
{
select firstOnly Name from cicBusinessType
where cicBusinessType.BusinessTypeId == CustTrans.CICBusinessType;
if (cicBusinessType)
{
cicCreditReportTmp.BusinessType = cicBusinessType.Name;
}
}
cicCreditReportTmp.insert();
}
======================================================================
[AifDocumentCreateAttribute, SysEntryPointAttribute(true)]
public void processReport()
{
Query query;
QueryRun qr;
QueryBuildRange qbdRange, custTransQbr,businessTypeQbr,userInfoQbr,cicGBCreditCommittalQbr,profitCenterQbr;
QueryBuildDataSource custTransQbds, businessTypeQbds,userInfoQbds,cicGBCreditCommittalQbds, profitCenterQbds;
CIC_CreditReportContract contract = this.parmDataContract() as CIC_CreditReportContract;
fromDate = contract.parmFromDate();
toDate = contract.parmToDate();
userId = contract.parmUserId();
profitCenter = contract.parmProfitCenter();
//Checking for null date
if (!fromDate)
{
fromDate = systemdateget();
}
//Checking for null date
if (!toDate)
{
toDate = systemdateget();
}
query = this.parmQuery();
if(fromDate && toDate)
{
query.dataSourceTable(tableNum(CustTrans)).addRange(fieldNum(CustTrans,TransDate)).value(SysQuery::range(fromDate, todate));
}
if(!userId.empty())
{
literator = new ListIterator(userId);
cicGBCreditCommittalQbds = query.dataSourceTable(tableNum(CICGBCreditCommittal));
userInfoQbds = cicGBCreditCommittalQbds.addDataSource(tableNum(UserInfo));
userInfoQbds.addLink(fieldNum(CICGBCreditCommittal,Approver),fieldNum(UserInfo,name));
while (literator.more())
{
userInfoQbr = userInfoQbds.addRange(fieldNum(UserInfo,name));
userInfoQbr.value(literator.value());
literator.next();
}
}
if(!profitCenter.empty())
{
literator = new ListIterator(profitCenter);
custTransQbds = query.dataSourceTable(tableNum(custTrans));
profitCenterQbds = custTransQbds.addDataSource(tableNum(DefaultDimensionView));
profitCenterQbds.addLink(fieldNum(custTrans,DefaultDimension),fieldNum(DefaultDimensionView,DefaultDimension));
while (literator.more())
{
profitCenterQbr = profitCenterQbds.addRange(fieldNum(DefaultDimensionView, DisplayValue));
profitCenterQbr.value(literator.value());
literator.next();
}
}
qr = new QueryRun(query);
while (qr.next())
{
custTrans = qr.get(tableNum(custTrans));
cicGBCreditCommittal = qr.get(tableNum(cicGBCreditCommittal));
if(custTrans.Voucher)
{
select firstOnly AccountNum from vendTable
where VendTable.AccountNum == custTrans.CICAgentBroker;
//vendTable = vendTable::find(custTrans.CICAgentBroker);
this.insertIntoTempTable();
}
}
}
No comments:
Post a Comment