Skip to content

Commit 3b3ea76

Browse files
authored
Merge pull request #95 from ralcorta/chore/get_iva_receptor_types
[Chore] new use cases and doc config
2 parents e57de7e + 31989a2 commit 3b3ea76

File tree

78 files changed

+14969
-6204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+14969
-6204
lines changed

docs/.vitepress/config.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export default withMermaid(
88
description: "Arca typescript SDK",
99
lang: "es",
1010
appearance: "dark",
11+
sitemap: {
12+
hostname: "https://afipts.com",
13+
},
1114
head: [["link", { rel: "icon", href: "/logo.ico" }]],
1215
themeConfig: {
1316
logo: "/logo.png",

jest.setup.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
jest.setTimeout(30000)
1+
jest.setTimeout(30000);
2+
3+
// Global error sanitization to prevent circular structure issues in Jest serialization
4+
const originalProcessEmit = process.emit;
5+
process.emit = function (event, error, ...args) {
6+
if (event === "unhandledRejection" && error && typeof error === "object") {
7+
// Sanitize the error to avoid circular structure issues
8+
const sanitizedError = new Error(error?.message || "Unknown error");
9+
sanitizedError.name = error?.name || "Error";
10+
if (error?.code) {
11+
sanitizedError.code = error.code;
12+
}
13+
if (error?.stack) {
14+
sanitizedError.stack = error.stack;
15+
}
16+
return originalProcessEmit.call(this, event, sanitizedError, ...args);
17+
}
18+
return originalProcessEmit.apply(this, arguments);
19+
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
"build": "nx run-many --target=build --all",
1111
"build:core": "nx build core",
1212
"test": "nx run-many --target=test --all --skip-nx-cache",
13+
"test:integration": "nx run-many --target=test:integration --all --skip-nx-cache",
14+
"lint": "nx run-many --target=lint --all",
1315
"test:core": "nx test core",
1416
"test:core:unit": "nx test:unit core",
1517
"test:core:integration": "nx test:integration core",
16-
"lint": "nx run-many --target=lint --all",
1718
"lint:core": "nx lint core",
1819
"publish:core": "nx publish core",
1920
"version:core": "nx version core --versionType=${VERSION:-patch}",
@@ -56,4 +57,4 @@
5657
"soap",
5758
"wsaa"
5859
]
59-
}
60+
}

