-
Couldn't load subscription status.
- Fork 5.5k
New Components - the_bookie #13995
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 - the_bookie #13995
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
139 changes: 139 additions & 0 deletions
139
components/the_bookie/actions/create-contact/create-contact.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,139 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import thebookie from "../../the_bookie.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_bookie-create-contact", | ||
| name: "Create Contact", | ||
| description: "Instantly creates a new contact in the address book. [See the documentation](https://app.thebookie.nl/nl/help/article/api-documentatie/#contact_create)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| thebookie, | ||
| organisationName: { | ||
| type: "string", | ||
| label: "Organisation Name", | ||
| description: "The contact's organization name", | ||
| }, | ||
| street: { | ||
| type: "string", | ||
| label: "Street", | ||
| description: "The contact's address street", | ||
| optional: true, | ||
| }, | ||
| streetNumber: { | ||
| type: "string", | ||
| label: "Street Number", | ||
| description: "The contact's address number", | ||
| optional: true, | ||
| }, | ||
| streetNumberAddition: { | ||
| type: "string", | ||
| label: "Street Number Addition", | ||
| description: "The contact's address number addition", | ||
| optional: true, | ||
| }, | ||
| extraAddressLine: { | ||
| type: "string", | ||
| label: "Extra Address Line", | ||
| description: "The contact's extra address line", | ||
| optional: true, | ||
| }, | ||
| postalCode: { | ||
| type: "string", | ||
| label: "Postal Code", | ||
| description: "The contact's address postal code", | ||
| optional: true, | ||
| }, | ||
| town: { | ||
| type: "string", | ||
| label: "Town", | ||
| description: "The contact's city", | ||
| optional: true, | ||
| }, | ||
| country: { | ||
| type: "string", | ||
| label: "Country", | ||
| description: "The contact's country", | ||
| optional: true, | ||
| }, | ||
| isSupplier: { | ||
| type: "boolean", | ||
| label: "Is Supplier", | ||
| description: "Whether the contact is supplier or not", | ||
| optional: true, | ||
| }, | ||
| isClient: { | ||
| type: "boolean", | ||
| label: "Is Client", | ||
| description: "Whether the contact is client or not", | ||
| optional: true, | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The contact's email address", | ||
| optional: true, | ||
| }, | ||
| telephoneNumber: { | ||
| type: "string", | ||
| label: "Telephone Number", | ||
| description: "The contact's telephone number", | ||
| optional: true, | ||
| }, | ||
| mobileNumber: { | ||
| type: "string", | ||
| label: "Mobile Number", | ||
| description: "The contact's mobile number", | ||
| optional: true, | ||
| }, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "First name of the contact", | ||
| optional: true, | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "Last name of the contact", | ||
| optional: true, | ||
| }, | ||
| extraInfo: { | ||
| type: "string", | ||
| label: "Extra Info", | ||
| description: "An additional info", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.isClient && !this.isSupplier) { | ||
| throw new ConfigurationError("'Is Supplier' or 'Is Client' must be true (or both)"); | ||
| } | ||
|
|
||
| const response = await this.thebookie.createContact({ | ||
| $, | ||
| data: { | ||
| organisation_name: this.organisationName, | ||
| street: this.street, | ||
| street_number: this.streetNumber, | ||
| street_number_addition: this.streetNumberAddition, | ||
| extra_address_line: this.extraAddressLine, | ||
| postal_code: this.postalCode, | ||
| town: this.town, | ||
| country: this.country, | ||
| is_supplier: this.isSupplier, | ||
| is_client: this.isClient, | ||
| email: this.email, | ||
| telephone_number: this.telephoneNumber, | ||
| mobile_number: this.mobileNumber, | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| extra_info: this.extraInfo, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created contact with ID ${response.id}`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; |
99 changes: 99 additions & 0 deletions
99
components/the_bookie/actions/create-sales-invoice/create-sales-invoice.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,99 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import fs from "fs"; | ||
| import { | ||
| checkTmp, parseObject, | ||
| } from "../../common/utils.mjs"; | ||
| import theBookie from "../../the_bookie.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_bookie-create-sales-invoice", | ||
| name: "Create Sales Invoice", | ||
| description: "Creates a new sales invoice. [See the documentation](https://app.thebookie.nl/nl/help/article/api-documentatie/#salesentry_create)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| theBookie, | ||
| contactId: { | ||
| propDefinition: [ | ||
| theBookie, | ||
| "contactId", | ||
| ], | ||
| }, | ||
| invoiceNumber: { | ||
| type: "string", | ||
| label: "Invoice Number", | ||
| description: "The number of the invoice", | ||
| }, | ||
| invoiceDate: { | ||
| type: "string", | ||
| label: "Invoice Date", | ||
| description: "The date of the invoice. **Format: YYYY-MM-DD**", | ||
| }, | ||
| expirationDate: { | ||
| type: "string", | ||
| label: "Expiration Date", | ||
| description: "The expiration date of the invoice. **Format: YYYY-MM-DD**", | ||
| }, | ||
| btwShifted: { | ||
| type: "string", | ||
| label: "VAT shifted", | ||
| description: "The VAT type", | ||
| options: [ | ||
| { | ||
| label: "No (standard)", | ||
| value: "NONE", | ||
| }, | ||
| { | ||
| label: "Shifted within The Netherlands", | ||
| value: "NL", | ||
| }, | ||
| { | ||
| label: "Shifted within EU", | ||
| value: "EU", | ||
| }, | ||
| { | ||
| label: "Shifted outside EU", | ||
| value: "NON_EU", | ||
| }, | ||
| ], | ||
| optional: true, | ||
| }, | ||
| journalEntryLines: { | ||
| type: "string[]", | ||
| label: "Journal Entry Lines", | ||
| description: "An array of stringified objects of item entry lines. **Example: { \"description\": \"Boekregel 1\", \"btw_type\": \"PROCENT_21\", \"amount\": \"1200.0\", \"quantity\": \"2.00\"}** btw_type can be only 'PERCENT_9', 'PERCENT_21' or 'PERCENT_0'", | ||
| optional: true, | ||
| }, | ||
| attachment: { | ||
| type: "string", | ||
| label: "Attachment", | ||
| description: "The path to the pdf file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.journalEntryLines) { | ||
| throw new ConfigurationError("At least one (1) 'Journal Entry Line' should be added"); | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (this.attachment) { | ||
| this.attachment = fs.readFileSync(checkTmp(this.attachment), { | ||
| encoding: "base64", | ||
| }); | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const response = await this.theBookie.createInvoice({ | ||
| $, | ||
| data: { | ||
| contact_id: this.contactId, | ||
| invoice_number: this.invoiceNumber, | ||
| invoice_date: this.invoiceDate, | ||
| expiration_date: this.expirationDate, | ||
| btw_shifted: this.btwShifted, | ||
| journal_entry_lines: parseObject(this.journalEntryLines), | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| attachment: this.attachment, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created invoice with number ${this.invoiceNumber}`); | ||
| return response; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
51 changes: 51 additions & 0 deletions
51
components/the_bookie/actions/find-contact/find-contact.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,51 @@ | ||
| import { capitalize } from "../../common/utils.mjs"; | ||
| import theBookie from "../../the_bookie.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_bookie-find-contact", | ||
| name: "Find Contacts", | ||
| description: "Find a contact from the address book. [See the documentation](https://app.thebookie.nl/nl/help/article/api-documentatie/#contact_list)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| theBookie, | ||
| search: { | ||
| type: "string", | ||
| label: "Search", | ||
| description: "Search by company name.", | ||
| optional: true, | ||
| }, | ||
| isClient: { | ||
| type: "boolean", | ||
| label: "Is Client", | ||
| description: "Return only client contacts.", | ||
| optional: true, | ||
| }, | ||
| isSupplier: { | ||
| type: "boolean", | ||
| label: "Is Supplier", | ||
| description: "Return only supplier contacts.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = this.theBookie.paginate({ | ||
| $, | ||
| fn: this.theBookie.searchContact, | ||
| params: { | ||
| search: this.search, | ||
| is_client: capitalize(this.isClient), | ||
| is_supplier: capitalize(this.isSupplier), | ||
| }, | ||
| }); | ||
|
|
||
| const responseArray = []; | ||
|
|
||
| for await (const item of response) { | ||
| responseArray.push(item); | ||
| } | ||
|
|
||
| $.export("$summary", `Found ${responseArray.length} contact(s)`); | ||
| return responseArray; | ||
| }, | ||
| }; |
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 @@ | ||
| export const LIMIT = 100; |
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,37 @@ | ||
| export const checkTmp = (filename) => { | ||
| if (!filename.startsWith("/tmp")) { | ||
| return `/tmp/${filename}`; | ||
| } | ||
| return filename; | ||
| }; | ||
|
|
||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | ||
|
|
||
| export const capitalize = (string) => { | ||
| if (!string) return null; | ||
| string = string.toString(); | ||
| return string[0].toUpperCase() + string.slice(1); | ||
| }; |
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
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.