project QadFinancials > class BCInvoice > method DefaultValuesDaybookSetCodeSite


Parameters


icCInvoiceRowIDinputcharacter
icInvoiceTypeinputcharacter
ilCInvoiceIsInitialStatusinputlogicalInitial status flag of the supplier invoice
bcDaybookSetCodeinput-outputcharacter
bcSiteinput-outputcharacter
ilUpdateDaybookAndVoucherinputlogical
bcDaybookinput-outputcharacter
biVoucherinput-outputinteger
iiOldCInvoicePostingYearinputinteger
icOldJournalCodeinputcharacter
iiOldCInvoiceVoucherinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CreateCInvoicesDet
method BCInvoice.DefaultValuesPO
method BCInvoice.DefaultValuesSupplier


program code (program3/bcinvoice.p)

if ilCInvoiceIsInitialStatus = ? then assign ilCInvoiceIsInitialStatus = false.
if ilUpdateDaybookAndVoucher = ? then assign ilUpdateDaybookAndVoucher = false.
if bcDaybookSetCode = ? then assign bcDaybookSetCode = "":U.
if bcDaybook = ? then assign bcDaybook = "":U.
if biVoucher = ? then assign biVoucher = 0.
if bcSite    = ? then assign bcSite    = "":U.

find first tCInvoice where
           tCInvoice.tc_Rowid = icCInvoiceRowId
           no-error.
if not available tCInvoice
then do:
    <M-1 run SetMessage
       (input  #T-13'Invalid Supplier Invoice':255(999890851)T-13# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'D':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-9380':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    assign oiReturnStatus = -3.
    return.
end.

<Q-70 run SelectMfgDaybookSet (all) (Read) (NoCache)
   (input vcDomainCode, (DomainCode)
    output dataset tqSelectMfgDaybookSet) in BMfgDaybookSet>

<Q-29 run POAccountingControlByDomain (all) (Read) (NoCache)
   (input vcDomainCode, (Domain)
    output dataset tqPOAccountingControlByDomain) in BMfgPOAccountingControl>

find first tqPOAccountingControlByDomain 
     where tqPOAccountingControlByDomain.tcpoc_domain = vcDomainCode no-error.                    
if available tqPOAccountingControlByDomain and 
             tqPOAccountingControlByDomain.tlpoc_dybkset_by_site = yes 
then do:
    
    if bcSite <> "":U and bcDaybookSetCode = "":U
    then do:
                  
        find first tqSelectMfgDaybookSet where  tqSelectMfgDaybookSet.tcdybs_type = '2':U and
                                                tqSelectMfgDaybookSet.tcdybs_site = bcSite no-error.
        if available tqSelectMfgDaybookSet
        then do:     
            assign bcDaybookSetCode =  tqSelectMfgDaybookSet.tcdybs_code
                   bcSite           =  tqSelectMfgDaybookSet.tcdybs_site.     
        end. 
    end. /* if bcSite <> "":U and bcDaybookSetCode = "":U */

    if bcSite = "":U and bcDaybookSetCode <> "":U
    then do:
        find first tqSelectMfgDaybookSet where  tqSelectMfgDaybookSet.tcdybs_code = bcDaybookSetCode and
                                                tqSelectMfgDaybookSet.tcdybs_type = '2':U no-error.
        if available tqSelectMfgDaybookSet
        then do:     
            assign bcDaybookSetCode =  tqSelectMfgDaybookSet.tcdybs_code
                   bcSite           =  tqSelectMfgDaybookSet.tcdybs_site.     
        end. 
    end. /* if bcSite = "":U and bcDaybookSetCode <> "":U */

    if bcSite <> "":U and bcDaybookSetCode <> "":U
    then do:
    
        find first tqSelectMfgDaybookSet where  tqSelectMfgDaybookSet.tcdybs_code = bcDaybookSetCode and
                                                tqSelectMfgDaybookSet.tcdybs_type = '2':U and
                                                tqSelectMfgDaybookSet.tcdybs_site = bcSite no-error.
        if available tqSelectMfgDaybookSet
        then do:     
            assign bcDaybookSetCode =  tqSelectMfgDaybookSet.tcdybs_code
                   bcSite           =  tqSelectMfgDaybookSet.tcdybs_site.     
        end. 
        else do:
            assign bcSite = "".        
        end. 
    end. /* if bcSite <> "":U and bcDaybookSetCode <> "":U */
    
end. /* if available tqPOAccountingControlByDomain and */
else assign bcSite = "".

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

if ilUpdateDaybookAndVoucher = true
then do:
    if bcDaybookSetCode <> "":U 
    then do:
    assign vhFcComponent = ?.
    <M-16 run ApiGetDaybookCodeByType
       (input  bcDaybookSetCode (icDaybookSetCode), 
        input  bcSite (icSite), 
        input  '2':U (icDaybookSetType), 
        input  icInvoiceType (icInvoiceType), 
        output bcDaybook (ocDaybookCode), 
        output oiReturnStatus (oiReturnStatus)) in BMfgDaybookSet>
    end.
    if bcDaybook <> "":U 
    then do:
    <M-17 run DefaultValuesJournal
       (input  icCInvoiceRowID (icCInvoiceRowId), 
        input-output bcDaybook (bcJournalCode), 
        input  tCInvoice.CInvoicePostingYear (iiCInvoicePostingYear), 
        input  icInvoiceType (icCInvoiceType), 
        input  iiOldCInvoicePostingYear (iiOldCInvoicePostingYear), 
        input  icOldJournalCode (icOldJournalCode), 
        input  iiOldCInvoiceVoucher (iiOldCInvoiceVoucher), 
        input  ilCInvoiceIsInitialStatus (ilCInvoiceIsInitialStatus), 
        output biVoucher (oiCInvoiceVoucher), 
        output oiReturnStatus (oiReturnStatus)) in BCInvoice>

    end.
end.