project QadFinancials > class BBankEntry > method AddBankEntryLine

Description

This method creates new bank entry line record.


Parameters


icBankEntryRowIdinputcharacter
itTransactionDateinputdate
itValueDateinputdate
icDescriptioninputcharacter
idTransactionAmountTCinputdecimal
icTransactionInOutinputcharacter
icReferenceinputcharacter
icReferenceExtinputcharacter
icInfoinputcharacter
icPartnerNameinputcharacter
icAddressLineinputcharacter
icAddressCityinputcharacter
icAddressZipinputcharacter
icAddressCountryinputcharacter
icPartnerBankNumberinputcharacter
icPartnerDebCredinputcharacter
idOrigAmountTCinputdecimal
icOrigCurrCodeinputcharacter
idBankExchangeRateinputdecimal
idBankRateScaleinputdecimal
icCostinputcharacter
icBankImportLineRowIDinputcharacter
ocBankStateLineRowIdoutputcharacter
ilIsUnAllocatedStatementinputlogical
icBankImpLineRefinputcharacterBank Importing Reference
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankImportLine.ProcessBankImpLineNewBankEntry
method BBankImportLine.CreateUnallocatedBankEntry

QadFitnesse
method BBankEntry.ApiBankingEntryCreate


program code (program6/bbankentry.p)

/* =================================================================================================== */
/* Method      : AddBankEntryLine                                                                      */
/* Desc        : Add new bank entry line to bank entry                                                 */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  BankEntryRowId       Row id of bank entry header record                               */
/*          (I)  Name                 Description                                                      */
/* =================================================================================================== */

assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Default output values                                                                               */
/* =================================================================================================== */
assign ocBankStateLineRowId = ?.

/* =================================================================================================== */
/* Normalize input parameters                                                                          */
/* =================================================================================================== */
if idBankExchangeRate = ? or idBankExchangeRate = 0 then assign idBankExchangeRate = 1.
if idBankRateScale    = ? or idBankRateScale    = 0 then assign idBankRateScale    = 1.


/* =================================================================================================== */
/* Validate input parameters                                                                           */
/* =================================================================================================== */
if icBankEntryRowId = ?
then do:
    assign vcMessage = #T-1'You have not entered all the mandatory values.':255(63250)T-1#
           vcContext = 'BankEntryRowId=&1':U
           vcContext = substitute(vcContext,icBankEntryRowId).
    <M-2 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'S':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-7570':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
    assign oiReturnStatus = -1.
    return.
end.

find tBankState where
     tBankState.tc_Rowid = icBankEntryRowId no-error.
if not available tBankState
then do:
    assign vcMessage = #T-5'Missing mandatory BankState record.':255(68037)T-5#
           vcContext = 'BankEntryRowId=&1':U
           vcContext = substitute(vcContext,icBankEntryRowId).
    <M-4 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'S':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-7571':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
    assign oiReturnStatus = -1.
    return.
end.

