Using the Form Designer, you can create a dashboard to show current invoice totals, with links to lists of the invoices. This tutorial requires the IN Module.
Property |
Value |
Alignment |
taCentre |
ParentColor |
True |
Transparent |
True |
Next, you can write MaxBasic code to add the figures to the labels.
Sub RefreshCurrentPeriodInvoices
Dim PeriodToUse as Number
Dim TotalSales as Number
PeriodToUse = CurrentPeriod("AR")
TotalSales = 0
'Enter the SQL Query to extract the current Open Invoices
strSQLInvoices ="SELECT INHEAD.PeriodID as PeriodID " & _
" ,Sum(INHEAD.ExclusiveAmountBs) as ExclusiveAmount " & _
"FROM INHEAD " & _
"WHERE INHEAD.PeriodID = :PeriodToUse " & _
" AND INHEAD.PostStatus = 'O' " & _
" AND INHEAD.DocumentClass IN ('I', 'C') " & _
"GROUP BY INHEAD.PeriodID " & _
"ORDER BY INHEAD.PeriodID "
tblInvoices = ExecuteSQL(strSQLInvoices, PeriodTouse)
lblInvOpen.caption = " " & CHR(10) & " $" & FormatNumber(tblInvoices.ExclusiveAmount, ",0.00")
TotalSales = TotalSales + tblInvoices.ExclusiveAmount
'Enter the SQL Query to extract the current Posted Invoices
SQLInvoices ="SELECT INHEAD.PeriodID as PeriodID " & _
" ,Sum(INHEAD.ExclusiveAmountBs) as ExclusiveAmount " & _
"FROM INHEAD " & _
"WHERE INHEAD.PeriodID = :PeriodToUse " & _
" AND INHEAD.PostStatus = 'P' " & _
" AND INHEAD.DocumentClass IN ('I', 'C') " & _
"GROUP BY INHEAD.PeriodID " & _
"ORDER BY INHEAD.PeriodID "
tblInvoices = ExecuteSQL(SQLInvoices, PeriodTouse)
lblInvPosted.caption = " " & CHR(10) & " $" & FormatNumber(tblInvoices.ExclusiveAmount, ",0.00")
TotalSales = tblInvoices.ExclusiveAmount
'Enter the SQL Query to extract the current Unposted Invoices
strSQLInvoices ="SELECT INHEAD.PeriodID as PeriodID " & _
" ,Sum(INHEAD.ExclusiveAmountBs) as ExclusiveAmount " & _
"FROM INHEAD " & _
"WHERE INHEAD.PeriodID = :PeriodToUse " & _
" AND INHEAD.PostStatus = 'U' " & _
" AND INHEAD.DocumentClass IN ('I', 'C') " & _
"GROUP BY INHEAD.PeriodID " & _
"ORDER BY INHEAD.PeriodID "
tblInvoices = ExecuteSQL(strSQLInvoices, PeriodTouse)
lblInvUnPosted.caption = " " & CHR(10) & " $" & FormatNumber(tblInvoices.ExclusiveAmount, ",0.00")
TotalSales = TotalSales + tblInvoices.ExclusiveAmount
lblInvTotal.caption = " TOTAL " & CHR(10) & " $" & FormatNumber(TotalSales, ",0.00")
End Sub
Sub OnCreate
RefreshCurrentPeriodInvoices
End Sub
(Ctrl+S).(Ctrl+R) to test the form.Next, you can link the Link Labels to lists of invoices.
Sub ONLinkInvOpen
Dim Form1 as Object
Form1 = CreateObject("Accredo.INInvoiceListForm")
Form1.AutoSelect = True
Form1.ToggleShowAll
Form1.Selection = "All Documents"
Form1.PeriodSelection = "Period"
Form1.Invoice.FilterSort.Filter = "(DocumentClass=""C"" Or DocumentClass=""I"") And (PostStatus=""O"")"
End Sub
Sub ONLinkInvPosted
Dim PeriodToUse as Number
PeriodToUse = CurrentPeriod("AR")
SQLInvoices ="SELECT INHEAD.DocumentID as DocumentID " & _
" ,INHEAD.CustomerCode as Customer " & _
" ,INHEAD.DocumentDate as Date" & _
" ,INHEAD.DocumentNo as InvoiceNo " & _
" ,INHEAD.DocumentClass as Type " & _
" ,INHEAD.GrossAmountBs as GrossAmount" & _
" ,INHEAD.PeriodID as PeriodID " & _
" ,INHEAD.ExclusiveAmountBs as ExclusiveAmount " & _
"FROM INHEAD " & _
"WHERE INHEAD.PeriodID = :PeriodToUse " & _
" AND INHEAD.PostStatus = 'P' " & _
" AND INHEAD.DocumentClass IN ('I', 'C') " & _
" ORDER BY INHEAD.DocumentID "
tblPostedInvoices = ExecuteSQL(SQLInvoices, PeriodTouse)
tblPostedInvoices.Fields.Item(5).Total=True
tblPostedInvoices.Fields.Item(7).Total=True
Report = CreateReport(tblPostedInvoices, " Posted Invoices For Period " & PeriodName(PeriodToUse))
Report.Destination = "Screen"
Report.Run
End Sub
Sub ONLinkInvUnposted
Dim Form1 as Object
Form1 = CreateObject("Accredo.INInvoiceListForm")
Form1.AutoSelect = True
Form1.ToggleShowAll
Form1.Selection = "All Documents"
Form1.PeriodSelection = "Period"
Form1.Invoice.FilterSort.Filter = "(DocumentClass=""C"" Or DocumentClass=""I"") And (PostStatus=""U"")"
End Sub
(Ctrl+S).(Ctrl+R) to test the form. When you click on the Link Labels you will see the relevant list of Invoices.