Skip to content

Commit d09ddfe

Browse files
committed
[FEATURE] Add the Statement of Cash Flows and Balance Sheet reports
1 parent 1f97c22 commit d09ddfe

File tree

4 files changed

+330
-0
lines changed

4 files changed

+330
-0
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
import quickbooks from "../../quickbooks.app.mjs";
2+
import { DATE_MACRO_OPTIONS } from "../../common/constants.mjs";
3+
import {
4+
commaSeparateArray,
5+
booleanToString,
6+
} from "../../common/utils.mjs";
7+
8+
export default {
9+
key: "quickbooks-get-balance-sheet-report",
10+
name: "Get Balance Sheet Report",
11+
description: "Retrieves the balance sheet report from Quickbooks Online. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/balancesheet#query-a-report)",
12+
version: "0.0.1",
13+
type: "action",
14+
annotations: {
15+
destructiveHint: false,
16+
openWorldHint: true,
17+
readOnlyHint: true,
18+
},
19+
props: {
20+
quickbooks,
21+
customer: {
22+
type: "string[]",
23+
label: "Customer IDs",
24+
description: "Filters report contents to include information for specified customers",
25+
optional: true,
26+
propDefinition: [
27+
quickbooks,
28+
"customer",
29+
],
30+
},
31+
qzurl: {
32+
type: "boolean",
33+
label: "Include Quick Zoom URL",
34+
description: "Specifies whether Quick Zoom URL information should be generated for rows in the report",
35+
optional: true,
36+
},
37+
accountingMethod: {
38+
propDefinition: [
39+
quickbooks,
40+
"accountingMethod",
41+
],
42+
},
43+
dateMacro: {
44+
type: "string",
45+
label: "Date Macro",
46+
description: "Predefined date range. Use if you want the report to cover a standard report date range; otherwise, use the **Start Date** and **End Date** to cover an explicit report date range",
47+
options: DATE_MACRO_OPTIONS,
48+
optional: true,
49+
},
50+
startDate: {
51+
type: "string",
52+
label: "Start Date",
53+
description: "The start date of the report, in the format `YYYY-MM-DD`. **Start Date** must be less than **End Date**",
54+
optional: true,
55+
},
56+
endDate: {
57+
type: "string",
58+
label: "End Date",
59+
description: "The end date of the report, in the format `YYYY-MM-DD`. **Start Date** must be less than **End Date**",
60+
optional: true,
61+
},
62+
adjustedGainLoss: {
63+
type: "boolean",
64+
label: "Adjusted Gain Loss",
65+
description: "Specifies whether unrealized gain and losses are included in the report",
66+
optional: true,
67+
},
68+
classIds: {
69+
propDefinition: [
70+
quickbooks,
71+
"classIds",
72+
],
73+
},
74+
item: {
75+
type: "string[]",
76+
label: "Item IDs",
77+
description: "Filters report contents to include information for specified items",
78+
optional: true,
79+
propDefinition: [
80+
quickbooks,
81+
"itemId",
82+
],
83+
},
84+
sortOrder: {
85+
type: "string",
86+
label: "Sort Order",
87+
description: "The sort order for report results",
88+
options: [
89+
"ascend",
90+
"descend",
91+
],
92+
optional: true,
93+
},
94+
summarizeColumnBy: {
95+
type: "string",
96+
label: "Summarize Column By",
97+
description: "The criteria by which to group the report results",
98+
options: [
99+
"Total",
100+
"Month",
101+
"Week",
102+
"Days",
103+
"Quarter",
104+
"Year",
105+
"Customers",
106+
"Vendors",
107+
"Classes",
108+
"Departments",
109+
"Employees",
110+
"ProductsAndServices",
111+
],
112+
optional: true,
113+
},
114+
department: {
115+
propDefinition: [
116+
quickbooks,
117+
"departmentIds",
118+
],
119+
},
120+
vendor: {
121+
propDefinition: [
122+
quickbooks,
123+
"vendorIds",
124+
],
125+
},
126+
},
127+
async run({ $ }) {
128+
const {
129+
quickbooks,
130+
customer,
131+
qzurl,
132+
accountingMethod,
133+
dateMacro,
134+
startDate,
135+
endDate,
136+
adjustedGainLoss,
137+
classIds,
138+
item,
139+
sortOrder,
140+
summarizeColumnBy,
141+
department,
142+
vendor,
143+
} = this;
144+
145+
const response = await quickbooks.getBalanceSheetReport({
146+
$,
147+
params: {
148+
customer: commaSeparateArray(customer),
149+
qzurl: booleanToString(qzurl),
150+
accounting_method: accountingMethod,
151+
date_macro: dateMacro,
152+
start_date: startDate,
153+
end_date: endDate,
154+
adjusted_gain_loss: booleanToString(adjustedGainLoss),
155+
class: commaSeparateArray(classIds),
156+
item: commaSeparateArray(item),
157+
sort_order: sortOrder,
158+
summarize_column_by: summarizeColumnBy,
159+
department: commaSeparateArray(department),
160+
vendor: commaSeparateArray(vendor),
161+
},
162+
});
163+
$.export("$summary", "Successfully retrieved Balance Sheet Report");
164+
return response;
165+
},
166+
};
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import quickbooks from "../../quickbooks.app.mjs";
2+
import { DATE_MACRO_OPTIONS } from "../../common/constants.mjs";
3+
import { commaSeparateArray } from "../../common/utils.mjs";
4+
5+
export default {
6+
key: "quickbooks-get-cash-flow-report",
7+
name: "Get Cash Flow Report",
8+
description: "Retrieves the cash flow report from Quickbooks Online. [See the documentation](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/cashflow#query-a-report)",
9+
version: "0.0.1",
10+
type: "action",
11+
annotations: {
12+
destructiveHint: false,
13+
openWorldHint: true,
14+
readOnlyHint: true,
15+
},
16+
props: {
17+
quickbooks,
18+
customer: {
19+
type: "string[]",
20+
label: "Customer IDs",
21+
description: "Filters report contents to include information for specified customers",
22+
optional: true,
23+
propDefinition: [
24+
quickbooks,
25+
"customer",
26+
],
27+
},
28+
vendor: {
29+
propDefinition: [
30+
quickbooks,
31+
"vendorIds",
32+
],
33+
},
34+
dateMacro: {
35+
type: "string",
36+
label: "Date Macro",
37+
description: "Predefined date range. Use if you want the report to cover a standard report date range; otherwise, use the **Start Date** and **End Date** to cover an explicit report date range",
38+
options: DATE_MACRO_OPTIONS,
39+
optional: true,
40+
},
41+
startDate: {
42+
type: "string",
43+
label: "Start Date",
44+
description: "The start date of the report, in the format `YYYY-MM-DD`. **Start Date** must be less than **End Date**",
45+
optional: true,
46+
},
47+
endDate: {
48+
type: "string",
49+
label: "End Date",
50+
description: "The end date of the report, in the format `YYYY-MM-DD`. **Start Date** must be less than **End Date**",
51+
optional: true,
52+
},
53+
classIds: {
54+
propDefinition: [
55+
quickbooks,
56+
"classIds",
57+
],
58+
},
59+
item: {
60+
type: "string[]",
61+
label: "Item IDs",
62+
description: "Filters report contents to include information for specified items",
63+
optional: true,
64+
propDefinition: [
65+
quickbooks,
66+
"itemId",
67+
],
68+
},
69+
sortOrder: {
70+
type: "string",
71+
label: "Sort Order",
72+
description: "The sort order for report results",
73+
options: [
74+
"ascend",
75+
"descend",
76+
],
77+
optional: true,
78+
},
79+
summarizeColumnBy: {
80+
type: "string",
81+
label: "Summarize Column By",
82+
description: "The criteria by which to group the report results",
83+
options: [
84+
"Total",
85+
"Month",
86+
"Week",
87+
"Days",
88+
"Quarter",
89+
"Year",
90+
"Customers",
91+
"Vendors",
92+
"Classes",
93+
"Departments",
94+
"Employees",
95+
"ProductsAndServices",
96+
],
97+
optional: true,
98+
},
99+
department: {
100+
propDefinition: [
101+
quickbooks,
102+
"departmentIds",
103+
],
104+
},
105+
},
106+
async run({ $ }) {
107+
const {
108+
quickbooks,
109+
customer,
110+
vendor,
111+
dateMacro,
112+
startDate,
113+
endDate,
114+
classIds,
115+
item,
116+
sortOrder,
117+
summarizeColumnBy,
118+
department,
119+
} = this;
120+
121+
const response = await quickbooks.getCashFlowReport({
122+
$,
123+
params: {
124+
customer: commaSeparateArray(customer),
125+
vendor: commaSeparateArray(vendor),
126+
date_macro: dateMacro,
127+
start_date: startDate,
128+
end_date: endDate,
129+
class: classIds,
130+
item: commaSeparateArray(item),
131+
sort_order: sortOrder,
132+
summarize_column_by: summarizeColumnBy,
133+
department: commaSeparateArray(department),
134+
},
135+
});
136+
$.export("$summary", "Successfully retrieved Cash Flow Report");
137+
return response;
138+
},
139+
};

components/quickbooks/common/utils.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,16 @@ export function buildPurchaseLineItems(numLineItems, context) {
219219
}
220220
return lineItems;
221221
}
222+
223+
export function commaSeparateArray(arr) {
224+
if (Array.isArray(arr) && arr.length > 0) {
225+
return arr.join(",");
226+
}
227+
return arr;
228+
}
229+
230+
export function booleanToString(bool) {
231+
return bool === true || bool === "true"
232+
? "true"
233+
: "false";
234+
}

components/quickbooks/quickbooks.app.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,18 @@ export default {
834834
...opts,
835835
});
836836
},
837+
getBalanceSheetReport(opts = {}) {
838+
return this._makeRequest({
839+
path: `company/${this._companyId()}/reports/BalanceSheet`,
840+
...opts,
841+
});
842+
},
843+
getCashFlowReport(opts = {}) {
844+
return this._makeRequest({
845+
path: `company/${this._companyId()}/reports/CashFlow`,
846+
...opts,
847+
});
848+
},
837849
async *paginate({
838850
fn, params = {}, fieldList, query, maxResults = null, ...opts
839851
}) {

0 commit comments

Comments
 (0)