parser-de-notas-de-corretagem 0.0.2 → 0.0.4
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/README.md +9 -7
- package/notes-parser.d.ts +19 -0
- package/notes-parser.js +1 -1
- package/notes-parser.js.map +1 -1
- package/package.json +24 -17
package/README.md
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
# Parse Brazilian brokerage notes PDFs (Inter and Clear holders available)
|
|
2
2
|
|
|
3
|
+
[](https://github.com/planetsLightningArrester/parser-de-notas-de-corretagem/actions/workflows/ci.yml)
|
|
4
|
+
|
|
3
5
|
Easing the PITA of making IRRF
|
|
4
6
|
|
|
5
|
-
> Note: This is a JS/TS package. If you want the
|
|
7
|
+
> Note: This is a JS/TS package. If you want the end-user solution, check the [Leitor de notas de corretagem](https://github.com/planetsLightningArrester/leitor-de-notas-de-corretagem)
|
|
6
8
|
|
|
7
9
|
## Example result
|
|
8
10
|
> The `price` and `average` fields already include the fees paid
|
|
9
11
|
```JSON
|
|
10
12
|
[
|
|
11
13
|
{
|
|
12
|
-
"number": "11111",
|
|
14
|
+
"number": "11111", // Brokerage note number
|
|
13
15
|
"buyTotal": "4054.58",
|
|
14
16
|
"sellTotal": "0.00",
|
|
15
17
|
"buyFees": "1.24",
|
|
16
18
|
"sellFees": "0.00",
|
|
17
19
|
"fees": "1.24",
|
|
18
|
-
"date": "02/02/2022",
|
|
20
|
+
"date": "02/02/2022", // Can also output in yyyy-MM-dd format
|
|
19
21
|
"holder": "rico",
|
|
20
22
|
"deals": [
|
|
21
23
|
{
|
|
@@ -34,7 +36,7 @@ Easing the PITA of making IRRF
|
|
|
34
36
|
"average": "112.80",
|
|
35
37
|
"price": "564.02",
|
|
36
38
|
"date": "02/02/2022",
|
|
37
|
-
"cnpj": "00.000.000/0000-00"
|
|
39
|
+
"cnpj": "00.000.000/0000-00" // FIIs' CNPJs aren't supported yet
|
|
38
40
|
},
|
|
39
41
|
{
|
|
40
42
|
"type": "buy",
|
|
@@ -88,8 +90,8 @@ async function main() {
|
|
|
88
90
|
|
|
89
91
|
// Get all negotiation notes inside a PDF, even with password
|
|
90
92
|
const possiblePDFpasswords: string[] = ['123', '456'];
|
|
91
|
-
let
|
|
92
|
-
let parseResult = await assets.parseNote(
|
|
93
|
+
let pdfPath = path.join(__dirname, 'note.pdf');
|
|
94
|
+
let parseResult = await assets.parseNote(pdfPath, possiblePDFpasswords);
|
|
93
95
|
|
|
94
96
|
// Merge all negotiation notes
|
|
95
97
|
let allDeals: Deal[][] = [];
|
|
@@ -147,6 +149,6 @@ Consider thanking me: send a "Thanks!" 👋 by [PIX](https://www.bcb.gov.br/en/f
|
|
|
147
149
|
> a09e5878-2355-45f7-9f36-6df4ccf383cf
|
|
148
150
|
|
|
149
151
|
## License
|
|
150
|
-
As license, this software is provided as is, free of charge, without any warranty whatsoever
|
|
152
|
+
As license, this software is provided as is, free of charge, **without any warranty whatsoever**. Its author is not responsible for its usage. Use it by your own risk.
|
|
151
153
|
|
|
152
154
|
[GNU GPLv3](https://choosealicense.com/licenses/gpl-3.0/)
|
package/notes-parser.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export declare class NegotiationNote {
|
|
|
72
72
|
*/
|
|
73
73
|
deals: Deal[];
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Possible date formats to be used
|
|
77
|
+
*/
|
|
78
|
+
export type DateFormat = "dd/MM/yyyy" | "yyyy-MM-dd";
|
|
75
79
|
/**
|
|
76
80
|
* Brokerage notes parser
|
|
77
81
|
*/
|
|
@@ -80,6 +84,10 @@ export declare class NoteParser {
|
|
|
80
84
|
* Path to the JSON data file
|
|
81
85
|
*/
|
|
82
86
|
private stockParser;
|
|
87
|
+
/**
|
|
88
|
+
* The date format used. Default is "dd/MM/yyyy"
|
|
89
|
+
*/
|
|
90
|
+
private dateFormat;
|
|
83
91
|
/**
|
|
84
92
|
* Instantiate a new `NoteParser`
|
|
85
93
|
* @param autoUpdateLookUpList whether the application should auto-update
|
|
@@ -87,6 +95,11 @@ export declare class NoteParser {
|
|
|
87
95
|
* Updating this package to the latest version also gets the latest infos
|
|
88
96
|
*/
|
|
89
97
|
constructor(autoUpdateLookUpList?: boolean);
|
|
98
|
+
/**
|
|
99
|
+
* Set the date format
|
|
100
|
+
* @param format a `DateFormat`
|
|
101
|
+
*/
|
|
102
|
+
setDateFormat(format: DateFormat): void;
|
|
90
103
|
/**
|
|
91
104
|
* Read and parse a given PDF negotiation note by its full path
|
|
92
105
|
* @param noteFullPath the full path to the PDF note to be parsed
|
|
@@ -100,5 +113,11 @@ export declare class NoteParser {
|
|
|
100
113
|
* @param cnpj stock CNPJ
|
|
101
114
|
*/
|
|
102
115
|
defineStock(code: string, name: string, cnpj?: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Convert a date according to `dateFormat`
|
|
118
|
+
* @param date the date to be formatted
|
|
119
|
+
* @returns the formatted date
|
|
120
|
+
*/
|
|
121
|
+
private formatDate;
|
|
103
122
|
}
|
|
104
123
|
//# sourceMappingURL=notes-parser.d.ts.map
|