project QadFinancials > class BCInvoice > method CreateCInvoiceMovementsCrossCyJrnl

Description

CreateCInvoiceMovementsCrossCyJrnl; sub -mehtod of CreateCInvoiceMovementsCrossCy that is called in case the control-posting-line of the posting should be replaced by a cross-company account.


Parameters


icPostingRowIdinputcharacterPostingRowid
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CreateCInvoiceMovementsCrossCy


program code (program7/bcinvoice.p)

/* ================================================================================= */
    /* Get the JournalCode of the current posting. This JournalCode should also exist in */
    /* the company of the CInvoice and the type of these 2 Journals should be the same   */
    /* ================================================================================= */
    
    /* ==================================================================================== */
    /* Get the Journal of the current Posting; an instance of BJournalEntry is already open */
    /* ==================================================================================== */
    <M-1 run GetPostingHeaderByPostingId (input  ? (iiPostingId), 
                                      input  icPostingRowId (icPostingRowID), 
                                      output viDummy (oiPostingYear), 
                                      output viDummy (oiPostingPeriod), 
                                      output vtDummy (otPostingDate), 
                                      output vcCurrentPostingJournalCode (ocPostingJournalCode), 
                                      output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.    
    if oiReturnStatus              < 0 or 
       vcCurrentPostingJournalCode = "":U or 
       vcCurrentPostingJournalCode = ?
    then do :
        assign vcMessage      = trim(substitute(#T-5'A cross-company error occurred. The system cannot find the originating posting.':255(31362)t-5#)) + chr(10) + 
                                trim(substitute(#T-6'Searched for a posting instance with row ID: &1':222(31363)T-6#,icPostingRowId))
               oiReturnStatus = -3.
        <M-4 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QadFin-4814':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        Return.
    end. /* if */
    
    /* ==================================================================================== */
    /* Get the JournalType of Journal of the current Posting (in the current company)       */      
    /* ==================================================================================== */
    <Q-2 run JournalByJournalIDCodeType (all) (Read) (Cache)
       (input viCompanyId, (CompanyId)
        input ?, (JournalID)
        input vcCurrentPostingJournalCode, (JournalCode)
        input ?, (JournalTypeCode)
        output dataset tqJournalByJournalIDCodeType) in BJournal>
    find tqJournalByJournalIDCodeType where 
         tqJournalByJournalIDCodeType.tcJournalCode = vcCurrentPostingJournalCode
         no-lock no-error.
    if not available tqJournalByJournalIDCodeType  
    then do :
        assign vcMessage      = trim(substitute(#T-8'A cross-company error occurred. The daybook used in the originating posting has not been defined.':255(31364)t-8#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-9'Daybook code: &1':222(31365)T-9#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-10'Entity ID of the posting: &1':222(31369)T-10#,string(viCompanyId)))
               oiReturnStatus = -3.
        <M-7 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QadFin-4815':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        Return.
    end. /* if */
    if tqJournalByJournalIDCodeType.tcJournalTypeCode = "":U or 
       tqJournalByJournalIDCodeType.tcJournalTypeCode = ? 
    then do :
        assign vcMessage      = trim(substitute(#T-12'A cross-company error occurred. The daybook type of the daybook (&1) used in the originating posting has not been defined.':255(31367)t-12#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-13'Daybook code: &1':222(31365)T-13#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-14'Entity ID of the posting: &1':222(31369)T-14#,string(viCompanyId)))
               oiReturnStatus = -3.
        <M-11 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QadFin-4816':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        Return.
    end. /* if */
    assign vcCurrentPostingJournalTypeCode = tqJournalByJournalIDCodeType.tcJournalTypeCode.
    
    /* ==================================================================================== */
    /* Get the Journal in the company of the CInvoice (not the current company)             */            
    /* ==================================================================================== */
    <Q-3 run JournalByJournalIDCodeType (all) (Read) (Cache)
       (input tqCInvoiceByCyIDYearJrnlVchr.tiCompany_ID, (CompanyId)
        input ?, (JournalID)
        input vcCurrentPostingJournalCode, (JournalCode)
        input ?, (JournalTypeCode)
        output dataset tqJournalByJournalIDCodeType) in BJournal>
    find tqJournalByJournalIDCodeType where 
         tqJournalByJournalIDCodeType.tcJournalCode = vcCurrentPostingJournalCode
         no-lock no-error.
    if not available tqJournalByJournalIDCodeType 
    then do :
        assign vcMessage      = trim(substitute(#T-16'A cross-company error occurred. The system cannot find the daybook (&1) used in the originating posting.':255(31368)t-16#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-19'This daybook should be defined in the entity of the invoice also.':255(31372)T-19#)) + chr(10) + 
                                trim(substitute(#T-17'Daybook code: &1':222(31365)T-17#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-18'Entity ID of the posting: &1':222(31369)T-18#,string(viCompanyId))) + chr(10) + 
                                trim(substitute(#T-20'Entity ID of the invoice: &1':222(31371)T-20#,string(tqCInvoiceByCyIDYearJrnlVchr.tiCompany_ID)))
               oiReturnStatus = -3.
        <M-15 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QadFin-4817':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        Return.
    end. /* if */
    if tqJournalByJournalIDCodeType.tcJournalTypeCode <> vcCurrentPostingJournalTypeCode
    then do :
        assign vcMessage      = trim(substitute(#T-22'A cross-company error occurred. The daybook type (&1) of the originating posting is different than the daybook type used with the same daybook code in the entity of the invoice.':255(31373)t-22#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-23'You must define this daybook with the same daybook type in both the entity of the invoice and the current entity.':255(31374)t-23#)) + chr(10) + 
                                trim(substitute(#T-24'Daybook code: &1':222(31365)T-24#,vcCurrentPostingJournalCode)) + chr(10) + 
                                trim(substitute(#T-27'Daybook type of the daybook in the entity of the posting: &1':222(31375)T-27#,vcCurrentPostingJournalTypeCode)) + chr(10) + 
                                trim(substitute(#T-29'Daybook type of the daybook in the entity of the invoice: &1':222(31376)T-29#,tqJournalByJournalIDCodeType.tcJournalTypeCode)) + chr(10) + 
                                trim(substitute(#T-25'Entity ID of the posting: &1':222(31369)T-25#,string(viCompanyId))) + chr(10) + 
                                trim(substitute(#T-26'Entity ID of the invoice: &1':222(31371)T-26#,string(tqCInvoiceByCyIDYearJrnlVchr.tiCompany_ID)))
               oiReturnStatus = -3.
        <M-21 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QadFin-4818':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        Return.
    end. /* if */