pangea-server 3.3.8 → 3.3.10
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.
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type ArcaConfig = {
|
|
2
|
+
cuit: number;
|
|
3
|
+
cert: string;
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
6
|
+
type VoucherType = 'invoice_a' | 'invoice_b' | 'invoice_c' | 'debit_note_a' | 'debit_note_b' | 'debit_note_c' | 'credit_note_a' | 'credit_note_b' | 'credit_note_c';
|
|
7
|
+
type Concept = 'products' | 'services' | 'products_and_services';
|
|
8
|
+
type DocumentType = 'cuit' | 'cuil' | 'dni' | 'final_consumer';
|
|
9
|
+
type VatConditionReceiver = 'vat_registered' | 'vat_exempt' | 'final_consumer' | 'monotaxpayer' | 'unclassified' | 'foreign_supplier' | 'foreign_client' | 'vat_exempt_law_19640' | 'social_monotaxpayer' | 'vat_not_applicable' | 'promoted_independent_monotaxpayer';
|
|
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,77 @@
|
|
|
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
|
+
const voucherTypeMap = {
|
|
11
|
+
invoice_a: 1,
|
|
12
|
+
invoice_b: 6,
|
|
13
|
+
invoice_c: 11,
|
|
14
|
+
debit_note_a: 2,
|
|
15
|
+
debit_note_b: 7,
|
|
16
|
+
debit_note_c: 12,
|
|
17
|
+
credit_note_a: 3,
|
|
18
|
+
credit_note_b: 8,
|
|
19
|
+
credit_note_c: 13,
|
|
20
|
+
};
|
|
21
|
+
const conceptMap = { products: 1, services: 2, products_and_services: 3 };
|
|
22
|
+
const documentTypeMap = { cuit: 80, cuil: 86, dni: 96, final_consumer: 99 };
|
|
23
|
+
const vatConditionReceiverMap = {
|
|
24
|
+
vat_registered: 1,
|
|
25
|
+
vat_exempt: 4,
|
|
26
|
+
final_consumer: 5,
|
|
27
|
+
monotaxpayer: 6,
|
|
28
|
+
unclassified: 7,
|
|
29
|
+
foreign_supplier: 8,
|
|
30
|
+
foreign_client: 9,
|
|
31
|
+
vat_exempt_law_19640: 10,
|
|
32
|
+
social_monotaxpayer: 13,
|
|
33
|
+
vat_not_applicable: 15,
|
|
34
|
+
promoted_independent_monotaxpayer: 16,
|
|
35
|
+
};
|
|
36
|
+
class Arca {
|
|
37
|
+
constructor(config) {
|
|
38
|
+
const { cuit, cert, key } = config;
|
|
39
|
+
this.__afip = new afip_js_1.default({
|
|
40
|
+
access_token: (0, helpers_1.getEnvStr)('AFIP_ACCESS_TOKEN'),
|
|
41
|
+
...(cuit === 20409378472 ? { cuit } : { cuit, cert, key, production: true }),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async createVoucher(createVoucherOptions) {
|
|
45
|
+
const { pointOfSale, voucherType, concept, documentType, documentNumber, taxableAmount, exemptAmount, vatAmount, vatConditionReceiver, serviceFrom = null, serviceTo = null, paymentDueDate = null, } = createVoucherOptions;
|
|
46
|
+
const afipVoucherType = voucherTypeMap[voucherType];
|
|
47
|
+
const lastVoucher = await this.__afip.ElectronicBilling.getLastVoucher(pointOfSale, afipVoucherType);
|
|
48
|
+
const voucherNumber = lastVoucher + 1;
|
|
49
|
+
const voucherDate = Number(new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString().split('T')[0].replace(/-/g, ''));
|
|
50
|
+
const data = {
|
|
51
|
+
CantReg: 1,
|
|
52
|
+
PtoVta: pointOfSale,
|
|
53
|
+
CbteTipo: afipVoucherType,
|
|
54
|
+
Concepto: conceptMap[concept],
|
|
55
|
+
DocTipo: documentTypeMap[documentType],
|
|
56
|
+
DocNro: documentNumber,
|
|
57
|
+
CbteDesde: voucherNumber,
|
|
58
|
+
CbteHasta: voucherNumber,
|
|
59
|
+
CbteFch: voucherDate,
|
|
60
|
+
FchServDesde: serviceFrom,
|
|
61
|
+
FchServHasta: serviceTo,
|
|
62
|
+
FchVtoPago: paymentDueDate,
|
|
63
|
+
ImpTotal: taxableAmount + vatAmount + exemptAmount,
|
|
64
|
+
ImpTotConc: 0,
|
|
65
|
+
ImpNeto: taxableAmount,
|
|
66
|
+
ImpOpEx: exemptAmount,
|
|
67
|
+
ImpIVA: vatAmount,
|
|
68
|
+
ImpTrib: 0,
|
|
69
|
+
MonId: 'PES',
|
|
70
|
+
MonCotiz: 1,
|
|
71
|
+
CondicionIVAReceptorId: vatConditionReceiverMap[vatConditionReceiver],
|
|
72
|
+
Iva: vatAmount > 0 ? [{ Id: 5, BaseImp: taxableAmount, Importe: vatAmount }] : [],
|
|
73
|
+
};
|
|
74
|
+
return this.__afip.ElectronicBilling.createVoucher(data);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.Arca = Arca;
|
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.10",
|
|
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",
|