project QadFinancials > class BCInvoice > method ValidateComponentPostJournal

Description

This method is a submethod of ValidateComponentPost.

This method does some validations on the creditor invoice journal.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ValidateComponentPost


program code (program5/bcinvoice.p)

assign vlJournalNotInDaybookSet = false.

if (t_sCInvoice.tc_Status     = "N":U or
    t_sCInvoice.tc_Status     = "C":U and
   (t_sCInvoice.CInvoiceType <> t_iCInvoice.CInvoiceType or
    t_sCInvoice.Journal_ID   <> t_iCInvoice.Journal_ID)) and
    t_sCInvoice.Journal_ID   <> 0                       and 
    t_sCInvoice.Journal_ID   <> ?
then do:
    PROCESSBLOCK: DO:
        /* If daybook sets are in use check to see if the user can have a journal that is   */
        /* not part of that daybook set if not check that the journal is in the daybook set */
        if  vlPOCAllowUpdateDaybookOnInv        = false and
            t_sCInvoice.CInvoiceDayBookSetCode <> "":U  and 
            t_sCInvoice.CInvoiceDayBookSetCode <> ?     and
            t_sCInvoice.tcJournalCode <> "":U           and
            t_sCInvoice.tcJournalCode <> ?             
        then do : 
            <Q-11 run DaybookSetByCodeBySite (all) (Read) (Cache)
               (input t_sCInvoice.CInvoiceDayBookSetCode, (DaybookSetCode)
                input ?, (Site)
                input vcDomainCode, (DomainCode)
                output dataset tqDaybookSetByCodeBySite) in BMfgDaybookSet>
            find first tqDaybookSetByCodeBySite 
                 where tqDaybookSetByCodeBySite.tcdybs_code = t_sCInvoice.CInvoiceDayBookSetCode no-error.
            if available tqDaybookSetByCodeBySite 
            then do :
                if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} and
                   t_sCInvoice.tcJournalCode <> tqDaybookSetByCodeBySite.tcdybs_invoices_dybk
                then vlJournalNotInDaybookSet = true.    
                else if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE} and
                   t_sCInvoice.tcJournalCode <> tqDaybookSetByCodeBySite.tcdybs_credit_dybk
                then vlJournalNotInDaybookSet = true.
                else if t_sCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION} and
                   t_sCInvoice.tcJournalCode <> tqDaybookSetByCodeBySite.tcdybs_neg_criv_dybk
                then vlJournalNotInDaybookSet = true.
                else if t_sCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION} and
                   t_sCInvoice.tcJournalCode <> tqDaybookSetByCodeBySite.tcdybs_neg_crcn_dybk
                then vlJournalNotInDaybookSet = true.            
            end. /* if available tqDaybookSetByCodeBySite */      
        end. /* if  vlPOCAllowUpdateDaybookOnInv = false and */
        
        if vlJournalNotInDaybookSet
        then do:
            <M-12 run SetMessage
               (input  trim(#T-14'The daybook is not valid for the daybook set':255(999890925)T-14#) (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoice.tcJournalCode':U (icFieldName), 
                input  t_sCInvoice.tcJournalCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoice.tc_Rowid (icRowid), 
                input  'QadFin-9452':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        
            assign oiReturnStatus = -1.
            LEAVE PROCESSBLOCK.
        end.

        
        <Q-6 run JournalByJournalIDCodeType (all) (Read) (Cache)
           (input ?, (CompanyId)
            input t_sCInvoice.Journal_ID, (JournalID)
            input ?, (JournalCode)
            input ?, (JournalTypeCode)
            output dataset tqJournalByJournalIDCodeType) in BJournal>
        find first tqJournalByJournalIDCodeType where
                   tqJournalByJournalIDCodeType.tiJournal_ID     = t_sCInvoice.Journal_ID and
                   tqJournalByJournalIDCodeType.tcJournalControl = {&JOURNALCONTROL-FINANCIAL}
                   no-error.
        if available tqJournalByJournalIDCodeType
        then do:
            if t_sCInvoice.tc_Status   = "N":U or
               t_sCInvoice.tc_Status   = "C":U and
               t_sCInvoice.Journal_ID <> t_iCInvoice.Journal_ID
            then do:
                <M-4 run ValIsActive
                   (input  t_sCInvoice.tcJournalCode (icTargetField), 
                    input  'tCInvoice.tcJournalCode':U (icTargetFieldName), 
                    input  t_sCInvoice.tc_Rowid (icRowid), 
                    input  tqJournalByJournalIDCodeType.tlJournalIsActive (ilIsActive), 
                    input  trim(#T-2'Daybook':30(17643)T-2#) (icParentObjectLabel), 
                    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>    
                if viFcReturnSuper < 0 or
                   oiReturnStatus  = 0
                then assign oiReturnStatus = viFcReturnSuper.
            end.    
            if t_sCInvoice.CInvoiceType                        = {&INVOICETYPE-INVOICE}                and
               tqJournalByJournalIDCodeType.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORINVOICE}        or
               t_sCInvoice.CInvoiceType                        = {&INVOICETYPE-CREDITNOTE}             and
               tqJournalByJournalIDCodeType.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORCREDITNOTE}     or
               t_sCInvoice.CInvoiceType                        = {&INVOICETYPE-INVOICECORRECTION}      and
               tqJournalByJournalIDCodeType.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORINVOICECORRECT} or
               t_sCInvoice.CInvoiceType                        = {&INVOICETYPE-CREDITNOTECORRECTION}   and
               tqJournalByJournalIDCodeType.tcJournalTypeCode <> {&JOURNALTYPE-CREDITORCREDITNOTECORRECT}
            then do:
                <M-5 run SetMessage
                   (input  trim(#T-3'The daybook has an invalid daybook type ($1).':255(65436)T-3#) (icMessage), 
                    input  tqJournalByJournalIDCodeType.tcJournalTypeCode (icArguments), 
                    input  'tCInvoice.tcJournalCode':U (icFieldName), 
                    input  t_sCInvoice.tcJournalCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sCInvoice.tc_Rowid (icRowid), 
                    input  'QadFin-7052':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>    
                assign oiReturnStatus = -1.
            end.
        end.
        else do:
            <M-3 run SetMessage
               (input  trim(#T-1'The specified daybook code is not defined in the system or is invalid.':200(16192)t-1#) (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoice.tcJournalCode':U (icFieldName), 
                input  t_sCInvoice.tcJournalCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoice.tc_Rowid (icRowid), 
                input  'QadFin-7051':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>    
            assign oiReturnStatus = -1.
        end.
    END. /*PROCESSBLOCK */
end.