Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docs/banks/cz/fio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Every line under `Další parametry` but `Typ pohybu` and `ID pokynu` appears on

Every kind of e-mail Fio can send, and whether a real one has been read. ✅ read, 🚫 seen and refused, ❔ not seen yet,
👁 seen only as a preview in the settings form. A ❔ needs one raw `.eml`, exported as the original, never forwarded; see
[development](../../../development.md#adding-a-bank). Parser, tests and fixtures are in `modules/bank-notifications/src/banks/fio-cz/`.
[development](../../../development.md#adding-a-bank). Parser, tests and fixtures are in `modules/bank-notifications/src/banks/cz/fio/`.

### What the account holder chooses

Expand Down
18 changes: 11 additions & 7 deletions .docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@ scan in `security.yml` reads it, and the build fails when it drifts from what sh

## Adding a bank

Each bank has a folder of its own, `modules/bank-notifications/src/banks/<bank>/`:
Each bank has a folder of its own, `modules/bank-notifications/src/banks/<country>/<bank>/`, and its documentation is
`.docs/banks/<country>/<bank>/README.md`, with a row in [banks](banks/README.md). The country is a folder (`cz`, later
`sk` and others), the same in both places:

```text
src/banks/fio-cz/
src/banks/cz/fio/
java/cz/insuit/bank/notification/FioCz.java the parser
test/cz/insuit/bank/notification/FioCzTest.java its tests
fixtures/fio-cz/*.eml its anonymised e-mails, read as /fio-cz/<name>.eml
```

Its documentation is `.docs/banks/<country>/<bank>/README.md`, with a row in [banks](banks/README.md); the country
is a folder (`cz`, later `sk` and others). Gradle picks every code folder up as another source root. Each is in the package `cz.insuit.bank.notification`, like the
rest, so the parser stays package-private and out of the public API: a folder is not a package.
The fixtures' own folder keeps the country in its name (`fio-cz`): every bank's fixtures share one classpath, so Fio
in Slovakia needs `fio-sk`, not a second `fio`. Gradle picks every bank folder up as another source root. Each is in the
package `cz.insuit.bank.notification`, like the rest, so the parser stays package-private and out of the public API: a
folder is not a package.

1. **Get a real e-mail**: the raw `.eml`, exported as "show original" or "raw source", never forwarded, which rewrites
the headers. An incoming payment with a variable symbol and a message is the most useful first one.
2. **Verify its signature** against the bank's key in DNS before anything else, e.g.
`uvx --from dkimpy==1.1.8 --with dnspython dkimverify < message.eml`. Note the `d=`, the selector, the key size,
and that there is no `l=`.
3. **Anonymise it into a fixture** under `src/banks/<bank>/fixtures/<bank>/`: keep the headers from
3. **Anonymise it into a fixture** under `src/banks/<country>/<bank>/fixtures/<bank>-<country>/` (or the name the bank's
existing fixtures use): keep the headers from
`Date:` on, drop the transport headers and the signature, replace accounts, names, balance, transaction codes and
the recipient (`bruce.wayne@gothba.org`), and keep everything else byte for byte, line ends and invisible characters
included. `.gitattributes` keeps git from touching `*.eml`.
4. **Write the parser** in `src/banks/<bank>/java/`, with its test in `src/banks/<bank>/test/`, as `AirBank` and `FioCz` are:
4. **Write the parser** in `src/banks/<country>/<bank>/java/`, with its test in `src/banks/<country>/<bank>/test/`, as `AirBank` and `FioCz` are:
a class implementing `Bank`, listed in `BankNotifications.BANKS`, reading the body through `NotificationLines`
(one-off lines, labelled lines, the guard against a forged line after a payer's message). What stays the bank's
own: its patterns, the amount format, the movement types; lines read by label, the direction stated twice and required to agree,
Expand Down
11 changes: 8 additions & 3 deletions modules/bank-notifications/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

// One folder per bank, src/banks/<bank>/: its parser in java/, its tests in test/, its anonymised e-mails in fixtures/.
// Every folder is in the same package as the rest, so a parser stays package-private; a folder is not a package.
val banks = file("src/banks").listFiles { file -> file.isDirectory }.orEmpty().sortedBy { it.name }
// One folder per bank, src/banks/<country>/<bank>/: its parser in java/, its tests in test/, its anonymised e-mails in
// fixtures/. Every folder is in the same package as the rest, so a parser stays package-private; a folder is not a package.
val banks =
file("src/banks")
.listFiles { file -> file.isDirectory }
.orEmpty()
.flatMap { country -> country.listFiles { file -> file.isDirectory }.orEmpty().toList() }
.sortedBy { it.path }

sourceSets {
main { java.srcDirs(banks.map { it.resolve("java") }) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.jspecify.annotations.Nullable;

/**
* One bank whose notification e-mail the library reads. Each lives in its own folder, {@code src/banks/<bank>/}, and
* One bank whose notification e-mail the library reads. Each lives in its own folder, {@code src/banks/<country>/<bank>/}, and
* is listed in {@link BankNotifications}; the e-mail's {@code From} domain picks it.
*/
interface Bank {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public final class BankNotifications {

/** Every bank this release reads; adding one is a class in {@code src/banks/<bank>/} and a line here. */
/** Every bank this release reads; adding one is a class in {@code src/banks/<country>/<bank>/} and a line here. */
private static final List<Bank> BANKS =
List.of(new AirBank(), new FioCz(), new Moneta(), new Creditas(), new Raiffeisenbank());

Expand Down
Loading