Skip to content

Commit 6cbb387

Browse files
committed
[Components] pennylane #14952
Sources - New Billing Subscription - New Customer Invoice - New Customer Actions - Create Customer - Create Billing Subscription - Create Customer Invoice
1 parent 93c610d commit 6cbb387

File tree

14 files changed

+941
-649
lines changed

14 files changed

+941
-649
lines changed

components/pennylane/actions/create-billing-subscription/create-billing-subscription.mjs

Lines changed: 120 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,134 @@
1+
import { parseObject } from "../../common/utils.mjs";
12
import pennylane from "../../pennylane.app.mjs";
2-
import { axios } from "@pipedream/platform";
33

44
export default {
55
key: "pennylane-create-billing-subscription",
66
name: "Create Billing Subscription",
7-
description: "Creates a billing subscription for a customer. [See the documentation]().",
8-
version: "0.0.{{ts}}",
7+
description: "Creates a billing subscription for a customer. [See the documentation](https://pennylane.readme.io/reference/billing_subscriptions-post-1).",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
pennylane: {
12-
type: "app",
13-
app: "pennylane",
14-
},
15-
customerId: {
16-
propDefinition: [
17-
pennylane,
18-
"customerId",
19-
],
20-
},
21-
subscriptionPlanId: {
22-
propDefinition: [
23-
pennylane,
24-
"subscriptionPlanId",
25-
],
26-
},
27-
billingFrequency: {
28-
propDefinition: [
29-
pennylane,
30-
"billingFrequency",
31-
],
32-
},
33-
subscriptionDiscounts: {
34-
propDefinition: [
35-
pennylane,
36-
"subscriptionDiscounts",
37-
],
38-
optional: true,
39-
},
40-
subscriptionCustomNotes: {
41-
propDefinition: [
42-
pennylane,
43-
"subscriptionCustomNotes",
44-
],
11+
pennylane,
12+
mode: {
13+
type: "string",
14+
label: "Mode",
15+
description: "Mode",
16+
optional: true,
17+
},
18+
paymentConditions: {
19+
type: "string",
20+
label: "Payment Conditions",
21+
description: "PaymentConditions",
22+
optional: true,
23+
},
24+
paymentMethod: {
25+
type: "string",
26+
label: "Payment Method",
27+
description: "PaymentMethod",
28+
optional: true,
29+
},
30+
type: {
31+
type: "string",
32+
label: "Type",
33+
description: "Type",
34+
optional: true,
35+
},
36+
dayOfMonth: {
37+
type: "string",
38+
label: "Day Of Month",
39+
description: "DayOfMonth",
40+
optional: true,
41+
},
42+
dayOfWeek: {
43+
type: "string",
44+
label: "Day Of Week",
45+
description: "DayOfWeek",
46+
optional: true,
47+
},
48+
interval: {
49+
type: "string",
50+
label: "Interval",
51+
description: "Interval",
52+
optional: true,
53+
},
54+
count: {
55+
type: "string",
56+
label: "Count",
57+
description: "Count",
58+
optional: true,
59+
},
60+
sourceId: {
61+
type: "string",
62+
label: "Source Id",
63+
description: "SourceId",
64+
optional: true,
65+
},
66+
currency: {
67+
type: "string",
68+
label: "Currency",
69+
description: "Currency",
70+
optional: true,
71+
},
72+
start: {
73+
type: "string",
74+
label: "Start",
75+
description: "Start",
76+
optional: true,
77+
},
78+
specialMention: {
79+
type: "string",
80+
label: "Special Mention",
81+
description: "Special Mention",
82+
optional: true,
83+
},
84+
discount: {
85+
type: "integer",
86+
label: "Discount",
87+
description: "Discount",
88+
optional: true,
89+
},
90+
lineItemsSectionsAttributes: {
91+
type: "string",
92+
label: "Line Items Sections Attributes",
93+
description: "Line Items Sections Attributes",
94+
optional: true,
95+
},
96+
invoiceLines: {
97+
type: "string",
98+
label: "Invoice Lines",
99+
description: "Invoice Lines",
45100
optional: true,
46101
},
47102
},
48103
async run({ $ }) {
49-
const response = await this.pennylane.createBillingSubscription();
104+
const response = await this.pennylane.createBillingSubscription({
105+
$,
106+
data: {
107+
create_customer: false,
108+
create_products: false,
109+
billing_subscription: {
110+
currency: this.currency,
111+
mode: this.mode,
112+
start: this.start,
113+
payment_conditions: this.paymentConditions,
114+
payment_method: this.paymentMethod,
115+
recurring_rule: {
116+
type: this.type,
117+
day_of_month: this.dayOfMonth,
118+
day_of_week: this.dayOfWeek,
119+
interval: this.interval,
120+
count: this.count,
121+
},
122+
special_mention: this.specialMention,
123+
discount: this.discount,
124+
customer: {
125+
source_id: this.sourceId,
126+
},
127+
line_items_sections_attributes: parseObject(this.lineItemsSectionsAttributes),
128+
invoice_lines: parseObject(this.invoiceLines),
129+
},
130+
},
131+
});
50132
$.export("$summary", `Created billing subscription with ID ${response.billing_subscription.id}`);
51133
return response;
52134
},

components/pennylane/actions/create-customer-invoice/create-customer-invoice.mjs

Lines changed: 133 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,157 @@
1+
import { LANGUAGE_OPTIONS } from "../../common/constants.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
13
import pennylane from "../../pennylane.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "pennylane-create-customer-invoice",
67
name: "Create Customer Invoice",
78
description: "Generates a new invoice for a customer using Pennylane. [See the documentation](https://pennylane.readme.io/reference/customer_invoices-post-1)",
8-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
pennylane,
12-
invoiceCustomerId: {
13-
propDefinition: [
14-
pennylane,
15-
"invoiceCustomerId",
16-
],
13+
date: {
14+
type: "string",
15+
label: "Date",
16+
description: "Invoice date (ISO 8601)",
1717
},
18-
invoiceItems: {
19-
propDefinition: [
20-
pennylane,
21-
"invoiceItems",
22-
],
18+
deadline: {
19+
type: "string",
20+
label: "Deadline",
21+
description: "Invoice payment deadline (ISO 8601)",
2322
},
24-
paymentTerms: {
25-
propDefinition: [
26-
pennylane,
27-
"paymentTerms",
28-
],
23+
externalId: {
24+
type: "string",
25+
label: "External Id",
26+
description: "An id you can use to refer to the invoice from outside of Pennylane",
27+
optional: true,
2928
},
30-
invoiceTaxDetails: {
31-
propDefinition: [
32-
pennylane,
33-
"invoiceTaxDetails",
34-
],
29+
pdfInvoiceFreeText: {
30+
type: "string",
31+
label: "PDF Invoice Free Text",
32+
description: "For example, the contact details of the person to contact",
3533
optional: true,
3634
},
37-
invoiceFooterCustomization: {
35+
pdfInvoiceSubject: {
36+
type: "string",
37+
label: "PDF Invoice Subject",
38+
description: "Invoice title",
39+
optional: true,
40+
},
41+
draft: {
42+
type: "boolean",
43+
label: "Draft",
44+
description: "Do you wish to create a draft invoice (otherwise it is a finalized invoice) ? Reminder, once created, a finalized invoice cannot be edited !",
45+
},
46+
currency: {
47+
type: "string",
48+
label: "Currency",
49+
description: "Invoice Currency (ISO 4217). Default is EUR.",
50+
optional: true,
51+
},
52+
specialMention: {
53+
type: "string",
54+
label: "Special Mention",
55+
description: "Additional details",
56+
optional: true,
57+
},
58+
discount: {
59+
type: "integer",
60+
label: "Discount",
61+
description: "Invoice discount (in percent)",
62+
optional: true,
63+
},
64+
language: {
65+
type: "string",
66+
label: "Language",
67+
description: "invoice pdf language",
68+
options: LANGUAGE_OPTIONS,
69+
optional: true,
70+
},
71+
bankingProvider: {
72+
type: "string",
73+
label: "Banking Provider",
74+
description: "The banking provider for the transaction",
75+
},
76+
providerFieldName: {
77+
type: "string",
78+
label: "Provider Field Name",
79+
description: "Name of the field that you want to match",
80+
},
81+
providerFieldValue: {
82+
type: "string",
83+
label: "Provider Field Value",
84+
description: "Value that you want to match",
85+
},
86+
customerId: {
3887
propDefinition: [
3988
pennylane,
40-
"invoiceFooterCustomization",
89+
"customerId",
4190
],
91+
},
92+
lineItemsSectionsAttributes: {
93+
type: "string[]",
94+
label: "Line Items Sections Attributes",
95+
description: "A list of objects of items sections to be listed on the invoice",
96+
optional: true,
97+
},
98+
lineItems: {
99+
type: "string[]",
100+
label: "Line Items",
101+
description: "A list of objects of items to be listed on the invoice",
102+
},
103+
categories: {
104+
type: "string[]",
105+
label: "Categories",
106+
description: "A list of objects of categories",
42107
optional: true,
43108
},
109+
startDate: {
110+
type: "string",
111+
label: "Start Date",
112+
description: "Start date of the imputation period (ISO 8601)",
113+
},
114+
endDate: {
115+
type: "string",
116+
label: "End Date",
117+
description: "End date of the imputation period (ISO 8601)",
118+
},
44119
},
45120
async run({ $ }) {
46-
const invoice = await this.pennylane.generateInvoice();
121+
const invoice = await this.pennylane.createInvoice({
122+
$,
123+
data: {
124+
create_custome: false,
125+
create_products: false,
126+
invoice: {
127+
date: this.date,
128+
deadline: this.deadline,
129+
external_id: this.externalId,
130+
pdf_invoice_free_text: this.pdfInvoiceFreeText,
131+
pdf_invoice_subject: this.pdfInvoiceSubject,
132+
draft: this.draft,
133+
currency: this.currency,
134+
special_mention: this.specialMention,
135+
discount: this.discount,
136+
language: this.language,
137+
transactions_reference: {
138+
banking_provider: this.bankingProvider,
139+
provider_field_name: this.providerFieldName,
140+
provider_field_value: this.providerFieldValue,
141+
},
142+
customer: {
143+
source_id: this.customerId,
144+
},
145+
line_items_sections_attributes: parseObject(this.lineItemsSectionsAttributes),
146+
line_items: parseObject(this.lineItems),
147+
categories: parseObject(this.categories),
148+
imputation_dates: {
149+
start_date: this.startDate,
150+
end_date: this.endDate,
151+
},
152+
},
153+
},
154+
});
47155

48156
$.export("$summary", `Created invoice with ID ${invoice.invoice.id}`);
49157
return invoice;

0 commit comments

Comments
 (0)