project QadFinancials > class BDDocument > method DefaultValuesDebtorCode


Parameters


icRowidinputcharacter
icDebtorCodeinputcharacter
iiDDocumentYearinputinteger
ocGLCodeoutputcharacter
ocBusinessRelationCodeoutputcharacter
ocBusinessRelationNameoutputcharacter
ocCurrencyCodeoutputcharacter
oiDDocumentNumberoutputinteger
oiBankNumberIdoutputinteger
ocBankNumberoutputcharacter
ocPayFormatTypeCodeoutputcharacter
ocDocumentTypeoutputcharacter
ocOwnBankNumberoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bddocument.p)

if icRowid = ?
then assign icRowid = "":U.

if icRowid = "":U
then return.

find bDDocument where
     bDDocument.tc_Rowid = icRowid
     no-error.

if not available bDDocument
then return.

if icDebtorCode = ?
then assign icDebtorCode = "":U.

if icDebtorCode = "":U
then do:
    assign bDDocument.tcDebtorCode = icDebtorCode.
    return.
end.

if iiDDocumentYear = ?
then assign iiDDocumentYear = 0.

if bDDocument.tcDebtorCode <> icDebtorCode
then assign bDDocument.tcDebtorCode         = icDebtorCode
            bDDocument.tcBusinessRelationCode = "":U
            bDDocument.tcBusinessRelationName = "":U
            bDDocument.tcCurrencyCode         = "":U
            bDDocument.tcGLCode               = "":U
            bDDocument.BankNumber_ID          = 0
            bDDocument.tcDebtorBankNumber     = "":U
            bDDocument.tcPayFormatTypeCode    = "":U
            ocDocumentType                   = "":U.

if bDDocument.tcBusinessRelationCode = "":U
then do:
    <Q-1 run DebtorByDebtor (all) (Read) (NoCache)
       (input bDDocument.Company_ID, (CompanyId)
        input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
        input ?, (DebtorId)
        input icDebtorCode, (DebtorCode)
        output dataset tqDebtorByDebtor) in BDebtor >

    find first tqDebtorByDebtor where
               tqDebtorByDebtor.tcDebtorCode = icDebtorCode
               no-error.

    if not available tqDebtorByDebtor
    then return.

    assign bDDocument.tcBusinessRelationCode = tqDebtorByDebtor.tcBusinessRelationCode
           bDDocument.tcBusinessRelationName = tqDebtorByDebtor.tcBusinessRelationName1
           bDDocument.tcCurrencyCode         = tqDebtorByDebtor.tcCurrencyCode.
end.

 <Q-22 run DebtorBankPayFormatByParent (all) (Read) (NoCache)
    (input viCompanyID, (CompanyId)
     input icDebtorCode, (DebtorCode)
     input {&BANKNUMBERPARENTTYPE-DEBTOR}, (ParentType)
     output dataset tqDebtorBankPayFormatByParent) in BDebtor >

find tqDebtorBankPayFormatByParent where
     tqDebtorBankPayFormatByParent.tlBankNumberIsActive = true and
     tqDebtorBankPayFormatByParent.tlBankPayFormatIsActive = true and
     tqDebtorBankPayFormatByParent.tlPayFormatTypeIsActive = true and
     tqDebtorBankPayFormatByParent.tlOwnBankNumberIsActive = true and
     tqDebtorBankPayFormatByParent.tcPayFormatTypeModule = {&PAYFORMATMODULE-AR} and
     tqDebtorBankPayFormatByParent.tlBankNumberIsDefault no-error.

/* If not default bank pick any bank that satisfies the criteria */
if(not available(tqDebtorBankPayFormatByParent)) then do:
    find first tqDebtorBankPayFormatByParent where
         tqDebtorBankPayFormatByParent.tlBankNumberIsActive = true and
         tqDebtorBankPayFormatByParent.tlBankPayFormatIsActive = true and
         tqDebtorBankPayFormatByParent.tlPayFormatTypeIsActive = true and
         tqDebtorBankPayFormatByParent.tlOwnBankNumberIsActive = true and
         tqDebtorBankPayFormatByParent.tcPayFormatTypeModule = {&PAYFORMATMODULE-AR} no-error.
end.         

if available tqDebtorBankPayFormatByParent
then do:
    assign bDDocument.tcGLCode            = tqDebtorBankPayFormatByParent.tcGLCode
           bDDocument.BankNumber_ID       = tqDebtorBankPayFormatByParent.tiBankNumber_ID
           bDDocument.tcDebtorBankNumber  = tqDebtorBankPayFormatByParent.tcBankNumber
           bDDocument.tcOwnBankNumber     = tqDebtorBankPayFormatByParent.tcOwnBankNumber
           bDDocument.tcPayFormatTypeCode = tqDebtorBankPayFormatByParent.tcPayFormatTypeCode
           ocDocumentType                 = tqDebtorBankPayFormatByParent.tcPayFormatTypePayInstrument.

    <M-4 run DefaultValuesDDocumentNumber
       (input  bDDocument.tc_Rowid (icDDocumentRowid), 
        input  ocDocumentType (icDDocumentType), 
        input  iiDDocumentYear (iiDDocumentYear), 
        output oiDDocumentNumber (oiDDocumentNumber), 
        output viFcReturnSuper (oiReturnStatus)) in BDDocument>

    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
            then return.
    end.
end.

assign ocBusinessRelationCode = bDDocument.tcBusinessRelationCode
       ocBusinessRelationName = bDDocument.tcBusinessRelationName
       ocCurrencyCode         = bDDocument.tcCurrencyCode
       oiDDocumentNumber      = bDDocument.DDocumentNumber
       ocGLCode               = bDDocument.tcGLCode
       ocPayFormatTypeCode    = bDDocument.tcPayFormatTypeCode
       oiBankNumberId         = bDDocument.BankNumber_ID
       ocBankNumber           = bDDocument.tcDebtorBankNumber
       ocOwnBankNumber        = bDDocument.tcOwnBankNumber.