  f                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 VERSION =   3.00      dataenvironment      dataenvironment      Dataenvironment      JLeft = 1
Top = 220
Width = 520
Height = 200
Name = "Dataenvironment"
      1      1      t_form      ..\libs\t_base.vcx      form      frmInvoicing     Height = 329
Width = 277
DoCreate = .T.
AutoCenter = .T.
Caption = "Pre-Invoicing Report"
ccompanytoinvoice = 
dinvoicemonth = {}
ninvoicemonth = 1
dinvoicemonthplus2 = {}
lfirstinvoice = .T.
dinvoicedate = {}
dinvoicedateplus2 = {}
cinvcode = 
Name = "frmInvoicing"
     ,PROCEDURE formatinvoicedate
LOCAL temp1, temp2

* Change starting invoice date to first of the selected month in the YYYYMMDD format
temp1  = ALLTRIM(STR(YEAR(DATE()))) + ',' + ALLTRIM(STR(thisform.nInvoiceMonth)) + ',01'

* Change invoice dates to correct Y2K format and add 2 months
thisform.dInvoiceDate = DATE(&Temp1)
thisform.dInvoiceDatePlus2 = GOMONTH(DATE(&temp1), + 2)

* get the first 3 letters of the billing months.  1 = JAN, 2 = FEB
thisform.cInvoicemonth = LEFT(CMONTH(thisform.dInvoiceDate), 3)
thisform.cInvoiceMonthPlus2 = LEFT(CMONTH(thisform.dInvoiceDatePlus2), 3)

* Change date formats to MM/YY format
thisform.dInvoiceMonth   = thisform.mth_yr_format(thisform.dInvoiceDate)
thisform.dInvoiceMonthPlus2 = thisform.mth_yr_format(thisform.dInvoiceDatePlus2)

* get current system date and change to MM/YY format
thisform.cCurrentSystemDate = thisform.mth_yr_format(DATE())

* format string for date comparison when selecting invoice line items
thisform.sInvoiceMonth   = "InvoicableSalesRpt.sa_b" + thisform.cInvoicemonth
thisform.sInvoiceMonthPlus2 = "InvoicableSalesRpt.sa_b" + thisform.cInvoiceMonthPlus2
ENDPROC
PROCEDURE doinvoicing
thisform.FormatInvoiceDate
thisform.GetInvoicableSalesRecords
IF thisform.lContinue
	thisform.OpenDatabases
	thisform.GetInvoiceLineItems
	IF thisform.lContinue
		thisform.GetInvoiceHeaderInfo
		IF thisform.lContinue
			thisform.PrintReport
		ENDIF
		thisform.CloseDatabases
	ELSE
		MESSAGEBOX("Of the potential invoicable records non were eligable.",64,"Invoicing")
	ENDIF
ELSE
	MESSAGEBOX("No records were found to Invoice.",64,"Invoicing")
ENDIF

THISFORM.RELEASE()
ENDPROC
PROCEDURE mth_yr_format
PARAMETER tempdate

PRIVATE tmonth, tyear, rvalue

tmonth = MONTH(tempdate)
tyear  = YEAR(tempdate)

rvalue = ALLTRIM(STR(tmonth)) + '/' + ALLTRIM(STR(tyear))

RETURN(rvalue)

ENDPROC
PROCEDURE getinvoicablesalesrecords
* Get Sales records for appropriate months
PRIVATE SQLMonth, SQLMonth_2, cCompany, nPosition, cCompanyCode

SQLcurmth   = "sales.sa_b" + thisform.cInvoiceMonth
SQLcurmth_2 = "sales.sa_b" + thisform.cInvoiceMonthPlus2

* This is used to convert the company name to the company code
nPosition = ASCAN(thisform.aCompanyCode, ThisForm.cboCompanyCode.value) && Search for company
IF nPosition != 0
	nPosition = nPosition + 2
   *** Company found, get company code ***
   cCompanyCode = thisform.aCompanyCode[nPosition]
ENDIF

* Select appropriate sales records
	SELECT *;
	 FROM trackerdb!sales;
	 WHERE Sales.sa_status = 'A';
	   AND Sales.sa_company = cCompanyCode;
	   AND (&SQLcurmth = .T.;
	   OR (&SQLcurmth_2 = .T.));
	   AND (LEFT(Sales.sa_pr_id, 1) = 'A';
	   OR (LEFT( Sales.sa_pr_id, 1) = 'S'));
	 INTO TABLE tmp\InvoicableSalesRpt.dbf

