project QadFinancials > class BPaymentSelection > method AdditionalUpdatesRegisterPrePayment

Description

Method create prepayment


Parameters


icDivisionCodeinputcharacter
icCostCentreCodeinputcharacter
icProjectCodeinputcharacter
icNormalPaymentConditionCodeinputcharacter
blStart2input-outputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.AdditionalUpdatesRegister


program code (program5/bpaymentselection.p)


        create tOpenBalancePrepayment.

        assign tOpenBalancePrepayment.tcAction                     = {&DAEMONACTION-SAVE}
               tOpenBalancePrepayment.tcCreditorCode               = tPaySelLine.tcCreditorCode
               tOpenBalancePrepayment.tcDivisionCode               = icDivisionCode
               tOpenBalancePrepayment.tcCostCentreCode             = icCostCentreCode
               tOpenBalancePrepayment.tcProjectCode                = icProjectCode
               tOpenBalancePrepayment.tcInvoiceReference           = tPaySelLine.tcExternalNumber
               tOpenBalancePrepayment.tcInvoiceType                = {&INVOICETYPE-PREPAYMENT}
               tOpenBalancePrepayment.tcJournalCode                = tPaySel.tcPostingJournal
               tOpenBalancePrepayment.tcKey                        = tCDocumentInvoiceXRefPaySel.tc_Rowid
               tOpenBalancePrepayment.tcNormalPaymentConditionCode = icNormalPaymentConditionCode
               tOpenBalancePrepayment.tcPostingText                = trim(string(tPaySelLine.tcCreditorCode, "x(20)":U)) + "/":U +
                                                                          string(tPaySelLine.tcInvoiceCurrencyCode,"x(3)":U)
               tOpenBalancePrepayment.tcPostingType                = {&POSTINGTYPE-DEBIT}
               tOpenBalancePrepayment.tcTCCurrencyCode             = tPaySelLine.tcInvoiceCurrencyCode
               tOpenBalancePrepayment.tdInvoiceAmountTC            = abs(tPaySelLine.PaySelLineAmountTC)
               tOpenBalancePrepayment.tiCompanyId                  = tPaySel.Company_ID
               tOpenBalancePrepayment.tiInvoiceVoucher             = 0
               tOpenBalancePrepayment.tiPeriodPeriod               = tPaySel.tiPostingPeriod
               tOpenBalancePrepayment.tiPeriodYear                 = tPaySel.tiPostingYear
               tOpenBalancePrepayment.tlOnlyControlAccount         = true
               tOpenBalancePrepayment.ttInvoiceDate                = tPaySel.ttPostingDate
               tOpenBalancePrepayment.ttInvoiceDueDate             = tPaySel.ttPostingDate
               tOpenBalancePrepayment.ttInvoiceTaxPointDate        = tPaySel.ttPostingDate
               tOpenBalancePrepayment.ttPostingDate                = tPaySel.ttPostingDate
               tCDocumentInvoiceXRefPaySel.CInvoice_ID             = 0
               tCDocumentInvoiceXRefPaySel.tcAllocAmountCrDt       = vcDebitTR
               tCDocumentInvoiceXRefPaySel.tcCInvoiceBalanceCrDt   = vcDebitTR
               tCDocumentInvoiceXRefPaySel.tcCInvoiceType          = {&INVOICETYPE-PREPAYMENT}.
               tPaySelLine.PaySelLineObjectType                    = {&INVOICETYPE-INVOICE}.

        if tPaySelLine.BankNumber_ID <> ? and tPaySelLine.BankNumber_ID <> 0 then do:
            if not blStart2
            then do:
                <Q-1 run BankNumberByID
                   (Start) in BBankNumber >
                assign blStart2 = true.
            end.

            <Q-2 run BankNumberByID (all) (Read) (Cache)
               (input tPaySelLine.BankNumber_ID, (BankNumber_ID)
                input ?, (CompanyId)
                output dataset tqBankNumberByID) in BBankNumber >

            find first tqBankNumberByID where
                       tqBankNumberByID.tiBankNumber_ID = tPaySelLine.BankNumber_ID
                       no-error.

            if available tqBankNumberByID then  do:
                assign tOpenBalancePrepayment.tcBankNumber           = tqBankNumberByID.tcBankNumber
                        tOpenBalancePrepayment.tcBankNumberExtension = tqBankNumberByID.tcBankNumberExtension
                        tOpenBalancePrepayment.tiBankNumber_ID       = tPaySelLine.BankNumber_ID.
            end.
        end.

        if tPaySelLine.tcInvoiceCurrencyCode = vcCompanyLC
        then assign tOpenBalancePrepayment.tdExchangeRateTCLC  = 1
                    tOpenBalancePrepayment.tdExchangeRateScale = 1
                    tOpenBalancePrepayment.tdInvoiceAmountLC   = tOpenBalancePrepayment.tdInvoiceAmountTC.
        else do:
            <M-65 run GetExchangeRate
               (input  ? (iiCompanyID), 
                input  ? (iiFromCurrencyID), 
                input  tPaySelLine.tcInvoiceCurrencyCode (icFromCurrencyCode), 
                input  viCompanyLCId (iiToCurrencyID), 
                input  ? (icToCurrencyCode), 
                input  ? (iiExchangeRateTypeID), 
                input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
                input  tPaySel.ttPostingDate (itValidityDate), 
                output vdExchangeRate (odExchangeRate), 
                output vdExchangeRateScale (odExchangeScaleFactor), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            if viFcReturnSuper < 0 or
               oiReturnStatus  = 0
            then assign oiReturnStatus = viFcReturnSuper.

            if oiReturnStatus < 0
            then return.

            assign tOpenBalancePrepayment.tdExchangeRateTCLC  = vdExchangeRate
                   tOpenBalancePrepayment.tdExchangeRateScale = vdExchangeRateScale
                   tOpenBalancePrepayment.tdInvoiceAmountLC   =  <M-4 RoundAmount
                                                                    (input  tOpenBalancePrepayment.tdInvoiceAmountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount), 
                                                                     input  viCompanyLCId (iiCurrencyID), 
                                                                     input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.
        end.

        if tPaySelLine.tcInvoiceCurrencyCode = vcCompanyCC
        then assign tOpenBalancePrepayment.tdExchangeRateTCCC = 1
                    tOpenBalancePrepayment.tdCCExchangeRateScale = 1
                    tOpenBalancePrepayment.tdInvoiceAmountCC = tOpenBalancePrepayment.tdInvoiceAmountTC.
        else
        if vlDomainIsStatutory = false
        then assign tOpenBalancePrepayment.tdExchangeRateTCCC    = tOpenBalancePrepayment.tdExchangeRateTCLC
                    tOpenBalancePrepayment.tdCCExchangeRateScale = tOpenBalancePrepayment.tdExchangeRateScale
                    tOpenBalancePrepayment.tdInvoiceAmountCC = tOpenBalancePrepayment.tdInvoiceAmountLC.
        else do:
            <M-52 run GetExchangeRate
               (input  ? (iiCompanyID), 
                input  ? (iiFromCurrencyID), 
                input  tPaySelLine.tcInvoiceCurrencyCode (icFromCurrencyCode), 
                input  viCompanyCCId (iiToCurrencyID), 
                input  ? (icToCurrencyCode), 
                input  ? (iiExchangeRateTypeID), 
                input  {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode), 
                input  tPaySel.ttPostingDate (itValidityDate), 
                output vdExchangeRate (odExchangeRate), 
                output vdExchangeRateScale (odExchangeScaleFactor), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            if viFcReturnSuper < 0 or
               oiReturnStatus  = 0
            then assign oiReturnStatus = viFcReturnSuper.

            if oiReturnStatus < 0
            then return.

            assign  tOpenBalancePrepayment.tdExchangeRateTCCC    = vdExchangeRate
                    tOpenBalancePrepayment.tdCCExchangeRateScale = vdExchangeRateScale
                    tOpenBalancePrepayment.tdInvoiceAmountCC = <M-6 RoundAmount
                                                                 (input  tOpenBalancePrepayment.tdInvoiceAmountTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount), 
                                                                  input  viCompanyCCId (iiCurrencyID), 
                                                                  input  vcCompanyCC (icCurrencyCode)) in business>.
        end.