pangea-server 3.3.13 → 3.3.15
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 +21 -17
- package/dist/helpers/arca.helpers.js +58 -58
- package/package.json +1 -1
|
@@ -3,31 +3,35 @@ type ArcaConfig = {
|
|
|
3
3
|
cert: string;
|
|
4
4
|
key: string;
|
|
5
5
|
};
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
type CreateVoucherOptions = {
|
|
6
|
+
type Concept = '1_products' | '2_services' | '3_products_and_services';
|
|
7
|
+
type DocumentType = '80_cuit' | '86_cuil' | '96_dni' | '99_final_consumer';
|
|
8
|
+
type VatConditionReceiver = '1_vat_registered' | '4_vat_exempt' | '5_final_consumer' | '6_monotaxpayer' | '7_unclassified' | '8_foreign_supplier' | '9_foreign_client' | '10_vat_exempt_law_19640' | '13_social_monotaxpayer' | '15_vat_not_applicable' | '16_promoted_independent_monotaxpayer';
|
|
9
|
+
type CreateInvoiceCOptions = {
|
|
11
10
|
pointOfSale: number;
|
|
12
|
-
|
|
11
|
+
receiver: {
|
|
12
|
+
documentType: '99_final_consumer';
|
|
13
|
+
} | {
|
|
14
|
+
documentType: Exclude<DocumentType, '99_final_consumer'>;
|
|
15
|
+
documentNumber: number;
|
|
16
|
+
vatCondition: VatConditionReceiver;
|
|
17
|
+
};
|
|
13
18
|
concept: Concept;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
serviceFrom?: number | null;
|
|
21
|
-
serviceTo?: number | null;
|
|
22
|
-
paymentDueDate?: number | null;
|
|
19
|
+
amount: number;
|
|
20
|
+
service?: {
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
paymentDueDate: string;
|
|
24
|
+
};
|
|
23
25
|
};
|
|
24
|
-
type
|
|
26
|
+
type CreateVoucherCRes = {
|
|
25
27
|
cae: string;
|
|
26
28
|
caeExpirationDate: string;
|
|
27
29
|
};
|
|
28
30
|
export declare class Arca {
|
|
29
31
|
private __afip;
|
|
30
32
|
constructor(config: ArcaConfig);
|
|
31
|
-
|
|
33
|
+
getLastVoucher(pointOfSale: number, voucherTypeId: number): Promise<number>;
|
|
34
|
+
getVoucherInfo(lastVoucherNumber: number, pointOfSale: number, voucherTypeId: number): Promise<any>;
|
|
35
|
+
createInvoiceC(options: CreateInvoiceCOptions): Promise<CreateVoucherCRes>;
|
|
32
36
|
}
|
|
33
37
|
export {};
|
|
@@ -7,31 +7,36 @@ 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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
const voucherTypeIds = {
|
|
11
|
+
'1_invoice_a': 1,
|
|
12
|
+
'2_debit_note_a': 2,
|
|
13
|
+
'3_credit_note_a': 3,
|
|
14
|
+
'6_invoice_b': 6,
|
|
15
|
+
'7_debit_note_b': 7,
|
|
16
|
+
'8_credit_note_b': 8,
|
|
17
|
+
'11_invoice_c': 11,
|
|
18
|
+
'12_debit_note_c': 12,
|
|
19
|
+
'13_credit_note_c': 13,
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
const conceptIds = { '1_products': 1, '2_services': 2, '3_products_and_services': 3 };
|
|
22
|
+
const documentTypeIds = {
|
|
23
|
+
'80_cuit': 80,
|
|
24
|
+
'86_cuil': 86,
|
|
25
|
+
'96_dni': 96,
|
|
26
|
+
'99_final_consumer': 99,
|
|
27
|
+
};
|
|
28
|
+
const vatConditionReceiverIds = {
|
|
29
|
+
'1_vat_registered': 1,
|
|
30
|
+
'4_vat_exempt': 4,
|
|
31
|
+
'5_final_consumer': 5,
|
|
32
|
+
'6_monotaxpayer': 6,
|
|
33
|
+
'7_unclassified': 7,
|
|
34
|
+
'8_foreign_supplier': 8,
|
|
35
|
+
'9_foreign_client': 9,
|
|
36
|
+
'10_vat_exempt_law_19640': 10,
|
|
37
|
+
'13_social_monotaxpayer': 13,
|
|
38
|
+
'15_vat_not_applicable': 15,
|
|
39
|
+
'16_promoted_independent_monotaxpayer': 16,
|
|
35
40
|
};
|
|
36
41
|
class Arca {
|
|
37
42
|
constructor(config) {
|
|
@@ -42,51 +47,46 @@ class Arca {
|
|
|
42
47
|
...(cuit !== 20409378472 ? { cert, key, production: true } : {}),
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (concept !== 'products' && (serviceFrom === null || serviceTo === null || paymentDueDate === null)) {
|
|
50
|
+
getLastVoucher(pointOfSale, voucherTypeId) {
|
|
51
|
+
return this.__afip.ElectronicBilling.getLastVoucher(pointOfSale, voucherTypeId);
|
|
52
|
+
}
|
|
53
|
+
getVoucherInfo(lastVoucherNumber, pointOfSale, voucherTypeId) {
|
|
54
|
+
return this.__afip.ElectronicBilling.getVoucherInfo(lastVoucherNumber, pointOfSale, voucherTypeId);
|
|
55
|
+
}
|
|
56
|
+
async createInvoiceC(options) {
|
|
57
|
+
const { pointOfSale, receiver, concept, amount, service } = options;
|
|
58
|
+
const isConceptProducts = concept === '1_products';
|
|
59
|
+
if (!isConceptProducts && !service)
|
|
56
60
|
throw new Error('Service dates are required');
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const voucherNumber = lastVoucher + 1;
|
|
61
|
+
const voucherTypeId = voucherTypeIds['11_invoice_c'];
|
|
62
|
+
const lastVoucherNumber = await this.getLastVoucher(pointOfSale, voucherTypeId);
|
|
63
|
+
const voucherNumber = lastVoucherNumber + 1;
|
|
64
|
+
const localDate = new Date(Date.now() - new Date().getTimezoneOffset() * 60000);
|
|
65
|
+
const voucherDate = Number(localDate.toISOString().split('T')[0].replace(/-/g, ''));
|
|
66
|
+
const isFinalConsumer = receiver.documentType === '99_final_consumer';
|
|
67
|
+
const finalVatCondition = isFinalConsumer ? '5_final_consumer' : receiver.vatCondition;
|
|
67
68
|
const data = {
|
|
68
69
|
CantReg: 1,
|
|
69
70
|
PtoVta: pointOfSale,
|
|
70
|
-
CbteTipo:
|
|
71
|
-
Concepto:
|
|
72
|
-
DocTipo:
|
|
73
|
-
DocNro:
|
|
71
|
+
CbteTipo: voucherTypeId,
|
|
72
|
+
Concepto: conceptIds[concept],
|
|
73
|
+
DocTipo: documentTypeIds[receiver.documentType],
|
|
74
|
+
DocNro: isFinalConsumer ? 0 : receiver.documentNumber,
|
|
74
75
|
CbteDesde: voucherNumber,
|
|
75
76
|
CbteHasta: voucherNumber,
|
|
76
77
|
CbteFch: voucherDate,
|
|
77
|
-
FchServDesde:
|
|
78
|
-
FchServHasta:
|
|
79
|
-
FchVtoPago:
|
|
80
|
-
ImpTotal:
|
|
78
|
+
FchServDesde: isConceptProducts ? null : Number(service.from.replace(/-/g, '')),
|
|
79
|
+
FchServHasta: isConceptProducts ? null : Number(service.to.replace(/-/g, '')),
|
|
80
|
+
FchVtoPago: isConceptProducts ? null : Number(service.paymentDueDate.replace(/-/g, '')),
|
|
81
|
+
ImpTotal: amount,
|
|
81
82
|
ImpTotConc: 0,
|
|
82
|
-
ImpNeto:
|
|
83
|
-
ImpOpEx:
|
|
84
|
-
ImpIVA:
|
|
83
|
+
ImpNeto: amount,
|
|
84
|
+
ImpOpEx: 0,
|
|
85
|
+
ImpIVA: 0,
|
|
85
86
|
ImpTrib: 0,
|
|
86
87
|
MonId: 'PES',
|
|
87
88
|
MonCotiz: 1,
|
|
88
|
-
CondicionIVAReceptorId:
|
|
89
|
-
Iva: finalIvaArray,
|
|
89
|
+
CondicionIVAReceptorId: vatConditionReceiverIds[finalVatCondition],
|
|
90
90
|
};
|
|
91
91
|
const res = await this.__afip.ElectronicBilling.createVoucher(data);
|
|
92
92
|
return { cae: res.CAE, caeExpirationDate: res.CAEFchVto };
|