* If the there are no records found then we should stop	 
 	IF RECCOUNT() > 0
		thisform.lContinue = .T.
		INDEX ON sa_cu_id TAG sa_cu_id
	ELSE
		thisform.lContinue = .F.
	ENDIF

	USE
	
	SELECT sales
	USE

ENDPROC
PROCEDURE opendatabases
OPEN DATABASE trackerdb

IF USED("InvoicableSalesRpt.dbf")
	SELECT InvoicableSalesRpt.dbf
	SET ORDER TO sa_cu_id
ELSE
	SELECT 0
	USE (LOCFILE("tmp\InvoicableSalesRpt.dbf","DBF","Where is InvoicableSalesRpt ?"));
		AGAIN ALIAS InvoicableSalesRpt
	SET ORDER TO sa_cu_id
ENDIF

IF USED("PreInvoiceRpt")
	SELECT PreInvoiceRpt
	SET ORDER TO TAG Customer_i
ELSE
	SELECT 0
	USE (LOCFILE("PreInvoiceRpt.dbf","DBF","Where is PreInvoiceRpt ?")) EXCLUSIVE ;
		AGAIN ALIAS PreInvoiceRpt
	SET ORDER TO TAG Customer_i
ENDIF
ZAP

IF USED("customer")
	SELECT customer
	SET ORDER TO TAG cu_id
ELSE
	SELECT 0
	USE (LOCFILE("customer.dbf","DBF","Where is customer ?"));
		AGAIN ALIAS customer
	SET ORDER TO TAG cu_id
ENDIF

SELECT InvoicableSalesRpt
SET RELATION TO InvoicableSalesRpt.sa_cu_id INTO CUSTOMER ADDITIVE
SELECT customer

ENDPROC
PROCEDURE getinvoicelineitems
PRIVATE nRecordsRead, nInvoiceCount, cPrev_cu_id, cCu_ID
nRecordsRead = 0
nInvoiceCount = 0
cPrev_cu_id = ''
cCu_ID = ''


* For progress thermometer
#DEFINE c_thermtitle 'Invoice Extract'
#DEFINE c_thermmssg 'Processing Sales file'
_elibarcon = -1
_runmancon = 3
_iconpostion = 5

	SELECT PreInvoiceRpt
	SET ORDER TO TAG Customer_I
	
	SELECT InvoicableSalesRpt
	
	GOTO TOP
	DO therm WITH RECCOUNT(), nRecordsRead, 'Invoicing', 'Processing Sales file', ''

	DO WHILE NOT EOF("InvoicableSalesRpt") AND LASTKEY() <> 27

		cCu_ID = thisform.SelectInvoiceLineItem()

		IF !EMPTY(cCu_ID)
			SEEK cCU_ID IN PreInvoiceRpt
			IF !FOUND("PreInvoiceRpt")
				INSERT INTO PreInvoiceRpt (Customer_ID) VALUES (cCu_ID)
				nInvoiceCount = nInvoiceCount + 1
			ENDIF
		ENDIF
	
		SKIP 1 IN InvoicableSalesRpt
		nRecordsRead = nRecordsRead + 1
		DO therm WITH RECCOUNT(), nRecordsRead, 'Invoicing', 'Processing Sales file', ''
	
	ENDDO

	DO therm WITH RECCOUNT(), nRecordsRead, 'Invoicing', 'Processing Sales file', ''
	
	SELECT InvoicableSalesRpt
	USE
	
	IF RECCOUNT("PreInvoiceRpt") > 0
		thisform.lContinue = .T.
	ELSE
		thisform.lContinue = .F.
	ENDIF
	
RETURN


ENDPROC
PROCEDURE getinvoiceheaderinfo
PRIVATE recs_read, cMarket
recs_read = 0
_elibarcon = -1
_runmancon = 3
_iconpostion = 5

set exact on

SELECT Customer
	SET ORDER TO TAG Customer_I

SELECT PreInvoiceRpt
GOTO TOP

DO therm WITH RECCOUNT('PreInvoiceRpt'), recs_read, 'Invoicing', 'Matching sales and customer information', ''

