project QadFinancials > class BAPMatching > method AdditionalUpdatesAllLinesPLExpenseAcruals

Description

AdditionalUpdatesAllLinesPLExpenseAcruals; submethod of AdditionalUpdatesAllLines that is located in the same segment and that takes care of the creation of 2 posting-lines on accrual-aacounts for the logistic-charges


Parameters


icAPMatchingPostingRowidIDinputcharacterAPMatchingPostingRowidID
icPostingTextinputcharacterPostingText
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.AdditionalUpdatesAllLines


program code (program6/bapmatching.p)

/* ===================================================================================================== */
    /* If tAPMatchingLn.APMatchingLnPvodIsLgCharge = false and tAPMatchingLn.APMatchingLnPvodItemType = Memo */
    /* and the value of the GL, Division or CostCentre differs from the corresponding fields in pvod_det,    */
    /* then we will;                                                                                         */
    /* - create a first posting-line that reversed the posting-line that was created during the creation of  */
    /*   the pvod_det and used pvod_accrual_acc, pvod_accrual_sub and pvod_accrual_cc                        */
    /* - create a second posting-line that is similar to the first one but with the newly specified GL,      */
    /*   Division, CostCentre and Project and with the amount shifted from credit>debit and debit>credit     */
    /* The amount equals the UnitPrice-TC (at receipt) * Allocated-Qty                                       */
    /* ===================================================================================================== */
    
    /* ======================== */
    /* Set default ReturnStatus */
    /* ======================== */
    assign oiReturnStatus = -98.
    
    /* ===================================================================================================== */
    /* Elementary check to avoid mis-usage of this method                                                    */
    /* ===================================================================================================== */
    if tAPMatchingLn.APMatchingLnPvodIsLgCharge <> false                             or 
       tAPMatchingLn.APMatchingLnPvodItemType   <> {&APMATCHINGLNPVODITEMTYPE-MEMO}  or
       (tAPMatchingLn.tcGLCode         = tAPMatchingLn.APMatchingLnPvodGLCode  and 
        tAPMatchingLn.tcDivisionCode   = tAPMatchingLn.APMatchingLnPvodDivCode and
        tAPMatchingLn.tcCostCentreCode = tAPMatchingLn.APMatchingLnPvodCCCode  and 
        tAPMatchingLn.tcProjectCode    = tAPMatchingLn.APMatchingLnPvodPrjCode)
    then do :
        assign oiReturnStatus  = -3
               vcMsgAPMatching = trim(substitute(#T-13'Internal error: invalid call to the method that creates the posting lines on the expense accounts for the Memo items':255(53212)T-13#)) + chr(10) + 
                                 trim(substitute(#T-14'Pending invoice that includes logistic charges &1.':234(53213)T-14#,string(tAPMatchingLn.APMatchingLnPvodIsLgCharg))) + chr(10) + 
                                 trim(substitute(#T-15'Item type: &1.':234(53215)T-15#,tAPMatchingLn.APMatchingLnPvodItemType)) + chr(10) + 
                                 trim(substitute(#T-16'Technical details: &1.':222(55526)T-16#, "Expense/1":U)).
        <M-12 run SetMessage (input  vcMsgAPMatching (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  'QadFin-5435':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        Return.
    end. /* if tAPMatchingLn.APMatchingLnPvodIsLgCharge <> false and  */
    
    /* ============================================================================ */
    /* First check whether everything is available what is supposed to be avail     */
    /* ============================================================================ */
    if not available tAPMatching   or 
       not available tAPMatchingLn or 
       not available tqPendingVoucherForMatchingAcc 
    then do :
        assign oiReturnStatus  = -3
               vcMsgAPMatching = trim(substitute(#T-8'Internal error: information that should have been available is not available.':255(999890800)T-8#)) + chr(10) + 
                                 trim(substitute(#T-9'Available matching header: &1.':234(49819)T-9#,available (tAPMatching))) + chr(10) + 
                                 trim(substitute(#T-10'Available matching details: &1.':234(56036)T-10#,available (tAPMatchingLn))) + chr(10) + 
                                 trim(substitute(#T-11'Available pending invoice details: &1.':234(49821)T-11#,available (tqPendingVoucherForMatchingAcc))) + chr(10) + 
                                 trim(substitute(#T-17'Technical details: &1.':222(55526)T-17#, "Expense/2":U)).
        <M-7 run SetMessage (input  vcMsgAPMatching (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  'QadFin-5414':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        Return.
    end. /* if not avail */
    
    /* CA779219 - In case 'Create GL Transactions is disabled, no correction posting needs to be created as the */
    /* the system used the matching account immediately */
    <Q-40 run DomainForInventoryControlFile (all) (Read) (NoCache)
       (input tAPMatchingLn.PvoDomain, (DomainCode)
        output dataset tqDomainForInventoryControlFile) in BMfgDomain >
        
    find first tqDomainForInventoryControlFile where 
               tqDomainForInventoryControlFile.tcicc_domain = tAPMatchingLn.PvoDomain
               no-lock no-error.
    if available tqDomainForInventoryControlFile and 
       tqDomainForInventoryControlFile.tlicc_gl_tran = false    
    then do:
        assign oiReturnStatus = 0.
        return.
    end. /* if available tqDomainForInventoryControlFile */       
    
    /* CA779219 */

    /* ==================================================================================== */
    /* Create the posting line that reverses the original posting-line on the log-charges   */
    /* For this posting-line that should completely reverse the posting-line that was made  */
    /* during Receipt;                                                                      */
    /* - we use the GL-Div-CC-PRJ of the Pvod                                               */
    /* - the amount equals the UnitPrice-TC (at receipt) * Allocated-qty                    */
    /* - Positive amounts: posted on Credit                                                 */
    /* - Negative amounts: posted on Debit                                                  */ 
    /* ==================================================================================== */
    empty temp-table tDefaultSafsAPM.
    assign vdUnroundedTC = tAPMatchingLn.APMatchingLnReceiptAmtTC
                         + tAPMatchingLn.tdAPMatchingLnOrigARRecTaxTC
                         + tAPMatchingLn.tdAPMatchingLnOrigARNRecTaxTC
                         - tAPMatchingLn.tdAPMatchingLnOrigARRetainTaxTC
           vdUnroundedLC = vdUnroundedTC * tAPMatchingLn.APMatchingLnPvodExchRate2 / tAPMatchingLn.APMatchingLnPvodExchRate
           vdAmountTC    = <M-5 RoundAmount
                              (input  vdUnroundedTC (idUnroundedAmount), 
                               input  tAPMatching.Currency_ID (iiCurrencyID), 
                               input  ? (icCurrencyCode)) in business>
           vdAmountLC    = <M-6 RoundAmount
                              (input  vdUnroundedLC (idUnroundedAmount), 
                               input  viCompanyLCId (iiCurrencyID), 
                               input  ? (icCurrencyCode)) in business>
           vdAmountCC    = if viCompanyCCID = viCompanyLCID 
                           then vdAmountLC
                           else if viCompanyCCID = tAPMatching.Currency_ID
                                then vdAmountTC
                                else <M-27 RoundAmount
                                        (input  vdUnroundedLC * tAPMatchingLn.APMatchingLnPvodCCRate * tAPMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount), 
                                         input  viCompanyCCId (iiCurrencyID), 
                                         input  ? (icCurrencyCode)) in BAPMatching>
           vdDebitTC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountTC < 0 then vdAmountTC * -1 else 0
                        else if vdAmountTC > 0 then vdAmountTC * -1 else 0
           vdDebitLC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountLC < 0 then vdAmountLC * -1 else 0
                        else if vdAmountLC > 0 then vdAmountLC * -1 else 0
           vdDebitCC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountCC < 0 then vdAmountCC * -1 else 0
                        else if vdAmountCC > 0 then vdAmountCC * -1 else 0
           vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountTC > 0 then vdAmountTC else 0
                        else if vdAmountTC < 0 then vdAmountTC else 0
           vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountLC > 0 then vdAmountLC else 0
                        else if vdAmountLC < 0 then vdAmountLC else 0
           vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountCC > 0 then vdAmountCC else 0
                        else if vdAmountCC < 0 then vdAmountCC else 0.
    <M-25 run AdditionalUpdatesAllLinesPLAddPostingLine
       (input  icAPMatchingPostingRowidID (icAPMatchingPostingRowId), 
        input  tAPMatchingLn.APMatchingLnPvodGLCode (icGLCode), 
        input  tAPMatchingLn.APMatchingLnPvodDivCode (icDivisionCode), 
        input  tAPMatchingLn.APMatchingLnPvodCCCode (icCostCentreCode), 
        input  tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode), 
        input  tAPMatchingLn.APMatchingLnPvodOpAllocCode (icOpAllocCode), 
        input  vdDebitTC (idDebitTC), 
        input  vdDebitLC (idDebitLC), 
        input  vdDebitCC (idDebitCC), 
        input  vdCreditTC (idCreditTC), 
        input  vdCreditLC (idCreditLC), 
        input  vdCreditCC (idCreditCC), 
        input  icPostingText (icPostingText), 
        input  tAPMatchingLn.APMatchingLnPvodExchRate2 / tAPMatchingLn.APMatchingLnPvodExchRate (idTCLCExchangeRate), 
        input  1 (idTCLCExchangeScale), 
        input  ? (idTCCCExchangeRate), 
        input  ? (idTCCCExchangeScale), 
        input  tDefaultSafsOperAPM (tDefaultSafsAPM), 
        output tAPMatchingLn.RevExpensePostingLine_ID (oiPostingLineId), 
        input  false (ilisCallForVarianceOrTax), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper <  0 then return.
    
    /* ==================================================================================== */
    /* Create the posting line that is the new posting-line on the log-charges              */
    /* - we use the GL-Div-CC-PRJ that weer entered on the APMatchingLine                   */
    /* - the amount equals the UnitPrice-TC (at receipt) * Qty (always 1 for log-charges)   */
    /* - Positive amounts: posted on Debit                                                  */
    /* - Negative amounts: posted on Credit                                                 */ 
    /* ==================================================================================== */
    empty temp-table tDefaultSafsAPM. 
    assign vdDebitTC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountTC > 0 then vdAmountTC       else 0
                        else if vdAmountTC < 0 then vdAmountTC       else 0
           vdDebitLC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountLC > 0 then vdAmountLC       else 0
                        else if vdAmountLC < 0 then vdAmountLC       else 0
           vdDebitCC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountCC > 0 then vdAmountCC       else 0
                        else if vdAmountCC < 0 then vdAmountCC       else 0
           vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountTC < 0 then vdAmountTC * -1  else 0
                        else if vdAmountTC > 0 then vdAmountTC * -1  else 0
           vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountLC < 0 then vdAmountLC * -1  else 0
                        else if vdAmountLC > 0 then vdAmountLC * -1  else 0
           vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
                           tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
                        then if vdAmountCC < 0 then vdAmountCC * -1  else 0
                        else if vdAmountCC > 0 then vdAmountCC * -1  else 0.
    <M-26 run AdditionalUpdatesAllLinesPLAddPostingLine
       (input  icAPMatchingPostingRowidID (icAPMatchingPostingRowId), 
        input  tAPMatchingLn.tcGLCode (icGLCode), 
        input  tAPMatchingLn.tcDivisionCode (icDivisionCode), 
        input  tAPMatchingLn.tcCostCentreCode (icCostCentreCode), 
        input  tAPMatchingLn.tcProjectCode (icProjectCode), 
        input  tAPMatchingLn.APMatchingLnOpAllocCode (icOpAllocCode), 
        input  vdDebitTC (idDebitTC), 
        input  vdDebitLC (idDebitLC), 
        input  vdDebitCC (idDebitCC), 
        input  vdCreditTC (idCreditTC), 
        input  vdCreditLC (idCreditLC), 
        input  vdCreditCC (idCreditCC), 
        input  icPostingText (icPostingText), 
        input  tAPMatchingLn.APMatchingLnPvodExchRate2 / tAPMatchingLn.APMatchingLnPvodExchRate (idTCLCExchangeRate), 
        input  1 (idTCLCExchangeScale), 
        input  ? (idTCCCExchangeRate), 
        input  ? (idTCCCExchangeScale), 
        input  tDefaultSafsOperAPM (tDefaultSafsAPM), 
        output tAPMatchingLn.NewExpensePostingLine_ID (oiPostingLineId), 
        input  false (ilisCallForVarianceOrTax), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper <  0 then return.

    /* ======================== */
    /* Set ReturnStatus = OK    */
    /* ======================== */
    if oiReturnStatus = -98
    then assign oiReturnStatus = 0.