Skip to content

Commit 7b02b2f

Browse files
New Components - fakturoid (#13961)
* fakturoid init * [Components] fakturoid #13809 Sources - Invoice Status Change (Instant) - New Contact - New Invoice Actions - Create Invoice - Cancel Uncancel Invoice - Pay Remove Payment Invoice * pnpm update * [Components] fakturoid #13809 Sources - Invoice Updated - New Contact - New Invoice Actions - Create Invoice - Cancel Uncancel Invoice - Pay Remove Payment Invoice * update @pipedream/platform dependence version * pnpm update * Update components/fakturoid/actions/create-invoice/create-invoice.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6c50492 commit 7b02b2f

File tree

15 files changed

+1147
-8
lines changed

15 files changed

+1147
-8
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import constants from "../../common/constants.mjs";
2+
import fakturoid from "../../fakturoid.app.mjs";
3+
4+
export default {
5+
key: "fakturoid-cancel-uncancel-invoice",
6+
name: "Cancel or Uncancel Invoice",
7+
description: "Cancels an existing invoice or revokes previous cancellation. [See the documentation](https://www.fakturoid.cz/api/v3)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
fakturoid,
12+
accountSlug: {
13+
propDefinition: [
14+
fakturoid,
15+
"accountSlug",
16+
],
17+
},
18+
invoiceId: {
19+
propDefinition: [
20+
fakturoid,
21+
"invoiceId",
22+
({ accountSlug }) => ({
23+
accountSlug,
24+
}),
25+
],
26+
},
27+
action: {
28+
type: "string",
29+
label: "Action",
30+
description: "The action to perform on the invoice (cancel or uncancel)",
31+
options: constants.ACTION_OPTIONS,
32+
},
33+
},
34+
async run({ $ }) {
35+
const response = await this.fakturoid.fireInvoice({
36+
$,
37+
accountSlug: this.accountSlug,
38+
invoiceId: this.invoiceId,
39+
params: {
40+
event: this.action,
41+
},
42+
});
43+
44+
$.export("$summary", `${this.action === "cancel"
45+
? "Cancelled"
46+
: "Uncancelled"} invoice with ID ${this.invoiceId}`);
47+
return response;
48+
},
49+
};
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import constants, { parseObject } from "../../common/constants.mjs";
2+
import fakturoid from "../../fakturoid.app.mjs";
3+
4+
export default {
5+
key: "fakturoid-create-invoice",
6+
name: "Create Invoice",
7+
description: "Creates a new invoice. [See the documentation](https://www.fakturoid.cz/api/v3/invoices)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
fakturoid,
12+
accountSlug: {
13+
propDefinition: [
14+
fakturoid,
15+
"accountSlug",
16+
],
17+
},
18+
customId: {
19+
type: "string",
20+
label: "Custom Id",
21+
description: "Identifier in your application",
22+
optional: true,
23+
},
24+
documentType: {
25+
type: "string",
26+
label: "Document Type",
27+
description: "Type of document",
28+
options: constants.DOCUMENT_TYPE_OPTIONS,
29+
reloadProps: true,
30+
optional: true,
31+
},
32+
subjectId: {
33+
propDefinition: [
34+
fakturoid,
35+
"subjectId",
36+
({ accountSlug }) => ({
37+
accountSlug,
38+
}),
39+
],
40+
},
41+
orderNumber: {
42+
type: "string",
43+
label: "Order Number",
44+
description: "Order number in your application",
45+
optional: true,
46+
},
47+
note: {
48+
type: "string",
49+
label: "Note",
50+
description: "Additional notes for the invoice",
51+
optional: true,
52+
},
53+
due: {
54+
type: "string",
55+
label: "Due",
56+
description: "Invoice due date in number of days from today",
57+
optional: true,
58+
},
59+
issuedOn: {
60+
type: "string",
61+
label: "Issued On",
62+
description: "Date of issue. **Format: YYYY-MM-DD**",
63+
optional: true,
64+
},
65+
taxableFulfillmentDue: {
66+
type: "string",
67+
label: "Taxable Fulfillment Due",
68+
description: "Chargeable event date.",
69+
optional: true,
70+
},
71+
tags: {
72+
type: "string[]",
73+
label: "Tags",
74+
description: "List of tags",
75+
optional: true,
76+
},
77+
roundTotal: {
78+
type: "boolean",
79+
label: "Round Total",
80+
description: "Round total amount (VAT included)",
81+
optional: true,
82+
},
83+
subtotal: {
84+
type: "string",
85+
label: "Subtotal",
86+
description: "Total without VAT",
87+
optional: true,
88+
},
89+
total: {
90+
type: "string",
91+
label: "Total",
92+
description: "Total with VAT",
93+
optional: true,
94+
},
95+
lines: {
96+
type: "string[]",
97+
label: "Lines",
98+
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\"}**",
99+
},
100+
},
101+
async additionalProps() {
102+
const props = {};
103+
if (this.documentType === "proforma") {
104+
props.proformaFollowupDocument = {
105+
type: "string",
106+
label: "Proforma Followup Document",
107+
description: "What to issue after a proforma is paid.",
108+
options: constants.PROFORMA_OPTIONS,
109+
optional: true,
110+
};
111+
}
112+
return props;
113+
},
114+
async run({ $ }) {
115+
const response = await this.fakturoid.createInvoice({
116+
$,
117+
accountSlug: this.accountSlug,
118+
data: {
119+
custom_id: this.customId,
120+
document_type: this.documentType,
121+
proforma_followup_document: this.proformaFollowupDocument,
122+
subject_id: this.subjectId,
123+
order_number: this.orderNumber,
124+
note: this.note,
125+
due: this.due,
126+
issued_on: this.issuedOn,
127+
taxable_fulfillment_due: this.taxableFulfillmentDue,
128+
tags: parseObject(this.tags),
129+
round_total: this.roundTotal,
130+
subtotal: this.subtotal && parseFloat(this.subtotal),
131+
total: this.total && parseFloat(this.total),
132+
lines: parseObject(this.lines),
133+
},
134+
});
135+
136+
$.export("$summary", `Successfully created invoice with ID ${response.id}`);
137+
return response;
138+
},
139+
};
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import constants from "../../common/constants.mjs";
2+
import fakturoid from "../../fakturoid.app.mjs";
3+
4+
export default {
5+
key: "fakturoid-pay-remove-payment-invoice",
6+
name: "Pay or Remove Payment for Invoice",
7+
description: "Executes payment for an invoice or removes an already applied payment. [See the documentation](https://www.fakturoid.cz/api/v3/invoice-payments)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
fakturoid,
12+
accountSlug: {
13+
propDefinition: [
14+
fakturoid,
15+
"accountSlug",
16+
],
17+
},
18+
invoiceId: {
19+
propDefinition: [
20+
fakturoid,
21+
"invoiceId",
22+
({ accountSlug }) => ({
23+
accountSlug,
24+
}),
25+
],
26+
},
27+
actionType: {
28+
type: "string",
29+
label: "Action Type",
30+
description: "Specify if you want to execute or remove a payment",
31+
options: constants.ACTION_TYPE_OPTIONS,
32+
reloadProps: true,
33+
},
34+
},
35+
async additionalProps() {
36+
const props = {};
37+
if (this.actionType === "execute") {
38+
props.paidOn = {
39+
type: "string",
40+
label: "Paid On",
41+
description: "Payment date. **Format: YYYY-MM-DD** Default: Today",
42+
optional: true,
43+
};
44+
props.currency = {
45+
type: "string",
46+
label: "Currency",
47+
description: "Currency [ISO Code](https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes) (same as invoice currency)",
48+
optional: true,
49+
};
50+
props.amount = {
51+
type: "string",
52+
label: "Amount",
53+
description: "Paid amount in document currency. Default: Remaining amount to pay",
54+
optional: true,
55+
};
56+
props.markDocumentAsPaid = {
57+
type: "boolean",
58+
label: "Mark Document As Paid",
59+
description: "Mark document as paid? Default: true if the total paid amount becomes greater or equal to remaining amount to pay",
60+
optional: true,
61+
};
62+
} else if (this.actionType === "remove") {
63+
props.paymentId = {
64+
type: "string",
65+
label: "Payment ID",
66+
description: "ID of the payment to be removed.",
67+
options: async () => {
68+
const { payments } = await this.fakturoid.getInvoice({
69+
accountSlug: this.accountSlug,
70+
invoiceId: this.invoiceId,
71+
});
72+
73+
return payments.map(({
74+
id: value, paid_on: pOn, currency, amount,
75+
}) => ({
76+
label: `${currency} ${amount} (${pOn})`,
77+
value,
78+
}));
79+
},
80+
};
81+
}
82+
return props;
83+
},
84+
async run({ $ }) {
85+
if (this.actionType === "execute") {
86+
const response = await this.fakturoid.payInvoice({
87+
accountSlug: this.accountSlug,
88+
invoiceId: this.invoiceId,
89+
data: {
90+
paid_on: this.paidOn,
91+
currency: this.currency,
92+
amount: this.amount && parseFloat(this.amount),
93+
mark_document_as_paid: this.markDocumentAsPaid,
94+
},
95+
});
96+
$.export("$summary", `Successfully executed payment for invoice ID ${this.invoiceId}`);
97+
return response;
98+
} else if (this.actionType === "remove") {
99+
const response = await this.fakturoid.removePayment({
100+
$,
101+
accountSlug: this.accountSlug,
102+
invoiceId: this.invoiceId,
103+
paymentId: this.paymentId,
104+
});
105+
$.export("$summary", `Successfully removed payment ID ${this.paymentId} from invoice ID ${this.invoiceId}`);
106+
return response;
107+
}
108+
},
109+
};

0 commit comments

Comments
 (0)