project QadFinancials > class BCInvoice > method CreateCInvoicesDet

Description

Detail of CreateCInvoices because of 32K limit


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CreateCInvoices


program code (program3/bcinvoice.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

CREATEDETBLOCK:
do:
    /* must be after the defaulting of the reason because we need the initial flag */
    if tCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE}           or
       tCInvoice.CInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or
       tCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE}        or
       tCInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
    then do:         
        <M-1 run DefaultValuesDaybookSetCodeSite
           (input  tCInvoice.tc_Rowid (icCInvoiceRowID), 
            input  tCInvoice.CInvoiceType (icInvoiceType), 
            input  tCInvoice.CInvoiceIsInitialStatus (ilCInvoiceIsInitialStatus), 
            input-output tCInvoice.CInvoiceDayBookSetCode (bcDaybookSetCode), 
            input-output tCInvoice.CInvoiceSiteCode (bcSite), 
            input  false (ilUpdateDaybookAndVoucher), 
            input-output tCInvoice.tcJournalCode (bcDaybook), 
            input-output tCInvoice.CInvoiceVoucher (biVoucher), 
            input  0 (iiOldCInvoicePostingYear), 
            input  ? (icOldJournalCode), 
            input  0 (iiOldCInvoiceVoucher), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice> 
        if viFcReturnSuper <> 0 
        then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 
        then leave CREATEDETBLOCK.  
    end. /* if tCInvoice.CInvoiceType = {&INVOICETYPE-INVOICE}           or */

     /* Reserve a number for this sheet. */
     if tOpenBalanceCI.tiInvoiceVoucher   = 0 and
        tCInvoice.CInvoiceIsInitialStatus = false
     then do:
        /* ============================================== */
        /* Check if consecutive numbering is enabled.     */
        /* If so, use a temporary number.                 */
        /* Otherwise use standard numbering functionality */
        /* ============================================== */
        if vlCIDomainIsConsecutNr = true                              and
           (tOpenBalanceCI.tcInvoiceType <> {&INVOICETYPE-PREPAYMENT} and
            tOpenBalanceCI.tcInvoiceType <> {&INVOICETYPE-ADJUSTMENT})
        then assign viTempCInvoiceVoucher           = viTempCInvoiceVoucher + 1
                    tOpenBalanceCI.tiInvoiceVoucher = viTempCInvoiceVoucher.
        else do:
            /* This number will be released again by housekeeping if the */
            /* transaction was not committed by then.                    */
            assign vhFcComponent = ?.
            <M-2 run GetNumber
               (input  tOpenBalanceCI.tiCompanyId (iiCompanyId), 
                input  tOpenBalanceCI.tiPeriodYear (iiNumbrYear), 
                input  tOpenBalanceCI.tcJournalCode (icNumbrType), 
                output tOpenBalanceCI.tiInvoiceVoucher (oiNumber), 
                input  viFcCurrentInstanceId (iiInstanceId), 
                input  vcFcComponentName (icClassName), 
                output viFcReturnSuper (oiReturnStatus)) in BNumber>
            if viFcReturnSuper <> 0 
            then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0 
            then leave CREATEDETBLOCK.
        end. /* else do: */
    end. /* end tOpenBalanceCI.tiInvoiceVoucher = 0 and ... */
    assign tCInvoice.CInvoiceVoucher = tOpenBalanceCI.tiInvoiceVoucher.
end. /* CREATEDETBLOCK */

assign oiReturnStatus = viLocalReturnStatus.