DO WHILE NOT EOF('PreInvoiceRpt')

	SEEK PreInvoiceRpt.Customer_ID IN Customer

	IF FOUND('Customer')
		cMarket = LEFT(customer.cu_acctno, 1)
		IF (cMarket = "T") or (cMarket = "E")
			REPLACE PreInvoiceRpt.Name 			WITH customer.cu_sname
			REPLACE PreInvoiceRpt.City 			WITH customer.cu_scity
			REPLACE PreInvoiceRpt.State	 		WITH customer.cu_sstate
			REPLACE PreInvoiceRpt.Country 		WITH customer.cu_scounty
			REPLACE PreInvoiceRpt.AccountNum 	WITH customer.cu_acctno
			REPLACE PreInvoiceRpt.Region  		WITH customer.cu_region
		ELSE
			DELETE
		ENDIF
	ELSE
		MESSAGEBOX(PreInvoiceRpt.Customer_ID + " Customer detail data not found", 48 ,"Error")
	ENDIF
		
		SKIP 1 IN PreInvoiceRpt
		recs_read = recs_read + 1
		
		DO therm WITH RECCOUNT('PreInvoiceRpt'), recs_read, c_thermtitle, 'Matching sales and customer information', ''
ENDDO

DO therm WITH RECCOUNT('PreInvoiceRpt'), recs_read, c_thermtitle, 'Matching sales and customer information', ''

PACK

IF RECCOUNT() < 1
	MESSAGEBOX("There are no Trade or International accounts to Invoice",48,"Print Pre-Invoice Report")
	thisform.lContinue = .F.
ENDIF
ENDPROC
PROCEDURE getinvoicecodes
	WAIT WINDOW "Getting Invoice Codes" NOWAIT
	SELECT DISTINCT Inv_data.d_cuid, Inv_data.d_invnum, Inv_data.d_invcode, Inv_data.d_linvdt;
 		FROM Inv_data;
 		INTO TABLE tmp\tmp_code.dbf
	
	IF RECCOUNT('tmp_code') > 0
 		
		INDEX ON d_invnum TAG D_invnum ADDITIVE
	
		SELECT inv_head
		SET ORDER TO TAG D_invnum OF tmp\tmp_code.cdx IN Tmp_Code
		SET RELATION TO Inv_head.h_invnum INTO Tmp_code ADDITIVE

		REPLACE ALL inv_head.h_Invcode WITH Tmp_code.d_Invcode ;
			FOR Inv_head.h_invnum =  Tmp_code.d_invnum
			
		REPLACE ALL inv_head.h_linvdt WITH Tmp_code.d_linvdt ;
			FOR Inv_head.h_invnum =  Tmp_code.d_invnum
			
	ENDIF
	WAIT CLEAR
	
RETURN
ENDPROC
PROCEDURE countbillingperiods
	PRIVATE period_cnt

	period_cnt = 0

	IF InvoicableSalesRpt.sa_bjan = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bfeb = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bmar = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bapr = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bmay = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bjun = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bjul = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_baug = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bsep = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_boct = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bnov = .T.
		period_cnt = period_cnt + 1
	ENDIF
	IF InvoicableSalesRpt.sa_bdec = .T.
		period_cnt = period_cnt + 1
	ENDIF
	RETURN(period_cnt)


ENDPROC
PROCEDURE selectinvoicelineitem
	PRIVATE rvalue, sInvoiceMonth, sInvoiceMonthPlus2
	
	rvalue = ""
	sInvoiceMonth = thisform.sInvoiceMonth
	sInvoiceMonthPlus2 = thisform.sInvoiceMonthPlus2
	
	IF NOT DELETED() AND InvoicableSalesRpt.sa_status = 'A'
		IF &sInvoiceMonth OR &sInvoiceMonthPlus2
			IF &sInvoiceMonth
				IF LEFT(InvoicableSalesRpt.sa_pr_id, 1) = "A"

					lastinvdt = thisform.mth_yr_format(InvoicableSalesRpt.sa_linvdt)
					IF lastinvdt <> thisform.cCurrentSystemDate
						IF EMPTY(InvoicableSalesRpt.sa_linvdt)
							rvalue = InvoicableSalesRpt.sa_cu_id
						ELSE
							IF thisform.CountBillingPeriods() = 12
								rvalue = InvoicableSalesRpt.sa_cu_id
							ENDIF
						ENDIF
					ENDIF
				ELSE
					IF LEFT(InvoicableSalesRpt.sa_pr_id, 1) = "S"
						IF EMPTY(InvoicableSalesRpt.sa_linvdt)
							rvalue = InvoicableSalesRpt.sa_cu_id
						ENDIF
					ENDIF
				ENDIF
			ELSE
				IF &sInvoiceMonthPlus2 = .T.
					IF LEFT(InvoicableSalesRpt.sa_pr_id, 1) = "A"
	
						lastinvdt = thisform.mth_yr_format(InvoicableSalesRpt.sa_linvdt)
						IF lastinvdt <> thisform.cCurrentSystemDate
							rvalue = InvoicableSalesRpt.sa_cu_id
						ENDIF
					ELSE
						IF LEFT(InvoicableSalesRpt.sa_pr_id, 1) = "S"
							IF EMPTY(InvoicableSalesRpt.sa_linvdt)
								rvalue = InvoicableSalesRpt.sa_cu_id
							ENDIF
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
RETURN(rvalue)

