project QadFinancials > class BDDocument > method AdditionalUpdatesPostingDocCtrl2


Parameters


ilGLIsDivisionAccountinputlogical
icPostingRowidinputcharacter
icGLCodeinputcharacter
ilDebitinputlogical
icDDocumentStatusinputcharacter
icAllocationKeyinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.AdditionalUpdatesPostingDocCtrl


program code (program5/bddocument.p)

/* Error handling */
assign oiReturnStatus = -98
       viLocalReturn  = 0.

MAIN_BLOCK:
do on error undo, leave:
    /* Get the default CostCentreCode and ProjectCode */
    <Q-8 run GLByGLAnalysis (all) (Read) (Cache)
       (input viCompanyId, (CompanyId)
        input icGLCode, (GLCode)
        input 0, (GLID)
        output dataset tqGLByGLAnalysis) in BGL>
    find tqGLByGLAnalysis where
         tqGLByGLAnalysis.tcGLCode = icGLCode
         no-lock no-error.
    if available tqGLByGLAnalysis
    then assign vcCostCentreCode = tqGLByGLAnalysis.tcCostCentreCode
                vcProjectCode    = tqGLByGLAnalysis.tcProjectCode.
    else assign vcCostCentreCode = '':U
                vcProjectCode    = '':U.
    /* Get Business Relation Intercompany Code */
   <Q-89 run DebtorByBusinessRelation (all) (Read) (NoCache)
       (input ?, (CompanyId)
        input tDDocument.tcDebtorCode, (DebtorCode)
        input ?, (DebtorId)
        input ?, (BusinessRelationID)
        output dataset tqDebtorByBusinessRelation) in BDebtor>
    find first tqDebtorByBusinessRelation where 
               tqDebtorByBusinessRelation.tcDebtorCode = tDDocument.tcDebtorCode
               no-lock no-error.
    if available tqDebtorByBusinessRelation 
    then do :
        <Q-74 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
           (input tqDebtorByBusinessRelation.tiBusinessRelation_ID, (BusinessRelation_ID)
            output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation>
        find first tqBusinessRelationByIDAllInfo where  
                   tqBusinessRelationByIDAllInfo.tiBusinessRelation_ID = tqDebtorByBusinessRelation.tiBusinessRelation_ID
                   no-lock no-error.   
        if available tqBusinessRelationByIDAllInfo and 
                     tqBusinessRelationByIDAllInfo.tlBusinessRelationIsInterco
        then assign  vcBusinessRelationICCode =  tqBusinessRelationByIDAllInfo.tcBusinessRelationICCode .
        else assign  vcBusinessRelationICCode = "":U .
        
    end.                      
    /* Make posting to PIP account */
    if ilGLIsDivisionAccount
    then for each tDivisionDDoc:
        empty temp-table tDefaultSafsDDoc.
        <M-1 run AddControlPosting
           (input  icPostingRowid (icPostingtcRowid), 
            input  icGLCode (icGLCode), 
            input  tDivisionDDoc.tcDivisionCode (icDivisionCode), 
            input  vcBusinessRelationICCode (icIntercoBusinessRelationCode), 
            input  tDDocument.tcCurrencyCode (icCurrencyCode), 
            input  if ilDebit then tDivisionDDoc.tdAmountTC else 0 (idDebitTC), 
            input  if ilDebit then tDivisionDDoc.tdAmountLC else 0 (idDebitLC), 
            input  if ilDebit then tDivisionDDoc.tdAmountCC else 0 (idDebitCC), 
            input  if ilDebit then 0 else tDivisionDDoc.tdAmountTC (idCreditTC), 
            input  if ilDebit then 0 else tDivisionDDoc.tdAmountLC (idCreditLC), 
            input  if ilDebit then 0 else tDivisionDDoc.tdAmountCC (idCreditCC), 
            input  tDDocument.tcPostingText (icText), 
            input  tDDocument.DDocument_ID (iiMasterId), 
            input  tDDocument.DDocument_ID (iiTransactionId), 
            input  tDivisiondDoc.tdLCExchangeRate (idExchangeRate), 
            input  tDivisionDDoc.tdLCExchangeRateScale (idExchangeRateScale), 
            input  tDivisionDDoc.tdCCExchangeRate (idPostingLineCCRate), 
            input  tDivisionDDoc.tdCCExchangeRateScale (idPostingLineCCScale), 
            input  icAllocationKey (icAllocationKey), 
            input  vcCostCentreCode (icCostCentreCode), 
            input  vcProjectCode (icProjectCode), 
            input  tDefaultSafsDDoc (tDefaultSafs), 
            output viPostingLineId (oiPostingLineId), 
            input  false (ilLinkedCrCyDaemonReqExists), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
        if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    
        /* Add record in CDocumentPostingLine */
        <M-2 run AdditionalUpdatesDDocumentPostingLine
           (input  viPostingLineId (iiPostingLineId), 
            input  icDDocumentStatus (icDDocumentStatus), 
            output viFcReturnSuper (oiReturnStatus)) in BDDocument>
        if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    
        /* Create DPay */
        <M-3 run AdditionalUpdatesDPay
           (input  viPostingLineId (iiPostingLineId), 
            input  ilGLIsDivisionAccount (ilGLIsDivisionAccount), 
            input  tDivisionDDoc.tcDivisionCode (icDivisionCode), 
            output viFcReturnSuper (oiReturnStatus)) in BDDocument>
        if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    end.
    else do:
        empty temp-table tDefaultSafsDDoc.
        <M-4 run AddControlPosting
           (input  icPostingRowid (icPostingtcRowid), 
            input  icGLCode (icGLCode), 
            input  '':U (icDivisionCode), 
            input  vcBusinessRelationICCode (icIntercoBusinessRelationCode), 
            input  tDDocument.tcCurrencyCode (icCurrencyCode), 
            input  if ilDebit then tDDocument.DDocumentOriginalDebitTC else 0 (idDebitTC), 
            input  if ilDebit then tDDocument.DDocumentOriginalDebitLC else 0 (idDebitLC), 
            input  if ilDebit then tDDocument.DDocumentOriginalDebitCC else 0 (idDebitCC), 
            input  if ilDebit then 0 else tDDocument.DDocumentOriginalDebitTC (idCreditTC), 
            input  if ilDebit then 0 else tDDocument.DDocumentOriginalDebitLC (idCreditLC), 
            input  if ilDebit then 0 else tDDocument.DDocumentOriginalDebitCC (idCreditCC), 
            input  tDDocument.tcPostingText (icText), 
            input  tDDocument.DDocument_ID (iiMasterId), 
            input  tDDocument.DDocument_ID (iiTransactionId), 
            input  tDDocument.DDocumentExchangeRate (idExchangeRate), 
            input  tDDocument.DDocumentRateScale (idExchangeRateScale), 
            input  tDDocument.DDocumentCCRate (idPostingLineCCRate), 
            input  tDDocument.DDocumentCCScale (idPostingLineCCScale), 
            input  icAllocationKey (icAllocationKey), 
            input  vcCostCentreCode (icCostCentreCode), 
            input  vcProjectCode (icProjectCode), 
            input  tDefaultSafsDDoc (tDefaultSafs), 
            output viPostingLineId (oiPostingLineId), 
            input  false (ilLinkedCrCyDaemonReqExists), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
        if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    
        /* Add record in CDocumentPostingLine */
        <M-5 run AdditionalUpdatesDDocumentPostingLine
           (input  viPostingLineId (iiPostingLineId), 
            input  icDDocumentStatus (icDDocumentStatus), 
            output viFcReturnSuper (oiReturnStatus)) in BDDocument>
        if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    
        /* Create DPay */
        <M-6 run AdditionalUpdatesDPay
           (input  viPostingLineId (iiPostingLineId), 
            input  ilGLIsDivisionAccount (ilGLIsDivisionAccount), 
            input  '':U (icDivisionCode), 
            output viFcReturnSuper (oiReturnStatus)) in BDDocument>
        if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    end.
end. /* MAIN_BLOCK */

/* Error handling */
assign oiReturnStatus = viLocalReturn.