project QadFinancials > class BDInvoice > method ValidateComponentAllPostDAJournalCode

validation procedure

Description

This method is a submethod of ValidateComponentAllPost.

This method validates the DA Journal Code : this can only be filled for credit notes and where linked to invoice is filled


Parameters


icRowidinputcharacterContents of field tc_Rowid, if the target field is a field of a component temp-table.
icDInvoiceTypeinputcharacterDInvoice Type
iiLinkedDInvoiceIdinputintegerLinked DInvoice ID
icDAJournalCodeinputcharacterDaybook of Debtor Adjustment
blstartJrnlByJrnlIDCodeTypeinput-outputlogicalIs query tqJournalByJournalIDCodeType already started or not ?
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ValidateComponentAllPost


program code (program5/bdinvoice.p)

if (icDInvoiceType     = {&INVOICETYPE-INVOICE} or
        icDInvoiceType     = {&INVOICETYPE-FINANCECHARGE}) and
        icDAJournalCode      <> "":U and
        icDAJournalCode      <> ?
    then do:
        assign vcMessage      = trim(substitute(dynamic-function ('GetTranslation':U in {&TARGETPROCEDURE}, 63162, 'QadFin':U, 'Adjustment is only allowed for invoice type &1, &2 and &3.'),{&INVOICETYPE-CREDITNOTE-TR}, {&INVOICETYPE-INVOICECORRECTION-TR}, {&INVOICETYPE-CREDITNOTECORRECTION-TR}))
               oiReturnStatus = -1.
               
        <M-12 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tDinvoice.tcDaJournalCode':U (icFieldName), 
            input  icDAJournalCode (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  icRowid (icRowid), 
            input  'QadFin-7312':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>       
        
    end.

    if (icDInvoiceType      = {&INVOICETYPE-CREDITNOTE} or 
        icDInvoiceType      = {&INVOICETYPE-INVOICECORRECTION} or
        icDInvoiceType      = {&INVOICETYPE-CREDITNOTECORRECTION}) and
       iiLinkedDInvoiceId <> 0
    then do:
        if icDAJournalCode       = "":U
        then do:
            assign vcMessage      = trim(substitute(dynamic-function ('GetTranslation':U in {&TARGETPROCEDURE}, 63164, 'QadFin':U, 'Adjustment is mandatory for invoice type &1, &2 and &3.'),{&INVOICETYPE-CREDITNOTE-TR}, {&INVOICETYPE-INVOICECORRECTION-TR}, {&INVOICETYPE-CREDITNOTECORRECTION-TR}))
                   oiReturnStatus = -1.
            
             <M-13 run SetMessage
                (input  vcMessage (icMessage), 
                 input  '':U (icArguments), 
                 input  'tDinvoice.tcDAJournalCode':U (icFieldName), 
                 input  icDAJournalCode (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  icRowid (icRowid), 
                 input  'QadFin-7313':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BDInvoice>         
        end.
        else do:
           if blstartJrnlByJrnlIDCodeType = false
           then do:
               <Q-23 run JournalByJournalIDCodeType  (Start) in BJournal >
               assign blstartJrnlByJrnlIDCodeType = true.
           end.
           <Q-22 run JournalByJournalIDCodeType (all) (Read) (NoCache)
              (input t_sDInvoice.Company_ID, (CompanyId)
               input ?, (JournalID)
               input icDAJournalCode, (JournalCode)
               input {&JOURNALTYPE-DEBTORADJUSTMENT}, (JournalTypeCode)
               output dataset tqJournalByJournalIDCodeType) in BJournal >
            find first tqJournalByJournalIDCodeType where 
                       tqJournalByJournalIDCodeType.tcJournalCode     = icDAJournalCode and
                       tqJournalByJournalIDCodeType.tcJournalTypeCode = {&JOURNALTYPE-DEBTORADJUSTMENT}
                       no-error.
            if not available tqJournalByJournalIDCodeType
            then do:
                assign vcMessage      = trim(#T-18'Adjustment daybook not found':255(999890161)T-18#)
                       oiReturnStatus = -1.
                <M-21 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tDinvoice.tcDAJournalCode':U (icFieldName), 
                    input  icDAJournalCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  icRowid (icRowid), 
                    input  'QadFin-7449':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDInvoice>       
                return.
                
            end.
            
            if not tqJournalByJournalIDCodeType.tlJournalIsActive
            then do:
                assign vcMessage      = trim(dynamic-function ('GetTranslation':U in {&TARGETPROCEDURE}, 1077, 'QadFin':U, 'Only active daybooks are allowed.'))
                       oiReturnStatus = -1.
               <M-14 run SetMessage
                (input  vcMessage (icMessage), 
                 input  '':U (icArguments), 
                 input  'tDinvoice.tcDAJournalCode':U (icFieldName), 
                 input  icDAJournalCode (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  icRowid (icRowid), 
                 input  'QadFin-7314':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BDInvoice>        
            end.
            
            if tqJournalByJournalIDCodeType.tcJournalTypeCode <> {&JOURNALTYPE-DEBTORADJUSTMENT}
            then do:
                assign vcMessage      = trim(substitute(dynamic-function ('GetTranslation':U in {&TARGETPROCEDURE}, 1078, 'QadFin':U, 'The daybook has an invalid daybook type (&1).'),tqJournalByJournalIDCodeType.tcJournalTypeCode)) + chr(10) +
                                        trim(substitute(dynamic-function ('GetTranslation':U in {&TARGETPROCEDURE}, 1222, 'QadFin':U, 'Only the following daybook type is allowed: &1.'),{&JOURNALTYPE-DEBTORADJUSTMENT}))
                       oiReturnStatus = -1.
               <M-15 run SetMessage
                (input  vcMessage (icMessage), 
                 input  '':U (icArguments), 
                 input  'tDinvoice.tcDAJournalCode':U (icFieldName), 
                 input  icDAJournalCode (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  icRowid (icRowid), 
                 input  'QadFin-7315':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BDInvoice>   
            end.
        end.
    end.