-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
511689e
commit 75ee53d
Showing
13 changed files
with
403 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Conto : CONTO COGNOME NOME ,,,,,,,,,,, | ||
Data estrazione : 2-1-2025 11:58:30,,,,,,,,,,, | ||
,,,,,,,,,,, | ||
Tutti i movimenti ordinati per Data Operazione,,,,,,,,,,, | ||
Dal : 01-01-2022,,,,,,,,,,, | ||
al : 01-01-2025,,,,,,,,,,, | ||
,,,,,,,,,,, | ||
Il file include i primi 3000 movimenti,,,,,,,,,,, | ||
,,,,,,,,,,, | ||
Data operazione,Data valuta,Tipo operazione,Ticker,Isin,Protocollo,Descrizione,Quantità,Importo euro,Importo Divisa,Divisa,Riferimento ordine | ||
30-12-2024,30-12-2024,Conferimento con bonifico,,,YYYYYYY,,0,1200,0,EUR, | ||
27-12-2024,27-12-2024,Provento etf,IEMB,IE00B2NPKV68,YYYYYYY,ISHARES JPMORGAN s EMERGING MA,0,20.95,0,EUR, | ||
27-12-2024,27-12-2024,Rit.provento etf,IEMB,IE00B2NPKV68,YYYYYYY,ISHARES JPMORGAN s EMERGING MA,0,-3.57,0,EUR, | ||
27-12-2024,27-12-2024,Provento etf,CNYB,IE00BYPC1H27,YYYYYYY,ISHARES CHINA CNY BOND UCITS E,0,10.94,0,EUR, | ||
27-12-2024,27-12-2024,Rit.provento etf,CNYB,IE00BYPC1H27,YYYYYYY,ISHARES CHINA CNY BOND UCITS E,0,-2.15,0,EUR, | ||
27-12-2024,27-12-2024,Ritenuta su plusvalenza,,,YYYYYYY,,0,-2.86,0,EUR, | ||
27-12-2024,27-12-2024,Coupon certif.,CXF549,IT0006755497,YYYYYYY,MAR SeP 500 EP 240327,0,11,0,EUR, | ||
13-12-2024,13-12-2024,Conferimento con bonifico,,,YYYYYYY,,0,1200,0,EUR, | ||
06-12-2024,05-12-2024,Cedola obb.,M.511185,IT0005595373,YYYYYYY,ALPER FX JUN29 EUR,0,71.25,0,EUR, | ||
06-12-2024,05-12-2024,Rit.cedola obb.,M.511185,IT0005595373,YYYYYYY,ALPER FX JUN29 EUR,0,-18.53,0,EUR, | ||
02-12-2024,05-12-2024,Cedola obb.,M.510999,IT0005583478,YYYYYYY,BTP VALORE SC MZ30 CUM BONUS,0,24.38,0,EUR, | ||
02-12-2024,05-12-2024,Rit.cedola obb.,M.510999,IT0005583478,YYYYYYY,BTP VALORE SC MZ30 CUM BONUS,0,-3.05,0,EUR, | ||
02-12-2024,04-12-2024,Acquisto,ICOV,IE00B3B8Q275,,ETF COVERED BOND ISH,3,-431.04,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,EHYA,IE00BJK55C48,,ISHARES E HIGH YIELD CORP BOND,36,-197.82,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,SMEA,IE00B4K48X80,,ISHARES MSCI EUROPE UCITS ETF,2,-158.58,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,IEMB,IE00B2NPKV68,,ISHARES JPMORGAN s EMERGING MA,2,-171.06,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,EIMI,IE00BKM4GZ66,,ISHARES CORE MSCI EMER MKT IMI,4,-132.18,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,CNYB,IE00BYPC1H27,,ISHARES CHINA CNY BOND UCITS E,39,-196.33,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,SWDA,IE00B4L5Y983,,ISHARES MSCI WORLD (ACC),1,-105.71,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,IWVL,IE00BP3QZB59,,ISHARES MSCI WORLD VALUE FACT,3,-126.53,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,IEVL,IE00BQN1K901,,ISHARES MSCI EUR VALUE FACTOR,22,-192.24,0,EUR,XXXXXXXXX | ||
02-12-2024,04-12-2024,Acquisto,IWDP,IE00B1FZS350,,ETF EPRA DEVMKTS ISH,6,-139.68,0,EUR,XXXXXXXXX | ||
29-05-2024,31-05-2024,Vendita,AV,IT0005366601,,ANTARES VISION,200,666,0,EUR,Q8610242012248 | ||
29-05-2024,33-09-2024,Pippo,AV,IT0005366601,,ANTARES VISION,200,666,0,EUR,Q8610242012248 | ||
29-05-2024,31-05-2024,,,,,,,,0,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { DirectaConverter } from "./directaConverter"; | ||
import { SecurityService } from "../securityService"; | ||
import { GhostfolioExport } from "../models/ghostfolioExport"; | ||
import YahooFinanceServiceMock from "../testing/yahooFinanceServiceMock"; | ||
|
||
describe("directaConverter", () => { | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, "log").mockImplementation(jest.fn()); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it("should construct", () => { | ||
|
||
// Act | ||
const sut = new DirectaConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
// Assert | ||
expect(sut).toBeTruthy(); | ||
}); | ||
|
||
it("should process sample CSV file", (done) => { | ||
|
||
// Arrange | ||
const sut = new DirectaConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
const inputFile = "samples/directa-export.csv"; | ||
|
||
// Act | ||
sut.readAndProcessFile(inputFile, (actualExport: GhostfolioExport) => { | ||
|
||
// Assert | ||
expect(actualExport).toBeTruthy(); | ||
expect(actualExport.activities.length).toBeGreaterThan(0); | ||
expect(actualExport.activities.length).toBe(17); | ||
|
||
done(); | ||
}, () => { done.fail("Should not have an error!"); }); | ||
}); | ||
|
||
describe("should throw an error if", () => { | ||
it("the input file does not exist", (done) => { | ||
|
||
// Arrange | ||
const sut = new DirectaConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
let tempFileName = "tmp/testinput/directa-filedoesnotexist.csv"; | ||
|
||
// Act | ||
sut.readAndProcessFile(tempFileName, () => { done.fail("Should not succeed!"); }, (err: Error) => { | ||
|
||
// Assert | ||
expect(err).toBeTruthy(); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it("the input file is empty", (done) => { | ||
|
||
// Arrange | ||
const sut = new DirectaConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
let tempFileContent = ""; | ||
tempFileContent += "Data operazione,Data valuta,Tipo operazione,Ticker,Isin,Protocollo,Descrizione,Quantità,Importo euro,Importo Divisa,Divisa,Riferimento ordine\n"; | ||
|
||
// Act | ||
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => { | ||
|
||
// Assert | ||
expect(err).toBeTruthy(); | ||
expect(err.message).toContain("An error ocurred while parsing"); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it("the header and row column count doesn't match", (done) => { | ||
|
||
// Arrange | ||
const sut = new DirectaConverter(new SecurityService(new YahooFinanceServiceMock())); | ||
|
||
let tempFileContent = ""; | ||
tempFileContent += "Data operazione,Data valuta,Tipo operazione,Ticker,Isin,Protocollo,Descrizione,Quantità,Importo euro,Importo Divisa,Divisa,Riferimento ordine\n"; | ||
tempFileContent += "02-12-2024,04-12-2024,Acquisto,ICOV,IE00B3B8Q275,,ETF COVERED BOND ISH,3,-431.04,0,EUR,XXXXXXXXX,\n"; | ||
|
||
// Act | ||
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => { | ||
|
||
// Assert | ||
expect(err).toBeTruthy(); | ||
expect(err.message).toBe("An error ocurred while parsing!"); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it("should log when Yahoo Finance returns no symbol", (done) => { | ||
|
||
// Arrange | ||
let tempFileContent = ""; | ||
|
||
// add fake 10 rows | ||
for (let i = 0; i < 9; i++) { | ||
tempFileContent += "\n"; | ||
} | ||
|
||
tempFileContent += "Data operazione,Data valuta,Tipo operazione,Ticker,Isin,Protocollo,Descrizione,Quantità,Importo euro,Importo Divisa,Divisa,Riferimento ordine\n"; | ||
tempFileContent += "02-12-2024,04-12-2024,Acquisto,ICOV,XXXXXXXX,,ETF COVERED BOND ISH,3,-431.04,0,EUR,T3717285639899" | ||
|
||
// Mock Yahoo Finance service to return no quotes. | ||
const yahooFinanceServiceMock = new YahooFinanceServiceMock(); | ||
jest.spyOn(yahooFinanceServiceMock, "search").mockImplementation(() => { return Promise.resolve({ quotes: [] }) }); | ||
const sut = new DirectaConverter(new SecurityService(yahooFinanceServiceMock)); | ||
|
||
// Bit hacky, but it works. | ||
const consoleSpy = jest.spyOn((sut as any).progress, "log"); | ||
|
||
// Act | ||
sut.processFileContents(tempFileContent, () => { | ||
|
||
expect(consoleSpy).toHaveBeenCalledWith("[i] No result found for buy action for XXXXXXXX with currency EUR! Please add this manually..\n"); | ||
|
||
done(); | ||
}, () => done.fail("Should not have an error!")); | ||
}); | ||
}); |
Oops, something went wrong.