project QadFinancials > class BBox1099Report > method M1099MiscPaperDeclaration

report procedure


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrM1099MiscPaperDeclarationoutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bbox1099report.p)

/* clear the working temptable */
/* --------------------------- */
empty temp-table tqM1099MiscPaperDeclaration.

/* assign the filterdata based in the tfilter recrods */
/* -------------------------------------------------- */
<M-5 run SetDataItemsBasedOnFilterTT  (output viFcReturnSuper (oiReturnStatus)) in BBox1099Report>
if viFcReturnSuper <> 0 and oiReturnStatus  >= 0
then assign oiReturnStatus = viFcReturnSuper.

if viFcReturnSuper < 0
then return.

/* validate the payment year (mandatory) */
/* ------------------------------------- */
if viPaymentYearFilter = ? or
   viPaymentYearFilter = 0
then do:
    <M-58 run SetMessage
       (input  #T-55'You must specify the payment year.':99(64981)T-55# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-821046':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BBox1099Report>
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}.     

/* MAIN FLOW */
do viBoxCompanyIterator = 1 to viBoxCompanyEntries:

    <Q-44 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>

    for each tqBoxesByYearBySupplier where
        tqBoxesByYearBySupplier.tcCInvoiceType         = {&INVOICETYPE-PREPAYMENT}  or
       (tqBoxesByYearBySupplier.tcCInvoiceType         <> {&INVOICETYPE-PREPAYMENT} and
        tqBoxesByYearBySupplier.tcCInvoiceMovementType = {&MOVEMENTTYPE-MOVEMENT})
        no-lock
        break by tqBoxesByYearBySupplier.tcCompanyTaxIDFederal
              by tqBoxesByYearBySupplier.tcCreditorCode
              by tqBoxesByYearBySupplier.tcBox1099Reference:

        /* create by payer federaltaxid in combination with supplier */              
        if first-of(tqBoxesByYearBySupplier.tcCreditorCode)
        then do:
            assign vcSSN = "":U
                   viCnt = 1.
            create tqM1099MiscPaperDeclaration.
            assign tqM1099MiscPaperDeclaration.tcCompanyFederalTaxID      = tqBoxesByYearBySupplier.tcCompanyTaxIDFederal
                   tqM1099MiscPaperDeclaration.tcCompanyName              = tqBoxesByYearBySupplier.tcBusinessRelationName1
                   tqM1099MiscPaperDeclaration.tcCompanyAddress           = tqBoxesByYearBySupplier.tcCompanyStreet1
                   tqM1099MiscPaperDeclaration.tcCompanyAddress2          = tqBoxesByYearBySupplier.tcCompanyStreet2
                   tqM1099MiscPaperDeclaration.tcCompanyAddress3          = tqBoxesByYearBySupplier.tcCompanyStreet3
                   tqM1099MiscPaperDeclaration.tcCompanyCity              = tqBoxesByYearBySupplier.tcCompanyCity
                   tqM1099MiscPaperDeclaration.tcCompanyState             = tqBoxesByYearBySupplier.tcCompanyStateCode
                   tqM1099MiscPaperDeclaration.tcCompanyStateDescription  = tqBoxesByYearBySupplier.tcCompanyStateDescription
                   tqM1099MiscPaperDeclaration.tcCompanyZip               = tqBoxesByYearBySupplier.tcCompanyZip
                   tqM1099MiscPaperDeclaration.tcCompanyTelephone         = tqBoxesByYearBySupplier.tcCompanyTelephone
                   tqM1099MiscPaperDeclaration.tcSupplier                 = tqBoxesByYearBySupplier.tcSupplierName                 
                   tqM1099MiscPaperDeclaration.tcSupplierAddress          = tqBoxesByYearBySupplier.tcSupplierStreet1
                   tqM1099MiscPaperDeclaration.tcSupplierAddress2         = tqBoxesByYearBySupplier.tcSupplierStreet2
                   tqM1099MiscPaperDeclaration.tcSupplierAddress3         = tqBoxesByYearBySupplier.tcSupplierStreet3
                   tqM1099MiscPaperDeclaration.tcSupplierCity             = tqBoxesByYearBySupplier.tcSupplierCity
                   tqM1099MiscPaperDeclaration.tcSupplierState            = tqBoxesByYearBySupplier.tcSupplierStateCode
                   tqM1099MiscPaperDeclaration.tcSupplierStateDescription = tqBoxesByYearBySupplier.tcSupplierStateDescription
                   tqM1099MiscPaperDeclaration.tcSupplierZip              = tqBoxesByYearBySupplier.tcSupplierZip
                   tqM1099MiscPaperDeclaration.tcSupplierTelephone        = tqBoxesByYearBySupplier.tcSupplierTelephone.
            
            if vlMaskSSN = true and 
               length(tqBoxesByYearBySupplier.tcCreditorTaxIDFederal, "CHARACTER":U) > 4
            then do:
                assign vistrLength = length(tqBoxesByYearBySupplier.tcCreditorTaxIDFederal, "CHARACTER":U).
                do vicnt = 1 TO (vistrLength - 4):
                    assign viAsc = ASC(substring(tqBoxesByYearBySupplier.tcCreditorTaxIDFederal, vicnt, 1, "CHARACTER":U)).
                    if viAsc >= 48  and /*0*/
                       viAsc <= 57  or  /*9*/
                       viAsc >= 65  and /*A*/
                       viAsc <= 90  or  /*Z*/
                       viAsc >= 97  and /*a*/
                       viAsc <= 122     /*z*/
                    then assign vcSSN = vcSSN + "*":U.
                    else assign vcSSN = vcSSN + substring(tqBoxesByYearBySupplier.tcCreditorTaxIDFederal, vicnt, 1, "CHARACTER":U).
                end.
                assign tqM1099MiscPaperDeclaration.tcSupplierFederalTaxID = trim(vcSSN + substring(tqBoxesByYearBySupplier.tcCreditorTaxIDFederal,(vistrLength - 3),-1,"CHARACTER":U)).
            end.
            else assign tqM1099MiscPaperDeclaration.tcSupplierFederalTaxID = tqBoxesByYearBySupplier.tcCreditorTaxIDFederal.

        end.
        
        assign vdBoxAmount = vdBoxAmount 
                           + tqBoxesByYearBySupplier.tdPostingLineDebitLC 
                           - tqBoxesByYearBySupplier.tdPostingLineCreditLC
                           + tqBoxesByYearBySupplier.tdCInvoiceMovementDiscountTC.

        if last-of(tqBoxesByYearBySupplier.tcBox1099Reference)
        then do:
        
            case tqBoxesByYearBySupplier.tcBox1099Reference:
                when "1"
                    then assign tqM1099MiscPaperDeclaration.tdBox1Amount    = vdBoxAmount 
                                tqM1099MiscPaperDeclaration.tdBox1MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.
                when "2"
                    then assign tqM1099MiscPaperDeclaration.tdBox2Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox2MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.
                when "3"
                    then assign tqM1099MiscPaperDeclaration.tdBox3Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox3MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "4"
                    then assign tqM1099MiscPaperDeclaration.tdBox4Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox4MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "5"
                    then assign tqM1099MiscPaperDeclaration.tdBox5Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox5MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "6"
                    then assign tqM1099MiscPaperDeclaration.tdBox6Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox6MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "7"
                    then assign tqM1099MiscPaperDeclaration.tdBox7Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox7MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "8"
                    then assign tqM1099MiscPaperDeclaration.tdBox8Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox8MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "9"
                    then assign tqM1099MiscPaperDeclaration.tdBox9Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox9MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "10"
                    then assign tqM1099MiscPaperDeclaration.tdBox10Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox10MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "13"
                    then assign tqM1099MiscPaperDeclaration.tdBox13Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox13MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "14"
                    then assign tqM1099MiscPaperDeclaration.tdBox14Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox14MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "15a"
                    then assign tqM1099MiscPaperDeclaration.tdBox15aAmount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox15aMinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.   
                when "15b"
                    then assign tqM1099MiscPaperDeclaration.tdBox15bAmount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox15bMinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                  
                when "16"
                    then assign tqM1099MiscPaperDeclaration.tdBox16Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox16MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "17"
                    then assign tqM1099MiscPaperDeclaration.tdBox17Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox17MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                when "18"
                    then assign tqM1099MiscPaperDeclaration.tdBox18Amount    = vdBoxAmount
                                tqM1099MiscPaperDeclaration.tdBox18MinAmount = tqBoxesByYearBySupplier.tdBox1099MinimumAmountLC.                    
                    
            end case.        
            assign vdBoxAmount = 0.
        end. /* last-of(tqBoxesByYearBySupplier.tcBox1099Reference) */
    end. /* for each tqBoxesByYearBySupplier */
    
    for each tqM1099MiscPaperDeclaration no-lock:
    
        if   (tqM1099MiscPaperDeclaration.tdBox1Amount    < tqM1099MiscPaperDeclaration.tdBox1MinAmount   or tqM1099MiscPaperDeclaration.tdBox1MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox2Amount    < tqM1099MiscPaperDeclaration.tdBox2MinAmount   or tqM1099MiscPaperDeclaration.tdBox2MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox3Amount    < tqM1099MiscPaperDeclaration.tdBox3MinAmount   or tqM1099MiscPaperDeclaration.tdBox3MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox4Amount    < tqM1099MiscPaperDeclaration.tdBox4MinAmount   or tqM1099MiscPaperDeclaration.tdBox4MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox5Amount    < tqM1099MiscPaperDeclaration.tdBox5MinAmount   or tqM1099MiscPaperDeclaration.tdBox5MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox6Amount    < tqM1099MiscPaperDeclaration.tdBox6MinAmount   or tqM1099MiscPaperDeclaration.tdBox6MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox7Amount    < tqM1099MiscPaperDeclaration.tdBox7MinAmount   or tqM1099MiscPaperDeclaration.tdBox7MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox8Amount    < tqM1099MiscPaperDeclaration.tdBox8MinAmount   or tqM1099MiscPaperDeclaration.tdBox8MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox9Amount    < tqM1099MiscPaperDeclaration.tdBox9MinAmount   or tqM1099MiscPaperDeclaration.tdBox9MinAmount  = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox10Amount   < tqM1099MiscPaperDeclaration.tdBox10MinAmount  or tqM1099MiscPaperDeclaration.tdBox10MinAmount = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox13Amount   < tqM1099MiscPaperDeclaration.tdBox13MinAmount  or tqM1099MiscPaperDeclaration.tdBox13MinAmount = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox14Amount   < tqM1099MiscPaperDeclaration.tdBox14MinAmount  or tqM1099MiscPaperDeclaration.tdBox14MinAmount = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox15aAmount  < tqM1099MiscPaperDeclaration.tdBox15aMinAmount or tqM1099MiscPaperDeclaration.tdBox15aMinAmount= 0)  and    
             (tqM1099MiscPaperDeclaration.tdBox15bAmount  < tqM1099MiscPaperDeclaration.tdBox15bMinAmount or tqM1099MiscPaperDeclaration.tdBox15bMinAmount= 0)  and
             (tqM1099MiscPaperDeclaration.tdBox16Amount   < tqM1099MiscPaperDeclaration.tdBox16MinAmount  or tqM1099MiscPaperDeclaration.tdBox16MinAmount = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox17Amount   < tqM1099MiscPaperDeclaration.tdBox17MinAmount  or tqM1099MiscPaperDeclaration.tdBox17MinAmount = 0)  and
             (tqM1099MiscPaperDeclaration.tdBox18Amount   < tqM1099MiscPaperDeclaration.tdBox18MinAmount  or tqM1099MiscPaperDeclaration.tdBox18MinAmount = 0)
       then
          delete tqM1099MiscPaperDeclaration.
    end. /* tqM1099MiscPaperDeclaration */ 
end. /* END MAIN FLOW */