PO report custom changes

// Custom  PO report invoke 

[ExtensionOf(classstr(PrintMgmtDelegatesHandler))]

final class HIGPrintMgmtDelegatesHandler_Extension

{

 

    public static void getDefaultReportFormatDelegateHandler(PrintMgmtDocumentType _docType, EventHandlerResult _result)

    {

        PrintMgmtReportFormatName formatName;

        

        next getDefaultReportFormatDelegateHandler(_docType, _result);

 

        formatName = PrintMgmtDelegatesHandler::rangelineGetDefaultReportFormat(_docType, _result.result());

 

        if (formatName)

        {

            _result.result(formatName);

        }

    }


    private static PrintMgmtReportFormatName rangelineGetDefaultReportFormat(

    PrintMgmtDocumentType       _docType,

    PrintMgmtReportFormatName   _origFormatName)

    {

        PrintMgmtReportFormatName formatName;

 

        switch (_docType)

        {

            case PrintMgmtDocumentType::PurchaseOrderConfirmationRequest ,

                PrintMgmtDocumentType::PurchaseOrderRequisition:

               // if (_origFormatName == ssrsReportStr(PurchPurchaseOrder, Report))

                {

               //     formatName = ssrsReportStr(HIGPurchPurchaseOrder, Report);

                }

                break;

        }

        

        return formatName;

    }


}


// Our custom fields logic implement


[Extensionof(classStr(PurchPurchaseOrderDP))]

final class HIGPurchPurchaseOrderDP_Extension

{

    protected PurchPurchaseOrderHeader initializePurchaseOrderHeader(VendPurchOrderJour _vendPurchOrderJour)

    {

        PurchTable purchTableLoc =       _vendPurchOrderJour.purchTable();

        PurchPurchaseOrderHeader header = next initializePurchaseOrderHeader(_vendPurchOrderJour); 


        header.HIGDeliveryDate =  purchTableLoc.DeliveryDate;

        header.Payment =  purchTableLoc.Payment;


        LogisticsPostalAddress postalAddrInvoice = this.getPostalAddressByType(CompanyInfo::find().RecId ,LogisticsLocationRoleType::Invoice);

        

        header.HIGCompanyInvAddress =  postalAddrInvoice.Address; 


        LogisticsPostalAddress postalAddrBusiness = this.getPostalAddressByType(CompanyInfo::find().RecId ,LogisticsLocationRoleType::Business);

        

        header.HIGContactAddress =  postalAddrBusiness.Address+ "\n"+this.contactOnAddress(postalAddrBusiness);


        header.HIGFooterNotes = FormLetterRemarks::find(purchTableLoc.LanguageId,FormTextType::PurchPurchaseOrder).Txt;


        header.HIGLineNotes =VendParameters::find().HIGLineNotes;


        return header;


    }


    protected PurchPurchaseOrderTmp initializeOrderLine(

        PurchPurchaseOrderHeader                    _purchaseOrderHeader,

        boolean                                     _highlightUpdated,

        PurchPurchaseOrderDPOrderLineQuerySelection _orderLineSelection)

    {

        PurchPurchaseOrderTmp orderTmp;

        orderTmp = next  initializeOrderLine(_purchaseOrderHeader,_highlightUpdated,_orderLineSelection) ;

        orderTmp.HIGSymbol =  Currency::find(orderTmp.CurrencyCode).Symbol;

        return orderTmp;

    }


    public  LogisticsPostalAddress getPostalAddressByType(DirPartyRecId _party, LogisticsLocationRoleType _type)

    {

        DirPartyLocation        partyLocation;

        DirPartyLocationRole    partyLocationRole;

        LogisticsLocation       location;

        LogisticsLocationRole   locationRole;

        LogisticsPostalAddress  postalAddress;


        select firstonly postalAddress

        exists join location

            where location.RecId == postalAddress.Location

        exists join locationRole

            where locationRole.Type  == _type

        exists join partyLocation

            where partyLocation.Location == location.RecId &&

                partyLocation.Party == _party

        exists join partyLocationRole

            where partyLocationRole.PartyLocation == partyLocation.RecId &&

                partyLocationRole.LocationRole == locationRole.RecId;


        return postalAddress;


    }


    public Description1000 contactOnAddress(LogisticsPostalAddress  postalAddress)

    {

        Description                 phone,fax,Url;

        LogisticsLocation           parentLocation, childLocation;

        DirPartyLocation            dirPartyLocation;

        LogisticsElectronicAddress  electronicAddress;


        while select childLocation

        where childLocation.ParentLocation == postalAddress.Location

        join electronicAddress

        where electronicAddress.Location == childLocation.RecId

        {

            if(electronicAddress.Type == LogisticsElectronicAddressMethodType::Phone )

            {

                phone =  electronicAddress.Locator;

            }

            if(electronicAddress.Type == LogisticsElectronicAddressMethodType::Fax )

            {

                fax =  electronicAddress.Locator;

            }

            if(electronicAddress.Type == LogisticsElectronicAddressMethodType::URL )

            {

                Url =  electronicAddress.Locator;

            }

            

        }

        return "Phone :"+phone+ " Fax :" +fax+"\n"+Url;

    }


}


Comments

Popular posts from this blog

Logistics address, postal address, address phone fax contact information

Ledger dimensions and financial Dimensions X++

Prepay posting vendor invoice with amounts