| 
 | 1 | +import { LANGUAGE_OPTIONS } from "../../common/constants.mjs";  | 
 | 2 | +import { parseObject } from "../../common/utils.mjs";  | 
1 | 3 | import pennylane from "../../pennylane.app.mjs";  | 
2 |  | -import { axios } from "@pipedream/platform";  | 
3 | 4 | 
 
  | 
4 | 5 | export default {  | 
5 | 6 |   key: "pennylane-create-customer-invoice",  | 
6 | 7 |   name: "Create Customer Invoice",  | 
7 | 8 |   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",  | 
9 | 10 |   type: "action",  | 
10 | 11 |   props: {  | 
11 | 12 |     pennylane,  | 
12 |  | -    invoiceCustomerId: {  | 
13 |  | -      propDefinition: [  | 
14 |  | -        pennylane,  | 
15 |  | -        "invoiceCustomerId",  | 
16 |  | -      ],  | 
 | 13 | +    date: {  | 
 | 14 | +      type: "string",  | 
 | 15 | +      label: "Date",  | 
 | 16 | +      description: "Invoice date (ISO 8601)",  | 
17 | 17 |     },  | 
18 |  | -    invoiceItems: {  | 
19 |  | -      propDefinition: [  | 
20 |  | -        pennylane,  | 
21 |  | -        "invoiceItems",  | 
22 |  | -      ],  | 
 | 18 | +    deadline: {  | 
 | 19 | +      type: "string",  | 
 | 20 | +      label: "Deadline",  | 
 | 21 | +      description: "Invoice payment deadline (ISO 8601)",  | 
23 | 22 |     },  | 
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,  | 
29 | 28 |     },  | 
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",  | 
35 | 33 |       optional: true,  | 
36 | 34 |     },  | 
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: {  | 
38 | 87 |       propDefinition: [  | 
39 | 88 |         pennylane,  | 
40 |  | -        "invoiceFooterCustomization",  | 
 | 89 | +        "customerId",  | 
41 | 90 |       ],  | 
 | 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",  | 
42 | 107 |       optional: true,  | 
43 | 108 |     },  | 
 | 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 | +    },  | 
44 | 119 |   },  | 
45 | 120 |   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 | +    });  | 
47 | 155 | 
 
  | 
48 | 156 |     $.export("$summary", `Created invoice with ID ${invoice.invoice.id}`);  | 
49 | 157 |     return invoice;  | 
 | 
0 commit comments