project QadFinancials > class BExpenseNote > method ExpNoteRegisterPosting

Description

Some parts of APIExpnoteRegister need to be moved to a separate method (due to limited buffer size).


Parameters


icInvoiceJournalCodeinputcharacter
iiPosting_IDinputinteger
itRegistrationDateinputdate
iiAccYearinputinteger
iiReason_IDinputinteger
icPostingRowidinputcharacter
icCIRECCodeinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BExpenseNote.APIExpNoteRegister


program code (program3/bexpensenote.p)

/* Create Posting Lines - MF Posting */
for each tPostingLineEN:
    
    empty temp-table tDefaultSafsEN.

    if tPostingLineEN.tiExpNoteLine_ID <> 0 and
       tPostingLineEN.tiExpNoteLine_ID <> ?
    then do:
        <Q-2 run ExpNoteLineSafByLine (all) (Read) (NoCache)
          (input tPostingLineEN.tiExpNoteLine_ID, (ExpNoteLine_ID)
           output dataset tqExpNoteLineSafByLine) in BExpenseNote >
        find first tqExpNoteLineSafByLine no-error.
        if available tqExpNoteLineSafByLine
        then assign vcSafStructureCode = tqExpNoteLineSafByLine.tcSafStructureCode.
        else assign vcSafStructureCode = "":U.
    
        /* Fill-in SAFs that are to be posted */
        for each tqExpNoteLineSafByLine:
            create tDefaultSafsEN.
            assign tDefaultSafsEN.tcSafCode        = tqExpNoteLineSafByLine.tcSafCode
                   tDefaultSafsEN.tcSafConceptCode = tqExpNoteLineSafByLine.tcSafConceptCode.
        end.
    end.

    <M-1 run AddStandardPosting (input  icPostingRowid (icPostingtcRowid), 
                             input  tPostingLineEN.tcGLCode (icGLCode), 
                             input  tPostingLineEN.tcDivisionCode (icDivisionCode), 
                             input  tPostingLineEN.tcCostCentreCode (icCostCentreCode), 
                             input  '':U (icCostCentreText), 
                             input  tPostingLineEN.tcProjectCode (icProjectCode), 
                             input  '':U (icProjectText), 
                             input  tqCreditorByPaysel.tcBusinessRelationICCode (icIntercoBusinessRelationCode), 
                             input  tPostingLineEN.tcCurrencyCode (icCurrencyCode), 
                             input  tPostingLineEN.tdDebitTC (idDebitTC), 
                             input  tPostingLineEN.tdDebitLC (idDebitLC), 
                             input  tPostingLineEN.tdDebitCC (idDebitCC), 
                             input  ? (idDebitPC), 
                             input  tPostingLineEN.tdCreditTC (idCreditTC), 
                             input  tPostingLineEN.tdCreditLC (idCreditLC), 
                             input  tPostingLineEN.tdCreditCC (idCreditCC), 
                             input  ? (idCreditPC), 
                             input  ? (idQty), 
                             input  tPostingLineEN.tcPostingLineDescription (icLineText), 
                             input  '':U (icSafText), 
                             input  tDefaultSafsEN (tDefaultSafs), 
                             input  {&EXCHANGERATETYPE-CASH} (icExchangeRateType), 
                             input  tPostingLineEN.tdExchangeRateXCLC (idExchangeRate), 
                             input  tPostingLineEN.tdExchangeRateScaleXCLC (idExchangeRateScale), 
                             output viPostingLine_ID (oiPostingLineId), 
                             input  ? (iiSafStructureId), 
                             input  vcSafStructureCode (icSafStructureCode), 
                             input  ? (icAllocationKey), 
                             output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>    
    if viFcReturnSuper < 0
    then do:
        assign oiReturnStatus = min(-1, viFcReturnSuper).
        return.
    end.

    assign tPostingLineEN.tiPostingLine_ID = viPostingLine_ID.
    
    /* Keep all references necessary to invoice allocations */
    if tPostingLineEN.tcGLCode = icCIRECCode
    then do:
        create tAllocCInvoice.
        assign tAllocCInvoice.tcJournalCode                = icInvoiceJournalCode
               tAllocCInvoice.tiCirecPostingLineId         = viPostingLine_ID
               tAllocCInvoice.tiPostingId                  = iiPosting_ID
               /*few lines above in AddPostingHeader PostingDate = RegistrationDate*/
               tAllocCInvoice.ttPostingDate                = itRegistrationDate
               tAllocCInvoice.tiCICompanyId                = viCompanyId
               tAllocCInvoice.tiPeriodYear                 = iiAccYear
               tAllocCInvoice.tiReasonId                   = iiReason_ID
               tAllocCInvoice.tlCInvoiceIsLogisticMatching = false.
        create tMFPostingENRef.
        assign tMFPostingENRef.tiRefExpNote_ID = tExpNote.ExpNote_ID
               tMFPostingENRef.tiRefPosting_ID = iiPosting_ID.
    end.
end.