project QadFinancials > class BCInvoice > method DefaultValuesReverseDaybookSet

Description

This method uses the Daybook Set of the invoice to be reversed and takes the daybook from that to use in the reverse


Parameters


icCInvoiceRowidinputcharacter
icDaybookSetinputcharacter
icSiteinputcharacter
icReverseInvoiceTypeinputcharacter
iiReverseInvoiceYearinputinteger
ocReverseInvoiceJournaloutputcharacter
oiReverseInvoiceVoucheroutputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/bcinvoice.p)

/* =================================================================================================== */
/* Method      : DefaultValuesReverseDaybookSet                                                        */
/* Desc        : Get default values for daybooks from the daybook set of the invoice being reversed    */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  DaybookSet            Daybook Set of the invoice being reversed                       */
/*          (I)  Site                  Site of the invoice being reversed                              */
/*          (I)  ReverseInvoiceType    Type of reverse invoice                                         */
/*          (I)  ReverseInvoiceYear    Year of reverse invoice                                         */
/*          (O)  ReverseInvoiceJournal Journal for reversing of invoice                                */
/*          (O)  ReverseInvoiceVoucher Vouchaer number for reversing of inovice                        */
/* =================================================================================================== */

assign oiReturnStatus          = -98
       ocReverseInvoiceJournal = ?
       oiReverseInvoiceVoucher = ?.

/* =================================================================================================== */
/* Normalize input parameters                                                                          */
/* =================================================================================================== */
if icDaybookSet = '':U then assign icDaybookSet = ?.
if icSite = '':U then assign icSite = ?.
if icReverseInvoiceType = '':U then assign icReverseInvoiceType = ?.
if iiReverseInvoiceYear = ? then assign iiReverseInvoiceYear = 0.

/* =================================================================================================== */
/* Get journal for reversing of invoice                                                                */
/* =================================================================================================== */
if icDaybookSet = ?
then assign icDaybookSet = vcPOCDefaultDaybookSet.
if vlPOCUseDaybookSetBySet = true and 
   icSite <> ? 
then do:
    <Q-3 run DaybookSetByCodeBySite (all) (Read) (NoCache)
       (input icDaybookSet, (DaybookSetCode)
        input icSite, (Site)
        input vcDomainCode, (DomainCode)
        output dataset tqDaybookSetByCodeBySite) in BMfgDaybookSet >
    find first tqDaybookSetByCodeBySite 
         where tqDaybookSetByCodeBySite.tcdybs_code = icDaybookSet
         and   tqDaybookSetByCodeBySite.tcdybs_site = icSite no-error.          
end.
else do:    
    <Q-5 run DaybookSetByCodeBySite (all) (Read) (NoCache)
       (input icDaybookSet, (DaybookSetCode)
        input ?, (Site)
        input vcDomainCode, (DomainCode)
        output dataset tqDaybookSetByCodeBySite) in BMfgDaybookSet >
    find first tqDaybookSetByCodeBySite 
         where tqDaybookSetByCodeBySite.tcdybs_code = icDaybookSet no-error.          
end.

if available tqDaybookSetByCodeBySite
then do:
    if icReverseInvoiceType = {&INVOICETYPE-INVOICE}
    then assign ocReverseInvoiceJournal = tqDaybookSetByCodeBySite.tcdybs_invoices_dybk.
    else if icReverseInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
    then assign ocReverseInvoiceJournal = tqDaybookSetByCodeBySite.tcdybs_neg_criv_dybk.
    else if icReverseInvoiceType = {&INVOICETYPE-CREDITNOTE}
    then assign ocReverseInvoiceJournal = tqDaybookSetByCodeBySite.tcdybs_credit_dybk.
    else if icReverseInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
    then assign ocReverseInvoiceJournal = tqDaybookSetByCodeBySite.tcdybs_neg_crcn_dybk.
end.

if ocReverseInvoiceJournal <> '':U and
   ocReverseInvoiceJournal <> ?
then do: 
    if iiReverseInvoiceYear = 0
    then assign iiReverseInvoiceYear = Year(Today). 
       
    <M-2 run DefaultValuesJournal
       (input  icCInvoiceRowId (icCInvoiceRowId), 
        input-output ocReverseInvoiceJournal (bcJournalCode), 
        input  iiReverseInvoiceYear (iiCInvoicePostingYear), 
        input  icReverseInvoiceType (icCInvoiceType), 
        input  ? (iiOldCInvoicePostingYear), 
        input  ? (icOldJournalCode), 
        input  ? (iiOldCInvoiceVoucher), 
        input  false (ilCInvoiceIsInitialStatus), 
        output oiReverseInvoiceVoucher (oiCInvoiceVoucher), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper <  0 then return.
end.
else if (ocReverseInvoiceJournal = '':U or
         ocReverseInvoiceJournal = ?) and
         vlPOCAllowUpdateDaybookOnInv = true
then assign ocReverseInvoiceJournal = ""
            oiReverseInvoiceVoucher = 0. 
          
else do:
    <M-6 run SetMessage
       (input  trim(#T-7'Unable to retrieve the correct daybook from daybook set $1':255(413958374)T-7#) (icMessage), 
        input  icDaybookSet (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  1 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-9623':U:U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    assign oiReturnStatus = -1.
    return.
end.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.