pangea-server 3.3.14 → 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.
|
@@ -3,15 +3,15 @@ type ArcaConfig = {
|
|
|
3
3
|
cert: string;
|
|
4
4
|
key: string;
|
|
5
5
|
};
|
|
6
|
-
type Concept = '
|
|
7
|
-
type DocumentType = '
|
|
8
|
-
type VatConditionReceiver = '
|
|
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
9
|
type CreateInvoiceCOptions = {
|
|
10
10
|
pointOfSale: number;
|
|
11
11
|
receiver: {
|
|
12
|
-
documentType: '
|
|
12
|
+
documentType: '99_final_consumer';
|
|
13
13
|
} | {
|
|
14
|
-
documentType: Exclude<DocumentType, '
|
|
14
|
+
documentType: Exclude<DocumentType, '99_final_consumer'>;
|
|
15
15
|
documentNumber: number;
|
|
16
16
|
vatCondition: VatConditionReceiver;
|
|
17
17
|
};
|
|
@@ -8,30 +8,35 @@ const afip_js_1 = __importDefault(require("@afipsdk/afip.js"));
|
|
|
8
8
|
// helpers
|
|
9
9
|
const helpers_1 = require("../helpers");
|
|
10
10
|
const voucherTypeIds = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
};
|
|
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,
|
|
20
27
|
};
|
|
21
|
-
const conceptIds = { products: 1, services: 2, products_and_services: 3 };
|
|
22
|
-
const documentTypeIds = { cuit: 80, cuil: 86, dni: 96, final_consumer: 99 };
|
|
23
28
|
const vatConditionReceiverIds = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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) {
|
|
@@ -50,31 +55,29 @@ class Arca {
|
|
|
50
55
|
}
|
|
51
56
|
async createInvoiceC(options) {
|
|
52
57
|
const { pointOfSale, receiver, concept, amount, service } = options;
|
|
53
|
-
|
|
58
|
+
const isConceptProducts = concept === '1_products';
|
|
59
|
+
if (!isConceptProducts && !service)
|
|
54
60
|
throw new Error('Service dates are required');
|
|
55
|
-
const voucherTypeId = voucherTypeIds['
|
|
61
|
+
const voucherTypeId = voucherTypeIds['11_invoice_c'];
|
|
56
62
|
const lastVoucherNumber = await this.getLastVoucher(pointOfSale, voucherTypeId);
|
|
57
|
-
console.log('lastVoucherNumber: ', lastVoucherNumber);
|
|
58
63
|
const voucherNumber = lastVoucherNumber + 1;
|
|
59
64
|
const localDate = new Date(Date.now() - new Date().getTimezoneOffset() * 60000);
|
|
60
|
-
console.log('localDate: ', localDate);
|
|
61
|
-
console.log('toISOString: ', localDate.toISOString());
|
|
62
65
|
const voucherDate = Number(localDate.toISOString().split('T')[0].replace(/-/g, ''));
|
|
63
|
-
|
|
64
|
-
const finalVatCondition =
|
|
66
|
+
const isFinalConsumer = receiver.documentType === '99_final_consumer';
|
|
67
|
+
const finalVatCondition = isFinalConsumer ? '5_final_consumer' : receiver.vatCondition;
|
|
65
68
|
const data = {
|
|
66
69
|
CantReg: 1,
|
|
67
70
|
PtoVta: pointOfSale,
|
|
68
71
|
CbteTipo: voucherTypeId,
|
|
69
72
|
Concepto: conceptIds[concept],
|
|
70
73
|
DocTipo: documentTypeIds[receiver.documentType],
|
|
71
|
-
DocNro:
|
|
74
|
+
DocNro: isFinalConsumer ? 0 : receiver.documentNumber,
|
|
72
75
|
CbteDesde: voucherNumber,
|
|
73
76
|
CbteHasta: voucherNumber,
|
|
74
77
|
CbteFch: voucherDate,
|
|
75
|
-
FchServDesde:
|
|
76
|
-
FchServHasta:
|
|
77
|
-
FchVtoPago:
|
|
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, '')),
|
|
78
81
|
ImpTotal: amount,
|
|
79
82
|
ImpTotConc: 0,
|
|
80
83
|
ImpNeto: amount,
|