packages/core/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
"main": "lib/index.js",
77
"types": "lib/index.d.ts",
88
"scripts": {
9-
"build": "npx tsc",
9+
"build": "npx tsc -p tsconfig.build.json",
1010
"test": "jest",
1111
"test:unit": "jest ./tests/unit",
1212
"test:integration": "jest ./tests/integration",
1313
"test:integration:watch": "jest ./tests/integration --watch",
1414
"test:integration:manual": "jest ./tests/integration/electronic-billing-manual-tokens.integration.test.ts",
15-
"test:integration:auto": "jest ./tests/integration/electronic-billing.integration.test.ts"
15+
"test:integration:auto": "jest ./tests/integration/electronic-billing.integration.test.ts",
16+
"generate:wsdl-strings": "node scripts/generate-wsdl-strings.js"
1617
},
1718
"dependencies": {
1819
"dotenv": "^16.3.1",
@@ -70,4 +71,4 @@
7071
"endpoint",
7172
"wsaa"
7273
]
73-
}
74+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const wsdlDir = path.join(
5+
__dirname,
6+
"../src/infrastructure/outbound/adapters/soap/wsdl"
7+
);
8+
const outputFile = path.join(
9+
__dirname,
10+
"../src/infrastructure/outbound/adapters/soap/wsdl-strings.ts"
11+
);
12+
13+
const header = `/**
14+
* WSDL files embedded as strings
15+
* This file is auto-generated to avoid file system access issues in bundled environments
16+
* Generated from files in src/infrastructure/outbound/adapters/soap/wsdl/
17+
*
18+
* DO NOT EDIT THIS FILE MANUALLY
19+
* Run: npm run generate:wsdl-strings
20+
*/
21+
22+
export const WSDL_STRINGS: Record<string, string> = {
23+
`;
24+
25+
const footer = `};
26+
27+
export function getWsdlString(wsdlName: string): string | undefined {
28+
return WSDL_STRINGS[wsdlName];
29+
}
30+
`;
31+
32+
function generate() {
33+
console.log("Generating wsdl-strings.ts...");
34+
35+
if (!fs.existsSync(wsdlDir)) {
36+
console.error(`WSDL directory not found: ${wsdlDir}`);
37+
process.exit(1);
38+
}
39+
40+
const files = fs
41+
.readdirSync(wsdlDir)
42+
.filter((file) => file.endsWith(".wsdl"));
43+
let content = header;
44+
45+
files.forEach((file, index) => {
46+
const filePath = path.join(wsdlDir, file);
47+
const fileContent = fs.readFileSync(filePath, "utf8");
48+
49+
// Escape backticks in the content if any (though unlikely in XML)
50+
const escapedContent = fileContent
51+
.replace(/\\/g, "\\\\")
52+
.replace(/`/g, "\\`")
53+
.replace(/\${/g, "\\${");
54+
55+
content += ` '${file}': \`${escapedContent}\``;
56+
57+
if (index < files.length - 1) {
58+
content += ",\n";
59+
} else {
60+
content += "\n";
61+
}
62+
});
63+
64+
content += footer;
65+
66+
fs.writeFileSync(outputFile, content);
67+
console.log(`Successfully generated ${outputFile}`);
68+
}
69+
70+
generate();

packages/core/scripts/generate-wsdl-strings.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/core/src/application/dto/electronic-billing.dto.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import {
1515
CurrencyType,
1616
OptionalType,
1717
TaxType,
18+
IvaReceptorType,
19+
CaeaResponse,
20+
CaeaNoMovement,
21+
PaisType,
22+
ActividadType,
23+
CotizacionType,
1824
ErrorInfo,
1925
} from "@domain/types/electronic-billing.types";
2026

@@ -136,3 +142,79 @@ export interface TaxTypesResultDto {
136142
err?: ErrorInfo[];
137143
};
138144
}
145+
146+
/**
147+
* IVA Receptor Types Result DTO
148+
*/
149+
export interface IvaReceptorTypesResultDto {
150+
resultGet?: {
151+
condicionIvaReceptor?: IvaReceptorType[];
152+
};
153+
errors?: {
154+
err?: ErrorInfo[];
155+
};
156+
}
157+
158+
/**
159+
* CAEA Result DTO
160+
*/
161+
export interface CaeaResultDto {
162+
resultGet?: CaeaResponse;
163+
errors?: {
164+
err?: ErrorInfo[];
165+
};
166+
}
167+
168+
/**
169+
* CAEA No Movement Result DTO
170+
*/
171+
export interface CaeaNoMovementResultDto {
172+
resultGet?: CaeaNoMovement[];
173+
errors?: {
174+
err?: ErrorInfo[];
175+
};
176+
}
177+
178+
/**
179+
* Countries Result DTO
180+
*/
181+
export interface CountriesResultDto {
182+
resultGet?: {
183+
paisTipo?: PaisType[];
184+
};
185+
errors?: {
186+
err?: ErrorInfo[];
187+
};
188+
}
189+
190+
/**
191+
* Activities Result DTO
192+
*/
193+
export interface ActivitiesResultDto {
194+
resultGet?: {
195+
actividadesTipo?: ActividadType[];
196+
};
197+
errors?: {
198+
err?: ErrorInfo[];
199+
};
200+
}
201+
202+
/**
203+
* Quotation Result DTO
204+
*/
205+
export interface QuotationResultDto {
206+
resultGet?: CotizacionType;
207+
errors?: {
208+
err?: ErrorInfo[];
209+
};
210+
}
211+
212+
/**
213+
* Max Records Result DTO
214+
*/
215+
export interface MaxRecordsResultDto {
216+
resultGet?: number;
217+
errors?: {
218+
err?: ErrorInfo[];
219+
};
220+
}

packages/core/src/application/ports/electronic-billing/electronic-billing-repository.port.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import {
1818
CurrencyTypesResultDto,
1919
OptionalTypesResultDto,
2020
TaxTypesResultDto,
21+
IvaReceptorTypesResultDto,
22+
CaeaResultDto,
23+
CaeaNoMovementResultDto,
24+
CountriesResultDto,
25+
ActivitiesResultDto,
26+
QuotationResultDto,
27+
MaxRecordsResultDto,
2128
} from "@application/dto/electronic-billing.dto";
2229

2330
export interface IElectronicBillingRepositoryPort {
@@ -105,4 +112,82 @@ export interface IElectronicBillingRepositoryPort {
105112
* @returns Tax types information
106113
*/
107114
getTaxTypes(): Promise<TaxTypesResultDto>;
115+
116+
/**
117+
* Get available IVA receptor types
118+
* @param claseCmp Voucher class (optional)
119+
* @returns IVA receptor types information
120+
*/
121+
getIvaReceptorTypes(claseCmp?: string): Promise<IvaReceptorTypesResultDto>;
122+
123+
/**
124+
* Request CAEA (Anticipated Electronic Authorization Code)
125+
* @param period Period (YYYYMM)
126+
* @param order Fortnight (1 or 2)
127+
* @returns CAEA information
128+
*/
129+
getCaea(period: number, order: number): Promise<CaeaResultDto>;
130+
131+
/**
132+
* Consult CAEA
133+
* @param period Period (YYYYMM)
134+
* @param order Fortnight (1 or 2)
135+
* @returns CAEA information
136+
*/
137+
consultCaea(period: number, order: number): Promise<CaeaResultDto>;
138+
139+
/**
140+
* Inform CAEA No Movement
141+
* @param caea CAEA number
142+
* @param salesPoint Sales point number
143+
* @returns CAEA No Movement information
144+
*/
145+
informCaeaNoMovement(
146+
caea: string,
147+
salesPoint: number
148+
): Promise<CaeaNoMovementResultDto>;
149+
150+
/**
151+
* Consult CAEA No Movement
152+
* @param caea CAEA number
153+
* @param salesPoint Sales point number
154+
* @returns CAEA No Movement information
155+
*/
156+
consultCaeaNoMovement(
157+
caea: string,
158+
salesPoint: number
159+
): Promise<CaeaNoMovementResultDto>;
160+
161+
/**
162+
* Inform CAEA Usage (Regimen Informativo)
163+
* @param caea CAEA number
164+
* @param salesPoint Sales point number
165+
* @returns CAEA Usage information
166+
*/
167+
informCaeaUsage(voucher: Voucher, caea: string): Promise<CaeaResultDto>;
168+
169+
/**
170+
* Get Quotation
171+
* @param currencyId Currency ID
172+
* @returns Quotation information
173+
*/
174+
getQuotation(currencyId: string): Promise<QuotationResultDto>;
175+
176+
/**
177+
* Get Countries
178+
* @returns Countries information
179+
*/
180+
getCountries(): Promise<CountriesResultDto>;
181+
182+
/**
183+
* Get Activities
184+
* @returns Activities information
185+
*/
186+
getActivities(): Promise<ActivitiesResultDto>;
187+
188+
/**
189+
* Get Max Records per Request
190+
* @returns Max records number
191+
*/
192+
getMaxRecordsPerRequest(): Promise<MaxRecordsResultDto>;
108193
}

0 commit comments

Comments
 (0)