-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - fakturoid #13961
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 - fakturoid #13961
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e42f6b7
fakturoid init
luancazarine b754a4b
[Components] fakturoid #13809
luancazarine 2163ec6
pnpm update
luancazarine a5141c5
Merge branch 'master' into issue-13809
luancazarine a66356e
[Components] fakturoid #13809
luancazarine 36f3873
update @pipedream/platform dependence version
luancazarine 1fbd4d8
pnpm update
luancazarine 115031f
Update components/fakturoid/actions/create-invoice/create-invoice.mjs
luancazarine f22fc7a
Merge branch 'master' into issue-13809
luancazarine 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
49 changes: 49 additions & 0 deletions
49
components/fakturoid/actions/cancel-uncancel-invoice/cancel-uncancel-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,49 @@ | ||
| import constants from "../../common/constants.mjs"; | ||
| import fakturoid from "../../fakturoid.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "fakturoid-cancel-uncancel-invoice", | ||
| name: "Cancel or Uncancel Invoice", | ||
| description: "Cancels an existing invoice or revokes previous cancellation. [See the documentation](https://www.fakturoid.cz/api/v3)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| fakturoid, | ||
| accountSlug: { | ||
| propDefinition: [ | ||
| fakturoid, | ||
| "accountSlug", | ||
| ], | ||
| }, | ||
| invoiceId: { | ||
| propDefinition: [ | ||
| fakturoid, | ||
| "invoiceId", | ||
| ({ accountSlug }) => ({ | ||
| accountSlug, | ||
| }), | ||
| ], | ||
| }, | ||
| action: { | ||
| type: "string", | ||
| label: "Action", | ||
| description: "The action to perform on the invoice (cancel or uncancel)", | ||
| options: constants.ACTION_OPTIONS, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.fakturoid.fireInvoice({ | ||
| $, | ||
| accountSlug: this.accountSlug, | ||
| invoiceId: this.invoiceId, | ||
| params: { | ||
| event: this.action, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `${this.action === "cancel" | ||
| ? "Cancelled" | ||
| : "Uncancelled"} invoice with ID ${this.invoiceId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
139 changes: 139 additions & 0 deletions
139
components/fakturoid/actions/create-invoice/create-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,139 @@ | ||
| import constants, { parseObject } from "../../common/constants.mjs"; | ||
| import fakturoid from "../../fakturoid.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "fakturoid-create-invoice", | ||
| name: "Create Invoice", | ||
| description: "Creates a new invoice. [See the documentation](https://www.fakturoid.cz/api/v3/invoices)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| fakturoid, | ||
| accountSlug: { | ||
| propDefinition: [ | ||
| fakturoid, | ||
| "accountSlug", | ||
| ], | ||
| }, | ||
| customId: { | ||
| type: "string", | ||
| label: "Custom Id", | ||
| description: "Identifier in your application", | ||
| optional: true, | ||
| }, | ||
| documentType: { | ||
| type: "string", | ||
| label: "Document Type", | ||
| description: "Type of document", | ||
| options: constants.DOCUMENT_TYPE_OPTIONS, | ||
| reloadProps: true, | ||
| optional: true, | ||
| }, | ||
| subjectId: { | ||
| propDefinition: [ | ||
| fakturoid, | ||
| "subjectId", | ||
| ({ accountSlug }) => ({ | ||
| accountSlug, | ||
| }), | ||
| ], | ||
| }, | ||
| orderNumber: { | ||
| type: "string", | ||
| label: "Order Number", | ||
| description: "Order number in your application", | ||
| optional: true, | ||
| }, | ||
| note: { | ||
| type: "string", | ||
| label: "Note", | ||
| description: "Additional notes for the invoice", | ||
| optional: true, | ||
| }, | ||
| due: { | ||
| type: "string", | ||
| label: "Due", | ||
| description: "Invoice due date in number of days from today", | ||
| optional: true, | ||
| }, | ||
| issuedOn: { | ||
| type: "string", | ||
| label: "Issued On", | ||
| description: "Date of issue. **Format: YYYY-MM-DD**", | ||
| optional: true, | ||
| }, | ||
| taxableFulfillmentDue: { | ||
| type: "string", | ||
| label: "Taxable Fulfillment Due", | ||
| description: "Chargeable event date.", | ||
| optional: true, | ||
| }, | ||
| tags: { | ||
| type: "string[]", | ||
| label: "Tags", | ||
| description: "List of tags", | ||
| optional: true, | ||
| }, | ||
| roundTotal: { | ||
| type: "boolean", | ||
| label: "Round Total", | ||
| description: "Round total amount (VAT included)", | ||
| optional: true, | ||
| }, | ||
| subtotal: { | ||
| type: "string", | ||
| label: "Subtotal", | ||
| description: "Total without VAT", | ||
| optional: true, | ||
| }, | ||
| total: { | ||
| type: "string", | ||
| label: "Total", | ||
| description: "Total with VAT", | ||
| optional: true, | ||
| }, | ||
| lines: { | ||
| type: "string[]", | ||
| label: "Lines", | ||
| description: "List of object lines to invoice. [See the documentation](https://www.fakturoid.cz/api/v3/invoices#attributes). **Example: {\"name\": \"Hard work\",\"quantity\": \"1.0\",\"unit_name\": \"h\",\"unit_price\": \"40000\",\"vat_rate\": \"21\"}**", | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (this.documentType === "proforma") { | ||
| props.proformaFollowupDocument = { | ||
| type: "string", | ||
| label: "Proforma Followup Document", | ||
| description: "What to issue after a proforma is paid.", | ||
| options: constants.PROFORMA_OPTIONS, | ||
| optional: true, | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.fakturoid.createInvoice({ | ||
| $, | ||
| accountSlug: this.accountSlug, | ||
| data: { | ||
| custom_id: this.customId, | ||
| document_type: this.documentType, | ||
| proforma_followup_document: this.proformaFollowupDocument, | ||
| subject_id: this.subjectId, | ||
| order_number: this.orderNumber, | ||
| note: this.note, | ||
| due: this.due, | ||
| issued_on: this.issuedOn, | ||
| taxable_fulfillment_due: this.taxableFulfillmentDue, | ||
| tags: parseObject(this.tags), | ||
| round_total: this.roundTotal, | ||
| subtotal: this.subtotal && parseFloat(this.subtotal), | ||
| total: this.total && parseFloat(this.total), | ||
| lines: parseObject(this.lines), | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created invoice with ID ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
109 changes: 109 additions & 0 deletions
109
components/fakturoid/actions/pay-remove-payment-invoice/pay-remove-payment-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,109 @@ | ||
| import constants from "../../common/constants.mjs"; | ||
| import fakturoid from "../../fakturoid.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "fakturoid-pay-remove-payment-invoice", | ||
| name: "Pay or Remove Payment for Invoice", | ||
| description: "Executes payment for an invoice or removes an already applied payment. [See the documentation](https://www.fakturoid.cz/api/v3/invoice-payments)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| fakturoid, | ||
| accountSlug: { | ||
| propDefinition: [ | ||
| fakturoid, | ||
| "accountSlug", | ||
| ], | ||
| }, | ||
| invoiceId: { | ||
| propDefinition: [ | ||
| fakturoid, | ||
| "invoiceId", | ||
| ({ accountSlug }) => ({ | ||
| accountSlug, | ||
| }), | ||
| ], | ||
| }, | ||
| actionType: { | ||
| type: "string", | ||
| label: "Action Type", | ||
| description: "Specify if you want to execute or remove a payment", | ||
| options: constants.ACTION_TYPE_OPTIONS, | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (this.actionType === "execute") { | ||
| props.paidOn = { | ||
| type: "string", | ||
| label: "Paid On", | ||
| description: "Payment date. **Format: YYYY-MM-DD** Default: Today", | ||
| optional: true, | ||
| }; | ||
| props.currency = { | ||
| type: "string", | ||
| label: "Currency", | ||
| description: "Currency [ISO Code](https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes) (same as invoice currency)", | ||
| optional: true, | ||
| }; | ||
| props.amount = { | ||
| type: "string", | ||
| label: "Amount", | ||
| description: "Paid amount in document currency. Default: Remaining amount to pay", | ||
| optional: true, | ||
| }; | ||
| props.markDocumentAsPaid = { | ||
| type: "boolean", | ||
| label: "Mark Document As Paid", | ||
| description: "Mark document as paid? Default: true if the total paid amount becomes greater or equal to remaining amount to pay", | ||
| optional: true, | ||
| }; | ||
| } else if (this.actionType === "remove") { | ||
| props.paymentId = { | ||
| type: "string", | ||
| label: "Payment ID", | ||
| description: "ID of the payment to be removed.", | ||
| options: async () => { | ||
| const { payments } = await this.fakturoid.getInvoice({ | ||
| accountSlug: this.accountSlug, | ||
| invoiceId: this.invoiceId, | ||
| }); | ||
|
|
||
| return payments.map(({ | ||
| id: value, paid_on: pOn, currency, amount, | ||
| }) => ({ | ||
| label: `${currency} ${amount} (${pOn})`, | ||
| value, | ||
| })); | ||
| }, | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| if (this.actionType === "execute") { | ||
| const response = await this.fakturoid.payInvoice({ | ||
| accountSlug: this.accountSlug, | ||
| invoiceId: this.invoiceId, | ||
| data: { | ||
| paid_on: this.paidOn, | ||
| currency: this.currency, | ||
| amount: this.amount && parseFloat(this.amount), | ||
| mark_document_as_paid: this.markDocumentAsPaid, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully executed payment for invoice ID ${this.invoiceId}`); | ||
| return response; | ||
| } else if (this.actionType === "remove") { | ||
| const response = await this.fakturoid.removePayment({ | ||
| $, | ||
| accountSlug: this.accountSlug, | ||
| invoiceId: this.invoiceId, | ||
| paymentId: this.paymentId, | ||
| }); | ||
| $.export("$summary", `Successfully removed payment ID ${this.paymentId} from invoice ID ${this.invoiceId}`); | ||
| return response; | ||
| } | ||
| }, | ||
| }; |
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.