ENDPROC
PROCEDURE getsubscriptionperiod
PARAMETER billingmonth
PRIVATE periods, begindate, enddate, billingmonth

periods = thisform.CountBillingPeriods()
*	begindate = CTOD(ALLTRIM(STR(MONTH(billingmonth))) + "/01/" + ALLTRIM(STR(YEAR(billingmonth))))
begindate = DATE(YEAR(billingmonth), MONTH(billingmonth), 01)

periods = (12/periods) - 1
enddate = GOMONTH(begindate, periods)

m.d_subdate = ALLTRIM(CMONTH(begindate))  + " " + ALLTRIM(STR(YEAR(begindate))) + ;
	" - " + ALLTRIM(CMONTH(enddate)) + " " + ALLTRIM(STR(YEAR(enddate)))

ENDPROC
PROCEDURE closedatabases
IF USED("InvoicableSalesRpt.dbf")
	SELECT InvoicableSalesRpt.dbf
	USE
ENDIF

IF USED("customer")
	SELECT customer
	USE
ENDIF

IF USED("company")
	SELECT company
	USE
ENDIF

IF USED("PreinvoiceRpt")
	SELECT PreinvoiceRpt
	USE
ENDIF

ENDPROC
PROCEDURE printreport
SELECT PreInvoiceRpt
SET ORDER TO TAG Rpt

IF MESSAGEBOX("Would you like to see a preview",4,"Print Report")=6
	REPORT FORM PreInvoice NOCONSOLE PREVIEW
ELSE
	REPORT FORM PreInvoice NOCONSOLE TO PRINTER
ENDIF

ENDPROC
PROCEDURE Init
SET PATH TO PROGS, FORMS, LIBS, MENUS, DATA, ;
        REPORTS, INCLUDES, HELP, BITMAPS

ON ERROR DO progs\errhand WITH ;
   ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( ), SELECT(), RECNO()

* Build array for company codes
SELECT Company.co_name, Company.company_id, Company.co_code;
 FROM trackerdb!company;
 ORDER BY Company.co_name;
 INTO ARRAY thisform.aCompanyCode
 
USE

ThisForm.cboCompanyCode.NumberOfElements = ALEN(thisform.aCompanyCode)

ThisForm.cboCompanyCode.value = 'Baker & Taylor'
ENDPROC
                                         %   S       h      b             U    C    U  THISFORM RELEASE Click,     1  1                       #       )                                                         '   %                             U  F  %C   
 
     ?  R, Company is empty  U  THISFORM CCOMPANYTOINVOICE DOINVOICING Click,     1 1  A 1                       {       )                           !Arial, 0, 9, 5, 15, 12, 32, 3, 0
      eCaption = "Invoice What Company"
Height = 16
Left = 24
Top = 209
Width = 144
Name = "T_label2"
      frmInvoicing      T_label2      label      ..\libs\t_base.vcx      t_label      pAlignment = 2
Caption = "Invoice What Month"
Height = 16
Left = 57
Top = 7
Width = 162
Name = "T_label1"
      frmInvoicing      T_label1      label      ..\libs\t_base.vcx      t_label     ColumnCount = (ALEN(aCompanyCode,2))
RowSourceType = 5
RowSource = "thisform.aCompanyCode"
DisplayValue = 
ControlSource = "thisform.cCompanyToInvoice"
FirstElement = 1
Height = 24
Left = 24
NumberOfElements = 0
Style = 2
Top = 228
Width = 228
Name = "cboCompanyCode"
      frmInvoicing      cboCompanyCode      combobox      ..\libs\t_base.vcx      
t_combobox      .PROCEDURE Click
thisform.release()
ENDPROC
      VTop = 288
