pangea-server 3.3.13 → 3.3.14
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 +18 -14
- package/dist/helpers/arca.helpers.js +35 -38
- package/package.json +1 -1
|
@@ -3,31 +3,35 @@ type ArcaConfig = {
|
|
|
3
3
|
cert: string;
|
|
4
4
|
key: string;
|
|
5
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
6
|
type Concept = 'products' | 'services' | 'products_and_services';
|
|
8
7
|
type DocumentType = 'cuit' | 'cuil' | 'dni' | 'final_consumer';
|
|
9
8
|
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
|
|
9
|
+
type CreateInvoiceCOptions = {
|
|
11
10
|
pointOfSale: number;
|
|
12
|
-
|
|
11
|
+
receiver: {
|
|
12
|
+
documentType: 'final_consumer';
|
|
13
|
+
} | {
|
|
14
|
+
documentType: Exclude<DocumentType, '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,7 +7,7 @@ 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
|
|
10
|
+
const voucherTypeIds = {
|
|
11
11
|
invoice_a: 1,
|
|
12
12
|
invoice_b: 6,
|
|
13
13
|
invoice_c: 11,
|
|
@@ -18,9 +18,9 @@ const voucherTypeMap = {
|
|
|
18
18
|
credit_note_b: 8,
|
|
19
19
|
credit_note_c: 13,
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
21
|
+
const conceptIds = { products: 1, services: 2, products_and_services: 3 };
|
|
22
|
+
const documentTypeIds = { cuit: 80, cuil: 86, dni: 96, final_consumer: 99 };
|
|
23
|
+
const vatConditionReceiverIds = {
|
|
24
24
|
vat_registered: 1,
|
|
25
25
|
vat_exempt: 4,
|
|
26
26
|
final_consumer: 5,
|
|
@@ -42,51 +42,48 @@ class Arca {
|
|
|
42
42
|
...(cuit !== 20409378472 ? { cert, key, production: true } : {}),
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const finalIvaArray = isInvoiceC || finalVatAmount === 0 ? [] : [{ Id: 5, BaseImp: finalTaxableAmount, Importe: finalVatAmount }];
|
|
55
|
-
if (concept !== 'products' && (serviceFrom === null || serviceTo === null || paymentDueDate === null)) {
|
|
45
|
+
getLastVoucher(pointOfSale, voucherTypeId) {
|
|
46
|
+
return this.__afip.ElectronicBilling.getLastVoucher(pointOfSale, voucherTypeId);
|
|
47
|
+
}
|
|
48
|
+
getVoucherInfo(lastVoucherNumber, pointOfSale, voucherTypeId) {
|
|
49
|
+
return this.__afip.ElectronicBilling.getVoucherInfo(lastVoucherNumber, pointOfSale, voucherTypeId);
|
|
50
|
+
}
|
|
51
|
+
async createInvoiceC(options) {
|
|
52
|
+
const { pointOfSale, receiver, concept, amount, service } = options;
|
|
53
|
+
if (concept !== 'products' && !service)
|
|
56
54
|
throw new Error('Service dates are required');
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
55
|
+
const voucherTypeId = voucherTypeIds['invoice_c'];
|
|
56
|
+
const lastVoucherNumber = await this.getLastVoucher(pointOfSale, voucherTypeId);
|
|
57
|
+
console.log('lastVoucherNumber: ', lastVoucherNumber);
|
|
58
|
+
const voucherNumber = lastVoucherNumber + 1;
|
|
59
|
+
const localDate = new Date(Date.now() - new Date().getTimezoneOffset() * 60000);
|
|
60
|
+
console.log('localDate: ', localDate);
|
|
61
|
+
console.log('toISOString: ', localDate.toISOString());
|
|
62
|
+
const voucherDate = Number(localDate.toISOString().split('T')[0].replace(/-/g, ''));
|
|
63
|
+
console.log('voucherDate: ', voucherDate);
|
|
64
|
+
const finalVatCondition = receiver.documentType === 'final_consumer' ? 'final_consumer' : receiver.vatCondition;
|
|
67
65
|
const data = {
|
|
68
66
|
CantReg: 1,
|
|
69
67
|
PtoVta: pointOfSale,
|
|
70
|
-
CbteTipo:
|
|
71
|
-
Concepto:
|
|
72
|
-
DocTipo:
|
|
73
|
-
DocNro:
|
|
68
|
+
CbteTipo: voucherTypeId,
|
|
69
|
+
Concepto: conceptIds[concept],
|
|
70
|
+
DocTipo: documentTypeIds[receiver.documentType],
|
|
71
|
+
DocNro: receiver.documentType === 'final_consumer' ? 0 : receiver.documentNumber,
|
|
74
72
|
CbteDesde: voucherNumber,
|
|
75
73
|
CbteHasta: voucherNumber,
|
|
76
74
|
CbteFch: voucherDate,
|
|
77
|
-
FchServDesde: concept === 'products' ? null :
|
|
78
|
-
FchServHasta: concept === 'products' ? null :
|
|
79
|
-
FchVtoPago: concept === 'products' ? null : paymentDueDate,
|
|
80
|
-
ImpTotal:
|
|
75
|
+
FchServDesde: concept === 'products' ? null : Number(service.from.replace(/-/g, '')),
|
|
76
|
+
FchServHasta: concept === 'products' ? null : Number(service.to.replace(/-/g, '')),
|
|
77
|
+
FchVtoPago: concept === 'products' ? null : Number(service.paymentDueDate.replace(/-/g, '')),
|
|
78
|
+
ImpTotal: amount,
|
|
81
79
|
ImpTotConc: 0,
|
|
82
|
-
ImpNeto:
|
|
83
|
-
ImpOpEx:
|
|
84
|
-
ImpIVA:
|
|
80
|
+
ImpNeto: amount,
|
|
81
|
+
ImpOpEx: 0,
|
|
82
|
+
ImpIVA: 0,
|
|
85
83
|
ImpTrib: 0,
|
|
86
84
|
MonId: 'PES',
|
|
87
85
|
MonCotiz: 1,
|
|
88
|
-
CondicionIVAReceptorId:
|
|
89
|
-
Iva: finalIvaArray,
|
|
86
|
+
CondicionIVAReceptorId: vatConditionReceiverIds[finalVatCondition],
|
|
90
87
|
};
|
|
91
88
|
const res = await this.__afip.ElectronicBilling.createVoucher(data);
|
|
92
89
|
return { cae: res.CAE, caeExpirationDate: res.CAEFchVto };
|