RDP Report In D365Fo X++
RDP Report In D365Fo X++
Contract Class:
[DataContractAttribute,SysOperationContractProcessingAttribute(classStr(CBLPODetailUIBuilder))]
public class CblPurchDetailPrintContract
{
List PONumber;
Str VendName;
InvoicedUnInvoiced InvoicedUnInvoiced;
TransDate frmdate;
TransDate todate;
NoYes checkFlag;
[
DataMemberAttribute('Check'),
SysOperationLabelAttribute(literalStr("Report On Date")),
SysOperationControlVisibilityAttribute(true),
SysOperationDisplayOrderAttribute('1')
]
public NoYes parmCheck(NoYes _CheckFlag = checkFlag)
{
checkFlag = _CheckFlag;
return checkFlag;
}
[DataMemberAttribute('fromDate'),SysOperationLabelAttribute(literalStr("From Date"))]
public TransDate parmFromDate(TransDate _FromDate = frmdate)
{
frmdate = _FromDate;
return frmdate;
}
[DataMemberAttribute('ToDate'),SysOperationLabelAttribute(literalStr("To Date"))]
public TransDate parmToDate(TransDate _ToDate = todate)
{
todate = _ToDate;
return todate;
}
[DataMemberAttribute("PONumber"),AifCollectionTypeAttribute("PONumber", Types::String),SysOperationLabelAttribute(literalStr("Purchase Order#"))]
public List parmPONumber(List _PONumber = PONumber)
{
PONumber = _PONumber;
return PONumber;
}
[DataMemberAttribute('VendName'),SysOperationLabelAttribute(literalStr("Vendor Account"))]
public Str parmVendName(Str _VendName = VendName)
{
VendName = _VendName;
return VendName;
}
}UI Builder Class:
class CBLPODetailUIBuilder extends SrsReportDataContractUIBuilder
{
CblPurchDetailPrintContract _contract;
DialogField DialogPONO, DialogVendName, DialogItemId;
DialogField DialogFromDate , DialogToDate, DialogCheck;
int _check;
public void build()
{
_contract = this.dataContractObject() as CblPurchDetailPrintContract;
// Create the dialog field
DialogCheck = this.addDialogField(methodStr(CblPurchDetailPrintContract, parmCheck), _contract);
DialogPONO = this.addDialogField(methodStr(CblPurchDetailPrintContract, parmPONumber), _contract);
DialogFromDate = this.addDialogField(methodStr(CblPurchDetailPrintContract, ParmFromDate), _contract);
DialogToDate = this.addDialogField(methodStr(CblPurchDetailPrintContract, ParmToDate), _contract);
DialogVendName = this.addDialogField(methodStr(CblPurchDetailPrintContract, parmVendName), _contract);
//For Visibilty
DialogFromDate.visible(false);
DialogToDate.visible(false);
DialogPONO.visible(true);
DialogVendName.visible(true);
}
public void postBuild()
{
super();
// Register Modify for Check field
DialogCheck.value(0);
DialogCheck = this.bindInfo().getDialogField(_contract,methodStr(CblPurchDetailPrintContract , parmCheck));
DialogCheck.registerOverrideMethod(methodStr(FormCheckBoxControl, modified ), methodStr(CBLPODetailUIBuilder, checkModified), this);
// Register lookup for Fromdate field
DialogFromDate.value(today());
DialogFromDate = this.bindInfo().getDialogField(_contract,methodStr(CblPurchDetailPrintContract , parmFromDate));
// Register lookup for ToDate field
DialogToDate.value(today());
DialogToDate = this.bindInfo().getDialogField(_contract,methodStr(CblPurchDetailPrintContract , parmToDate));
// Register lookup for VendName field
DialogVendName.value('All');
DialogVendName = this.bindInfo().getDialogField(_contract,methodStr(CblPurchDetailPrintContract , parmVendName));
DialogVendName.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(CBLPODetailUIBuilder, VendNameLookup), this);
// Register lookup for Purch Id field
DialogPONO.value('All');
DialogPONO = this.bindInfo().getDialogField(_contract,methodStr(CblPurchDetailPrintContract , parmPONumber));
DialogPONO.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(CBLPODetailUIBuilder, PONOLookup), this);
}
public void postRun()
{
//super();
}
private void PONOLookup(FormStringControl _control)
{
// Perform the lookup for Purch Id field
container con ;
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTablelookup;
QueryBuildRange qbr;
ListEnumerator Enum;
queryBuildDataSource = query.addDataSource(tableNum(TxlGatePassLine));
queryBuildDataSource.fields().dynamic(false);
queryBuildDataSource.fields().clearFieldList();
queryBuildDataSource.addSelectionField(fieldNum(TxlGatePassLine, DocumentNum));
queryBuildDataSource.addsortfield(fieldNum(TxlGatePassLine, DocumentNum));
queryBuildDataSource.addOrderByField(fieldNum(TxlGatePassLine, DocumentNum));
queryBuildDataSource.ordermode(ordermode::groupby);
SysLookupMultiSelectGrid::lookup(query,_control,_control,_control,conNull());
}
private void VendNameLookup(FormStringControl _control)
{
//Perform the lookup for VendName field
VendTable::lookupVendor(_control);
}
public boolean checkModified(FormCheckBoxControl _control)
{
_check = _control.value();
if(_check)
{
DialogFromDate.visible(true);
DialogFromDate.value(today());
DialogToDate.visible(true);
DialogToDate.value(today());
DialogPONO.visible(false);
DialogVendName.visible(false);
}
else
{
DialogFromDate.visible(false);
DialogToDate.visible(false);
DialogPONO.visible(true);
DialogPONO.value('All');
DialogVendName.visible(true);
DialogVendName.value('All');
}
return true;
}
}DP Class:
[SRSReportParameterAttribute(classStr(CblPurchDetailPrintContract))]
class CblPurchDetailPrintDp extends SRSReportDataProviderBase
{
CBLPurchDetailTmp PurchDetailTmp;
[SRSReportDataSetAttribute(tablestr(CBLPurchDetailTmp))]
public CBLPurchDetailTmp get_CBLPurchDetailTmp()
{
select PurchDetailTmp;
return PurchDetailTmp;
}
public void processReport()
{
CblPurchDetailPrintContract contract;
int _check;
contract = this.parmDataContract();
_check = contract.parmCheck();
if(_check)
{
this.rptOnDate();
}
else
{
this.rptDateAndPO();
}
}
public void rptOnDate()
{
CblPurchDetailPrintContract contract;
PurchTable PurchTable;
purchline purchline;
VendInvoiceJour VendInvoiceJour;
VendPackingSlipJour VendPackingSlipJour;
VendPackingSlipTrans VendPackingSlipTrans;
CBLEntUserInfoTbl CBLEntUserInfoTbl;
InventQualityOrderTable InventQualityOrderTable;
CBL_Memo CBL_Memo;
container con, conInvoice;
PurchRFQCaseTable PurchRFQCaseTable;
SalesTable SalesTable;
utcdatetime _frmdate, _todate;
contract = this.parmDataContract();
_frmdate = DateTimeUtil::newDateTime(contract.ParmFromDate(),0 );
_todate = DateTimeUtil::newDateTime(contract.ParmToDate(),86400);
while
select PurchTable
where (PurchTable.CreatedDateTime >= _frmdate && PurchTable.CreatedDateTime <= _todate)
join purchline
where purchline.purchid == PurchTable.purchid
{
CBL_Memo = '';
select Name, ID
from CBLEntUserInfoTbl
where CBLEntUserInfoTbl.ID == PurchTable.CreatedBy;
while
select QualityOrderId
from InventQualityOrderTable
where InventQualityOrderTable.InventRefId == purchline.PurchId
&& InventQualityOrderTable.ItemId == purchline.ItemId
{
CBL_Memo = CBL_Memo + "," + InventQualityOrderTable.QualityOrderId;
}
conInvoice = this.get_InvoiceAmount(PurchLine.PurchId, PurchLine.ItemId, PurchLine.LineNumber);
con = this.get_QOQty(purchline.PurchId, purchline.ItemId);
if(PurchLine.PurchReqId)
{
PurchDetailTmp.RFQNo = this.Get_RFQFromPR(PurchLine.PurchReqId);
PurchDetailTmp.PRNo = purchline.PurchReqId;
}
else
{
PurchDetailTmp.RFQNo = this.Get_MSPO(PurchLine.ReqPOId);
PurchDetailTmp.PRNo = purchline.ReqPOId;
}
PurchDetailTmp.PurchId = Purchtable.PurchId;
PurchDetailTmp.PRNo = purchline.PurchReqId;
PurchDetailTmp.PODate = DateTimeUtil::date(Purchtable.CreatedDateTime);
PurchDetailTmp.PurchType = enum2Str(Purchtable.PurchaseType);
PurchDetailTmp.OrderType = Purchtable.bfpPurchTypeId;
PurchDetailTmp.CblTaxGroup = Purchtable.Cbl_TaxGroup;
PurchDetailTmp.PurchStatus = enum2Str(Purchtable.DocumentState);
PurchDetailTmp.Buyer = CBLEntUserInfoTbl.Name;
PurchDetailTmp.VendorAcc = Purchtable.OrderAccount;
PurchDetailTmp.VendorName = Purchtable.PurchName;
PurchDetailTmp.PayTerms = Purchtable.Payment;
PurchDetailTmp.PayMode = Purchtable.PaymMode;
PurchDetailTmp.DeliveryTerms = Purchtable.DlvTerm;
PurchDetailTmp.DeliveryMode = Purchtable.DlvMode;
PurchDetailTmp.Voyage = purchline.ITMId;
PurchDetailTmp.GDNo = this.get_GDNO(PurchLine.PurchId, PurchLine.ItemId, PurchLine.ITMId, PurchLine.InventTransId);
PurchDetailTmp.ItemId = purchline.ItemId;
PurchDetailTmp.ItemName = InventTable::name(purchline.ItemId);
PurchDetailTmp.UOM = purchline.PurchUnit;
PurchDetailTmp.Currency = purchline.CurrencyCode;
PurchDetailTmp.SalesTaxType = purchline.TaxGroup;
PurchDetailTmp.SalesTaxAmount = this.GetTaxForPO(purchline);
PurchDetailTmp.Qty = purchline.PurchQty;
PurchDetailTmp.UnitPrice = purchline.PurchPrice;
PurchDetailTmp.Totals = purchline.PurchQty * purchline.PurchPrice;
PurchDetailTmp.QONo = CBL_Memo;
PurchDetailTmp.AccpQty = conPeek(con, 1);
PurchDetailTmp.RejectQty = conPeek(con, 2);
PurchDetailTmp.InvoiceNo = conPeek(conInvoice, 1);
PurchDetailTmp.InvoiceAmnt = conPeek(conInvoice, 2);
PurchDetailTmp.insert();
}
}
public void rptDateAndPO()
{
List POList;
str Vendor, PONO;
ListEnumerator enumeratorList;
PurchTable PurchTable;
purchline purchline;
CBLEntUserInfoTbl CBLEntUserInfoTbl;
InventQualityOrderTable InventQualityOrderTable;
CBL_Memo CBL_Memo;
container con, conInvoice;
CblPurchDetailPrintContract contract;
contract = this.parmDataContract();
POList = contract.parmPONumber();
Vendor = contract.parmVendName();
enumeratorList = POList.getEnumerator();
enumeratorList.reset();
while(enumeratorList.moveNext())
{
PONO = enumeratorList.current();
while
select PurchTable
where (PurchTable.PurchId == PONO || PONO == 'All') && (Vendor == PurchTable.OrderAccount || Vendor == 'All')
join purchline
where purchline.purchid == PurchTable.purchid
{
CBL_Memo = '';
select Name, ID
from CBLEntUserInfoTbl
where CBLEntUserInfoTbl.ID == PurchTable.CreatedBy;
while
select QualityOrderId
from InventQualityOrderTable
where InventQualityOrderTable.InventRefId == purchline.PurchId
&& InventQualityOrderTable.ItemId == purchline.ItemId
{
CBL_Memo = CBL_Memo + "," + InventQualityOrderTable.QualityOrderId;
}
conInvoice = this.get_InvoiceAmount(PurchLine.PurchId, PurchLine.ItemId, PurchLine.LineNumber);
con = this.get_QOQty(purchline.PurchId, purchline.ItemId);
if(PurchLine.PurchReqId)
{
PurchDetailTmp.RFQNo = this.Get_RFQFromPR(PurchLine.PurchReqId);
PurchDetailTmp.PRNo = purchline.PurchReqId;
}
else
{
PurchDetailTmp.RFQNo = this.Get_MSPO(PurchLine.ReqPOId);
PurchDetailTmp.PRNo = purchline.ReqPOId;
}
PurchDetailTmp.PurchId = Purchtable.PurchId;
PurchDetailTmp.PODate = DateTimeUtil::date(Purchtable.CreatedDateTime);
PurchDetailTmp.PurchType = enum2Str(Purchtable.PurchaseType);
PurchDetailTmp.OrderType = Purchtable.bfpPurchTypeId;
PurchDetailTmp.CblTaxGroup = Purchtable.Cbl_TaxGroup;
PurchDetailTmp.PurchStatus = enum2Str(Purchtable.DocumentState);
PurchDetailTmp.Buyer = CBLEntUserInfoTbl.Name;
PurchDetailTmp.VendorAcc = Purchtable.OrderAccount;
PurchDetailTmp.VendorName = Purchtable.PurchName;
PurchDetailTmp.PayTerms = Purchtable.Payment;
PurchDetailTmp.PayMode = Purchtable.PaymMode;
PurchDetailTmp.DeliveryTerms = Purchtable.DlvTerm;
PurchDetailTmp.DeliveryMode = Purchtable.DlvMode;
PurchDetailTmp.Voyage = purchline.ITMId;
PurchDetailTmp.GDNo = this.get_GDNO(PurchLine.PurchId, PurchLine.ItemId, PurchLine.ITMId, PurchLine.InventTransId);
PurchDetailTmp.ItemId = purchline.ItemId;
PurchDetailTmp.ItemName = InventTable::name(purchline.ItemId);
PurchDetailTmp.UOM = purchline.PurchUnit;
PurchDetailTmp.Currency = purchline.CurrencyCode;
PurchDetailTmp.SalesTaxType = purchline.TaxGroup;
PurchDetailTmp.SalesTaxAmount = this.GetTaxForPO(purchline);
PurchDetailTmp.Qty = purchline.PurchQty;
PurchDetailTmp.UnitPrice = purchline.PurchPrice;
PurchDetailTmp.Totals = purchline.PurchQty * purchline.PurchPrice;
PurchDetailTmp.QONo = CBL_Memo;
PurchDetailTmp.AccpQty = conPeek(con, 1);
PurchDetailTmp.RejectQty = conPeek(con, 2);
PurchDetailTmp.InvoiceNo = conPeek(conInvoice, 1);
PurchDetailTmp.InvoiceAmnt = conPeek(conInvoice, 2);
PurchDetailTmp.insert();
}
}
}
public str Get_MSPO(str RePOID)
{
PURCHLINE PURCHLINE;
PurchRFQLine PurchRFQLine;
PurchRFQCaseLine PurchRFQCaseLine;
SELECT REQPOID, PURCHID
FROM PURCHLINE
where PURCHLINE.REQPOID == RePOID
JOIN RFQId
from PurchRFQLine
where PURCHLINE.PURCHID == PurchRFQLine.PURCHID
JOIN RFQCASEID
from PurchRFQCaseLine
where PurchRFQCaseLine.RECID == PurchRFQLine.RFQCaseLineRefRecId;
str RFQ = PurchRFQCaseLine.RFQCASEID;
return RFQ;
}
public str Get_RFQFromPR(str PR)
{
PURCHLINE PURCHLINE;
PURCHREQTABLE PURCHREQTABLE;
PURCHREQLINE PURCHREQLINE;
PURCHRFQCASETABLE PURCHRFQCASETABLE;
select
PURCHREQID
FROM PURCHREQTABLE
WHERE PURCHREQTABLE.PURCHREQID == PR
JOIN PURCHREQLINE
WHERE PURCHREQTABLE.RECID == PURCHREQLINE.PURCHREQTABLE
JOIN RFQCASEID
from PURCHRFQCASETABLE
WHERE PURCHRFQCASETABLE.RFQCASEID == PURCHREQLINE.PURCHRFQCASEID
join purchid
from PURCHLINE
WHERE PURCHLINE.purchreqid == PURCHREQTABLE.PURCHREQID;
str RFQ = PURCHRFQCASETABLE.RFQCASEID;
return RFQ;
}
public container get_QOQty(str PurchId, str ItemId)
{
InventQualityOrderTable InventQualityOrderTable;
real POAmount;
container con;
select sum(AcceptedQuantity), sum(RejectedQuantity)
from InventQualityOrderTable
where InventQualityOrderTable.InventRefId == PurchId
&& InventQualityOrderTable.ItemId == ItemId;
con = conIns(con,1, InventQualityOrderTable.AcceptedQuantity);
con = conIns(con,2, InventQualityOrderTable.RejectedQuantity);
return con;
}
public real GetTaxForPO (purchline _PurchLine)
{
TaxOnItem TaxOnItem;
TaxGroupData TaxGroupData, TaxGroupData_1;
real TaxAmount = 0, TaxAmount_1 = 0;
TaxValue TaxValue = 0, TaxValue_1 = 0;
;
if(_PurchLine.TaxItemGroup && _PurchLine.TaxGroup && _PurchLine.LineAmount != 0)
{
while select TaxOnItem
where TaxOnItem.TaxItemGroup == _PurchLine.TaxItemGroup
{
if(TaxOnItem)
{
while select TaxGroupData
where TaxGroupData.TaxGroup == _PurchLine.TaxGroup && TaxGroupData.TaxCode == TaxOnItem.TaxCode
{
if(TaxGroupData)
{
TaxValue = TaxData::find(TaxOnItem.TaxCode, Systemdateget(), 0).TaxValue;
TaxValue_1 += TaxValue;
TaxAmount = (_PurchLine.LineAmount * TaxValue)/100;
TaxAmount_1 += TaxAmount;
}
}
}
}
}
return TaxAmount_1 ;
}
public str get_GDNO(str PurchId, str itemid, str VoyageID, str LotID)
{
ITMTABLE ITMTABLE;
ITMLINE ITMLINE;
str GDNO;
select ITMTABLE
where ITMTABLE.ShipId == VoyageID
join ITMLINE
WHERE ITMTABLE.SHIPID == ITMLINE.SHIPID
&& ITMLINE.TransRefId == PurchID
&& ITMLINE.ShipItemId == itemid
&& ITMLINE.InventTransId == LotID;
GDNO = ITMTABLE.SLD_GDNumber;
return GDNO;
}
public container get_InvoiceAmount(str PurchId, str itemid, real LineNum)
{
VendInvoiceTrans VendInvoiceTrans;
real InvoiceAmount, TaxAmount;
container con;
CBL_Memo CBL_Memo;
while
select VendInvoiceTrans
where VendInvoiceTrans.OrigPurchId == PurchId
&& VendInvoiceTrans.ItemId == itemid
&& VendInvoiceTrans.LineNum == LineNum
{
CBL_Memo = CBL_Memo + "," + VendInvoiceTrans.InvoiceId;
InvoiceAmount = InvoiceAmount + VendInvoiceTrans.lineAmountExclTax();
TaxAmount = TaxAmount + VendInvoiceTrans.TaxAmount;
}
con = conIns(con,1, CBL_Memo);
con = conIns(con,2, InvoiceAmount);
con = conIns(con,3, TaxAmount);
return con;
}
}The code to get current worker legal entity.
Comments
Post a Comment