Left = 155
Height = 24
Width = 75
Caption = "\<Quit"
Name = "cmdQuit"
      frmInvoicing      cmdQuit      commandbutton      ..\libs\t_base.vcx      t_commandbutton      PROCEDURE Click
IF !EMPTY(ThisForm.cCompanyToInvoice)
	thisform.DoInvoicing
ELSE
	wait window "Company is empty"
ENDIF
ENDPROC
      ]Top = 288
Left = 47
Height = 24
Width = 75
Caption = "\<Continue"
Name = "cmdContinue"
      frmInvoicing      cmdContinue      commandbutton      ..\libs\t_base.vcx      t_commandbutton     aAutoSize = .F.
ButtonCount = 12
Value = 1
ControlSource = "thisform.nInvoiceMonth"
Height = 154
Left = 57
Top = 24
Width = 162
Name = "cmgMonth"
Command1.AutoSize = .F.
Command1.Top = 5
Command1.Left = 5
Command1.Height = 24
Command1.Width = 75
Command1.Caption = "January"
Command1.Name = "Command1"
Command2.AutoSize = .F.
Command2.Top = 29
Command2.Left = 5
Command2.Height = 24
Command2.Width = 75
Command2.Caption = "February"
Command2.Name = "Command2"
Command3.AutoSize = .F.
Command3.Top = 53
Command3.Left = 5
Command3.Height = 24
Command3.Width = 75
Command3.Caption = "March"
Command3.Name = "Command3"
Command4.AutoSize = .F.
Command4.Top = 77
Command4.Left = 5
Command4.Height = 24
Command4.Width = 75
Command4.Caption = "April"
Command4.Name = "Command4"
Command5.AutoSize = .F.
Command5.Top = 101
Command5.Left = 5
Command5.Height = 24
Command5.Width = 75
Command5.Caption = "May"
Command5.Name = "Command5"
Command6.AutoSize = .F.
Command6.Top = 125
Command6.Left = 5
Command6.Height = 24
Command6.Width = 75
Command6.Caption = "June"
Command6.Name = "Command6"
Command7.AutoSize = .F.
Command7.Top = 5
Command7.Left = 82
Command7.Height = 24
Command7.Width = 75
Command7.Caption = "July"
Command7.Name = "Command7"
Command8.AutoSize = .F.
Command8.Top = 29
Command8.Left = 82
Command8.Height = 24
Command8.Width = 75
Command8.Caption = "August"
Command8.Name = "Command8"
Command9.AutoSize = .F.
Command9.Top = 53
Command9.Left = 82
Command9.Height = 24
Command9.Width = 75
Command9.Caption = "Septemeber"
Command9.Name = "Command9"
Command10.AutoSize = .F.
Command10.Top = 77
Command10.Left = 82
Command10.Height = 24
Command10.Width = 75
Command10.Caption = "October"
Command10.Name = "Command10"
Command11.AutoSize = .F.
Command11.Top = 101
Command11.Left = 82
Command11.Height = 24
Command11.Width = 75
Command11.Caption = "November"
Command11.Name = "Command11"
Command12.AutoSize = .F.
Command12.Top = 125
Command12.Left = 82
Command12.Height = 24
Command12.Width = 75
Command12.Caption = "December"
Command12.Name = "Command12"
      frmInvoicing      cmgMonth      commandgroup      ..\libs\t_base.vcx      t_commandgroup     cccompanytoinvoice
dinvoicemonth
ninvoicemonth
dinvoicemonthplus2
cinvoicemonth
cinvoicemonthplus2
sinvoicemonth
sinvoicemonthplus2
lfirstinvoice
ccurrentsystemdate
dinvoicedate
dinvoicedateplus2
ccurrentinvoicenumber
cpreviousinvoicenumber
cheaderinvoicenumber
cdetailinvoicenumber
lcontinue
cinvcode
^acompanycode[1,0] 
*formatinvoicedate 
*doinvoicing 
*mth_yr_format 
*getinvoicablesalesrecords 
*opendatabases 
*getinvoicelineitems 
*getinvoiceheaderinfo 
*getinvoicecodes 
*countbillingperiods 
*selectinvoicelineitem 
*getsubscriptionperiod 
*closedatabases 
*printreport 
     "    "  "                           %         !  -  %            U  t    ) T  CCCC$iZ ,CC  Z ,01( thisform.dInvoiceDate = DATE(&Temp1)
