activepieces-piece-coretool 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/index.js +33 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,19 @@
|
|
|
13
13
|
## Install (self-hosted Activepieces)
|
|
14
14
|
|
|
15
15
|
1. In Activepieces open **Settings → My Pieces → Install Piece**.
|
|
16
|
-
2. Choose npm and enter the package name `activepieces-piece-coretool` (
|
|
16
|
+
2. Choose npm and enter the package name `activepieces-piece-coretool` (latest version: `0.1.3`).
|
|
17
17
|
3. Create a connection with your Coretool API key (get a free test key `ct_test_…` at https://coretool.de; test-mode PDFs are watermarked).
|
|
18
18
|
|
|
19
19
|
Note: this piece is published on npm by Coretool and is not part of the official Activepieces piece catalog. Installing custom pieces may depend on your Activepieces edition.
|
|
20
20
|
|
|
21
|
+
## Changes in 0.1.3
|
|
22
|
+
|
|
23
|
+
- Line items use `tax_rate` (19, 7 or 0). Since 0.1.3 the older field `vat_rate` is mapped to `tax_rate`, so 7 % lines are invoiced at 7 % (before, they were invoiced at 19 %). Flows that used `vat_rate` therefore produce different, correct amounts. If a line has both fields, `tax_rate` wins. With small business, reverse charge or intra-community supply as Tax Exemption, `vat_rate` is not used (the whole invoice is 0 %); with § 4 UStG or letting it is only used when at least one line is explicitly 0 %.
|
|
24
|
+
- A 0 % line now needs a Tax Exemption; the API rejects 0 % without one.
|
|
25
|
+
- Seller IBAN is required (the API already rejected invoices without it).
|
|
26
|
+
- "Too many requests" errors now show the reason from the API (for example the daily limit of test keys) instead of always "wait a minute".
|
|
27
|
+
- If Line Items is not valid JSON, the error now explains how to fix it and shows an example.
|
|
28
|
+
|
|
21
29
|
## Develop
|
|
22
30
|
|
|
23
31
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -27968,7 +27968,7 @@ async function request({
|
|
|
27968
27968
|
headers: {
|
|
27969
27969
|
"X-API-Key": apiKey,
|
|
27970
27970
|
Accept: "application/json",
|
|
27971
|
-
"User-Agent": "coretool-activepieces/0.
|
|
27971
|
+
"User-Agent": "coretool-activepieces/0.1.3"
|
|
27972
27972
|
},
|
|
27973
27973
|
body,
|
|
27974
27974
|
queryParams,
|
|
@@ -28032,7 +28032,7 @@ function buildErrorMessage({ error: error48, what }) {
|
|
|
28032
28032
|
message = `${what}: the file is too large \u2013 the maximum is 5 MB`;
|
|
28033
28033
|
break;
|
|
28034
28034
|
case 429:
|
|
28035
|
-
message = "Too many requests \u2013 wait a minute and try again";
|
|
28035
|
+
message = apiMessage ? `Too many requests \u2013 ${apiMessage}` : "Too many requests \u2013 wait a minute and try again";
|
|
28036
28036
|
break;
|
|
28037
28037
|
case 503:
|
|
28038
28038
|
message = "The validation service is briefly unavailable \u2013 try again in a minute";
|
|
@@ -28068,13 +28068,15 @@ function dateOnly({ value, label }) {
|
|
|
28068
28068
|
}
|
|
28069
28069
|
return match[0];
|
|
28070
28070
|
}
|
|
28071
|
-
function parseLineItems(value) {
|
|
28071
|
+
function parseLineItems(value, taxExemption) {
|
|
28072
28072
|
let parsed = value;
|
|
28073
28073
|
if (typeof value === "string") {
|
|
28074
28074
|
try {
|
|
28075
28075
|
parsed = JSON.parse(value);
|
|
28076
28076
|
} catch (error48) {
|
|
28077
|
-
throw new Error(
|
|
28077
|
+
throw new Error(
|
|
28078
|
+
`Line Items: the list is not written correctly \u2013 check brackets, commas and double quotes. Example: [{"description": "Consulting", "quantity": 1, "unit_price": 100, "tax_rate": 19}] (technical detail: ${error48 instanceof Error ? error48.message : String(error48)})`
|
|
28079
|
+
);
|
|
28078
28080
|
}
|
|
28079
28081
|
}
|
|
28080
28082
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -28083,14 +28085,33 @@ function parseLineItems(value) {
|
|
|
28083
28085
|
if (!Array.isArray(parsed) || parsed.length === 0) {
|
|
28084
28086
|
throw new Error("Line Items: add at least one line item");
|
|
28085
28087
|
}
|
|
28086
|
-
|
|
28087
|
-
|
|
28088
|
+
const isSet = (v) => v !== void 0 && v !== null && !(typeof v === "string" && v.trim() === "");
|
|
28089
|
+
const isZero = (v) => isSet(v) && Number(v) === 0;
|
|
28090
|
+
const exemption = isSet(taxExemption) ? String(taxExemption) : "";
|
|
28091
|
+
const exempt = exemption !== "" && exemption !== "none";
|
|
28092
|
+
const MIXED_EXEMPTIONS = /* @__PURE__ */ new Set(["steuerfrei_4", "vermietung"]);
|
|
28093
|
+
const records = parsed.map((entry) => typeof entry === "string" ? asRecord(entry) : entry);
|
|
28094
|
+
const mixed = records.some(
|
|
28095
|
+
(e) => {
|
|
28096
|
+
if (!e || typeof e !== "object") return false;
|
|
28097
|
+
const r = e;
|
|
28098
|
+
return isZero(isSet(r["tax_rate"]) ? r["tax_rate"] : r["vat_rate"]);
|
|
28099
|
+
}
|
|
28100
|
+
);
|
|
28101
|
+
const dropVatRate = exempt && (!MIXED_EXEMPTIONS.has(exemption) || !mixed);
|
|
28102
|
+
return records.map((record3) => {
|
|
28088
28103
|
if (!record3 || typeof record3 !== "object" || Array.isArray(record3) || !Object.keys(record3).length) {
|
|
28089
28104
|
throw new Error(
|
|
28090
|
-
'Line Items: every line item must be an object such as {"description": "Consulting", "quantity": 1, "unit_price": 100, "
|
|
28105
|
+
'Line Items: every line item must be an object such as {"description": "Consulting", "quantity": 1, "unit_price": 100, "tax_rate": 19}'
|
|
28091
28106
|
);
|
|
28092
28107
|
}
|
|
28093
|
-
|
|
28108
|
+
const item = { ...record3 };
|
|
28109
|
+
if (isSet(item["vat_rate"]) && !dropVatRate && !isSet(item["tax_rate"])) {
|
|
28110
|
+
item["tax_rate"] = item["vat_rate"];
|
|
28111
|
+
}
|
|
28112
|
+
delete item["vat_rate"];
|
|
28113
|
+
if (!isSet(item["tax_rate"])) delete item["tax_rate"];
|
|
28114
|
+
return item;
|
|
28094
28115
|
});
|
|
28095
28116
|
}
|
|
28096
28117
|
function safeFileName({ name, fallback }) {
|
|
@@ -28254,11 +28275,11 @@ var createEInvoice = createAction({
|
|
|
28254
28275
|
buyerVatId: Property.ShortText({ displayName: "Buyer VAT ID", description: "Needed for reverse charge and intra-community supplies.", required: false }),
|
|
28255
28276
|
items: Property.Json({
|
|
28256
28277
|
displayName: "Line Items",
|
|
28257
|
-
description:
|
|
28278
|
+
description: 'JSON array of line items. Fields: description, quantity, unit (e.g. C62 = piece, HUR = hour), unit_price (net), tax_rate (19, 7 or 0). With Tax Exemption "Small business", "Reverse charge" or "Intra-community supply" use tax_rate 0 or leave it out. With "Tax-exempt (\xA7 4 UStG)" or "Tax-exempt letting" set tax_rate on every line: 0 on exempt lines, 19 or 7 on taxable lines (lines without tax_rate become 0 %).',
|
|
28258
28279
|
required: true,
|
|
28259
|
-
defaultValue: [{ description: "Consulting services", quantity: 2, unit: "HUR", unit_price: 95,
|
|
28280
|
+
defaultValue: [{ description: "Consulting services", quantity: 2, unit: "HUR", unit_price: 95, tax_rate: 19 }]
|
|
28260
28281
|
}),
|
|
28261
|
-
iban: Property.ShortText({ displayName: "IBAN", required:
|
|
28282
|
+
iban: Property.ShortText({ displayName: "IBAN", description: "Your IBAN \u2013 printed on the invoice and in the payment QR code.", required: true }),
|
|
28262
28283
|
bic: Property.ShortText({ displayName: "BIC", required: false }),
|
|
28263
28284
|
bankName: Property.ShortText({ displayName: "Bank Name", required: false }),
|
|
28264
28285
|
dueDays: Property.Number({ displayName: "Payment Due (Days)", description: "Days until payment is due, e.g. 14.", required: false }),
|
|
@@ -28328,7 +28349,7 @@ var createEInvoice = createAction({
|
|
|
28328
28349
|
phone: p.buyerPhone,
|
|
28329
28350
|
vat_id: p.buyerVatId
|
|
28330
28351
|
},
|
|
28331
|
-
items: coretoolClient.parseLineItems(p.items),
|
|
28352
|
+
items: coretoolClient.parseLineItems(p.items, p.taxExemption),
|
|
28332
28353
|
payment: {
|
|
28333
28354
|
iban: p.iban,
|
|
28334
28355
|
bic: p.bic,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activepieces-piece-coretool",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Activepieces piece for Coretool: create and validate German e-invoices (ZUGFeRD, XRechnung), check Leitweg-IDs, read usage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "coretool-de <info@coretool.de>",
|