- Create an extension of the SalesInvoiceHeaderFooterTmp table and add the fields.
- Copy the post-handler event method of processReport() of the DP class.
- Write the following logic to insert the data into the field:
class SalesInvoiceDPEventHandler
{
[PostHandlerFor(classStr(SalesInvoiceDP), methodStr(SalesInvoiceDP, processReport))]
public static void SalesInvoiceDP_Post_processReport(XppPrePostArgs args)
{
SalesInvoiceDP dpInstance = args.getThis() as SalesInvoiceDP;
SalesInvoiceHeaderFooterTmp tmpTable = dpInstance.getSalesInvoiceHeaderFooterTmp();
FormLetterRemarks formLetterRemarks;
CustPackingSlipJour custPackingSlipJour;
ttsbegin;
while select forUpdate tmpTable
{
select firstonly firstfast PackingSlipId from custPackingSlipJour
where custPackingSlipJour.SalesId == tmpTable.SalesId;
tmpTable.Email = CustTable::find(SalesTable::find(tmpTable.SalesId).CustAccount).email();
tmpTable.DeliveryNote = custPackingSlipJour.PackingSlipId;
tmpTable.update();
}
ttscommit;
}
}
---------------------------------OR-----------------------------------------[ExtensionOf(classstr(SalesInvoiceDP))]
final class SalesInvoiceDP_Extension
{
protected void populateSalesInvoiceTmp(CustInvoiceJour _custInvoiceJour,
CustInvoiceTrans _custInvoiceTrans,
TaxSpec _taxSpec,
CustPaymSchedLine _custPaymSchedLine,
CustTrans _prepaymentCustTrans,
TaxTrans _prepaymentTaxTrans)
{
next populateSalesInvoiceTmp(_custInvoiceJour,
_custInvoiceTrans,
_taxSpec,
_custPaymSchedLine,
_prepaymentCustTrans,
_prepaymentTaxTrans);
salesInvoiceTmp.TrackingId = _custInvoiceTrans.salesLine().TrackingId;
}
protected void populateSalesInvoiceHeaderFooterTmp(CustInvoiceJour _custInvoiceJour, CompanyInfo _companyInfo)
{
CustPackingSlipJour custPackingSlipJour;
next populateSalesInvoiceHeaderFooterTmp(_custInvoiceJour, _companyInfo);
select firstonly firstfast PackingSlipId from custPackingSlipJour
where custPackingSlipJour.SalesId == salesInvoiceHeaderFooterTmp.SalesId;
salesInvoiceHeaderFooterTmp.Email = CustTable::find(_custInvoiceJour.InvoiceAccount).email();
salesInvoiceHeaderFooterTmp.DeliveryNote = custPackingSlipJour.PackingSlipId;
}
}- You can also use the OnInserting event of the table instead of processReport() of DP class.
- Find out the SalesInvoicereport in the AOT
- Right-click the report and click Duplicate in the project.
- Restore the report data source to get additional fields.
- Customize the design and add fields as per your requirements.
- Create another class named SalesInvoiceControllerExt
which extends the SalesInvoiceController class. Override the main() method. Give the new report and its design name in it. - Add the following logic in the SalesInvoiceControllerExt class:
class SalesInvoiceControllerExt extends SalesInvoiceController
{
public static SalesInvoiceControllerExt construct()
{
return new SalesInvoiceControllerExt();
}
public static void main(Args _args)
{
SrsReportRunController formLetterController = SalesInvoiceControllerExt::construct();
SalesInvoiceControllerExt controller = formLetterController;
controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(SalesInvoiceExt, Report));
controller.parmShowDialog(false);
controller.parmDialogCaption("@SYS22766");
controller.startOperation();
}
}- Create another class named PrintMgtDocTypeHandlersExt.
- Add a method in it that subscribes to the event delegate of the PrintMgmtDocType class.
- Add the following logic in the PrintMgtDocTypeHandlersExt class:
class PrintMgtDocTypeHandlersExt
{
[SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
{
switch (_docType)
{
case PrintMgmtDocumentType::SalesOrderInvoice:
_result.result(ssrsReportStr(SalesInvoiceExt, Report));
break;
}
}
}- Create an extension of the following menu items which executes the report:
- SalesInvoiceOriginal
- SalesInvoiceCopy
- Change the controller class name in extended menu items.
- Save, build, synchronize and deploy.
Output:
- AR-> Setup-> Forms ->Form setup -> Genral tab -> print managment(button).
- Right click on Customer invoice and select New.
- In Report format select our custom design.








No comments:
Post a Comment