project QadFinancials > class BCInvoice > method DefaultValuesCAJournal


Parameters


icCInvoiceRowIdinputcharacterrow ID of the supplier invoice
bcCAJournalCodeinput-outputcharacter
iiCInvoicePostingYearinputinteger
iiOldCInvoicePostingYearinputinteger
icOldCAJournalCodeinputcharacter
iiOldCAVoucherinputinteger
oiCAVoucheroutputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ApiStdMaintainTTV01
method BCInvoice.DefaultValuesLinkedInvoice
method BCInvoice.DefaultValuesPostingDate
method BCInvoice.DefaultValuesPostingYear
method BCInvoice.DefaultValuesReverseDaybook


program code (program3/bcinvoice.p)

find first tCInvoice where
           tCInvoice.tc_Rowid = icCInvoiceRowId
           no-error.
if not available tCInvoice
then do:
    <M-7 run SetMessage
       (input  #T-1'The specified supplier invoice is not defined in the system or is invalid.':255(69257)t-1# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'D':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-7997':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    assign oiReturnStatus = -3.
    return.
end.

if iiOldCInvoicePostingYear <> 0    and
   iiOldCInvoicePostingYear <> ?    and
   icOldCAJournalCode       <> "":U and
   icOldCAJournalCode       <> ?    and
   iiOldCAVoucher           <> 0    and
   iiOldCAVoucher           <> ?
then do:
    assign vhFcComponent = ?.
    <M-4 run ReleaseNumber
       (input  viCompanyId (iiCompanyId), 
        input  iiOldCInvoicePostingYear (iiNumbrYear), 
        input  icOldCAJournalCode (icNumbrType), 
        input  iiOldCAVoucher (iiNumbr), 
        input  viFcCurrentInstanceId (iiInstanceId), 
        input  vcFcComponentName (icClassName), 
        output viFcReturnSuper (oiReturnStatus)) in BNumber>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)        
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.
end.

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

if bcCAJournalCode = "":U
then do:
    assign tCInvoice.tcCAJournalCode = bcCAJournalCode
           tCInvoice.tiCAVoucher     = 0.
    return.
end.

assign vcOriginalCAJournalCode = bcCAJournalCode.

if bcCAJournalCode <> icOldCAJournalCode
then do:
end.               

    <Q-8 run JournalBeginsForJEDefault (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input bcCAJournalCode, (JournalCode)
        input {&JOURNALCONTROL-FINANCIAL}, (JournalControl)
        input {&JOURNALTYPE-CREDITORADJUSTMENT}, (JournalTypeCode)
        output dataset tqJournalBeginsForJEDefault) in BJournal >

    find first tqJournalBeginsForJEDefault no-error.
    
    if not available tqJournalBeginsForJEDefault
    then do:
        assign oiReturnStatus = -4.
        return.
    end.
    else do:
        find first tqJournalBeginsForJEDefault
             where tqJournalBeginsForJEDefault.tcJournalCode = bcCAJournalCode no-error.
        if not available tqJournalBeginsForJEDefault
           then do:
               find tqJournalBeginsForJEDefault
                    where tqJournalBeginsForJEDefault.tcJournalCode BEGINS bcCAJournalCode no-error.
                /* if there's only one record - ambiguous records will not be found and available will be false */
               if available tqJournalBeginsForJEDefault 
               then do:
                        assign bcCAJournalCode = tqJournalBeginsForJEDefault.tcJournalCode.
               end.
               else do:
                       assign  bcCAJournalCode = vcOriginalCAJournalCode
                       oiReturnStatus = -4.
                       return.                  
               end. 
         end.
    end.

if iiCInvoicePostingYear <> 0 and
   iiCInvoicePostingYear <> ?
then do:
    assign vhFcComponent = ?.

    <M-5 run GetNumber
       (input  viCompanyId (iiCompanyId), 
        input  iiCInvoicePostingYear (iiNumbrYear), 
        input  bcCAJournalCode (icNumbrType), 
        output oiCAVoucher (oiNumber), 
        input  viFcCurrentInstanceId (iiInstanceId), 
        input  vcFcComponentName (icClassName), 
        output viFcReturnSuper (oiReturnStatus)) in BNumber>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then return.

    assign tCInvoice.tcCAJournalCode       = bcCAJournalCode
           tCInvoice.tiCAVoucher           = oiCAVoucher.
end.