pangea-server 3.3.9 → 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.
|
@@ -3,10 +3,10 @@ type ArcaConfig = {
|
|
|
3
3
|
cert: string;
|
|
4
4
|
key: string;
|
|
5
5
|
};
|
|
6
|
-
type VoucherType =
|
|
7
|
-
type Concept =
|
|
8
|
-
type DocumentType =
|
|
9
|
-
type VatConditionReceiver =
|
|
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
10
|
type CreateVoucherOptions = {
|
|
11
11
|
pointOfSale: number;
|
|
12
12
|
voucherType: VoucherType;
|
|
@@ -7,6 +7,32 @@ exports.Arca = void 0;
|
|
|
7
7
|
const afip_js_1 = __importDefault(require("@afipsdk/afip.js"));
|
|
8
8
|
// helpers
|
|
9
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
|
+
};
|
|
10
36
|
class Arca {
|
|
11
37
|
constructor(config) {
|
|
12
38
|
const { cuit, cert, key } = config;
|
|
@@ -17,15 +43,16 @@ class Arca {
|
|
|
17
43
|
}
|
|
18
44
|
async createVoucher(createVoucherOptions) {
|
|
19
45
|
const { pointOfSale, voucherType, concept, documentType, documentNumber, taxableAmount, exemptAmount, vatAmount, vatConditionReceiver, serviceFrom = null, serviceTo = null, paymentDueDate = null, } = createVoucherOptions;
|
|
20
|
-
const
|
|
46
|
+
const afipVoucherType = voucherTypeMap[voucherType];
|
|
47
|
+
const lastVoucher = await this.__afip.ElectronicBilling.getLastVoucher(pointOfSale, afipVoucherType);
|
|
21
48
|
const voucherNumber = lastVoucher + 1;
|
|
22
49
|
const voucherDate = Number(new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString().split('T')[0].replace(/-/g, ''));
|
|
23
50
|
const data = {
|
|
24
51
|
CantReg: 1,
|
|
25
52
|
PtoVta: pointOfSale,
|
|
26
|
-
CbteTipo:
|
|
27
|
-
Concepto: concept,
|
|
28
|
-
DocTipo: documentType,
|
|
53
|
+
CbteTipo: afipVoucherType,
|
|
54
|
+
Concepto: conceptMap[concept],
|
|
55
|
+
DocTipo: documentTypeMap[documentType],
|
|
29
56
|
DocNro: documentNumber,
|
|
30
57
|
CbteDesde: voucherNumber,
|
|
31
58
|
CbteHasta: voucherNumber,
|
|
@@ -41,7 +68,7 @@ class Arca {
|
|
|
41
68
|
ImpTrib: 0,
|
|
42
69
|
MonId: 'PES',
|
|
43
70
|
MonCotiz: 1,
|
|
44
|
-
CondicionIVAReceptorId: vatConditionReceiver,
|
|
71
|
+
CondicionIVAReceptorId: vatConditionReceiverMap[vatConditionReceiver],
|
|
45
72
|
Iva: vatAmount > 0 ? [{ Id: 5, BaseImp: taxableAmount, Importe: vatAmount }] : [],
|
|
46
73
|
};
|
|
47
74
|
return this.__afip.ElectronicBilling.createVoucher(data);
|