project QadFinancials > class BBox1099Report > method M1099MiscReport

report procedure


Parameters


icLanguageCodeinputcharacterLanguage Code.
tFilterinputtemp-tableTemp table to store input parameters.
dcrM1099MiscReportoutputdatasetDataset of 1099MiscReport.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bbox1099report.p)

empty temp-table tqM1099MiscReport.

<M-1 run GetReportLabels
   (input  'M1099MiscReport':U (icReportName), 
    input  icLanguageCode (icLanguageCode), 
    input  tFilter (tFilter), 
    output tqHeader (tqHeader), 
    output tqFilter (tqFilter), 
    output tqText (tqText), 
    output oiReturnStatus (oiReturnStatus)) in BBox1099Report>
if oiReturnStatus <> 0
then return.

/* ========================================================== */ 
/* Assign the filter-data-items based on the tFilter records  */
/* ========================================================== */ 

<M-15 run SetDataItemsBasedOnFilterTT
   (output oiReturnStatus (oiReturnStatus)) in BBox1099Report>   

/* Validate filter */
if viPaymentYearFilter = ? or
   viPaymentYearFilter = 0
then do:
    <M-16 run SetMessage
       (input  #T-21'You must specify the payment year.':99(64981)T-21# (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-6870':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output oiReturnStatus (oiReturnStatus)) in BBox1099Report>
        assign oiReturnStatus = -1.
    return.
end.

assign vcjournaltypelist  = {&JOURNALTYPE-BANKINGENTRY} + "," +
                            {&JOURNALTYPE-CREDITORPAYMENT}
       vcinvoicetypelist  = {&INVOICETYPE-INVOICE}              + "," +
                            {&INVOICETYPE-CREDITNOTE}           + "," +
                            {&INVOICETYPE-INVOICECORRECTION}    + "," +
                            {&INVOICETYPE-CREDITNOTECORRECTION} + "," +
                            {&INVOICETYPE-ADJUSTMENT}           + "," +
                            {&INVOICETYPE-PREPAYMENT}
       vcMovementTypeList = {&MOVEMENTTYPE-INITIAL} + "," +
                            {&MOVEMENTTYPE-MOVEMENT}.

do viBoxCompanyIterator = 1 to viBoxCompanyEntries:
       
    if vlCheckUnlinkedInvoices = true
    then do:
        <Q-27 run GetPurchaseTypes (all) (Read) (NoCache)
           (input viBoxCurrentCompany_ID, (CompanyId)
            input vtStartDate, (StartDate)
            input vtEndDate, (EndDate)
            output dataset tqGetPurchaseTypes) in BBox1099Report >            
        
        for each tqGetPurchaseTypes break by tiPurchaseType_ID:
            if first-of(tqGetPurchaseTypes.tiPurchaseType_ID) 
            then do:
                <Q-30 assign vlFcQueryRecordsAvailable = GetPurchaseTypeLink (NoCache)
                   (input tqGetPurchaseTypes.tiPurchaseType_ID, (PurchaseTypeID)
                    input viPaymentYearFilter, (PaymentYear)) in BBox1099Report >
            end.
            if vlFcQueryRecordsAvailable = false then leave. 
        end.      
           
        if vlFcQueryRecordsAvailable = false 
        then do:
            <M-25 run SetMessage
               (input  #T-26'Payments were found on invoices that are not linked to a 1099 Box.':99(65014)T-26# (icMessage), 
                input  '' (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '' (icRowid), 
                input  'QadFin-6885':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output oiReturnStatus (oiReturnStatus)) in BBox1099Report>
                assign oiReturnStatus = -1.
            return.
        end.     
    end.

    
    <Q-17 run CompanyWithTaxRep (all) (Read) (NoCache)
       (input viBoxCurrentCompany_ID, (CompanyId)
        output dataset tqCompanyWithTaxRep) in BBox1099Report >

    for first tqCompanyWithTaxRep where 
              tqCompanyWithTaxRep.tcAddressTypeCode = "HEADOFFICE" and
              (tqCompanyWithTaxRep.tcAddressTaxIDFederal = ? or    
              tqCompanyWithTaxRep.tcAddressTaxIDFederal = ''):
        <M-18 run SetMessage
           (input  #T-20'All entities must have a federal tax ID.':99(64980)T-20# (icMessage), 
            input  '' (icArguments), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'QadFin-6873':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output oiReturnStatus (oiReturnStatus)) in BBox1099Report>
           assign oiReturnStatus = -1.
        return. 
    end.   
end.
<Q-84 run BoxesByYearBySupplier (all) (Read) (NoCache)
   (input viBoxCurrentCompany_ID, (CompanyId)
    input vcjournaltypelist, (JournalTypeList)
    input vcinvoicetypelist, (InvoiceTypeList)
    input vcMovementTypeList, (InvoiceMovementType)
    input viPaymentYearFilter, (PaymentYear)
    input vcFromSupplierFilter, (SupplierFrom)
    input vcBoxFederalTaxIDFilter, (FederalTaxID)
    input vcToSupplierFilter, (SupplierTill)
    input vcSupplierTypeFilter, (CreditorTypeList)
    input vcBoxEntityFilter, (CompanyList)
    input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
    output dataset tqBoxesByYearBySupplier) in BBox1099Report> 
    
assign viInvoiceVoucher = 0.
for each tqBoxesByYearBySupplier where
         tqBoxesByYearBySupplier.tcCInvoiceType         = {&INVOICETYPE-PREPAYMENT}  or
        (tqBoxesByYearBySupplier.tcCInvoiceType         <> {&INVOICETYPE-PREPAYMENT} and
         tqBoxesByYearBySupplier.tcCInvoiceMovementType = {&MOVEMENTTYPE-MOVEMENT})
         no-lock 
         by tqBoxesByYearBySupplier.tcCompanyTaxIDFederal
         by tqBoxesByYearBySupplier.tcCreditorCode 
         by tqBoxesByYearBySupplier.tcBox1099Reference:
         
    create tqM1099MiscReport.
    assign tqM1099MiscReport.tcCompanyAddress       = tqBoxesByYearBySupplier.tcCompanyStreet1
           tqM1099MiscReport.tcCompanyCity          = tqBoxesByYearBySupplier.tcCompanyCity
           tqM1099MiscReport.tcCompanyName          = tqBoxesByYearBySupplier.tcBusinessRelationName1
           tqM1099MiscReport.tcCompanyState         = tqBoxesByYearBySupplier.tcCompanyStateCode
           tqM1099MiscReport.tcCompanyTelephone     = tqBoxesByYearBySupplier.tcCompanyTelephone
           tqM1099MiscReport.tcCompanyZip           = tqBoxesByYearBySupplier.tcCompanyZip
           tqM1099MiscReport.tcFederalTaxID         = tqBoxesByYearBySupplier.tcCompanyTaxIDFederal
           tqM1099MiscReport.tcSupplier             = tqBoxesByYearBySupplier.tcSupplierName
           tqM1099MiscReport.tcSupplierAddress      = tqBoxesByYearBySupplier.tcSupplierStreet1
           tqM1099MiscReport.tcSupplierCity         = tqBoxesByYearBySupplier.tcSupplierCity
           tqM1099MiscReport.tcSupplierFederalTaxID = tqBoxesByYearBySupplier.tcCreditorTaxIDFederal
           tqM1099MiscReport.tcSupplierState        = tqBoxesByYearBySupplier.tcSupplierStateCode
           tqM1099MiscReport.tcSupplierTelephone    = tqBoxesByYearBySupplier.tcSupplierTelephone
           tqM1099MiscReport.tcSupplierZip          = tqBoxesByYearBySupplier.tcSupplierZip
           tqM1099MiscReport.tcBoxReferenceNumber   = tqBoxesByYearBySupplier.tcBox1099Reference
           tqM1099MiscReport.tdMinAmount            = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC
           tqM1099MiscReport.tlShowTransactions     = vlShowTransactionDetails
           tqM1099MiscReport.tlShowEntity           = vlShowEntityDetails
           tqM1099MiscReport.tcBoxReportDescription = vcBoxReportDescription
           tqM1099MiscReport.tdVoucherAmountPaid    = tqBoxesByYearBySupplier.tdPostingLineDebitLC
                                                    - tqBoxesByYearBySupplier.tdPostingLineCreditLC
                                                    + tqBoxesByYearBySupplier.tdCInvoiceMovementDiscountTC                   
           tqM1099MiscReport.tcEntity               = tqBoxesByYearBySupplier.tcCompanyCode
           tqM1099MiscReport.tcVoucherNumber        = STRING(tqBoxesByYearBySupplier.tiPostingVoucher) 
           tqM1099MiscReport.tcVoucherYearPeriod    = STRING(tqBoxesByYearBySupplier.tiPostingYear) + "/" + STRING(tqBoxesByYearBySupplier.tiPostingPeriod)
           tqM1099MiscReport.ttVoucherPayDate       = tqBoxesByYearBySupplier.ttPostingDate
           tqM1099MiscReport.tcBoxCodeDescription   = tqBoxesByYearBySupplier.tcBox1099Description
           tqM1099MiscReport.tcPurchaseType         = tqBoxesByYearBySupplier.tcPurchaseTypeCode
           tqM1099MiscReport.tcPayNumber            = tqBoxesByYearBySupplier.tcJournalCode + "/" + STRING(tqBoxesByYearBySupplier.tiPostingVoucher)
           tqM1099MiscReport.tcCurrencyCode         = tqBoxesByYearBySupplier.tcCurrencyCode.               
        
    if vcBoxReportDescription <> ?  and 
       vcBoxReportDescription <> "" 
    then assign tqM1099MiscReport.tcBoxReportDescription = vcBoxReportDescription.
    else assign tqM1099MiscReport.tcBoxReportDescription = "".
end. /* for each tqBox1099BySupplier */