for the vendor account statement report, i've added a boolean field "Exclude Prepayments". i want to make it that if this field is true, to exclude all the invoices of type "Prepayment". So what i did first is extended the contract class and added the parameter. then, i extended the Classes\VendAccountStatementIntDP\initVendTransQuery method to add a range based on this parameter value. but it's still not working till now. the vendor invoice type is "InvoiceType" field in VendInvoiceJour table, and has Enum PurchInvoiceType::VendorAdvance (for the value prepayment).
[ExtensionOf(classStr(VendAccountStatementIntDP))]
final class VendAccountStatementIntDP_Extension
{
private NoYes ExclPrepayments;
public void processReport()
{
// Call the base class method
next processReport();
// Retrieve the contract object
VendAccountStatementIntContract vendAccountStatementIntContract = this.parmDataContract();
// Get the value of the exclusion parameter
ExclPrepayments = vendAccountStatementIntContract.parmExclPrepayment();
// Initialize the query
Query query = this.initVendTransQuery();
}
public Query initVendTransQuery()
{
Query query = next initVendTransQuery();
// Initialize the base query as done in the standard DP class
QueryBuildDataSource vendTransDataSourceBase = SysQuery::findOrCreateDataSource(query, tableNum(VendTrans), tableNum(VendTable));
// Add VendInvoiceJour as a child data source of VendTrans
QueryBuildDataSource vendInvoiceJourDataSource = vendTransDataSourceBase.addDataSource(tableNum(VendInvoiceJour));
vendInvoiceJourDataSource.relations(true);
vendInvoiceJourDataSource.joinMode(JoinMode::OuterJoin);
// Define correct linking
vendInvoiceJourDataSource.addLink(fieldNum(VendInvoiceJour, LedgerVoucher), fieldNum(VendTrans, Voucher));
vendInvoiceJourDataSource.addLink(fieldNum(VendInvoiceJour, InvoiceAccount), fieldNum(VendTrans, AccountNum));
// Add filtering condition based on the parameter value
if (ExclPrepayments == NoYes::Yes)
{
vendInvoiceJourDataSource.addRange(fieldNum(VendInvoiceJour, InvoiceType)).value(SysQuery::valueNot(Enum2Str(PurchInvoiceType::VendorAdvance)));
}
return query;
}
}