magaya-cai-number-honduras 1.0.0

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.
Files changed (55) hide show
  1. package/.github/workflows/release.yaml +37 -0
  2. package/.vscode/launch.json +18 -0
  3. package/.whitesource +30 -0
  4. package/LICENSE +21 -0
  5. package/README.md +1 -0
  6. package/combined.log +0 -0
  7. package/error.log +0 -0
  8. package/extension.config.json +58 -0
  9. package/index.js +220 -0
  10. package/package.json +56 -0
  11. package/src/integration/helpers/dbHelper.js +12 -0
  12. package/src/integration/helpers/initilize.js +111 -0
  13. package/src/integration/index.js +1053 -0
  14. package/src/integration/jobs/creditmemo.js +155 -0
  15. package/src/integration/jobs/debitnote.js +155 -0
  16. package/src/integration/jobs/invoices.js +176 -0
  17. package/src/integration/jobs/transactionlog.js +65 -0
  18. package/src/util/db/db.js +62 -0
  19. package/src/util/email/email.js +75 -0
  20. package/src/util/email/index.js +124 -0
  21. package/src/util/email/logo/logo.jpg +0 -0
  22. package/src/util/email/settingsEmail.js +33 -0
  23. package/src/util/files/uploadHelper.js +11 -0
  24. package/src/util/gateway.js +23 -0
  25. package/src/util/setting.js +25 -0
  26. package/static/assets/img/honduras-flag-icon.svg +214 -0
  27. package/static/fa-brands-400.eot +0 -0
  28. package/static/fa-brands-400.svg +1100 -0
  29. package/static/fa-brands-400.ttf +0 -0
  30. package/static/fa-brands-400.woff +0 -0
  31. package/static/fa-brands-400.woff2 +0 -0
  32. package/static/fa-regular-400.eot +0 -0
  33. package/static/fa-regular-400.svg +368 -0
  34. package/static/fa-regular-400.ttf +0 -0
  35. package/static/fa-regular-400.woff +0 -0
  36. package/static/fa-regular-400.woff2 +0 -0
  37. package/static/fa-solid-900.eot +0 -0
  38. package/static/fa-solid-900.svg +1892 -0
  39. package/static/fa-solid-900.ttf +0 -0
  40. package/static/fa-solid-900.woff +0 -0
  41. package/static/fa-solid-900.woff2 +0 -0
  42. package/static/favicon.ico +0 -0
  43. package/static/index.html +21 -0
  44. package/static/main.js +2436 -0
  45. package/static/main.js.map +1 -0
  46. package/static/polyfills.js +5793 -0
  47. package/static/polyfills.js.map +1 -0
  48. package/static/runtime.js +154 -0
  49. package/static/runtime.js.map +1 -0
  50. package/static/scripts.js +18 -0
  51. package/static/scripts.js.map +1 -0
  52. package/static/styles.js +776 -0
  53. package/static/styles.js.map +1 -0
  54. package/static/vendor.js +98718 -0
  55. package/static/vendor.js.map +1 -0
