project QadFinancials > class B1099MiscellaneousReport > method GetReportData

Description

Gets 1099 Box and Payment Data for selected Suppliers, Supplier Types and Company Addresses


Parameters


iiYearinputintegerInput Year.
icSupplierCodeFrominputcharacterSupplier Code From.
icSupplierCodeToinputcharacterSupplier Code To.
icSupplierTypeFrominputcharacterSupplier Type From.
icSupplierTypeToinputcharacterSupplier Type To.
icCompanyAddressFrominputcharacterCompany Address From.
icCompanyAddressToinputcharacterCompnay Address To.
t1099Boxesoutputtemp-tableTemp table to store 1099Box related information.
t1099CompanyAddressoutputtemp-tableTemp table to store Company Address related information.
t1099Creditorsoutputtemp-tableTemp table to store Creditor related information.
t1099Paymentsoutputtemp-tableTemp table to store Payment related information.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/b1099miscellaneousreport.p)

empty temp-table t1099Boxes.
empty temp-table t1099CompanyAddress.
empty temp-table t1099Payments.
empty temp-table t1099Creditors.

/* Validate Payment Year */
if viPaymentYear = ?
then do:
    <M-1 run SetMessage
       (input  #T-3'The Payment Year Must Be Specified':255(733741255)T-3# (icMessage), 
        input  '' (icArguments), 
        input  'iiYear' (icFieldName), 
        input  iiYear (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-7188':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output oiReturnStatus (oiReturnStatus)) in B1099MiscellaneousReport>
    assign oiReturnStatus = -1.
    return.
end.


/* Get the active 1099 Boxes */
<Q-3 run 1099Boxes (all) (Read) (NoCache)
   (input iiYear, (PaymentYear)
    output dataset tq1099Boxes) in B1099MiscellaneousReport >

for each tq1099Boxes:
    create t1099Boxes.
    assign t1099Boxes.tiBox1099ID = tq1099Boxes.tiBox1099_ID
           t1099Boxes.tcBox1099Code = tq1099Boxes.tcBox1099Code
           t1099Boxes.tiBox1099CalendarYear = tq1099Boxes.tiBox1099CalendarYear
           t1099Boxes.tcBox1099Reference = tq1099Boxes.tcBox1099Reference
           t1099Boxes.tdBox1099MinimumAmountLC = tq1099Boxes.tdBox1099MinimumAmountLC
           t1099Boxes.tiPurchaseTypeID = tq1099Boxes.tiPurchaseType_ID
           t1099Boxes.tcPurchaseTypeCode = tq1099Boxes.tcPurchaseTypeCode
           t1099Boxes.tiPurchaseTypeLinkID = tq1099Boxes.tiBox1099PurchaseTypeLink_ID
           t1099Boxes.tcRowid = tq1099Boxes.tc_rowid.
end.           

<Q-4 run 1099CompanyAddress (all) (Read) (NoCache)
   (input viDomainID, (DomainID)
    input icCompanyAddressFrom, (CompanyAddressFrom)
    input icCompanyAddressTo, (CompanyAddressTo)
    input ?, (CompanyId)
    output dataset tq1099CompanyAddress) in B1099MiscellaneousReport >

for each tq1099CompanyAddress no-lock:

    create t1099CompanyAddress.
    
    assign t1099CompanyAddress.tcBusinessRelationCode = tq1099CompanyAddress.tcBusinessRelationCode
           t1099CompanyAddress.tlBusinessRelationIsTaxRep = tq1099CompanyAddress.tlBusinessRelationIsTaxRep
           t1099CompanyAddress.tlBusinessRelationIsLastFill = tq1099CompanyAddress.tlBusinessRelationIsLastFill
           t1099CompanyAddress.tcBusinessRelationNameCtrl = tq1099CompanyAddress.tcBusinessRelationNameCtrl
           t1099CompanyAddress.tcAddressName = tq1099CompanyAddress.tcAddressName
           t1099CompanyAddress.tcAddressLogicKeyString = tq1099CompanyAddress.tcAddressLogicKeyString
           t1099CompanyAddress.tlAddressIsTemporary = tq1099CompanyAddress.tlAddressIsTemporary
           t1099CompanyAddress.tlAddressIsTaxIncluded = tq1099CompanyAddress.tlAddressIsTaxIncluded
           t1099CompanyAddress.tlAddressIsTaxInCity = tq1099CompanyAddress.tlAddressIsTaxInCity
           t1099CompanyAddress.tlAddressIsTaxable = tq1099CompanyAddress.tlAddressIsTaxable
           t1099CompanyAddress.tlAddressIsSendToPostal = tq1099CompanyAddress.tlAddressIsSendToPostal
           t1099CompanyAddress.tiAddressFormat = tq1099CompanyAddress.tiAddressFormat
           t1099CompanyAddress.tcAddressFax = tq1099CompanyAddress.tcAddressFax
           t1099CompanyAddress.tcAddressEmail = tq1099CompanyAddress.tcAddressEmail
           t1099CompanyAddress.tcAddressCounty = tq1099CompanyAddress.tcAddressCounty
           t1099CompanyAddress.tcAddressCity = tq1099CompanyAddress.tcAddressCity
           t1099CompanyAddress.tcAddressTelephone = tq1099CompanyAddress.tcAddressTelephone
           t1099CompanyAddress.tcAddressTaxIDState = tq1099CompanyAddress.tcAddressTaxIDState
           t1099CompanyAddress.tcAddressTaxIDMisc1 = tq1099CompanyAddress.tcAddressTaxIDMisc1
           t1099CompanyAddress.tcAddressTaxIDMisc2 = tq1099CompanyAddress.tcAddressTaxIDMisc2
           t1099CompanyAddress.tcAddressTaxIDMisc3 = tq1099CompanyAddress.tcAddressTaxIDMisc3
           t1099CompanyAddress.tcAddressTaxIDFederal = tq1099CompanyAddress.tcAddressTaxIDFederal
           t1099CompanyAddress.tiAddressTaxDeclaration = tq1099CompanyAddress.tiAddressTaxDeclaration
           t1099CompanyAddress.tcAddressStreet1 = tq1099CompanyAddress.tcAddressStreet1
           t1099CompanyAddress.tcAddressStreet2 = tq1099CompanyAddress.tcAddressStreet2
           t1099CompanyAddress.tcAddressStreet3 = tq1099CompanyAddress.tcAddressStreet3
           t1099CompanyAddress.tcAddressState = tq1099CompanyAddress.tcStateCode       /* CA741664 tq1099CompanyAddress.tcAddressState */
           t1099CompanyAddress.tcAddressSearchName = tq1099CompanyAddress.tcAddressSearchName
           t1099CompanyAddress.tcAddressZip = tq1099CompanyAddress.tcAddressZip
           t1099CompanyAddress.tcAddressWebSite = tq1099CompanyAddress.tcAddressWebSite
           t1099CompanyAddress.tcAddressTypeCode = tq1099CompanyAddress.tcAddressTypeCode
           t1099CompanyAddress.tiCountryFormat = tq1099CompanyAddress.tiCountryFormat
           t1099CompanyAddress.tcCountryCode = tq1099CompanyAddress.tcCountryCode
           t1099CompanyAddress.tcCountryDescription = tq1099CompanyAddress.tcCountryDescription
           t1099CompanyAddress.tcCountyCode = tq1099CompanyAddress.tcCountyCode
           t1099CompanyAddress.tcCountyDescription = tq1099CompanyAddress.tcCountyDescription
           t1099CompanyAddress.tcLngCode = tq1099CompanyAddress.tcLngCode
           t1099CompanyAddress.tcStateCode = tq1099CompanyAddress.tcStateCode
           t1099CompanyAddress.tcStateDescription = tq1099CompanyAddress.tcStateDescription
           t1099CompanyAddress.tcTxzTaxZone = tq1099CompanyAddress.tcTxzTaxZone
           t1099CompanyAddress.tcTxuTaxUsage = tq1099CompanyAddress.tcTxuTaxUsage
           t1099CompanyAddress.tcTxclTaxCls = tq1099CompanyAddress.tcTxclTaxCls.

end.
    
<Q-5 run 1099Creditors (all) (Read) (NoCache)
   (input viCompanyID, (CompanyId)
    input icSupplierCodeFrom, (SupplierCodeFrom)
    input icSupplierCodeTo, (SupplierCodeTo)
    input icSupplierTypeFrom, (SupplierTypeFrom)
    input icSupplierTypeTo, (SupplierTypeTo)
    output dataset tq1099Creditors) in B1099MiscellaneousReport >    

for each tq1099Creditors no-lock:

    create t1099Creditors.
    assign t1099Creditors.tiCreditor_ID = tq1099Creditors.tiCreditor_ID
           t1099Creditors.tcCreditorCode = tq1099Creditors.tcCreditorCode
           t1099Creditors.tcCreditorTypeCode = tq1099Creditors.tcCreditorTypeCode
           t1099Creditors.tcCurrencyCode = tq1099Creditors.tcCurrencyCode
           t1099Creditors.tcPurchaseTypeCode = tq1099Creditors.tcPurchaseTypeCode
           t1099Creditors.tlCreditorIsTaxReport = tq1099Creditors.tlCreditorIsTaxReport
           t1099Creditors.tcAddressName = tq1099Creditors.tcAddressName
           t1099Creditors.tcAddressLogicKeyString = tq1099Creditors.tcAddressLogicKeyString
           t1099Creditors.tlAddressIsTemporary = tq1099Creditors.tlAddressIsTemporary
           t1099Creditors.tlAddressIsTaxIncluded = tq1099Creditors.tlAddressIsTaxIncluded
           t1099Creditors.tlAddressIsTaxInCity = tq1099Creditors.tlAddressIsTaxInCity
           t1099Creditors.tlAddressIsTaxable = tq1099Creditors.tlAddressIsTaxable
           t1099Creditors.tlAddressIsSendToPostal = tq1099Creditors.tlAddressIsSendToPostal
           t1099Creditors.tiAddressFormat = tq1099Creditors.tiAddressFormat
           t1099Creditors.tcAddressFax = tq1099Creditors.tcAddressFax
           t1099Creditors.tcAddressEmail = tq1099Creditors.tcAddressEmail
           t1099Creditors.tcAddressCounty = tq1099Creditors.tcAddressCounty
           t1099Creditors.tcAddressCity = tq1099Creditors.tcAddressCity
           t1099Creditors.tcAddressTelephone = tq1099Creditors.tcAddressTelephone
           t1099Creditors.tcAddressTaxIDState = tq1099Creditors.tcAddressTaxIDState
           t1099Creditors.tcAddressTaxIDMisc1 = tq1099Creditors.tcAddressTaxIDMisc1
           t1099Creditors.tcAddressTaxIDMisc2 = tq1099Creditors.tcAddressTaxIDMisc2
           t1099Creditors.tcAddressTaxIDMisc3 = tq1099Creditors.tcAddressTaxIDMisc3
           t1099Creditors.tcAddressTaxIDFederal = tq1099Creditors.tcAddressTaxIDFederal
           t1099Creditors.tiAddressTaxDeclaration = tq1099Creditors.tiAddressTaxDeclaration
           t1099Creditors.tcAddressStreet1 = tq1099Creditors.tcAddressStreet1
           t1099Creditors.tcAddressStreet2 = tq1099Creditors.tcAddressStreet2
           t1099Creditors.tcAddressStreet3 = tq1099Creditors.tcAddressStreet3
           t1099Creditors.tcAddressState = t1099Creditors.tcStateCode          /* CA741664 tq1099Creditors.tcAddressState */
           t1099Creditors.tcAddressSearchName = tq1099Creditors.tcAddressSearchName
           t1099Creditors.tcAddressZip = tq1099Creditors.tcAddressZip
           t1099Creditors.tcAddressWebSite = tq1099Creditors.tcAddressWebSite
           t1099Creditors.tcAddressTypeCode = tq1099Creditors.tcAddressTypeCode
           t1099Creditors.tiCountryFormat = tq1099Creditors.tiCountryFormat
           t1099Creditors.tcCountryCode = tq1099Creditors.tcCountryCode
           t1099Creditors.tcCountryDescription = tq1099Creditors.tcCountryDescription
           t1099Creditors.tcCountyCode = tq1099Creditors.tcCountyCode
           t1099Creditors.tcCountyDescription = tq1099Creditors.tcCountyDescription
           t1099Creditors.tcLngCode = tq1099Creditors.tcLngCode
           t1099Creditors.tcStateCode = tq1099Creditors.tcStateCode
           t1099Creditors.tcStateDescription = tq1099Creditors.tcStateDescription
           t1099Creditors.tcTxzTaxZone = tq1099Creditors.tcTxzTaxZone
           t1099Creditors.tcTxuTaxUsage = tq1099Creditors.tcTxuTaxUsage
           t1099Creditors.tcTxclTaxCls = tq1099Creditors.tcTxclTaxCls.

end.
 
for each tq1099CompanyAddress no-lock:    
    for each tq1099Creditors no-lock:            
        <Q-6 run 1099Invoices (all) (Append) (NoCache)
           (input ?, (CompanyId)
            input iiYear, (PaymentYear)
            input tq1099Creditors.tiCreditor_ID, (CreditorID)
            input tq1099CompanyAddress.tiCompany_ID, (LiableCompanyID)
            output dataset tq1099Invoices) in B1099MiscellaneousReport >
    end.
end.

for each tq1099Invoices no-lock:
    create t1099Payments.
    assign t1099Payments.tcPurchaseTypeCode = tq1099Invoices.tcPurchaseTypeCode
           t1099Payments.tcCDocumentStatus = tq1099Invoices.tcCDocumentStatus
           t1099Payments.tdCDocumentOriginalCreditLC = tq1099Invoices.tdCDocumentOriginalCreditLC
           t1099Payments.tiCCollection_ID = tq1099Invoices.tiCCollection_ID
           t1099Payments.tiCDocumentYear = tq1099Invoices.tiCDocumentYear
           t1099Payments.tiCDocument_ID = tq1099Invoices.tiCDocument_ID
           t1099Payments.tiCInvoice_ID = tq1099Invoices.tiCInvoice_ID
           t1099Payments.tiCompany_ID = tq1099Invoices.tiCompany_ID
           t1099Payments.tiCreditor_ID = tq1099Invoices.tiCreditor_ID
           t1099Payments.tiPurchaseType_ID = tq1099Invoices.tiPurchaseType_ID.
end.    

empty temp-table tq1099Invoices.


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "B1099MiscellaneousReport".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "GetReportData".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/b1099miscellaneousreport.getreportdata.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiYear = <parameter value>
       vhParameter::icSupplierCodeFrom = <parameter value>
       vhParameter::icSupplierCodeTo = <parameter value>
       vhParameter::icSupplierTypeFrom = <parameter value>
       vhParameter::icSupplierTypeTo = <parameter value>
       vhParameter::icCompanyAddressFrom = <parameter value>
       vhParameter::icCompanyAddressTo = <parameter value>.

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.