project QadFinancials > class BMFGLegalDocument > method getHistInvoiceComponentsByNRM

Description

This procedure takes the inv_nbr and domain as the input, to get year, daybook and voucher number from nr_mstr table, which are make up the standard invoice number.


Parameters


icInvoiceNumberinputcharacter
icGlobalDomaininputcharacter
oiYearoutputinteger
ocJournalCodeoutputcharacter
oiVoucherNumberoutputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BMFGLegalDocument.ApiLegalDocumentReport


program code (program1/bmfglegaldocument.p)

/* Get Customer Invoice History data by Invoice Number */
<Q-92 run InvoiceHistoryByInvNbr (all) (Read) (NoCache)
   (input icInvoiceNumber, (InvoiceNumber)
    input icGlobalDomain, (DomainCode)
    output dataset tqInvoiceHistoryByInvNbr) in BMfgInvoiceHistory>

find first tqInvoiceHistoryByInvNbr no-error.
if available tqInvoiceHistoryByInvNbr
then assign ocJournalCode = tqInvoiceHistoryByInvNbr.tcih_daybook
            vtEffDate     = tqInvoiceHistoryByInvNbr.ttih_inv_date.

/* Get Number Range data by Journal Code */
<Q-47 run NumberRangeForSequenceID (all) (Read) (NoCache)
   (input icGlobalDomain, (Domain)
    input ocJournalCode, (Seq)
    output dataset tqNumberRangeForSequenceID) in BMfgNRM>

find first tqNumberRangeForSequenceID no-error.
if available tqNumberRangeForSequenceID
then assign vcNumRangeSegType    = tqNumberRangeForSequenceID.tcnr_seg_type
            vcNumRangeSegVal     = tqNumberRangeForSequenceID.tcnr_seg_value
            vcNumRangeSegFormat  = tqNumberRangeForSequenceID.tcnr_seg_format.

/* Get GL year */
<Q-98 run GLCalendarYrByDateDomain (all) (Read) (NoCache)
    (input icGlobalDomain, (DomainCode)
     input vtEffDate, (Date)
     output dataset tqGLCalendarYrByDateDomain) in BMfgGLCalendar>

find first tqGLCalendarYrByDateDomain no-error.
if available tqGLCalendarYrByDateDomain 
then assign viCurrentYear = tqGLCalendarYrByDateDomain.tiglc_year.

do viCounter = 1 to num-entries(vcNumRangeSegType):
   assign vcSegType   = trim(entry(viCounter, vcNumRangeSegType))
         vcSegValue  = trim(entry(viCounter, vcNumRangeSegVal))
         vcSegFormat = trim(entry(viCounter, vcNumRangeSegFormat)).
   case vcSegType:
      /* Fiscal - Year */
      when "3"
      then do:
         if vcSegFormat = "Y2" and length(vcSegValue, "CHARACTER") = 2
         then assign oiYear = truncate((viCurrentYear / 100 ),0) * 100 + int(vcSegValue).
         else if vcSegFormat = "Y1" and length(vcSegValue, "CHARACTER") = 1
         then assign oiYear = truncate((viCurrentYear / 10 ),0) * 10 + int(vcSegValue).
         else assign oiYear = int(vcSegValue).
      end.
  
      /* Date */
      when "2"
      then assign oiYear = int(vcSegValue).
     
      /* Int - Voucher */
      when "1"
      then assign oiVoucherNumber = int(vcSegValue).
   end.  
end.