n8n-nodes-roapp 1.0.7
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 +117 -0
- package/dist/credentials/RoappApi.credentials.d.ts +10 -0
- package/dist/credentials/RoappApi.credentials.js +37 -0
- package/dist/credentials/RoappApi.credentials.js.map +1 -0
- package/dist/nodes/Roapp/Roapp.node.d.ts +18 -0
- package/dist/nodes/Roapp/Roapp.node.js +237 -0
- package/dist/nodes/Roapp/Roapp.node.js.map +1 -0
- package/dist/nodes/Roapp/Roapp.node.json +18 -0
- package/dist/nodes/Roapp/resources/assets/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/assets/create.js +113 -0
- package/dist/nodes/Roapp/resources/assets/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/assets/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/assets/getAll.js +62 -0
- package/dist/nodes/Roapp/resources/assets/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/assets/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/assets/index.js +69 -0
- package/dist/nodes/Roapp/resources/assets/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/bookings/create.js +70 -0
- package/dist/nodes/Roapp/resources/bookings/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/createItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/bookings/createItem.js +86 -0
- package/dist/nodes/Roapp/resources/bookings/createItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/deleteItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/bookings/deleteItem.js +32 -0
- package/dist/nodes/Roapp/resources/bookings/deleteItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/bookings/getAll.js +201 -0
- package/dist/nodes/Roapp/resources/bookings/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/bookings/index.js +122 -0
- package/dist/nodes/Roapp/resources/bookings/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/update.d.ts +2 -0
- package/dist/nodes/Roapp/resources/bookings/update.js +50 -0
- package/dist/nodes/Roapp/resources/bookings/update.js.map +1 -0
- package/dist/nodes/Roapp/resources/bookings/updateItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/bookings/updateItem.js +95 -0
- package/dist/nodes/Roapp/resources/bookings/updateItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/catalog/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/catalog/getAll.js +63 -0
- package/dist/nodes/Roapp/resources/catalog/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/catalog/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/catalog/index.js +117 -0
- package/dist/nodes/Roapp/resources/catalog/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/company/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/company/index.js +101 -0
- package/dist/nodes/Roapp/resources/company/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/create.js +80 -0
- package/dist/nodes/Roapp/resources/estimates/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/createComment.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/createComment.js +43 -0
- package/dist/nodes/Roapp/resources/estimates/createComment.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/createItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/createItem.js +86 -0
- package/dist/nodes/Roapp/resources/estimates/createItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/deleteItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/deleteItem.js +32 -0
- package/dist/nodes/Roapp/resources/estimates/deleteItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/getAll.js +63 -0
- package/dist/nodes/Roapp/resources/estimates/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/getPublicUrl.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/getPublicUrl.js +20 -0
- package/dist/nodes/Roapp/resources/estimates/getPublicUrl.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/estimates/index.js +183 -0
- package/dist/nodes/Roapp/resources/estimates/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/updateItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/updateItem.js +97 -0
- package/dist/nodes/Roapp/resources/estimates/updateItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/estimates/updateStatus.d.ts +2 -0
- package/dist/nodes/Roapp/resources/estimates/updateStatus.js +38 -0
- package/dist/nodes/Roapp/resources/estimates/updateStatus.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/create.js +401 -0
- package/dist/nodes/Roapp/resources/invoices/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/createComment.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/createComment.js +43 -0
- package/dist/nodes/Roapp/resources/invoices/createComment.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/createItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/createItem.js +90 -0
- package/dist/nodes/Roapp/resources/invoices/createItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/deleteItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/deleteItem.js +32 -0
- package/dist/nodes/Roapp/resources/invoices/deleteItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/getAll.js +99 -0
- package/dist/nodes/Roapp/resources/invoices/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/invoices/index.js +147 -0
- package/dist/nodes/Roapp/resources/invoices/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/update.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/update.js +79 -0
- package/dist/nodes/Roapp/resources/invoices/update.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/updateItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/updateItem.js +98 -0
- package/dist/nodes/Roapp/resources/invoices/updateItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/invoices/updateStatus.d.ts +2 -0
- package/dist/nodes/Roapp/resources/invoices/updateStatus.js +38 -0
- package/dist/nodes/Roapp/resources/invoices/updateStatus.js.map +1 -0
- package/dist/nodes/Roapp/resources/lead/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/lead/create.js +176 -0
- package/dist/nodes/Roapp/resources/lead/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/lead/createComment.d.ts +2 -0
- package/dist/nodes/Roapp/resources/lead/createComment.js +40 -0
- package/dist/nodes/Roapp/resources/lead/createComment.js.map +1 -0
- package/dist/nodes/Roapp/resources/lead/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/lead/getAll.js +92 -0
- package/dist/nodes/Roapp/resources/lead/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/lead/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/lead/index.js +82 -0
- package/dist/nodes/Roapp/resources/lead/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/lead/updateStatus.d.ts +2 -0
- package/dist/nodes/Roapp/resources/lead/updateStatus.js +38 -0
- package/dist/nodes/Roapp/resources/lead/updateStatus.js.map +1 -0
- package/dist/nodes/Roapp/resources/marketing/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/marketing/index.js +46 -0
- package/dist/nodes/Roapp/resources/marketing/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/create.js +80 -0
- package/dist/nodes/Roapp/resources/orders/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/createComment.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/createComment.js +43 -0
- package/dist/nodes/Roapp/resources/orders/createComment.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/createItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/createItem.js +86 -0
- package/dist/nodes/Roapp/resources/orders/createItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/deleteItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/deleteItem.js +32 -0
- package/dist/nodes/Roapp/resources/orders/deleteItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/getAll.js +63 -0
- package/dist/nodes/Roapp/resources/orders/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/getPublicUrl.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/getPublicUrl.js +20 -0
- package/dist/nodes/Roapp/resources/orders/getPublicUrl.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/orders/index.js +183 -0
- package/dist/nodes/Roapp/resources/orders/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/updateItem.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/updateItem.js +97 -0
- package/dist/nodes/Roapp/resources/orders/updateItem.js.map +1 -0
- package/dist/nodes/Roapp/resources/orders/updateStatus.d.ts +2 -0
- package/dist/nodes/Roapp/resources/orders/updateStatus.js +38 -0
- package/dist/nodes/Roapp/resources/orders/updateStatus.js.map +1 -0
- package/dist/nodes/Roapp/resources/organization/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/organization/create.js +55 -0
- package/dist/nodes/Roapp/resources/organization/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/organization/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/organization/getAll.js +5 -0
- package/dist/nodes/Roapp/resources/organization/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/organization/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/organization/index.js +84 -0
- package/dist/nodes/Roapp/resources/organization/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/person/create.d.ts +2 -0
- package/dist/nodes/Roapp/resources/person/create.js +78 -0
- package/dist/nodes/Roapp/resources/person/create.js.map +1 -0
- package/dist/nodes/Roapp/resources/person/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/person/getAll.js +5 -0
- package/dist/nodes/Roapp/resources/person/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/person/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/person/index.js +83 -0
- package/dist/nodes/Roapp/resources/person/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/sale/getAll.d.ts +2 -0
- package/dist/nodes/Roapp/resources/sale/getAll.js +5 -0
- package/dist/nodes/Roapp/resources/sale/getAll.js.map +1 -0
- package/dist/nodes/Roapp/resources/sale/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/sale/index.js +46 -0
- package/dist/nodes/Roapp/resources/sale/index.js.map +1 -0
- package/dist/nodes/Roapp/resources/warehouse/getStock.d.ts +2 -0
- package/dist/nodes/Roapp/resources/warehouse/getStock.js +92 -0
- package/dist/nodes/Roapp/resources/warehouse/getStock.js.map +1 -0
- package/dist/nodes/Roapp/resources/warehouse/getWarehouses.d.ts +2 -0
- package/dist/nodes/Roapp/resources/warehouse/getWarehouses.js +43 -0
- package/dist/nodes/Roapp/resources/warehouse/getWarehouses.js.map +1 -0
- package/dist/nodes/Roapp/resources/warehouse/index.d.ts +3 -0
- package/dist/nodes/Roapp/resources/warehouse/index.js +47 -0
- package/dist/nodes/Roapp/resources/warehouse/index.js.map +1 -0
- package/dist/nodes/Roapp/roapp.svg +26 -0
- package/dist/nodes/Roapp/roapp_dark.svg +29 -0
- package/dist/nodes/Roapp/shared/methods.d.ts +27 -0
- package/dist/nodes/Roapp/shared/methods.js +576 -0
- package/dist/nodes/Roapp/shared/methods.js.map +1 -0
- package/dist/nodes/Roapp/shared/sharedFields.d.ts +2 -0
- package/dist/nodes/Roapp/shared/sharedFields.js +640 -0
- package/dist/nodes/Roapp/shared/sharedFields.js.map +1 -0
- package/dist/package.json +52 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500" width="100%" height="100%">
|
|
2
|
+
<style>
|
|
3
|
+
.brand-blue { fill: #0066ff; }
|
|
4
|
+
.brand-light-blue { fill: #cce0ff; }
|
|
5
|
+
.brand-white { fill: #ffffff; }
|
|
6
|
+
.text-main { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-weight: 500; }
|
|
7
|
+
</style>
|
|
8
|
+
|
|
9
|
+
<!-- Темный фон для предпросмотра, n8n автоматически подставит свой -->
|
|
10
|
+
<rect width="100%" height="100%" fill="#1a1a1a" />
|
|
11
|
+
|
|
12
|
+
<g transform="translate(110, 210)">
|
|
13
|
+
<!-- Буква R -->
|
|
14
|
+
<path class="brand-blue" d="M0,52 L0,2 H27 C38,2 47,8 47,21 C47,31 40,37 31,39 L50,52 L36,52 L19,40 L12,40 L12,52 Z M12,30 L25,30 C32,30 36,27 36,21 C36,15 32,12 25,12 L12,12 Z" />
|
|
15
|
+
|
|
16
|
+
<!-- Буква o (Кастомный элемент со стрелкой) -->
|
|
17
|
+
<g transform="translate(56, 16)">
|
|
18
|
+
<!-- Основное полукольцо стрелки -->
|
|
19
|
+
<path class="brand-blue" d="M37,18 C37,8 29,0 18,0 C8,0 0,8 0,18 C0,28 8,36 18,36 L18,25 C14,25 11,22 11,18 C11,14 14,11 18,11 C22,11 25,14 25,18 L25,23 L30,19 L37,25 Z" />
|
|
20
|
+
<!-- Наконечник стрелки -->
|
|
21
|
+
<polygon class="brand-blue" points="30,19 40,19 35,27" />
|
|
22
|
+
<!-- Светло-голубой квадратик снизу справа -->
|
|
23
|
+
<rect class="brand-light-blue" x="25" y="25" width="11" height="11" />
|
|
24
|
+
</g>
|
|
25
|
+
|
|
26
|
+
<!-- Текст "app" (Изменен на белый) -->
|
|
27
|
+
<text x="112" y="45" font-size="58" class="brand-white text-main" letter-spacing="-2">app</text>
|
|
28
|
+
</g>
|
|
29
|
+
</svg>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { INodePropertyOptions, IAllExecuteFunctions, ILoadOptionsFunctions, IExecuteFunctions, IHttpRequestMethods, IDataObject, INodeExecutionData, ResourceMapperField } from 'n8n-workflow';
|
|
2
|
+
export declare const BASE_URL: string;
|
|
3
|
+
export declare function phoneValidation(phone: string): boolean;
|
|
4
|
+
export declare function fetchCustomFieldsData(this: IExecuteFunctions | ILoadOptionsFunctions, resource: string): Promise<{
|
|
5
|
+
fields: ResourceMapperField[];
|
|
6
|
+
fieldsInfo: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
export declare function getResourceStatuses(this: IAllExecuteFunctions, resource: string): Promise<INodePropertyOptions[]>;
|
|
11
|
+
export declare function getResourceTypes(this: IAllExecuteFunctions, resource: string): Promise<INodePropertyOptions[]>;
|
|
12
|
+
export declare function getAdCampaigns(this: IAllExecuteFunctions): Promise<INodePropertyOptions[]>;
|
|
13
|
+
export declare function getEmployees(this: IAllExecuteFunctions): Promise<INodePropertyOptions[]>;
|
|
14
|
+
export declare function getLocations(this: IAllExecuteFunctions): Promise<INodePropertyOptions[]>;
|
|
15
|
+
export declare function getLocationResources(this: IAllExecuteFunctions, branch_id: string): Promise<INodePropertyOptions[]>;
|
|
16
|
+
export declare function getCustomFieldsInfo(this: IExecuteFunctions, resource: string): Promise<{
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function transformCustomFieldsValues(customFieldsData: IDataObject, fieldsInfo: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
}): IDataObject;
|
|
22
|
+
export declare function handleGetAll(this: IExecuteFunctions, index: number, url: string): Promise<INodeExecutionData[][]>;
|
|
23
|
+
export declare function handleGetOne(this: IExecuteFunctions, index: number, url: string, method?: IHttpRequestMethods): Promise<INodeExecutionData[][]>;
|
|
24
|
+
export declare function handlePost(this: IExecuteFunctions, index: number, url: string, body: IDataObject, method?: IHttpRequestMethods): Promise<INodeExecutionData[][]>;
|
|
25
|
+
export declare function handleCreateUpdate(this: IExecuteFunctions, index: number, url: string, method?: IHttpRequestMethods): Promise<INodeExecutionData[][]>;
|
|
26
|
+
export declare function transformInvoiceItems(items: IDataObject[]): IDataObject[];
|
|
27
|
+
export declare function transformInvoiceCustomItems(items: IDataObject[]): IDataObject[];
|
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE_URL = void 0;
|
|
4
|
+
exports.phoneValidation = phoneValidation;
|
|
5
|
+
exports.fetchCustomFieldsData = fetchCustomFieldsData;
|
|
6
|
+
exports.getResourceStatuses = getResourceStatuses;
|
|
7
|
+
exports.getResourceTypes = getResourceTypes;
|
|
8
|
+
exports.getAdCampaigns = getAdCampaigns;
|
|
9
|
+
exports.getEmployees = getEmployees;
|
|
10
|
+
exports.getLocations = getLocations;
|
|
11
|
+
exports.getLocationResources = getLocationResources;
|
|
12
|
+
exports.getCustomFieldsInfo = getCustomFieldsInfo;
|
|
13
|
+
exports.transformCustomFieldsValues = transformCustomFieldsValues;
|
|
14
|
+
exports.handleGetAll = handleGetAll;
|
|
15
|
+
exports.handleGetOne = handleGetOne;
|
|
16
|
+
exports.handlePost = handlePost;
|
|
17
|
+
exports.handleCreateUpdate = handleCreateUpdate;
|
|
18
|
+
exports.transformInvoiceItems = transformInvoiceItems;
|
|
19
|
+
exports.transformInvoiceCustomItems = transformInvoiceCustomItems;
|
|
20
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
21
|
+
const luxon_1 = require("luxon");
|
|
22
|
+
exports.BASE_URL = "https://api.roapp.io/";
|
|
23
|
+
const cf_types = {
|
|
24
|
+
0: "boolean",
|
|
25
|
+
1: "string",
|
|
26
|
+
2: "string",
|
|
27
|
+
3: "string",
|
|
28
|
+
4: "dateTime",
|
|
29
|
+
5: "dateTime",
|
|
30
|
+
6: "number"
|
|
31
|
+
};
|
|
32
|
+
const resources_cf_urls = {
|
|
33
|
+
"order": `${exports.BASE_URL}v2/orders/custom-fields`,
|
|
34
|
+
"estimate": `${exports.BASE_URL}v2/estimates/custom-fields`,
|
|
35
|
+
"person": `${exports.BASE_URL}v2/contacts/people/custom-fields`,
|
|
36
|
+
"organization": `${exports.BASE_URL}v2/contacts/organizations/custom-fields`,
|
|
37
|
+
"lead": `${exports.BASE_URL}lead/custom-fields/`,
|
|
38
|
+
'asset': `${exports.BASE_URL}warehouse/assets/custom-fields/`
|
|
39
|
+
};
|
|
40
|
+
const resources_stuses_urls = {
|
|
41
|
+
"order": `${exports.BASE_URL}v2/orders/statuses`,
|
|
42
|
+
"estimate": `${exports.BASE_URL}v2/estimates/statuses`,
|
|
43
|
+
"lead": `${exports.BASE_URL}statuses/leads`,
|
|
44
|
+
"invoice": `${exports.BASE_URL}v2/invoices/statuses`
|
|
45
|
+
};
|
|
46
|
+
const resources_types_urls = {
|
|
47
|
+
"order": `${exports.BASE_URL}v2/orders/types`,
|
|
48
|
+
"estimate": `${exports.BASE_URL}v2/estimates/types`,
|
|
49
|
+
"lead": `${exports.BASE_URL}lead/types/`,
|
|
50
|
+
"asset": `${exports.BASE_URL}v2/assets/types`
|
|
51
|
+
};
|
|
52
|
+
const cache = {};
|
|
53
|
+
const cacheTTL = {};
|
|
54
|
+
const CACHE_DURATION = 5 * 60 * 1000;
|
|
55
|
+
function errorHelper(error) {
|
|
56
|
+
const context = error === null || error === void 0 ? void 0 : error.context;
|
|
57
|
+
const errorMessage = `${String(JSON.stringify((error === null || error === void 0 ? void 0 : error.description) || (context === null || context === void 0 ? void 0 : context.data)))} ${String(error === null || error === void 0 ? void 0 : error.messages)}`;
|
|
58
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
|
|
59
|
+
message: errorMessage
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function phoneValidation(phone) {
|
|
63
|
+
const phoneRegex = /^\+?[1-9]\d{1,14}$/;
|
|
64
|
+
return phone != "" && phone != null && phone != "undefined" && phoneRegex.test(phone);
|
|
65
|
+
}
|
|
66
|
+
async function fetchCustomFieldsData(resource) {
|
|
67
|
+
const cacheKey = `cf_${resource}`;
|
|
68
|
+
if (cache[cacheKey] && cacheTTL[cacheKey] > Date.now()) {
|
|
69
|
+
return cache[cacheKey];
|
|
70
|
+
}
|
|
71
|
+
const url = resources_cf_urls[resource];
|
|
72
|
+
let data = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
73
|
+
method: 'GET',
|
|
74
|
+
url,
|
|
75
|
+
json: true,
|
|
76
|
+
});
|
|
77
|
+
data = (data === null || data === void 0 ? void 0 : data.data) || data;
|
|
78
|
+
const fields = data.map((field) => ({
|
|
79
|
+
id: `f${field.id}`,
|
|
80
|
+
displayName: field.title || field.name,
|
|
81
|
+
name: `f${field.id}`,
|
|
82
|
+
type: cf_types[parseInt(field.type)] || 'string',
|
|
83
|
+
default: cf_types[parseInt(field.type)] === 'boolean' ? false : '',
|
|
84
|
+
display: true,
|
|
85
|
+
}));
|
|
86
|
+
const fieldsInfo = {};
|
|
87
|
+
for (const field of data) {
|
|
88
|
+
const fieldType = cf_types[parseInt(field.type)] || 'string';
|
|
89
|
+
fieldsInfo[`f${field.id}`] = fieldType;
|
|
90
|
+
}
|
|
91
|
+
cache[cacheKey] = { fields, fieldsInfo };
|
|
92
|
+
cacheTTL[cacheKey] = Date.now() + CACHE_DURATION;
|
|
93
|
+
return { fields, fieldsInfo };
|
|
94
|
+
}
|
|
95
|
+
async function getResourceStatuses(resource) {
|
|
96
|
+
const url = resources_stuses_urls[resource];
|
|
97
|
+
if (!url) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
let response = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
101
|
+
method: "GET",
|
|
102
|
+
url,
|
|
103
|
+
json: true,
|
|
104
|
+
});
|
|
105
|
+
response = (response === null || response === void 0 ? void 0 : response.data) || response;
|
|
106
|
+
const fields = response.map((row) => ({
|
|
107
|
+
name: (row === null || row === void 0 ? void 0 : row.name) || (row === null || row === void 0 ? void 0 : row.title),
|
|
108
|
+
value: row.id
|
|
109
|
+
}));
|
|
110
|
+
return fields;
|
|
111
|
+
}
|
|
112
|
+
async function getResourceTypes(resource) {
|
|
113
|
+
const url = resources_types_urls[resource];
|
|
114
|
+
if (!url) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
let response = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
118
|
+
method: "GET",
|
|
119
|
+
url,
|
|
120
|
+
json: true,
|
|
121
|
+
});
|
|
122
|
+
response = (response === null || response === void 0 ? void 0 : response.data) || response;
|
|
123
|
+
const fields = response.map((row) => ({
|
|
124
|
+
name: (row === null || row === void 0 ? void 0 : row.title) || (row === null || row === void 0 ? void 0 : row.name),
|
|
125
|
+
value: row.id
|
|
126
|
+
}));
|
|
127
|
+
return fields;
|
|
128
|
+
}
|
|
129
|
+
async function getAdCampaigns() {
|
|
130
|
+
const url = `${exports.BASE_URL}marketing/campaigns/`;
|
|
131
|
+
let response = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
132
|
+
method: "GET",
|
|
133
|
+
url,
|
|
134
|
+
json: true,
|
|
135
|
+
});
|
|
136
|
+
response = response === null || response === void 0 ? void 0 : response.data;
|
|
137
|
+
const fields = response.map((row) => ({
|
|
138
|
+
name: row.name,
|
|
139
|
+
value: row.id
|
|
140
|
+
}));
|
|
141
|
+
return fields;
|
|
142
|
+
}
|
|
143
|
+
async function getEmployees() {
|
|
144
|
+
const url = `${exports.BASE_URL}v2/company/employees`;
|
|
145
|
+
let response = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
146
|
+
method: "GET",
|
|
147
|
+
url,
|
|
148
|
+
json: true,
|
|
149
|
+
});
|
|
150
|
+
response = (response === null || response === void 0 ? void 0 : response.data) || response;
|
|
151
|
+
const fields = response.map((row) => ({
|
|
152
|
+
name: `${row === null || row === void 0 ? void 0 : row.first_name} ${row === null || row === void 0 ? void 0 : row.last_name}`,
|
|
153
|
+
value: row.id
|
|
154
|
+
}));
|
|
155
|
+
return fields;
|
|
156
|
+
}
|
|
157
|
+
async function getLocations() {
|
|
158
|
+
const url = `${exports.BASE_URL}v2/company/locations`;
|
|
159
|
+
let response = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
160
|
+
method: "GET",
|
|
161
|
+
url,
|
|
162
|
+
json: true,
|
|
163
|
+
});
|
|
164
|
+
response = (response === null || response === void 0 ? void 0 : response.data) || response;
|
|
165
|
+
const fields = response.map((row) => ({
|
|
166
|
+
name: row === null || row === void 0 ? void 0 : row.name,
|
|
167
|
+
value: row.id
|
|
168
|
+
}));
|
|
169
|
+
return fields;
|
|
170
|
+
}
|
|
171
|
+
async function getLocationResources(branch_id) {
|
|
172
|
+
if (!branch_id) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
;
|
|
176
|
+
const url = `${exports.BASE_URL}v2/company/locations/${branch_id}/resources`;
|
|
177
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
178
|
+
method: "GET",
|
|
179
|
+
url,
|
|
180
|
+
json: true,
|
|
181
|
+
});
|
|
182
|
+
const fields = response.map((row) => ({
|
|
183
|
+
name: row.name,
|
|
184
|
+
value: row.id
|
|
185
|
+
}));
|
|
186
|
+
return fields;
|
|
187
|
+
}
|
|
188
|
+
async function getCustomFieldsInfo(resource) {
|
|
189
|
+
if (!resources_cf_urls[resource]) {
|
|
190
|
+
return {};
|
|
191
|
+
}
|
|
192
|
+
;
|
|
193
|
+
const { fieldsInfo } = await fetchCustomFieldsData.call(this, resource);
|
|
194
|
+
return fieldsInfo;
|
|
195
|
+
}
|
|
196
|
+
function transformCustomFieldsValues(customFieldsData, fieldsInfo) {
|
|
197
|
+
const transformed = {};
|
|
198
|
+
for (const [fieldKey, fieldValue] of Object.entries(customFieldsData)) {
|
|
199
|
+
const fieldType = fieldsInfo[fieldKey];
|
|
200
|
+
if (fieldType === 'dateTime' && fieldValue) {
|
|
201
|
+
try {
|
|
202
|
+
const dateObj = new Date(fieldValue);
|
|
203
|
+
if (!isNaN(dateObj.getTime())) {
|
|
204
|
+
transformed[fieldKey] = dateObj.toISOString().split('.')[0] + 'Z';
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
transformed[fieldKey] = fieldValue;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
transformed[fieldKey] = fieldValue;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
transformed[fieldKey] = fieldValue;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return transformed;
|
|
219
|
+
}
|
|
220
|
+
function isVisible(param, resourceName, operationName) {
|
|
221
|
+
const opts = param.displayOptions;
|
|
222
|
+
if (!opts)
|
|
223
|
+
return true;
|
|
224
|
+
const show = opts.show;
|
|
225
|
+
const hide = opts.hide;
|
|
226
|
+
const hideResource = hide.resource;
|
|
227
|
+
const hideOperation = hide.operation;
|
|
228
|
+
const showResource = show.resource;
|
|
229
|
+
const showOperation = show.operation;
|
|
230
|
+
if (hide) {
|
|
231
|
+
if (hideResource && Array.isArray(hideResource) && (hideResource.includes(resourceName)))
|
|
232
|
+
return false;
|
|
233
|
+
if (hideOperation && Array.isArray((hideOperation) && (hideOperation.includes(operationName))))
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (show) {
|
|
237
|
+
if (showResource && Array.isArray(showResource) && !(showResource.includes(resourceName)))
|
|
238
|
+
return false;
|
|
239
|
+
if (showOperation && Array.isArray(showOperation) && !(showOperation.includes(operationName)))
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
function makeQs(index, ignored = []) {
|
|
245
|
+
const parameters = this.getNode().parameters;
|
|
246
|
+
const qs = {};
|
|
247
|
+
const ignoredParameters = ['resource', 'operation', 'returnAll', 'limit', ...ignored];
|
|
248
|
+
const oldApiRresources = ['asset', 'lead', 'warehouse'];
|
|
249
|
+
const resourceName = this.getNodeParameter('resource', index);
|
|
250
|
+
const operationName = this.getNodeParameter('operation', index);
|
|
251
|
+
for (const parameterName of Object.keys(parameters)) {
|
|
252
|
+
if (!isVisible(parameters[parameterName], resourceName, operationName))
|
|
253
|
+
continue;
|
|
254
|
+
if (!ignoredParameters.includes(parameterName)) {
|
|
255
|
+
try {
|
|
256
|
+
const value = this.getNodeParameter(parameterName, index);
|
|
257
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
258
|
+
if (oldApiRresources.includes(resourceName)) {
|
|
259
|
+
qs[`${parameterName}[]`] = value;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
qs[`${parameterName}`] = value;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else if (typeof value === 'object' && value !== null && value != undefined) {
|
|
266
|
+
const processedFilters = { ...value };
|
|
267
|
+
if (parameterName == "created_at" || parameterName == "modified_at" || parameterName == "closed_at" || parameterName == "scheduled_for" || parameterName == "due_date" || parameterName == "issue_date") {
|
|
268
|
+
const from_name = `${parameterName}_from`;
|
|
269
|
+
const to_name = `${parameterName}_to`;
|
|
270
|
+
let from = '';
|
|
271
|
+
let to = '';
|
|
272
|
+
if (parameterName != "issue_date") {
|
|
273
|
+
from = processedFilters[from_name]
|
|
274
|
+
? `${String(luxon_1.DateTime.fromISO(String(processedFilters[from_name])).toISO()).split(".")[0]}Z`
|
|
275
|
+
: '';
|
|
276
|
+
to = processedFilters[to_name]
|
|
277
|
+
? `,${String(luxon_1.DateTime.fromISO(String(processedFilters[to_name])).toISO()).split(".")[0]}Z`
|
|
278
|
+
: '';
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
from = processedFilters[from_name]
|
|
282
|
+
? `${String(luxon_1.DateTime.fromISO(String(processedFilters[from_name])).toISO({ includeOffset: false, precision: 'day' }))}`
|
|
283
|
+
: '';
|
|
284
|
+
to = processedFilters[to_name]
|
|
285
|
+
? `,${String(luxon_1.DateTime.fromISO(String(processedFilters[to_name])).toISO({ includeOffset: false, precision: 'day' }))}`
|
|
286
|
+
: '';
|
|
287
|
+
}
|
|
288
|
+
if (from || to) {
|
|
289
|
+
qs[`${parameterName}`] = `${from}${to}`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
Object.assign(qs, value);
|
|
294
|
+
}
|
|
295
|
+
const idValues = processedFilters === null || processedFilters === void 0 ? void 0 : processedFilters.idValues;
|
|
296
|
+
if (Array.isArray(idValues)) {
|
|
297
|
+
qs[parameterName] = idValues.map((v) => v.value).join(',');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (value != undefined && String(value).trim() != '' && value !== null) {
|
|
301
|
+
qs[parameterName] = value;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return qs;
|
|
310
|
+
}
|
|
311
|
+
async function handleGetAll(index, url) {
|
|
312
|
+
const returnAll = this.getNodeParameter('returnAll', index, true);
|
|
313
|
+
const limit = this.getNodeParameter('limit', index, 50);
|
|
314
|
+
const resourceName = this.getNodeParameter('resource', index);
|
|
315
|
+
const oldApiRresources = ['asset', 'lead'];
|
|
316
|
+
const qs = makeQs.call(this, index);
|
|
317
|
+
const rawItems = [];
|
|
318
|
+
let page = parseInt(qs.page, 10) || 1;
|
|
319
|
+
let responseData;
|
|
320
|
+
let resObj = {};
|
|
321
|
+
let total_pages = 0;
|
|
322
|
+
do {
|
|
323
|
+
if (page !== 1) {
|
|
324
|
+
qs.page = page;
|
|
325
|
+
}
|
|
326
|
+
const options = {};
|
|
327
|
+
if (oldApiRresources.includes(resourceName)) {
|
|
328
|
+
options["arrayFormat"] = 'repeat';
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
options["arrayFormat"] = 'comma';
|
|
332
|
+
}
|
|
333
|
+
;
|
|
334
|
+
try {
|
|
335
|
+
responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
336
|
+
method: 'GET',
|
|
337
|
+
url: url,
|
|
338
|
+
json: true,
|
|
339
|
+
qs: qs,
|
|
340
|
+
...options
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
errorHelper.call(this, error);
|
|
345
|
+
}
|
|
346
|
+
resObj = (responseData || {});
|
|
347
|
+
const items = ((resObj === null || resObj === void 0 ? void 0 : resObj.data) || responseData || []);
|
|
348
|
+
if (items.length === 0) {
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
rawItems.push(...items);
|
|
352
|
+
const paging = resObj === null || resObj === void 0 ? void 0 : resObj.paging;
|
|
353
|
+
const rawCount = Number(resObj === null || resObj === void 0 ? void 0 : resObj.count);
|
|
354
|
+
if ((paging === null || paging === void 0 ? void 0 : paging.total_pages) !== undefined) {
|
|
355
|
+
total_pages = Number(paging.total_pages);
|
|
356
|
+
}
|
|
357
|
+
else if (!isNaN(rawCount) && rawCount > 0) {
|
|
358
|
+
total_pages = Math.ceil(rawCount / 50);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
total_pages = 1;
|
|
362
|
+
}
|
|
363
|
+
if (!returnAll && rawItems.length >= limit) {
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
if (page >= total_pages) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
page = page + 1;
|
|
370
|
+
} while (page <= total_pages);
|
|
371
|
+
const finalItems = returnAll ? rawItems : rawItems.slice(0, limit);
|
|
372
|
+
const executionData = finalItems.map((item) => ({
|
|
373
|
+
json: item,
|
|
374
|
+
pairedItem: {
|
|
375
|
+
item: index,
|
|
376
|
+
},
|
|
377
|
+
}));
|
|
378
|
+
return [executionData];
|
|
379
|
+
}
|
|
380
|
+
async function handleGetOne(index, url, method = 'GET') {
|
|
381
|
+
try {
|
|
382
|
+
const qs = makeQs.call(this, index);
|
|
383
|
+
return [[{
|
|
384
|
+
json: await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
385
|
+
method: method,
|
|
386
|
+
url: url,
|
|
387
|
+
json: true,
|
|
388
|
+
qs: qs,
|
|
389
|
+
}),
|
|
390
|
+
pairedItem: {
|
|
391
|
+
item: index,
|
|
392
|
+
},
|
|
393
|
+
}]];
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
errorHelper.call(this, error);
|
|
397
|
+
return [[{ json: {}, pairedItem: { item: index } }]];
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
;
|
|
401
|
+
async function handlePost(index, url, body, method = 'POST') {
|
|
402
|
+
try {
|
|
403
|
+
return [[{
|
|
404
|
+
json: await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
405
|
+
method: method,
|
|
406
|
+
url: url,
|
|
407
|
+
json: true,
|
|
408
|
+
body: body
|
|
409
|
+
}),
|
|
410
|
+
pairedItem: {
|
|
411
|
+
item: index,
|
|
412
|
+
},
|
|
413
|
+
}]];
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
errorHelper.call(this, error);
|
|
417
|
+
return [[{ json: {}, pairedItem: { item: index } }]];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
;
|
|
421
|
+
function isEmpty(value) {
|
|
422
|
+
if (Array.isArray(value))
|
|
423
|
+
return value.length === 0;
|
|
424
|
+
if (value && typeof value === 'object')
|
|
425
|
+
return Object.keys(value).length === 0;
|
|
426
|
+
if (value == null || value == undefined || String(value).trim() == '')
|
|
427
|
+
return true;
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
async function handleCreateUpdate(index, url, method = 'POST') {
|
|
431
|
+
var _a;
|
|
432
|
+
try {
|
|
433
|
+
const body = {};
|
|
434
|
+
const parameters = this.getNode().parameters;
|
|
435
|
+
for (const paramName in parameters) {
|
|
436
|
+
if (paramName === 'resource' || paramName === 'operation') {
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (Object.prototype.hasOwnProperty.call(parameters, paramName)) {
|
|
440
|
+
const value = this.getNodeParameter(paramName, index);
|
|
441
|
+
if (!isEmpty(value)) {
|
|
442
|
+
const valueObj = value;
|
|
443
|
+
if (paramName === "customFields" && (valueObj === null || valueObj === void 0 ? void 0 : valueObj.value)) {
|
|
444
|
+
const resource = this.getNodeParameter('resource', index);
|
|
445
|
+
const fieldsInfo = await getCustomFieldsInfo.call(this, resource);
|
|
446
|
+
const transformedCustomFields = transformCustomFieldsValues(valueObj.value, fieldsInfo);
|
|
447
|
+
body.custom_fields = transformedCustomFields;
|
|
448
|
+
}
|
|
449
|
+
else if (paramName === "scheduled_for" || paramName === "scheduled_to" || paramName === "due_date") {
|
|
450
|
+
body[paramName] = `${luxon_1.DateTime.fromISO(String(value)).toUTC().toFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")}`;
|
|
451
|
+
}
|
|
452
|
+
else if (paramName === "issue_date_invoice" || paramName === "due_date_invoice") {
|
|
453
|
+
body[paramName.slice(0, -8)] = `${luxon_1.DateTime.fromISO(String(value)).toUTC().toFormat("yyyy-MM-dd")}`;
|
|
454
|
+
}
|
|
455
|
+
else if (paramName === "items" && (valueObj === null || valueObj === void 0 ? void 0 : valueObj.item)) {
|
|
456
|
+
body.items = transformInvoiceItems(valueObj.item);
|
|
457
|
+
}
|
|
458
|
+
else if (paramName === "items_custom" && (valueObj === null || valueObj === void 0 ? void 0 : valueObj.customItem)) {
|
|
459
|
+
body.items_custom = transformInvoiceCustomItems(valueObj.customItem);
|
|
460
|
+
}
|
|
461
|
+
else if (paramName === "phonesUi" && (valueObj === null || valueObj === void 0 ? void 0 : valueObj.phones)) {
|
|
462
|
+
const phonesUi = Object.assign(valueObj);
|
|
463
|
+
if ((phonesUi === null || phonesUi === void 0 ? void 0 : phonesUi.phones) && ((_a = phonesUi === null || phonesUi === void 0 ? void 0 : phonesUi.phones) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
464
|
+
body.phones = phonesUi.phones.map((item) => {
|
|
465
|
+
const phone = item.phone;
|
|
466
|
+
if (phoneValidation(phone)) {
|
|
467
|
+
return {
|
|
468
|
+
title: item.title,
|
|
469
|
+
phone: item.phone,
|
|
470
|
+
notify: item.notify,
|
|
471
|
+
has_viber: item.has_viber,
|
|
472
|
+
has_whatsapp: item.has_whatsapp,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The phone number "${item.phone}" is not valid. Please use international format (e.g., +12021234567).`, { itemIndex: index });
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
body[paramName] = this.getNodeParameter(paramName, index);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'roappApi', {
|
|
488
|
+
method: method,
|
|
489
|
+
url: url,
|
|
490
|
+
json: true,
|
|
491
|
+
body: body
|
|
492
|
+
});
|
|
493
|
+
return [[{
|
|
494
|
+
json: responseData,
|
|
495
|
+
pairedItem: {
|
|
496
|
+
item: index,
|
|
497
|
+
}
|
|
498
|
+
}]];
|
|
499
|
+
}
|
|
500
|
+
catch (error) {
|
|
501
|
+
errorHelper.call(this, error);
|
|
502
|
+
return [[{ json: {}, pairedItem: { item: index } }]];
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function transformInvoiceItems(items) {
|
|
506
|
+
if (!items || !Array.isArray(items))
|
|
507
|
+
return [];
|
|
508
|
+
return items.map((item) => {
|
|
509
|
+
const result = {
|
|
510
|
+
entity_id: item.entity_id,
|
|
511
|
+
quantity: item.quantity,
|
|
512
|
+
price: item.price,
|
|
513
|
+
};
|
|
514
|
+
if (item.comment)
|
|
515
|
+
result.comment = item.comment;
|
|
516
|
+
if (item.comment_visibility)
|
|
517
|
+
result.comment_visibility = item.comment_visibility;
|
|
518
|
+
const tax = item === null || item === void 0 ? void 0 : item.tax_ids;
|
|
519
|
+
if (tax === null || tax === void 0 ? void 0 : tax.length)
|
|
520
|
+
result.tax_ids = tax.filter((v) => v !== '').map((v) => Number(v));
|
|
521
|
+
if (item.discount_type || item.discount_percentage || item.discount_amount || item.discount_sponsor) {
|
|
522
|
+
result.discount = {
|
|
523
|
+
type: item.discount_type,
|
|
524
|
+
percentage: Number(item.discount_percentage) || 0,
|
|
525
|
+
amount: Number(item.discount_amount) || 0,
|
|
526
|
+
sponsor: item.discount_sponsor,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
if (item.warranty_period || item.warranty_unit) {
|
|
530
|
+
result.warranty = {
|
|
531
|
+
period: Number(item.warranty_period) || 0,
|
|
532
|
+
unit: item.warranty_unit,
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
return result;
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
function transformInvoiceCustomItems(items) {
|
|
539
|
+
if (!items || !Array.isArray(items))
|
|
540
|
+
return [];
|
|
541
|
+
return items.map((item) => {
|
|
542
|
+
const result = {
|
|
543
|
+
entity: {
|
|
544
|
+
type: item.entity_type,
|
|
545
|
+
title: item.entity_title,
|
|
546
|
+
uom_id: Number(item.entity_uom_id),
|
|
547
|
+
description: item.entity_description || ''
|
|
548
|
+
},
|
|
549
|
+
quantity: item.quantity,
|
|
550
|
+
price: item.price,
|
|
551
|
+
};
|
|
552
|
+
if (item.comment)
|
|
553
|
+
result.comment = item.comment;
|
|
554
|
+
if (item.comment_visibility)
|
|
555
|
+
result.comment_visibility = item.comment_visibility;
|
|
556
|
+
const tax = item === null || item === void 0 ? void 0 : item.tax_ids;
|
|
557
|
+
if (tax === null || tax === void 0 ? void 0 : tax.length)
|
|
558
|
+
result.tax_ids = tax.filter((v) => v !== '').map((v) => Number(v));
|
|
559
|
+
if (item.discount_type || item.discount_percentage || item.discount_amount || item.discount_sponsor) {
|
|
560
|
+
result.discount = {
|
|
561
|
+
type: item.discount_type,
|
|
562
|
+
percentage: Number(item.discount_percentage) || 0,
|
|
563
|
+
amount: Number(item.discount_amount) || 0,
|
|
564
|
+
sponsor: item.discount_sponsor,
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
if (item.warranty_period || item.warranty_unit) {
|
|
568
|
+
result.warranty = {
|
|
569
|
+
period: Number(item.warranty_period) || 0,
|
|
570
|
+
unit: item.warranty_unit,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
return result;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
//# sourceMappingURL=methods.js.map
|