Documentation
¶
Overview ¶
Package reports provides report generation for QuickBooks Online.
This package supports generating standard QuickBooks financial reports including Profit & Loss, Balance Sheet, Accounts Receivable Aging, Accounts Payable Aging, Cash Flow, and Trial Balance.
Features ¶
- All standard QuickBooks reports
- Configurable date ranges and parameters
- Report flattening for tabular display
- Custom column and row handling
Basic Usage ¶
service := reports.NewService(client)
params := &reports.Params{
StartDate: "2024-01-01",
EndDate: "2024-12-31",
}
report, err := service.ProfitAndLoss(ctx, params)
if err != nil {
log.Fatal(err)
}
Available Reports ¶
- ProfitAndLoss: Income statement report
- BalanceSheet: Financial position report
- AgedReceivables: Customer aging report
- AgedReceivablesDetail: Detailed customer aging
- AgedPayables: Vendor aging report
- AgedPayablesDetail: Detailed vendor aging
- CashFlow: Cash flow statement
- TrialBalance: Trial balance report
Flattening Reports ¶
Reports have a hierarchical structure. Use Flatten() to convert to a tabular format:
rows := report.Flatten()
for _, row := range rows {
fmt.Printf("%s: %v\n", row.Label, row.Values)
}
Package reports provides report generation for QuickBooks Online.
Index ¶
- type AccountingMethod
- type ColData
- type Column
- type Columns
- type FlatRow
- type Header
- type MetaData
- type Option
- type Params
- type Report
- type ReportName
- type Row
- type RowHeader
- type Rows
- type Service
- func (s *Service) AgedPayables(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) AgedPayablesDetail(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) AgedReceivables(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) AgedReceivablesDetail(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) BalanceSheet(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) BalanceSheetDetail(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) CashFlow(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) Execute(ctx context.Context, name ReportName, params *Params) (*Report, error)
- func (s *Service) GeneralLedger(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) ProfitAndLoss(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) ProfitAndLossDetail(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) TransactionList(ctx context.Context, params *Params) (*Report, error)
- func (s *Service) TrialBalance(ctx context.Context, params *Params) (*Report, error)
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountingMethod ¶
type AccountingMethod string
AccountingMethod represents the accounting method for reports.
const ( // Accrual accounting method. Accrual AccountingMethod = "Accrual" // Cash accounting method. Cash AccountingMethod = "Cash" )
type ColData ¶
type ColData struct {
// Value is the display value.
Value string `json:"value,omitempty"`
// ID is the entity ID if applicable.
ID string `json:"id,omitempty"`
// Href is a link if applicable.
Href string `json:"href,omitempty"`
}
ColData represents column data in a row.
type Column ¶
type Column struct {
// ColTitle is the column title.
ColTitle string `json:"ColTitle,omitempty"`
// ColType is the type of column data.
ColType string `json:"ColType,omitempty"`
// MetaData contains column metadata.
MetaData []MetaData `json:"MetaData,omitempty"`
}
Column describes a single column in a report.
type Columns ¶
type Columns struct {
Column []Column `json:"Column,omitempty"`
}
Columns describes the column structure of a report.
type FlatRow ¶
type FlatRow struct {
// Label is the row label.
Label string
// Values contains the column values.
Values []string
// Depth is the nesting depth (for indentation).
Depth int
// IsSection indicates if this is a section header.
IsSection bool
// IsSummary indicates if this is a summary row.
IsSummary bool
}
FlatRow represents a flattened row for easier display.
func (FlatRow) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for FlatRow.
type Header ¶
type Header struct {
// ReportName is the name of the report.
ReportName string `json:"ReportName,omitempty"`
// ReportBasis is the accounting method (Accrual or Cash).
ReportBasis string `json:"ReportBasis,omitempty"`
// StartPeriod is the start date of the report period.
StartPeriod string `json:"StartPeriod,omitempty"`
// EndPeriod is the end date of the report period.
EndPeriod string `json:"EndPeriod,omitempty"`
// Currency is the currency code.
Currency string `json:"Currency,omitempty"`
// Time is when the report was generated.
Time string `json:"Time,omitempty"`
// Options contains additional report options.
Options []Option `json:"Option,omitempty"`
}
Header contains report metadata.
type Params ¶
type Params struct {
// StartDate is the start date for the report (YYYY-MM-DD).
StartDate string `url:"start_date,omitempty"`
// EndDate is the end date for the report (YYYY-MM-DD).
EndDate string `url:"end_date,omitempty"`
// DateMacro is a date range macro (e.g., "Last Month", "This Year").
DateMacro string `url:"date_macro,omitempty"`
// AccountingMethod is either "Accrual" or "Cash".
AccountingMethod string `url:"accounting_method,omitempty"`
// SummarizeColumnsBy controls column summarization.
SummarizeColumnsBy string `url:"summarize_column_by,omitempty"`
// Columns specifies which columns to include.
Columns string `url:"columns,omitempty"`
// Customer filters by customer ID.
Customer string `url:"customer,omitempty"`
// Vendor filters by vendor ID.
Vendor string `url:"vendor,omitempty"`
// Department filters by department.
Department string `url:"department,omitempty"`
// ReportDate is the as-of date for point-in-time reports (YYYY-MM-DD).
ReportDate string `url:"report_date,omitempty"`
// AgingMethod for aging reports ("Report_Date" or "Current").
AgingMethod string `url:"aging_method,omitempty"`
}
Params represents common report parameters.
type Report ¶
type Report struct {
// Header contains report metadata.
Header Header `json:"Header,omitempty"`
// Columns describes the column structure.
Columns Columns `json:"Columns,omitempty"`
// Rows contains the report data.
Rows Rows `json:"Rows,omitempty"`
}
Report represents a QuickBooks Online report response.
type ReportName ¶
type ReportName string
ReportName represents standard report names.
const ( // ProfitAndLoss is the Profit and Loss report. ProfitAndLoss ReportName = "ProfitAndLoss" // ProfitAndLossDetail is the detailed Profit and Loss report. ProfitAndLossDetail ReportName = "ProfitAndLossDetail" // BalanceSheet is the Balance Sheet report. BalanceSheet ReportName = "BalanceSheet" // BalanceSheetDetail is the detailed Balance Sheet report. BalanceSheetDetail ReportName = "BalanceSheetDetail" // CashFlow is the Cash Flow Statement report. CashFlow ReportName = "CashFlow" // AgedReceivables is the Accounts Receivable Aging Summary report. AgedReceivables ReportName = "AgedReceivables" // AgedReceivablesDetail is the Accounts Receivable Aging Detail report. AgedReceivablesDetail ReportName = "AgedReceivableDetail" // AgedPayables is the Accounts Payable Aging Summary report. AgedPayables ReportName = "AgedPayables" // AgedPayablesDetail is the Accounts Payable Aging Detail report. AgedPayablesDetail ReportName = "AgedPayableDetail" // TrialBalance is the Trial Balance report. TrialBalance ReportName = "TrialBalance" // GeneralLedger is the General Ledger report. GeneralLedger ReportName = "GeneralLedger" // TransactionList is the Transaction List report. TransactionList ReportName = "TransactionList" // CustomerIncome is the Income by Customer Summary report. CustomerIncome ReportName = "CustomerIncome" // VendorExpenses is the Expenses by Vendor Summary report. VendorExpenses ReportName = "VendorExpenses" )
type Row ¶
type Row struct {
// Type indicates the row type (Section, Data, Summary).
Type string `json:"type,omitempty"`
// Group is the group name for section rows.
Group string `json:"group,omitempty"`
// Header contains the row header for section rows.
Header *RowHeader `json:"Header,omitempty"`
// Rows contains nested rows for section rows.
Rows *Rows `json:"Rows,omitempty"`
// Summary contains the summary row for section rows.
Summary *Summary `json:"Summary,omitempty"`
// ColData contains the column data for data rows.
ColData []ColData `json:"ColData,omitempty"`
}
Row represents a single row in a report.
type RowHeader ¶
type RowHeader struct {
ColData []ColData `json:"ColData,omitempty"`
}
RowHeader represents a row header.
type Rows ¶
type Rows struct {
Row []Row `json:"Row,omitempty"`
}
Rows contains the rows of report data.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides report generation for QuickBooks Online.
func NewService ¶
NewService creates a new report service.
func (*Service) AgedPayables ¶
AgedPayables generates an Accounts Payable Aging Summary report.
func (*Service) AgedPayablesDetail ¶
AgedPayablesDetail generates an Accounts Payable Aging Detail report.
func (*Service) AgedReceivables ¶
AgedReceivables generates an Accounts Receivable Aging Summary report.
func (*Service) AgedReceivablesDetail ¶
AgedReceivablesDetail generates an Accounts Receivable Aging Detail report.
func (*Service) BalanceSheet ¶
BalanceSheet generates a Balance Sheet report.
func (*Service) BalanceSheetDetail ¶
BalanceSheetDetail generates a detailed Balance Sheet report.
func (*Service) GeneralLedger ¶
GeneralLedger generates a General Ledger report.
func (*Service) ProfitAndLoss ¶
ProfitAndLoss generates a Profit and Loss (Income Statement) report.
func (*Service) ProfitAndLossDetail ¶
ProfitAndLossDetail generates a detailed Profit and Loss report.
func (*Service) TransactionList ¶
TransactionList generates a Transaction List report.