@@ -0,0 +1,37 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - beta # Change this to your default branch if it's not 'main'
7
+ - main #
8
+ permissions: write-all
9
+ jobs:
10
+ release:
11
+ name: Semantic Release
12
+ runs-on: windows-latest
13
+ steps:
14
+ - name: Checkout Repository
15
+ uses: actions/checkout@v3
16
+ with:
17
+ fetch-depth: 0 # It's important to fetch all history for Semantic Release to work
18
+
19
+ - name: Setup Node.js
20
+ uses: actions/setup-node@v3
21
+ with:
22
+ node-version: '16' # Use the Node.js version compatible with your project
23
+
24
+ - name: Authenticate with private NPM package
25
+ run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
26
+
27
+ - name: Install Dependencies
28
+ run: npm install
29
+
30
+ - name: Release
31
+ env:
32
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34
+ run: |
35
+ git config user.name "github-actions"
36
+ git config user.email "github-actions@github.com"
37
+ npx semantic-release
@@ -0,0 +1,18 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "node",
9
+ "request": "launch",
10
+ "name": "Launch Program",
11
+ "outputCapture":"std",
12
+ "program": "${workspaceFolder}\\index.js",
13
+ "args": [
14
+ "-p", "8000", "-r", "/server","-i","26746", "--connection-string=WATERFALL:6110", "--gateway"
15
+ ]
16
+ }
17
+ ]
18
+ }
package/.whitesource ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "scanSettings": {
3
+ "configMode": "AUTO",
4
+ "configExternalURL": "",
5
+ "projectToken": "7e0f3f9a0b2e461c8de2331984124e26206572068e4d49f2a86765f803b22c17",
6
+ "baseBranches": []
7
+ },
8
+ "checkRunSettings": {
9
+ "vulnerableCheckRunConclusionLevel": "failure",
10
+ "displayMode": "diff",
11
+ "useMendCheckNames": true
12
+ },
13
+ "issueSettings": {
14
+ "minSeverityLevel": "LOW",
15
+ "issueType": "DEPENDENCY"
16
+ },
17
+ "remediateSettings": {
18
+ "workflowRules": {
19
+ "enabled": true
20
+ }
21
+ },
22
+ "imageSettings":{
23
+ "imageTracing":{
24
+ "enableImageTracingPR": false,
25
+ "addRepositoryCoordinate": false,
26
+ "addDockerfilePath": false,
27
+ "addMendIdentifier": false
28
+ }
29
+ }
30
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Magaya Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Services
package/combined.log ADDED
File without changes
package/error.log ADDED
File without changes
@@ -0,0 +1,58 @@
1
+ {
2
+ "id": {
3
+ "company": "magaya",
4
+ "name": "cai-number-honduras"
5
+ },
6
+ "name": "Números CAI Honduras",
7
+ "version": "latest",
8
+ "description": "Asigne números CAI a sus facturas, notas de débito y de crédito convenientemente desde el Explorador de Magaya.",
9
+ "tags": [
10
+ "magaya",
11
+ "honduras",
12
+ "facturación",
13
+ "contabilidad"
14
+ ],
15
+ "minimumMagayaVersion": "11.6.3",
16
+ "type": "httpServer",
17
+ "license": "MIT",
18
+ "install": {
19
+ "engine": "node",
20
+ "manager": "npm",
21
+ "name": "@magaya/cai-number-honduras"
22
+ },
23
+ "launch": {
24
+ "engine": "pm2",
25
+ "cluster": true,
26
+ "main": "./node_modules/@magaya/magaya-cai-number-honduras/index.js"
27
+ },
28
+ "interface": {
29
+ "title": "Numeros CAI",
30
+ "sections": {
31
+ "config": {
32
+ "menuEntries": [
33
+ {
34
+ "category": "Config",
35
+ "title": "Configuracion",
36
+ "selection": "none",
37
+ "type": "url",
38
+ "method": "GET",
39
+ "path": "/#/inv-setting",
40
+ "pathType": "cs-relative",
41
+ "launch" : "internal"
42
+ }
43
+ ]
44
+ }
45
+ }
46
+ }
47
+ ,
48
+ "documentation": [
49
+ {
50
+ "title": "Manual de Numeros CAI para Honduras",
51
+ "url": "https://www.magaya.com/ext/honduras/ManualNumerosCAIHonduras.pdf"
52
+ },
53
+ {
54
+ "title": "Reglamento del Regimen de Facturacion, Honduras.",
55
+ "url": "https://www.rsm.global/honduras/sites/default/files/media/acuerdo-481-2017-facturacion.pdf"
56
+ }
57
+ ]
58
+ }
package/index.js ADDED
@@ -0,0 +1,220 @@
1
+ const moment = require('moment');
2
+
3
+ const fsHelper = require('@magaya/extension-fs-helper');
4
+ const { program } = require('commander');
5
+ const packageJson = require('./package.json');
6
+ program
7
+ .version(packageJson.version)
8
+ .option("-p, --port <n>", "running port", parseInt)
9
+ .option("-r, --root <value>", "startup root for api")
10
+ .option("-s, --service-name <value>", "name for service")
11
+ .option("-g, --gateway", "dictates if we should be through gateway")
12
+ .option("-i, --network-id <n>", "magaya network id", parseInt)
13
+ .option("--connection-string <value>", "connection endpoint for database")
14
+ .option("--no-daemon", "pm2 no daemon option")
15
+ .allowExcessArguments()
16
+ .parse(process.argv);
17
+
18
+ const options = program.opts();
19
+ const port = options.port || process.env.PORT;
20
+ const root = options.root || process.env.ROOT;
21
+
22
+ const express = require('express');
23
+ const app = express();
24
+ const { Server } = require('socket.io'); // ✅ modern import
25
+ var e = require('events')
26
+ var events = new e.EventEmitter();
27
+
28
+ app.set('event', events);
29
+
30
+ // requiere path
31
+ const path = require('path');
32
+ // helper package to get the body of requests
33
+ const bodyParser = require("body-parser");
34
+
35
+
36
+
37
+ const dbhelper = require('./src/integration/helpers/dbHelper');
38
+ const cm = dbhelper.common;
39
+ const hyperion = cm.getHyperionObject();
40
+ if (!port) {
41
+ console.log('Must submit port on which to listen...');
42
+ process.exit(1);
43
+ } else if (!root) {
44
+ console.log('Must submit root...');
45
+ process.exit(1);
46
+ }
47
+ process.networkId = options.networkId;
48
+
49
+ //Requiring modules
50
+ var email = require('./src/util/email');
51
+ var integration = require('./src/integration/index');
52
+
53
+ if (!options.port) {
54
+ console.log('Must submit port on which to listen...');
55
+ process.exit(1);
56
+ } else if (!options.root) {
57
+ console.log('Must submit root...');
58
+ process.exit(1);
59
+ }
60
+
61
+
62
+ const configFolder = fsHelper.GetExtensionDataFolder({
63
+ "company": "magaya",
64
+ "name": "cai"
65
+ }, options.networkId);
66
+
67
+ // let db = new sqlite3.Database(path.join(configFolder, 'setting.db'), (err) => {
68
+ // if (err) {
69
+ // console.log(moment(d).format(), `=> Error loading database... \n${err}\n`);
70
+ // } else {
71
+ // initializeDB();
72
+ // }
73
+ // });
74
+
75
+ var sqliteDB = require('./src/util/db/db');
76
+ sqliteDB.createConnection().then((db, err) => {
77
+ if(err)
78
+ console.log(err);
79
+
80
+ if(db){
81
+ initializeDB(db);
82
+ }
83
+ });
84
+
85
+ const initializeDB = (db) => {
86
+ console.log("Initializing database");
87
+ db.exec(`BEGIN TRANSACTION;
88
+ CREATE TABLE IF NOT EXISTS "cdm_settings" (
89
+ "cai" TEXT,
90
+ "packageNumberStart" TEXT,
91
+ "packageNumberEnd" TEXT,
92
+ "packageEmailNotificationActive" INTEGER,
93
+ "packageEmailNotificationNumber" INTEGER,
94
+ "packageExpirationDate" TEXT,
95
+ "factorExcecutionTime" TEXT,
96
+ "valueExcecutionTime" INTEGER,
97
+ "current" INTEGER,
98
+ "startNumber" INTEGER,
99
+ "endNumber" INTEGER,
100
+ "firstPartDocumentNumber" TEXT,
101
+ "emailNotified" INTEGER,
102
+ "emailNotifiedDate" TEXT,
103
+ "range" TEXT,
104
+ "currentAssigned" INTEGER,
105
+ "active" INTEGER,
106
+ "deleted" INTEGER,
107
+ PRIMARY KEY("cai")
108
+ );
109
+ CREATE TABLE IF NOT EXISTS "dbn_settings" (
110
+ "cai" TEXT,
111
+ "packageNumberStart" TEXT,
112
+ "packageNumberEnd" TEXT,
113
+ "packageEmailNotificationActive" INTEGER,
114
+ "packageEmailNotificationNumber" INTEGER,
115
+ "packageExpirationDate" TEXT,
116
+ "factorExcecutionTime" TEXT,
117
+ "valueExcecutionTime" INTEGER,
118
+ "current" INTEGER,
119
+ "startNumber" INTEGER,
120
+ "endNumber" INTEGER,
121
+ "firstPartDocumentNumber" TEXT,
122
+ "emailNotified" INTEGER,
123
+ "emailNotifiedDate" TEXT,
124
+ "range" TEXT,
125
+ "currentAssigned" INTEGER,
126
+ "active" INTEGER,
127
+ "deleted" INTEGER,
128
+ PRIMARY KEY("cai")
129
+ );
130
+ CREATE TABLE IF NOT EXISTS "invoice_settings" (
131
+ "cai" TEXT,
132
+ "packageNumberStart" TEXT,
133
+ "packageNumberEnd" TEXT,
134
+ "packageEmailNotificationActive" INTEGER,
135
+ "packageEmailNotificationNumber" INTEGER,
136
+ "packageExpirationDate" TEXT,
137
+ "factorExcecutionTime" TEXT,
138
+ "valueExcecutionTime" INTEGER,
139
+ "current" INTEGER,
140
+ "startNumber" INTEGER,
141
+ "endNumber" INTEGER,
142
+ "firstPartDocumentNumber" TEXT,
143
+ "emailNotified" INTEGER,
144
+ "emailNotifiedDate" TEXT,
145
+ "range" TEXT,
146
+ "currentAssigned" INTEGER,
147
+ "active" INTEGER,
148
+ "deleted" INTEGER,
149
+ PRIMARY KEY("cai")
150
+ );
151
+ CREATE TABLE IF NOT EXISTS "email_settings" (
152
+ "server" TEXT,
153
+ "username" TEXT,
154
+ "password" TEXT,
155
+ "port" INTEGER,
156
+ "customerEmails" TEXT,
157
+ "magayaContacts" TEXT,
158
+ "feedbackToMagaya" INTEGER,
159
+ "sendEmailsToCustomers" INTEGER,
160
+ "tslSSL" INTEGER,
161
+ "credentials" INTEGER,
162
+ "active" INTEGER,
163
+ "deleted" INTEGER,
164
+ PRIMARY KEY("server","username","port")
165
+ );
166
+ COMMIT;`);
167
+ }
168
+
169
+
170
+
171
+ app.use(bodyParser.json());
172
+ app.use(bodyParser.urlencoded({ extended: false }));
173
+ const gateway = `${root}/gateway`;
174
+ // define the static files to the extensions using angular and
175
+ // routes for operations
176
+ app.use(`${root}`, express.static(path.join(__dirname, './static')));
177
+ app.use(`${root}/api/email`, email);
178
+ app.use(`${root}/integration`, integration);
179
+
180
+ // to get the URL for socket connection
181
+ app.get(`${root}/getURL`, function (req, res) {
182
+ res.send({ url: `http://localhost:${options.port}${options.root}` });
183
+ });
184
+ // define a route that can be consumed from a web browser
185
+ app.get(`${root}/test`, async function (request, response) {
186
+ const dbx = request.dbx; // hyperion namespaces
187
+ const algorithm = request.algorithm; // hyperion algorithms
188
+ const api = request.api; // api functions (requested with the second argument at require time)
189
+
190
+ response.send({ message: 'Success!!', env: options.env });
191
+ });
192
+
193
+ app.get(`${gateway}/ping`, function (req, res) {
194
+ res.send('Pong | '+packageJson.name+' App version is ' + packageJson.version);
195
+ });
196
+
197
+ // start your application in the port specified
198
+ let server = app.listen(port, async () => {
199
+ if (options.gateway) {
200
+ await require('./src/util/gateway')(options, gateway);
201
+ }
202
+ let d = new Date();
203
+ console.log(moment(d).format(), `=> Server started on port ${options.port}...`);
204
+ });
205
+
206
+ // Require Http
207
+ // let server = require('http').Server(app);
208
+ //Socket IO
209
+ const io = new Server(server, { cors: { origin: "*" } });
210
+
211
+ io.on('connection', (socket) => {
212
+ console.log('🟢 Socket connected:', socket.id);
213
+
214
+ socket.on('join', (data) => console.log('Client joined:', data));
215
+
216
+ // Forward events
217
+ ['InvCurrent', 'DBNCurrent', 'CDMCurrent'].forEach(event =>
218
+ events.on(event, (payload) => socket.emit(event, payload))
219
+ );
220
+ });
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "magaya-cai-number-honduras",
3
+ "version": "1.0.0",
4
+ "description": "Extension to create the CAI numbers into Invoices, Debit Notes and Credit Memos for Honduras.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "postinstall": "npm link @magaya/hyperion-node"
8
+ },
9
+ "author": "Magaya Corporation",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "@magaya/db-helper": "1.0.0-beta.34",
13
+ "@magaya/extension-fs-helper": "0.0.5",
14
+ "@magaya/socket-tunnel-node": "^1.0.0",
15
+ "bluebird": "3.5.5",
16
+ "body-parser": "1.20.3",
17
+ "commander": "^12.1.0",
18
+ "express": "4.21.1",
19
+ "minipass": "2.7.0",
20
+ "moment": "2.29.4",
21
+ "nodemailer": "6.6.1",
22
+ "socket.io": "4.8.0",
23
+ "sqlite": "5.1.1",
24
+ "sqlite3": "5.1.7"
25
+ },
26
+ "devDependencies": {
27
+ "@semantic-release/git": "^9.0.0",
28
+ "semantic-release": "^17.0.7"
29
+ },
30
+ "release": {
31
+ "plugins": [
32
+ "@semantic-release/commit-analyzer",
33
+ "@semantic-release/github",
34
+ "@semantic-release/npm",
35
+ "@semantic-release/release-notes-generator",
36
+ [
37
+ "@semantic-release/git",
38
+ {
39
+ "assets": [
40
+ "package.json",
41
+ "npm-shrinkwrap.json"
42
+ ],
43
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
44
+ }
45
+ ]
46
+ ],
47
+ "branches": [
48
+ "main",
49
+ {
50
+ "name": "beta",
51
+ "prerelease": true,
52
+ "channel": "beta"
53
+ }
54
+ ]
55
+ }
56
+ }
@@ -0,0 +1,12 @@
1
+ const extConfigJson = require('../../../extension.config.json');
2
+
3
+ const extension = {
4
+ company: extConfigJson.id.company,
5
+ name: extConfigJson.id.name,
6
+ };
7
+ const extensionId = `${extension.company}-${extension.name}`;
8
+
9
+ const hyperion = require('@magaya/hyperion-node')(process.argv, { clientId: extensionId });
10
+ const dbhelper = require("@magaya/db-helper")(hyperion);
11
+
12
+ module.exports = dbhelper;
@@ -0,0 +1,111 @@
1
+ const dbhelper = require('./dbHelper');
2
+ const cm = dbhelper.common;
3
+ const ac = dbhelper.accounting;
4
+ const { dbx, algorithm, dbw } = cm.getHyperionObject();
5
+ module.exports.initialize = async function (request) {
6
+ const cai_internal_name = 'numero_cai';
7
+ const objectType = dbx.Common.DbClassType.Invoice;
8
+ let caiDefinitionList = dbx.CustomField.Definition.Lists.at(objectType);
9
+
10
+ const caiCustomFieldExist = caiDefinitionList && await algorithm.find(dbx.using(caiDefinitionList)).where(obj => obj.InternalName === cai_internal_name);
11
+
12
+ if (!caiCustomFieldExist) {
13
+ let caiCustomFieldDefinition = new dbx.DbClass.CustomFieldDefinition();
14
+ caiCustomFieldDefinition.Type = dbx.CustomField.Definition.DataType.String;
15
+ caiCustomFieldDefinition.ObjectType = objectType;
16
+ caiCustomFieldDefinition.InternalName = cai_internal_name;
17
+ caiCustomFieldDefinition.DisplayName = 'CAI';
18
+ caiCustomFieldDefinition.IsReadOnly = true;
19
+ caiCustomFieldDefinition.IsInternal = false;
20
+ caiCustomFieldDefinition.IsSystemDateTime = false;
21
+ caiCustomFieldDefinition.DefaultValue = "";
22
+ caiCustomFieldDefinition.Category = "Régimen de factura";
23
+ caiCustomFieldDefinition.Description = "Campo donde se guarda el CAI del documento";
24
+
25
+ await dbx.save(caiCustomFieldDefinition);
26
+ }
27
+ const type_internal_name = 'tipo_documento';
28
+ let typeDefinitionList = dbx.CustomField.Definition.Lists.at(objectType);
29
+
30
+ const typeCustomFieldExist = typeDefinitionList && await algorithm.find(dbx.using(typeDefinitionList)).where(obj => obj.InternalName === type_internal_name);
31
+ if (!typeCustomFieldExist) {
32
+ let typeCustomFieldDefinition = new dbx.DbClass.CustomFieldDefinition();
33
+ typeCustomFieldDefinition.Type = dbx.CustomField.Definition.DataType.PickList;
34
+ typeCustomFieldDefinition.ObjectType = objectType;
35
+ typeCustomFieldDefinition.InternalName = type_internal_name;
36
+ typeCustomFieldDefinition.DisplayName = 'Tipo Documento';
37
+ typeCustomFieldDefinition.IsInternal = false;
38
+ typeCustomFieldDefinition.IsSystemDateTime = false;
39
+ typeCustomFieldDefinition.PickItems = ['Ninguno', 'Factura de Cobro', 'Nota de Débito', 'Nota de Crédito'];
40
+ typeCustomFieldDefinition.DefaultValue = 'Ninguno';
41
+ typeCustomFieldDefinition.Category = "Régimen de factura";
42
+ typeCustomFieldDefinition.Description = "Campo para la identificación del Tipo de documento";
43
+
44
+ await dbx.save(typeCustomFieldDefinition);
45
+ }
46
+
47
+ const range_internal_name = 'rango';
48
+ let rangeDefinitionList = dbx.CustomField.Definition.Lists.at(objectType);
49
+ const rangeCustomFieldExist = rangeDefinitionList && await algorithm.find(dbx.using(rangeDefinitionList)).where(obj => obj.InternalName === range_internal_name);
50
+
51
+ if (!rangeCustomFieldExist) {
52
+ let rangeCustomFieldDefinition = new dbx.DbClass.CustomFieldDefinition();
53
+ rangeCustomFieldDefinition.Type = dbx.CustomField.Definition.DataType.String;
54
+ rangeCustomFieldDefinition.ObjectType = objectType;
55
+ rangeCustomFieldDefinition.InternalName = range_internal_name;
56
+ rangeCustomFieldDefinition.DisplayName = 'Rango';
57
+ rangeCustomFieldDefinition.IsReadOnly = true;
58
+ rangeCustomFieldDefinition.IsInternal = false;
59
+ rangeCustomFieldDefinition.IsSystemDateTime = false;
60
+ rangeCustomFieldDefinition.DefaultValue = "";
61
+ rangeCustomFieldDefinition.Category = "Régimen de factura";
62
+ rangeCustomFieldDefinition.Description = "Campo donde se guarda el rango permitido de los números de documentos";
63
+
64
+ await dbx.save(rangeCustomFieldDefinition);
65
+ }
66
+
67
+ const number_internal_name = 'numero_documento';
68
+ let numberDefinitionList = dbx.CustomField.Definition.Lists.at(objectType);
69
+
70
+ const numberCustomFieldExist = numberDefinitionList && await algorithm.find(dbx.using(numberDefinitionList)).where(obj => obj.InternalName === number_internal_name);
71
+
72
+ if (!numberCustomFieldExist) {
73
+ let numberCustomFieldDefinition = new dbx.DbClass.CustomFieldDefinition();
74
+ numberCustomFieldDefinition.Type = dbx.CustomField.Definition.DataType.String;
75
+ numberCustomFieldDefinition.ObjectType = objectType;
76
+ numberCustomFieldDefinition.InternalName = number_internal_name;
77
+ numberCustomFieldDefinition.DisplayName = 'Número de documento';
78
+ numberCustomFieldDefinition.IsReadOnly = true;
79
+ numberCustomFieldDefinition.IsInternal = false;
80
+ numberCustomFieldDefinition.IsSystemDateTime = false;
81
+ numberCustomFieldDefinition.DefaultValue = "";
82
+ numberCustomFieldDefinition.Category = "Régimen de factura";
83
+ numberCustomFieldDefinition.Description = "Campo donde se guarda el número de documento asignado del rango disponible";
84
+
85
+ await dbx.save(numberCustomFieldDefinition);
86
+ }
87
+
88
+
89
+ const date_internal_name = 'fecha_limite';
90
+ let dateDefinitionList = dbx.CustomField.Definition.Lists.at(objectType);
91
+
92
+ const dateCustomFieldExist = dateDefinitionList && await algorithm.find(dbx.using(dateDefinitionList)).where(obj => obj.InternalName === date_internal_name);
93
+
94
+ if (!dateCustomFieldExist) {
95
+ let dateCustomFieldDefinition = new dbx.DbClass.CustomFieldDefinition();
96
+ dateCustomFieldDefinition.Type = dbx.CustomField.Definition.DataType.String;
97
+ dateCustomFieldDefinition.ObjectType = objectType;
98
+ dateCustomFieldDefinition.InternalName = date_internal_name;
99
+ dateCustomFieldDefinition.DisplayName = 'Fecha límite de emisión';
100
+ dateCustomFieldDefinition.IsReadOnly = true;
101
+ dateCustomFieldDefinition.IsInternal = false;
102
+ dateCustomFieldDefinition.IsSystemDateTime = false;
103
+ dateCustomFieldDefinition.DefaultValue = "";
104
+ dateCustomFieldDefinition.Category = "Régimen de factura";
105
+ dateCustomFieldDefinition.Description = "Campo donde se guarda la fecha de emisión límite asociada al CAI del documento";
106
+
107
+ await dbx.save(dateCustomFieldDefinition);
108
+ }
109
+
110
+
111
+ }