-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - clear_books #15287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - clear_books #15287
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
571e89d
clear_books init
michelle0927 ed2c989
new-components
michelle0927 a72e5b3
updates
michelle0927 8647dec
pnpm-lock.yaml
michelle0927 427124c
Merge remote-tracking branch 'origin/master' into issue-15253
michelle0927 6366449
pnpm-lock.yaml
michelle0927 597a6d5
add lineItemsJson prop
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
84 changes: 84 additions & 0 deletions
84
components/clear_books/actions/create-customer/create-customer.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import clearBooks from "../../clear_books.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "clear_books-create-customer", | ||
| name: "Create Customer", | ||
| description: "Creates a new customer in Clear Books. [See the documentation](https://u.pcloud.link/publink/show?code=XZkThJ5Z4zKewgCL6VBpfxlPeHPDdXXj0Cc7)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| clearBooks, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the customer", | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "Email address of the customer", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone", | ||
| description: "Phone number of the customer", | ||
| optional: true, | ||
| }, | ||
| streetAddress: { | ||
| type: "string", | ||
| label: "Street Address", | ||
| description: "Street address of the customer", | ||
| optional: true, | ||
| }, | ||
| town: { | ||
| type: "string", | ||
| label: "Town", | ||
| description: "Town of the customer", | ||
| optional: true, | ||
| }, | ||
| county: { | ||
| type: "string", | ||
| label: "County", | ||
| description: "County of the customer", | ||
| optional: true, | ||
| }, | ||
| postcode: { | ||
| type: "string", | ||
| label: "Postcode", | ||
| description: "Postcode of the customer", | ||
| optional: true, | ||
| }, | ||
| countryCode: { | ||
| type: "string", | ||
| label: "Country Code", | ||
| description: "Country code of the customer", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const hasAddress = this.streetAddress | ||
| || this.town | ||
| || this.county | ||
| || this.postcode | ||
| || this.countryCode; | ||
|
|
||
| const response = await this.clearBooks.createCustomer({ | ||
| $, | ||
| data: { | ||
| name: this.name, | ||
| email: this.email, | ||
| phone: this.phone, | ||
| address: hasAddress && { | ||
| line1: this.streetAddress, | ||
| town: this.town, | ||
| county: this.county, | ||
| postcode: this.postcode, | ||
| countryCode: this.countryCode, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created customer with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
124 changes: 124 additions & 0 deletions
124
components/clear_books/actions/create-purchase-document/create-purchase-document.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| import clearBooks from "../../clear_books.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "clear_books-create-purchase-document", | ||
| name: "Create Purchase Document", | ||
| description: "Creates a new Purchase Document in Clear Books. [See the documentation](https://u.pcloud.link/publink/show?code=XZkThJ5Z4zKewgCL6VBpfxlPeHPDdXXj0Cc7)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| clearBooks, | ||
| purchaseType: { | ||
| propDefinition: [ | ||
| clearBooks, | ||
| "purchaseType", | ||
| ], | ||
| }, | ||
| date: { | ||
| type: "string", | ||
| label: "Date", | ||
| description: "The date of the purchase. Format: YYYY-MM-DD", | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| supplierId: { | ||
| propDefinition: [ | ||
| clearBooks, | ||
| "supplierId", | ||
| ], | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "Description of the purchase document", | ||
| optional: true, | ||
| }, | ||
| numLineItems: { | ||
| type: "integer", | ||
| label: "Number of Line Items", | ||
| description: "The number of line items. Use this to manually enter Unit Price, Quantity, and Description of each line item.", | ||
| optional: true, | ||
| reloadProps: true, | ||
| }, | ||
| lineItemsJson: { | ||
| type: "string", | ||
| label: "Line Items JSON", | ||
| description: "JSON value containing an array of Line Items. For example: `[{\"description\":\"Line Item 1 Description\",\"unitPrice\":1022,\"quantity\":1,\"accountCode\":\"2001001\"},{\"description\":\"Line Item 2 Description\",\"unitPrice\":1023,\"quantity\":2,\"accountCode\":\"2001001\"}]`. [See documentation](https://u.pcloud.link/publink/show?code=XZkThJ5Z4zKewgCL6VBpfxlPeHPDdXXj0Cc7)", | ||
| optional: true, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| additionalProps() { | ||
| const props = {}; | ||
| if (!this.numLineItems) { | ||
| return props; | ||
| } | ||
| for (let i = 1; i <= this.numLineItems; i++) { | ||
| props[`line_item_${i}_unit_price`] = { | ||
| type: "string", | ||
| label: `Line Item ${i} - Unit Price`, | ||
| }; | ||
| props[`line_item_${i}_quantity`] = { | ||
| type: "integer", | ||
| label: `Line Item ${i} - Quantity`, | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| props[`line_item_${i}_description`] = { | ||
| type: "string", | ||
| label: `Line Item ${i} - Description`, | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| methods: { | ||
| buildLineItems() { | ||
| const lineItems = []; | ||
| for (let i = 1; i <= this.numLineItems; i++) { | ||
| lineItems.push({ | ||
| unitPrice: this[`line_item_${i}_unit_price`], | ||
| quantity: this[`line_item_${i}_quantity`], | ||
| description: this[`line_item_${i}_description`], | ||
| }); | ||
| } | ||
| return lineItems; | ||
| }, | ||
| parseLineItemsJson() { | ||
| try { | ||
| return Array.isArray(this.lineItemsJson) | ||
| ? this.lineItemsJson.map((item) => typeof item === "string" | ||
| ? JSON.parse(item) | ||
| : item) | ||
| : typeof this.lineItemsJson === "string" | ||
| ? JSON.parse(this.lineItemsJson) | ||
| : this.lineItemsJson; | ||
| } catch { | ||
| throw new ConfigurationError("Could not parse Line Items JSON"); | ||
| } | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.numLineItems && !this.lineItemsJson) { | ||
| throw new ConfigurationError("Please enter at least one line item"); | ||
| } | ||
|
|
||
| const lineItems = []; | ||
| if (this.numLineItems) { | ||
| const lineItemsManual = this.buildLineItems(); | ||
| lineItems.push(...lineItemsManual); | ||
| } | ||
| if (this.lineItemsJson) { | ||
| const lineItemsJson = this.parseLineItemsJson(); | ||
| lineItems.push(...lineItemsJson); | ||
| } | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const response = await this.clearBooks.createPurchaseDocument({ | ||
| $, | ||
| type: this.purchaseType, | ||
| data: { | ||
| date: this.date, | ||
| supplierId: this.supplierId, | ||
| description: this.description, | ||
| lineItems, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created purchase document with ID ${response.id}`); | ||
| return response; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
84 changes: 84 additions & 0 deletions
84
components/clear_books/actions/create-supplier/create-supplier.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import clearBooks from "../../clear_books.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "clear_books-create-supplier", | ||
| name: "Create Supplier", | ||
| description: "Creates a new supplier in Clear Books. [See the documentation](https://u.pcloud.link/publink/show?code=XZkThJ5Z4zKewgCL6VBpfxlPeHPDdXXj0Cc7)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| clearBooks, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the supplier", | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "Email address of the supplier", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone", | ||
| description: "Phone number of the supplier", | ||
| optional: true, | ||
| }, | ||
| streetAddress: { | ||
| type: "string", | ||
| label: "Street Address", | ||
| description: "Street address of the supplier", | ||
| optional: true, | ||
| }, | ||
| town: { | ||
| type: "string", | ||
| label: "Town", | ||
| description: "Town of the supplier", | ||
| optional: true, | ||
| }, | ||
| county: { | ||
| type: "string", | ||
| label: "County", | ||
| description: "County of the supplier", | ||
| optional: true, | ||
| }, | ||
| postcode: { | ||
| type: "string", | ||
| label: "Postcode", | ||
| description: "Postcode of the supplier", | ||
| optional: true, | ||
| }, | ||
| countryCode: { | ||
| type: "string", | ||
| label: "Country Code", | ||
| description: "Country code of the supplier", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const hasAddress = this.streetAddress | ||
| || this.town | ||
| || this.county | ||
| || this.postcode | ||
| || this.countryCode; | ||
|
|
||
| const response = await this.clearBooks.createSupplier({ | ||
| $, | ||
| data: { | ||
| name: this.name, | ||
| email: this.email, | ||
| phone: this.phone, | ||
| address: hasAddress && { | ||
| line1: this.streetAddress, | ||
| town: this.town, | ||
| county: this.county, | ||
| postcode: this.postcode, | ||
| countryCode: this.countryCode, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created supplier with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.