; thisform.dInvoiceDatePlus2 = GOMONTH(DATE(&temp1), + 2)
 T  CC  != T  CC  != T  C   	  T 
 C   	  T  CC$ 	 . T   InvoicableSalesRpt.sa_b  . T   InvoicableSalesRpt.sa_b   U  TEMP1 TEMP2 THISFORM NINVOICEMONTH CINVOICEMONTH DINVOICEDATE CINVOICEMONTHPLUS2 DINVOICEDATEPLUS2 DINVOICEMONTH MTH_YR_FORMAT DINVOICEMONTHPLUS2 CCURRENTSYSTEMDATE SINVOICEMONTH SINVOICEMONTHPLUS2/
    
     %    
    
     %   z 
     %   l 
     
      Q C6 Of the potential invoicable records non were eligable.@	 Invoicingx  < C! No records were found to Invoice.@	 Invoicingx  C  	  U
  THISFORM FORMATINVOICEDATE GETINVOICABLESALESRECORDS	 LCONTINUE OPENDATABASES GETINVOICELINEITEMS GETINVOICEHEADERINFO PRINTREPORT CLOSEDATABASES RELEASE_  4   5    T C  H T C  i T CC Z /CC Z
 B  U  TEMPDATE TMONTH TYEAR RVALUE  5       T 
 sales.sa_b   T 
 sales.sa_b 	  T C 
     %    T   T C   
   SELECT * FROM trackerdb!sales WHERE Sales.sa_status = 'A' AND Sales.sa_company = cCompanyCode AND (&SQLcurmth = .T. OR (&SQLcurmth_2 = .T.)) AND (LEFT(Sales.sa_pr_id, 1) = 'A' OR (LEFT( Sales.sa_pr_id, 1) = 'S')) INTO TABLE tmp\InvoicableSalesRpt.dbf
 %CN  T  a &     T  -  Q F  Q U  SQLMONTH
 SQLMONTH_2 CCOMPANY	 NPOSITION CCOMPANYCODE	 SQLCURMTH THISFORM CINVOICEMONTH SQLCURMTH_2 CINVOICEMONTHPLUS2 ACOMPANYCODE CBOCOMPANYCODE VALUE	 LCONTINUE SA_CU_ID SALES 	 trackerdb% %C InvoicableSalesRpt.dbfQ 
 F   G(( sa_cu_id   F  R QC tmp\InvoicableSalesRpt.dbf DBF Where is InvoicableSalesRpt ?  G(( sa_cu_id  %C PreInvoiceRpt  F  G((
 Customer_i f F  E QC PreInvoiceRpt.dbf DBF Where is PreInvoiceRpt ?  G((
 Customer_i  S %C customer F  G(( cu_id  F  : QC customer.dbf DBF Where is customer ?  G(( cu_id  F  G-(    F  U 	 TRACKERDB INVOICABLESALESRPT DBF SA_CU_ID PREINVOICERPT
 CUSTOMER_I CUSTOMER CU_ID 5      T    T   T    T    T  T  T  F  G((
 Customer_I F	  #)@ 
 CN  	 Invoicing Processing Sales file  - +C InvoicableSalesRpt+
 C|	 T C   %C 
 E   %C PreInvoiceRpt4
" r PreInvoiceRpt   T     H	  T    @ 
 CN  	 Invoicing Processing Sales file   @ 
 CN  	 Invoicing Processing Sales file   F	  Q  %C PreInvoiceRptN c T  a y T  -  B U  NRECORDSREAD NINVOICECOUNT CPREV_CU_ID CCU_ID
 _ELIBARCON
 _RUNMANCON _ICONPOSTION PREINVOICERPT
 CUSTOMER_I INVOICABLESALESRPT THERM THISFORM SELECTINVOICELINEITEM CUSTOMER_ID	 LCONTINUE 5    T    T  T  T  G  F  G((
 Customer_I F  #)b  C PreInvoiceRptN  	 Invoicing' Matching sales and customer information   +C PreInvoiceRpt+
 E  	  %C Customer4 T C 
 =  %  T
   E >     >     >     >     >   
  >        = C 	   Customer detail data not found0 Errorx  H  T    h  C PreInvoiceRptN   Invoice Extract' Matching sales and customer information   h  C PreInvoiceRptN   Invoice Extract' Matching sales and customer information   3 %CNa C7 There are no Trade or International accounts to Invoice0 Print Pre-Invoice Reportx T  -  U 	 RECS_READ CMARKET
 _ELIBARCON
 _RUNMANCON _ICONPOSTION CUSTOMER
 CUSTOMER_I PREINVOICERPT THERM CUSTOMER_ID	 CU_ACCTNO NAME CU_SNAME CITY CU_SCITY STATE	 CU_SSTATE COUNTRY
 CU_SCOUNTY
 ACCOUNTNUM REGION	 CU_REGION THISFORM	 LCONTINUE.  R,: Getting Invoice CodesI o Inv_data        1 tmp\tmp_code.dbf %C tmp_codeN  &    F ) G( ( D_invnum tmp\tmp_code.cdx G-( 	  $ >     	   $ >     	     R B U  DISTINCT INV_DATA D_CUID D_INVNUM	 D_INVCODE D_LINVDT TMP INV_HEAD TMP_CODE H_INVNUM ALL	 H_INVCODE FOR H_LINVDT 5   T    %  a7  T      %  a^  T      %  a  T      %  a  T      %  a  T      %  a  T      %  a! T      % 	 aH T      % 
 ao T      %  a T      %  a T      %  a T     
 B   U 
 PERIOD_CNT INVOICABLESALESRPT SA_BJAN SA_BFEB SA_BMAR SA_BAPR SA_BMAY SA_BJUN SA_BJUL SA_BAUG SA_BSEP SA_BOCT SA_BNOV SA_BDEC 5     T     T    T    %C'
    A	r0 IF &sInvoiceMonth OR &sInvoiceMonthPlus2n IF &sInvoiceMonth %C  = AA T C 	    %  
 = %C 	  T     9 %C  5 T         %C  = S %C 	  T        j$ IF &sInvoiceMonthPlus2 = .T.f %C  = A T C 	    %  
  T      b %C  = S^ %C 	 Z T           
 B   U  RVALUE SINVOICEMONTH SINVOICEMONTHPLUS2 THISFORM INVOICABLESALESRPT	 SA_STATUS SA_PR_ID	 LASTINVDT MTH_YR_FORMAT	 SA_LINVDT CCURRENTSYSTEMDATE SA_CU_ID COUNTBILLINGPERIODS  4   5      T C   T CC  iC  H$ T   T C  @ T CC !  CCC iZ  - CC !  CCC iZ U  BILLINGMONTH PERIODS	 BEGINDATE ENDDATE THISFORM COUNTBILLINGPERIODS	 D_SUBDATE % %C InvoicableSalesRpt.dbf3 
 F    Q  %C customerY  F  Q  %C company~  F  Q  %C PreinvoiceRpt  F  Q  U  INVOICABLESALESRPT DBF CUSTOMER COMPANY PREINVOICERPT  F   G(( RptE %C Would you like to see a preview Print Reportxl  ?
 PreInvoice9   ?
 PreInvoice(!9  U  PREINVOICERPT RPT
 PREINVOICE8K G)(B PROGS, FORMS, LIBS, MENUS, DATA,  REPORTS, INCLUDES, HELP, BITMAPSi 1a DO progs\errhand WITH  ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( ), SELECT(), RECNO()D o trackerdb!company           Q T  	 C  ! T  
  Baker & Taylor U  PROGS COMPANY CO_NAME
 COMPANY_ID CO_CODE	 TRACKERDB THISFORM ACOMPANYCODE CBOCOMPANYCODE NUMBEROFELEMENTS VALUE formatinvoicedate,      doinvoicingx     mth_yr_formatN     getinvoicablesalesrecords     opendatabases     getinvoicelineitems
     getinvoiceheaderinfo\     getinvoicecodes     countbillingperiods     selectinvoicelineitem     getsubscriptionperiodY     closedatabasesa     printreportP     Init    1  c2       A   A  A  2 q     3 rRA     A B r A 3 R   "A q 1  R1A A rq     A r 1q 3 1       r 1r R  !A A  B r A    A B 4      b r 1r Q "rQ111111 A A  A  A B  A 2  r 1CCB Q B 2 q  "A !A !A !A !A !A !A !A !A !A !A !A  4   rA! QA A A  !A A A  ArAA  !A A A A A A A  3 q 1b!3 Q A A rq A A bq A A q A A 3 q  RA QA 3 FB 1                       }                     b  /   '       <   :     E  d   X   o  !     |   L                                 r&  =    &  (  p    (  )      )  *    &  *  ,     )   "                  
