Skip to content

Commit 571e89d

Browse files
committed
clear_books init
1 parent 2e729e5 commit 571e89d

File tree

8 files changed

+762
-4
lines changed

8 files changed

+762
-4
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import clearBooks from "../../clear_books.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "clear_books-create-client",
6+
name: "Create Client",
7+
description: "Creates a new client in Clear Books. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
clear_books: {
12+
type: "app",
13+
app: "clear_books",
14+
},
15+
createClientName: {
16+
propDefinition: [
17+
"clear_books",
18+
"createClientName",
19+
],
20+
},
21+
createClientContactDetails: {
22+
propDefinition: [
23+
"clear_books",
24+
"createClientContactDetails",
25+
],
26+
},
27+
createClientNotes: {
28+
propDefinition: [
29+
"clear_books",
30+
"createClientNotes",
31+
],
32+
optional: true,
33+
},
34+
createClientTags: {
35+
propDefinition: [
36+
"clear_books",
37+
"createClientTags",
38+
],
39+
optional: true,
40+
},
41+
},
42+
async run({ $ }) {
43+
const data = {
44+
name: this.createClientName,
45+
contact_details: this.createClientContactDetails.map(JSON.parse),
46+
};
47+
48+
if (this.createClientNotes) {
49+
data.notes = this.createClientNotes;
50+
}
51+
52+
if (this.createClientTags) {
53+
data.tags = this.createClientTags;
54+
}
55+
56+
const client = await this.clear_books.createClient(data);
57+
$.export("$summary", `Created client ${client.name} with ID ${client.id}`);
58+
return client;
59+
},
60+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import clear_books from "../../clear_books.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "clear_books-create-invoice",
6+
name: "Create Invoice",
7+
description: "Creates a new invoice in Clear Books. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
clear_books,
12+
createInvoiceClientDetails: {
13+
propDefinition: [
14+
clear_books,
15+
"createInvoiceClientDetails",
16+
],
17+
},
18+
createInvoiceLineItems: {
19+
propDefinition: [
20+
clear_books,
21+
"createInvoiceLineItems",
22+
],
23+
},
24+
createInvoiceIssueDate: {
25+
propDefinition: [
26+
clear_books,
27+
"createInvoiceIssueDate",
28+
],
29+
},
30+
createInvoiceNotes: {
31+
propDefinition: [
32+
clear_books,
33+
"createInvoiceNotes",
34+
],
35+
},
36+
createInvoiceDueDate: {
37+
propDefinition: [
38+
clear_books,
39+
"createInvoiceDueDate",
40+
],
41+
},
42+
createInvoiceTags: {
43+
propDefinition: [
44+
clear_books,
45+
"createInvoiceTags",
46+
],
47+
},
48+
},
49+
async run({ $ }) {
50+
const clientDetails = JSON.parse(this.createInvoiceClientDetails[0]);
51+
const lineItems = this.createInvoiceLineItems.map((item) => JSON.parse(item));
52+
53+
const data = {
54+
client_details: clientDetails,
55+
line_items: lineItems,
56+
issue_date: this.createInvoiceIssueDate,
57+
};
58+
59+
if (this.createInvoiceNotes) {
60+
data.notes = this.createInvoiceNotes;
61+
}
62+
63+
if (this.createInvoiceDueDate) {
64+
data.due_date = this.createInvoiceDueDate;
65+
}
66+
67+
if (this.createInvoiceTags && this.createInvoiceTags.length > 0) {
68+
data.tags = this.createInvoiceTags;
69+
}
70+
71+
const response = await this.clear_books.createInvoice(data);
72+
73+
$.export("$summary", `Created invoice with ID ${response.id}`);
74+
return response;
75+
},
76+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import clear_books from "../../clear_books.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "clear_books-record-payment",
6+
name: "Record Payment",
7+
description: "Records a payment against an existing invoice. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
clear_books: {
12+
type: "app",
13+
app: "clear_books",
14+
},
15+
recordPaymentAmount: {
16+
propDefinition: [
17+
"clear_books",
18+
"recordPaymentAmount",
19+
],
20+
},
21+
recordInvoiceId: {
22+
propDefinition: [
23+
"clear_books",
24+
"recordInvoiceId",
25+
],
26+
},
27+
recordPaymentDate: {
28+
propDefinition: [
29+
"clear_books",
30+
"recordPaymentDate",
31+
],
32+
},
33+
recordPaymentMethod: {
34+
propDefinition: [
35+
"clear_books",
36+
"recordPaymentMethod",
37+
],
38+
},
39+
},
40+
async run({ $ }) {
41+
const paymentData = {
42+
amount: this.recordPaymentAmount,
43+
invoice_id: this.recordInvoiceId,
44+
payment_date: this.recordPaymentDate,
45+
};
46+
if (this.recordPaymentMethod) {
47+
paymentData.payment_method = this.recordPaymentMethod;
48+
}
49+
const response = await this.clear_books.recordPayment(paymentData);
50+
$.export("$summary", `Recorded payment of $${this.recordPaymentAmount} on invoice ${this.recordInvoiceId}`);
51+
return response;
52+
},
53+
};

0 commit comments

Comments
 (0)