pangea-server 3.3.7 → 3.3.9
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/dist/helpers/arca.helpers.d.ts +29 -0
- package/dist/helpers/arca.helpers.js +50 -0
- package/dist/helpers/file.helpers.d.ts +4 -2
- package/dist/helpers/file.helpers.js +6 -6
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/mailer.helpers.js +1 -4
- package/package.json +2 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type ArcaConfig = {
|
|
2
|
+
cuit: number;
|
|
3
|
+
cert: string;
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
6
|
+
type VoucherType = 1 | 6 | 11 | 2 | 7 | 12 | 3 | 8 | 13;
|
|
7
|
+
type Concept = 1 | 2 | 3;
|
|
8
|
+
type DocumentType = 80 | 86 | 96 | 99;
|
|
9
|
+
type VatConditionReceiver = 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 15 | 16;
|
|
10
|
+
type CreateVoucherOptions = {
|
|
11
|
+
pointOfSale: number;
|
|
12
|
+
voucherType: VoucherType;
|
|
13
|
+
concept: Concept;
|
|
14
|
+
documentType: DocumentType;
|
|
15
|
+
documentNumber: number;
|
|
16
|
+
taxableAmount: number;
|
|
17
|
+
exemptAmount: number;
|
|
18
|
+
vatAmount: number;
|
|
19
|
+
vatConditionReceiver: VatConditionReceiver;
|
|
20
|
+
serviceFrom?: number | null;
|
|
21
|
+
serviceTo?: number | null;
|
|
22
|
+
paymentDueDate?: number | null;
|
|
23
|
+
};
|
|
24
|
+
export declare class Arca {
|
|
25
|
+
private __afip;
|
|
26
|
+
constructor(config: ArcaConfig);
|
|
27
|
+
createVoucher(createVoucherOptions: CreateVoucherOptions): Promise<any>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Arca = void 0;
|
|
7
|
+
const afip_js_1 = __importDefault(require("@afipsdk/afip.js"));
|
|
8
|
+
// helpers
|
|
9
|
+
const helpers_1 = require("../helpers");
|
|
10
|
+
class Arca {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
const { cuit, cert, key } = config;
|
|
13
|
+
this.__afip = new afip_js_1.default({
|
|
14
|
+
access_token: (0, helpers_1.getEnvStr)('AFIP_ACCESS_TOKEN'),
|
|
15
|
+
...(cuit === 20409378472 ? { cuit } : { cuit, cert, key, production: true }),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async createVoucher(createVoucherOptions) {
|
|
19
|
+
const { pointOfSale, voucherType, concept, documentType, documentNumber, taxableAmount, exemptAmount, vatAmount, vatConditionReceiver, serviceFrom = null, serviceTo = null, paymentDueDate = null, } = createVoucherOptions;
|
|
20
|
+
const lastVoucher = await this.__afip.ElectronicBilling.getLastVoucher(pointOfSale, voucherType);
|
|
21
|
+
const voucherNumber = lastVoucher + 1;
|
|
22
|
+
const voucherDate = Number(new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString().split('T')[0].replace(/-/g, ''));
|
|
23
|
+
const data = {
|
|
24
|
+
CantReg: 1,
|
|
25
|
+
PtoVta: pointOfSale,
|
|
26
|
+
CbteTipo: voucherType,
|
|
27
|
+
Concepto: concept,
|
|
28
|
+
DocTipo: documentType,
|
|
29
|
+
DocNro: documentNumber,
|
|
30
|
+
CbteDesde: voucherNumber,
|
|
31
|
+
CbteHasta: voucherNumber,
|
|
32
|
+
CbteFch: voucherDate,
|
|
33
|
+
FchServDesde: serviceFrom,
|
|
34
|
+
FchServHasta: serviceTo,
|
|
35
|
+
FchVtoPago: paymentDueDate,
|
|
36
|
+
ImpTotal: taxableAmount + vatAmount + exemptAmount,
|
|
37
|
+
ImpTotConc: 0,
|
|
38
|
+
ImpNeto: taxableAmount,
|
|
39
|
+
ImpOpEx: exemptAmount,
|
|
40
|
+
ImpIVA: vatAmount,
|
|
41
|
+
ImpTrib: 0,
|
|
42
|
+
MonId: 'PES',
|
|
43
|
+
MonCotiz: 1,
|
|
44
|
+
CondicionIVAReceptorId: vatConditionReceiver,
|
|
45
|
+
Iva: vatAmount > 0 ? [{ Id: 5, BaseImp: taxableAmount, Importe: vatAmount }] : [],
|
|
46
|
+
};
|
|
47
|
+
return this.__afip.ElectronicBilling.createVoucher(data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Arca = Arca;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type PreviousFile = string | null | undefined;
|
|
2
|
+
export declare function uploadImage(image: UploadableImage, previousFile: PreviousFile, ...folders: string[]): Promise<string>;
|
|
2
3
|
export declare function uploadImages(images: UploadableImage[], ...folders: string[]): Promise<string[]>;
|
|
3
|
-
export declare function uploadVideo(file: MulterFile,
|
|
4
|
+
export declare function uploadVideo(file: MulterFile, previousFile: PreviousFile, ...folders: string[]): Promise<string>;
|
|
4
5
|
export declare function uploadVideos(files: MulterFile[], ...folders: string[]): Promise<string[]>;
|
|
5
6
|
export declare function deleteFile(fileName: string): Promise<void>;
|
|
6
7
|
export declare function deleteFiles(fileNames: string[]): Promise<void[]>;
|
|
8
|
+
export {};
|
|
@@ -21,11 +21,11 @@ const s3 = new aws_sdk_1.default.S3({
|
|
|
21
21
|
accessKeyId: (0, env_helpers_1.getEnvStr)('DIGITAL_OCEAN_SPACES_ACCESS_KEY'),
|
|
22
22
|
secretAccessKey: (0, env_helpers_1.getEnvStr)('DIGITAL_OCEAN_SPACES_SECRET_KEY'),
|
|
23
23
|
});
|
|
24
|
-
async function uploadImage(image,
|
|
24
|
+
async function uploadImage(image, previousFile, ...folders) {
|
|
25
25
|
if (!image)
|
|
26
26
|
error_helpers_1.AppError.Throw({ statusCodeName: 'BAD_REQUEST', errorCode: 'IMAGE_NOT_SENT' });
|
|
27
|
-
if (
|
|
28
|
-
await deleteFile(
|
|
27
|
+
if (previousFile)
|
|
28
|
+
await deleteFile(previousFile);
|
|
29
29
|
const imageBuffer = typeof image === 'string' ? await promises_1.default.readFile(path_1.default.join(process.cwd(), image)) : image.buffer;
|
|
30
30
|
const maxSizeKb = 200;
|
|
31
31
|
const maxSizeBytes = maxSizeKb * 1024;
|
|
@@ -43,11 +43,11 @@ function uploadImages(images, ...folders) {
|
|
|
43
43
|
return Promise.all(images.map((image) => uploadImage(image, undefined, ...folders)));
|
|
44
44
|
}
|
|
45
45
|
exports.uploadImages = uploadImages;
|
|
46
|
-
async function uploadVideo(file,
|
|
46
|
+
async function uploadVideo(file, previousFile, ...folders) {
|
|
47
47
|
if (!file)
|
|
48
48
|
error_helpers_1.AppError.Throw({ statusCodeName: 'BAD_REQUEST', errorCode: 'VIDEO_NOT_SENT' });
|
|
49
|
-
if (
|
|
50
|
-
await deleteFile(
|
|
49
|
+
if (previousFile)
|
|
50
|
+
await deleteFile(previousFile);
|
|
51
51
|
const stream = fs_1.default.createReadStream(file.path);
|
|
52
52
|
try {
|
|
53
53
|
return await uploadFile(stream, file.mimetype, ...folders);
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./arca.helpers"), exports);
|
|
17
18
|
__exportStar(require("./controllers.helpers"), exports);
|
|
18
19
|
__exportStar(require("./env.helpers"), exports);
|
|
19
20
|
__exportStar(require("./error.helpers"), exports);
|
|
@@ -17,10 +17,7 @@ class Mailer {
|
|
|
17
17
|
}
|
|
18
18
|
async sendMail(options, config) {
|
|
19
19
|
try {
|
|
20
|
-
const mailOptions = {
|
|
21
|
-
...options,
|
|
22
|
-
from: options.from || this.__user,
|
|
23
|
-
};
|
|
20
|
+
const mailOptions = { ...options, from: options.from || this.__user };
|
|
24
21
|
const res = await this.__transporter.sendMail(mailOptions);
|
|
25
22
|
return res;
|
|
26
23
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pangea-server",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.9",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/GianfrancoRaselli/pangea-server#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@afipsdk/afip.js": "1.2.2",
|
|
35
36
|
"@google/genai": "1.34.0",
|
|
36
37
|
"aws-sdk": "2.1692.0",
|
|
37
38
|
"bcrypt": "5.1.1",
|