project QadFinancials > class BBankEntry > method GetPossibleAllocations

Description

this method returns a temp-table containing all allocation possibilities that fit the input criteria of this method., called by UI when pressing Apply on the search criteria window


Parameters


iiCompanyIDinputintegerEntity ID
ilIncludeAllCompaniesinputlogicalIncludeAllCompanies
iiBankStateLineIDinputintegerBankStateLine ID wherefor the allocations need to be proposed
icBankStateLineTcRowidinputcharacterBankStateLine TcRowid wherefor the allocations need to be proposed
icBusinessRelationCodeinputcharacter
icCodeinputcharacterDebtorCreditorEmployeeCode
Code of the debtor/creditor/employee
icReferenceinputcharacterReference of the debtor/creditor/employee
idAmountinputdecimalAmount that should fit the Invoice/Collection/Document
idAmountMargininputdecimalMargin on the Amount that should fit the Invoice/Collection/Document
icAmountOperatorinputcharacterOperator that will be used to check the input-amount against the amounts on invoices
icCurrencyCodeinputcharacterCurrencyCode that should fit the Invoice/Collection/Document. This is not used in case iiCurrencyID is passed
icBankAccountNumberinputcharacterBankAccountNumber that should fit the Creditor-Invoice or the Debtor
ilIncludeDebtorinputlogicalIncludeDebtor
ilIncludeCreditorinputlogicalIncludeCreditor
ilIncludeInvoicesinputlogicalIncludeInvoices
iiPeriodYearinputinteger
icJournalCodeinputcharacterDaybook Code
iiVoucherinputintegerVoucher
icBankCurrencyCodeinputcharacterBank Currency Code
icBankGLCodeinputcharacterBank GL Account
itBankStateLineValueDateinputdateValue Date of the Bank State Line
icShipperCodeinputcharacter
tPossibleBankStateAllocoutputtemp-tableTable containing all possibilities that fit the selection critaria.
tPossibleBankStateStageAllocoutputtemp-table
icTSMNumberinputcharacterTSMNumber
iiBillYearinputinteger
iiBillNumberinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFitnesse
method BBankEntry.ApiGetPossibleAllocations


program code (program6/bbankentry.p)