/* =================================================================================================== */
/* Create new bank entry line record                                                                   */
/* =================================================================================================== */
<M-3 run AddDetailLine
   (input  'BankStateLine':U (icTable), 
    input  icBankEntryRowId (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper <  0 then return.

/* =================================================================================================== */
/* Assign values of the line from header                                                               */
/* =================================================================================================== */
assign tBankStateLine.Period_ID                  = tBankState.Period_ID
       tBankStateLine.tiPeriodPeriod             = tBankState.tiPeriodPeriod
       tBankStateLine.tiPeriodYear               = tBankState.tiPeriodYear
       tBankStateLine.BankStateLineValueDate     = tBankState.BankStatePostingDate
       tBankStateLine.BankStateLinePostingDate   = tBankState.BankStatePostingDate
       tBankStateLine.tcPostingJournalCode       = tBankState.tcGLJournalCode
       /*Every BankImportLine should be used to create one BankStazteLine
         Store the BankImportLine RowID in calc field for PIBF error message popup in BBankEntry.SetMessge*/
       tBankStateLine.tcExternalUniqueIdentifier = icBankImportLineRowID.

/* =================================================================================================== */
/* Assign values of the line from information passed from parent program                               */
/* =================================================================================================== */
assign tBankStateLine.BankStateLineNumber        = 1
       tBankStateLine.BankStateLinePostingDate   = itTransactionDate
       tBankStateLine.BankStateLineValueDate     = itValueDate
       tBankStateLine.BankStateLineDescription   = icDescription
       tBankStateLine.BankStateLineAmountTC      = idTransactionAmountTC
       tBankStateLine.BankStateLineInOut         = icTransactionInOut
       tBankStateLine.BankStateLineStatus        = {&BANKSTATELINESTATUS-UNALLOC}
       tBankStateLine.BankStateLineExtReference  = icReferenceExt
       tBankStateLine.BankStateLineInformation   = icInfo
       tBankStateLine.BankStateLineExtTSM        = icReference
       tBankStateLine.BankStateLineExtName       = icPartnerName
       tBankStateLine.BankStateLineExtAddress    = icAddressLine
       tBankStateLine.BankStateLineExtCity       = icAddressCity
       tBankStateLine.BankStateLineExtZip        = icAddressZip
       tBankStateLine.BankStateLineExtCountry    = icAddressCountry
       tBankStateLine.BankStateLineExtBankNumber = icPartnerBankNumber
       tBankStateLine.BankStateLineExtDebCred    = icPartnerDebCred
       tBankStateLine.BankStateLineExtOriginalTC = idOrigAmountTC
       tBankStateLine.BankStateLineExtCurrency   = icOrigCurrCode
       tBankStateLine.BankStateLineExtBankRate   = idBankExchangeRate
       tBankStateLine.BankStateLineExtRateScale  = idBankRateScale
       tBankStateLine.BankStateLineExtCostCode   = icCost
       tBankStateLine.BankStateLineBankImpRef    = icBankImpLineRef.
       
 
<Q-55 run PeriodByStartEndDate (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input itTransactionDate, (Date)
    output dataset tqPeriodByStartEndDate) in BPeriod>    
find first tqPeriodByStartEndDate where
           tqPeriodByStartEndDate.ttPeriodStartDate <= itTransactionDate and
           tqPeriodByStartEndDate.ttPeriodEndDate   >= itTransactionDate and
           tqPeriodByStartEndDate.tcPeriodTypeCode  =  {&PERIODTYPECODE-NORMAL} no-error.
if available tqPeriodByStartEndDate 
then assign tBankStateLine.tiPeriodPeriod             =  tqPeriodByStartEndDate.tiPeriodPeriod
            tBankStateLine.tiPeriodYear               =  tqPeriodByStartEndDate.tiPeriodYear. 

  
for each bLastBankStateLine where
          bLastBankStateLine.tc_ParentRowid =  tBankStateLine.tc_ParentRowid and
          bLastBankStateLine.tc_Rowid       <> tBankStateLine.tc_Rowid
       by bLastBankStateLine.BankStateLineNumber DESCENDING.
    assign tBankStateLine.BankStateLineNumber = bLastBankStateLine.BankStateLineNumber + 1.
    leave.
end.

/* =================================================================================================== */
/* Update header information                                                                           */
/* =================================================================================================== */
assign tBankState.BankStateMovement       = tBankState.BankStateMovement 
                                          + tBankStateLine.BankStateLineAmountTC
       tBankState.BankStateClosingBalance = tBankState.BankStateOpeningBalance 
                                          + tBankState.BankStateMovement
       tBankState.tc_Status               = if tBankState.tc_Status = ''
                                            then 'C'
                                            else tBankState.tc_Status.
 
if tBankState.BankStatePostingDate < tBankStateLine.BankStateLinePostingDate 
then
   assign tBankState.BankStatePostingDate = tBankStateLine.BankStateLinePostingDate
          tBankState.tiPeriodPeriod       = tBankStateLine.tiPeriodPeriod
          tBankState.tiPeriodYear         = tBankStateLine.tiPeriodYear.
      


/* =================================================================================================== */
/* Create posting header for bank statement line                                                       */
/* =================================================================================================== */

if not ilIsUnAllocatedStatement
then do:

<M-6 run CreatePostingHeader
   (input  ? (iiPeriodId), 
    input  tBankStateLine.tiPeriodYear (iiPeriodYear), 
    input  tBankStateLine.tiPeriodPeriod (iiPeriodPeriod), 
    input  ? (iiJournalId), 
    input  tBankStateLine.tcPostingJournalCode (icJournalCode), 
    output tBankStateLine.tiPostingVoucher (oiVoucher), 
    input  tBankStateLine.BankStateLinePostingDate (itBankStateLinePostingDate), 
    input  tBankStateLine.BankStateLineValueDate (itBankStateLineValueDate), 
    input  tBankStateLine.BankStateLineDescription (icBankStateLineDescription), 
    input  ? (iiGLId), 
    input  tBankState.tcGLCode (icGLCode), 
    input-output viBJournalEntryBEID (biBJournalEntryId), 
    input-output tBankStateLine.Posting_ID (biPostingId), 
    output tBankStateLine.tcPostingRowId (ocRowId), 
    input  tBankStateLine.tc_ParentRowid (icParentRowId), 
    input  tBankStateLine.tc_Rowid (icRowId), 
    input  tBankState.BankStateNumber (icBankStateNumber), 
    input  tBankState.BankStateYear (iiBankStateYear), 
    input  icBankImpLineRef (icBankImpLineRef), 
    output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper <  0 then return.
end.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
assign ocBankStateLineRowId = tBankStateLine.tc_Rowid.

if oiReturnStatus = -98 then assign oiReturnStatus = 0.