Extend Sales Invoice Report
https://denistrunin.com/xpptools-reportsalesinvoice/
Steps to follow for extending sales invoice report
------------------------------------------------------------------------------------
[ExtensionOf(classstr(PrintMgmtReportFormatPopulator))]
final class PrintMgmtReportFormatPopulator_Extension
{
protected void addDocuments()
{
this.addStandard(PrintMgmtDocumentType::SalesOrderInvoice);
next addDocuments();
}
}
[ExtensionOf(ClassStr(SalesInvoiceController))]
final class SalesInvoiceController_Extension
{
protected void initFormLetterReport()
{
next
initFormLetterReport();
this.printCopyOriginal = PrintCopyOriginal::OriginalPrint;
this.parmReportName(ssrsReportStr(SalesInvoiceExt, Report));
FormletterReport formLetterReport = this.formLetterReport
as FormLetterReport;
formLetterReport.parmUsePrintMgmtDestinations(true);
}
[ExtensionOf(ClassStr(SalesInvoiceDP))]
final class SalesInvoiceDP_Extension
{
protected void
populateSalesInvoiceHeaderFooterTmp(CustInvoiceJour _custInvoiceJour, CompanyInfo _companyInfo)
{
SalesInvoiceHeaderFooterTmp
salesInvoiceHeaderFooterTmp = this.salesInvoiceHeaderFooterTmp;
next populateSalesInvoiceHeaderFooterTmp(_custInvoiceJour,
_companyInfo);
select * from custPackingSlipJour where
custPackingSlipJour.SalesId ==
_custInvoiceJour.SalesId;
salesTable = SalesTable::find(_custInvoiceJour.SalesId);
companyInfo = companyInfo::find();
logisticsPostalAddress = salesTable.deliveryAddress();
salesInvoiceHeaderFooterTmp.ShipTo =
salesTable.DeliveryName;
salesInvoiceHeaderFooterTmp.ShipToAddress =
logisticsPostalAddress.Address;
salesInvoiceHeaderFooterTmp.SalesEngineer =
salesTable.SalesGroup;
salesInvoiceHeaderFooterTmp.QD_DunsNumber =
companyInfo.editDunsNumber(false, '');
this.parmSalesInvoiceHeaderFooterTmp_IT(salesInvoiceHeaderFooterTmp);
}
protected void populateSalesInvoiceTmp(CustInvoiceJour _custInvoiceJour,
CustInvoiceTrans _custInvoiceTrans,
TaxSpec _taxSpec,
CustPaymSchedLine _custPaymSchedLine,
CustTrans _prepaymentCustTrans,
TaxTrans _prepaymentTaxTrans)
{
next
populateSalesInvoiceTmp(_custInvoiceJour,_custInvoiceTrans,_taxSpec,_custPaymSchedLine,_prepaymentCustTrans,_prepaymentTaxTrans);
if (salesInvoiceTmp.Qty)
{
lineNum++;
salesInvoiceTmp.LineNum = lineNum;
}
InventTable inventTableLocal = _custInvoiceTrans.inventTable();
if (inventTableLocal)
{
salesInvoiceTmp.OrigCountry =
inventTableLocal.OrigCountryRegionId;
}
SalesLine salesline = _custInvoiceTrans.salesLine();
if (salesline)
{
salesInvoiceTmp.ReleaseNumber =
salesline.ReleaseNumber;
}
//Misc charges
if (!miscChargeCalculated)
{
miscChargeTotal =
custInvoiceJour.SumMarkup
shippingCharge = this.getShippingCharge(custInvoiceJour);
salesInvoiceTmp.MiscChargeLessShipping = miscChargeTotal -
shippingCharge;
salesInvoiceTmp.ShippingCharge = shippingCharge;
miscChargeCalculated = true;
}
if (!shipmentInfoLoaded)
{
salesInvoiceTmp.CartonsQty =
cartonsQty;
salesInvoiceTmp.Weight = shipmentWeight;
salesInvoiceTmp.TrackingNum =
trackingNum;
salesInvoiceTmp.PackingSlipId =
packingSlipId;
shipmentInfoLoaded = true;
}
this.parmSalesInvoiceTmp_IT(salesInvoiceTmp);
private MarkupValue getShippingCharge(CustInvoiceJour _custInvoiceJour)
{
MarkupTrans markUpTransLocal;
MarkupTable markUpTableLocal;
select sum(Value) from markUpTransLocal
join markUpTableLocal
where markUpTransLocal.TransTableId == _custInvoiceJour.TableId
&&
markUpTransLocal.TransRecId == _custInvoiceJour.RecId
&& markUpTransLocal.MarkupCode
== markUpTableLocal.MarkupCode
&&
markUpTableLocal.VendPosting == LedgerPostingType::SalesFreight;
return markUpTransLocal.Value;
}
class PrintMgtDocTypeHandlers_Extension
{
/// <summary>
/// Which report & design should be executed based on
PrintMgmtDocumentType
/// </summary>
/// <param name =
"_docType">docType</param>
/// <param name = "_result">result</param>
[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;
}
}
Duplicate the Report and name
it SalesInvoiceExt. Extend the menu items SalesInvoice, SalesInvoice Copy, Sales
invoiceOriginal and check the property object
is set to “SalesInvoiceController”
Comments
Post a Comment