assign oiReturnStatus     = -98
           vcExchangeRateType = <M-26 GetExchangeRateType () in BBankEntry>.
    
    /* Replace unknown values and return if no selection has been made */
    if iiCompanyID = ? then assign iiCompanyID = 0.
    if ilIncludeAllCompanies = ? then assign ilIncludeAllCompanies = false.
    if icBusinessRelationCode = ? then assign icBusinessRelationCode = "":U.
    if icCode = ? then assign icCode = "":U.
    if icReference = ? then assign icReference = "":U.
    if idAmount = ? then assign idAmount = 0.
    if icCurrencyCode = ? then assign icCurrencyCode = "":U.
    if idAmountMargin = ? then assign idAmountMargin = 0.
    if icAmountOperator = ? then assign icAmountOperator = "":U.
    if icBankAccountNumber = ? then assign icBankAccountNumber = "":U.
    if ilIncludeDebtor = ? then assign ilIncludeDebtor = false.
    if ilIncludeCreditor = ? then assign ilIncludeCreditor = false.
    if ilIncludeInvoices = ? then assign ilIncludeInvoices = false.
    if icBankCurrencyCode = ? then assign icBankCurrencyCode = "":U.
    if icBankGLCode = ? then assign icBankGLCode = "":U.
    if icShipperCode = ? then assign icShipperCode = "".
        
    if ilIncludeDebtor = FALSE and ilIncludeCreditor = FALSE 
    then do :
        assign vcMessage      = trim(#T-18'You must select at least one of the following options: Supplier, Customer, Employee.':255(17424)T-18#)
               oiReturnStatus = -3.
        <M-1 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-617':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
        Return.
    end. /* if ilIncludeDebtor    = FALSE and */

    if ilIncludeInvoices = false
    then do :
        assign vcMessage      = trim(#T-19'You must select invoices.':255(268)T-19#)
               oiReturnStatus = -3.
        <M-2 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-618':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
        return.
    end. /* if ilIncludeInvoices       = FALSE */

    if icAmountOperator <> "=":U  and icAmountOperator <> "<=":U and icAmountOperator <> ">=":U 
    then do :  
        assign vcMessage      = trim(substitute(#T-20'You must select one of the following options for the operator on the amount: '&1', '&2' or '&3'.':255(269)T-20#,"=":U,">=":U,"<=":U))
               oiReturnStatus = -3.
        <M-12 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-669':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
        Return.
    end. /* if icAmountOperator <> "=":U  and */
    
    /* check if the bankgl is filled */
    if icBankGLCode = "":U
    then do:
        assign vcMessage      = trim(#T-21'You must enter the GL bank account.':150(270)T-21#)
               oiReturnStatus = -1.
        <M-16 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-2125':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
        Return.
    end.

    /* Caluclate the minimum and maximum amount */
    if icAmountOperator = "=":U
    then assign vdMinimumAmount = idAmount - abs(idAmountMargin)
                vdMaximumAmount = idAmount + abs(idAmountMargin).
    else if icAmountOperator = "<=":U
         then assign vdMinimumAmount = 0.01 /* not 0 because then the condition is removed from the query */
                     vdMaximumAmount = idAmount.
         else assign vdMinimumAmount = idAmount 
                     vdMaximumAmount = 9999999999 /* not ? because then the condition is removed from the query */.
    
    /* fill the bankrate so it can be used on UI to calculate lc amounts */
    if icBankCurrencyCode = vcCompanyLC
    then assign vdBankRate      = 1
                vdBankRateScale = 1.
    else do:
        <M-24 run GetExchangeRate
           (input  iiCompanyID (iiCompanyID), 
            input  ? (iiFromCurrencyID), 
            input  icBankCurrencyCode (icFromCurrencyCode), 
            input  viCompanyLCId (iiToCurrencyID), 
            input  ? (icToCurrencyCode), 
            input  ? (iiExchangeRateTypeID), 
            input  vcExchangeRateType (icExchangeRateTypeCode), 
            input  itBankStateLineValueDate (itValidityDate), 
            output vdBankRate (odExchangeRate), 
            output vdBankRateScale (odExchangeScaleFactor), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
        if viFcReturnSuper <> 0
        then do:
            assign oiReturnStatus = viFcReturnSuper. 
            if oiReturnStatus < 0
            then return.
        end.
    end.

    /* Empty the output */
    empty temp-table tPossibleBankStateAlloc.
    empty temp-table tPossibleBankStateStageAlloc.
    
    if icBankAccountNumber <> "":U
    then assign icBankAccountNumber = replace(icBankAccountNumber," ":U,"":U)
                icBankAccountNumber = replace(icBankAccountNumber,".":U,"":U)
                icBankAccountNumber = replace(icBankAccountNumber,"/":U,"":U)
                icBankAccountNumber = replace(icBankAccountNumber,"-":U,"":U). 

    /* Creditor Invoice */
    assign vcInvoiceTypes = {&INVOICETYPES}.
    if ilIncludeCreditor and ilIncludeInvoices 
    then do :
        <M-35 run GetPossibleAllocationsCInvoice
           (input  iiCompanyID (iiCompanyID), 
            input  iiBankStateLineID (iiBankStateLineID), 
            input  icBankStateLineTcRowid (icBankStateLineTcRowid), 
            input  icBusinessRelationCode (icBusinessRelationCode), 
            input  icCode (icCode), 
            input  icReference (icReference), 
            input  icCurrencyCode (icCurrencyCode), 
            input  icBankAccountNumber (icBankAccountNumber), 
            input  ilIncludeAllCompanies (ilIncludeAllCompanies), 
            input  iiPeriodYear (iiPeriodYear), 
            input  icJournalCode (icJournalCode), 
            input  iiVoucher (iiVoucher), 
            input  icBankCurrencyCode (icBankCurrencyCode), 
            input  itBankStateLineValueDate (itBankStateLineValueDate), 
            input  icTSMNumber (icTSMNumber), 
            output tPossibleBankStateAlloc (tPossibleBankStateAlloc), 
            output tPossibleBankStateStageAlloc (tPossibleBankStateStageAlloc), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
         if viFcReturnSuper <> 0
         then do:
            assign oiReturnStatus = viFcReturnSuper. 
            if oiReturnStatus < 0
            then return.
         end.
    end. /* if ilIncludeCreditor and ilIncludeInvoices  */
    
    /* Debtor Invoice */
    if ilIncludeDebtor and ilIncludeInvoices 
    then do :
        <M-36 run GetPossibleAllocationsDInvoice
           (input  iiCompanyID (iiCompanyID), 
            input  ilIncludeAllCompanies (ilIncludeAllCompanies), 
            input  iiBankStateLineID (iiBankStateLineID), 
            input  icBankStateLineTcRowid (icBankStateLineTcRowid), 
            input  icBusinessRelationCode (icBusinessRelationCode), 
            input  icCode (icCode), 
            input  icReference (icReference), 
            input  icCurrencyCode (icCurrencyCode), 
            input  icBankAccountNumber (icBankAccountNumber), 
            input  iiPeriodYear (iiPeriodYear), 
            input  icJournalCode (icJournalCode), 
            input  iiVoucher (iiVoucher), 
            input  icBankCurrencyCode (icBankCurrencyCode), 
            input  itBankStateLineValueDate (itBankStateLineValueDate), 
            input  icTSMNumber (icTSMNumber), 
            input  icShipperCode (icShipperCode), 
            output tPossibleBankStateAlloc (tPossibleBankStateAlloc), 
            output tPossibleBankStateStageAlloc (tPossibleBankStateStageAlloc), 
            input  iiBillYear (iiBillYear), 
            input  iiBillNumber (iiBillNumber), 
            output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
         if viFcReturnSuper <> 0
         then do:
            assign oiReturnStatus = viFcReturnSuper. 
            if oiReturnStatus < 0
            then return.
         end.
     end. /* if ilIncludeDebtor and ilIncludeInvoices  */    
  
    
   if oiReturnStatus = -98
   then assign oiReturnStatus = 0.