docs(import): confirm the BMO export procedure on a real account (#371) #489
6 changed files with 203 additions and 15 deletions
|
|
@ -12,6 +12,7 @@
|
||||||
- Ajustements : la catégorie d'une ligne d'ajustement accepte désormais la saisie, comme la cellule de catégorie de la page Transactions : tapez quelques lettres pour filtrer la liste, qui montre la hiérarchie et les noms des catégories standard dans votre langue. Elle propose les mêmes catégories que la page Transactions, actives et autorisées à la saisie, comme la fenêtre de répartition ouverte depuis la page Ajustements ; une ligne déjà enregistrée sur une catégorie masquée de la saisie la garde, son champ vide tant que vous n'en choisissez pas une autre. Le filtre de catégorie de la fenêtre « Lier transferts » du Bilan accepte aussi la saisie, avec « Toutes les catégories » en tête. Une liste de catégories ouverte n'est plus coupée par le bord d'une fenêtre ou du tableau des transactions, dans la fenêtre de répartition comme sur les dernières lignes du tableau, et elle s'ouvre vers le haut quand elle ne tient pas en dessous mais tient au-dessus (#429).
|
- Ajustements : la catégorie d'une ligne d'ajustement accepte désormais la saisie, comme la cellule de catégorie de la page Transactions : tapez quelques lettres pour filtrer la liste, qui montre la hiérarchie et les noms des catégories standard dans votre langue. Elle propose les mêmes catégories que la page Transactions, actives et autorisées à la saisie, comme la fenêtre de répartition ouverte depuis la page Ajustements ; une ligne déjà enregistrée sur une catégorie masquée de la saisie la garde, son champ vide tant que vous n'en choisissez pas une autre. Le filtre de catégorie de la fenêtre « Lier transferts » du Bilan accepte aussi la saisie, avec « Toutes les catégories » en tête. Une liste de catégories ouverte n'est plus coupée par le bord d'une fenêtre ou du tableau des transactions, dans la fenêtre de répartition comme sur les dernières lignes du tableau, et elle s'ouvre vers le haut quand elle ne tient pas en dessous mais tient au-dessus (#429).
|
||||||
- Transactions : sur un profil sans aucune transaction, la carte « Aucune transaction pour l'instant » s'affiche dès que l'application sait que le profil est vide, au lieu des filtres, des totaux et de « Chargement... » jusqu'au retour de la première page de la liste (#384).
|
- Transactions : sur un profil sans aucune transaction, la carte « Aucune transaction pour l'instant » s'affiche dès que l'application sait que le profil est vide, au lieu des filtres, des totaux et de « Chargement... » jusqu'au retour de la première page de la liste (#384).
|
||||||
- Textes d'aide : l'aide de la page Rapports nomme désormais les rapports par leurs cartes, « Tendances » et « Analyse par catégorie », au lieu de « Tendances mensuelles » et « Catégories dans le temps », des onglets qui n'existent plus. La section Tableau de bord du guide d'utilisation nomme désormais les huit étapes de démarrage et dit comment elles se cochent : selon vos données, ou par « J'ai compris » (ou, pour les rapports, un clic sur la carte Tendances entourée) pour les visites (#446).
|
- Textes d'aide : l'aide de la page Rapports nomme désormais les rapports par leurs cartes, « Tendances » et « Analyse par catégorie », au lieu de « Tendances mensuelles » et « Catégories dans le temps », des onglets qui n'existent plus. La section Tableau de bord du guide d'utilisation nomme désormais les huit étapes de démarrage et dit comment elles se cochent : selon vos données, ou par « J'ai compris » (ou, pour les rapports, un clic sur la carte Tendances entourée) pour les visites (#446).
|
||||||
|
- Guide d'utilisation : la procédure BMO de « Exporter un CSV depuis votre banque » est désormais confirmée sur un compte réel (2026-10-22). Le bouton s'appelle « Télécharger » sur le site français, sans l'ancien « ou Exporter », et les trois points qui n'ont pas pu être vérifiés (l'historique de la Mastercard, les prêts qui ne s'exportent pas, les colonnes des comptes de dépôt) sont marqués comme non vérifiés. La note dit désormais que la détection générique lit les exports BMO, des comptes de dépôt comme de la Mastercard, en retenant pour la Mastercard la date de la transaction plutôt que celle de l'inscription au relevé, et qu'un fichier dont les vingt premières lignes comptent plus d'entrées que de sorties sort inversé à l'aperçu jusqu'à « Inverser les signes » (#371).
|
||||||
|
|
||||||
### Corrigé
|
### Corrigé
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
- Adjustments: the category of an adjustment line now takes typing, like the category cell of the Transactions page: type a few letters to filter the list, which shows the hierarchy and the names of the standard categories in your language. It offers the same categories as the Transactions page, active and allowed for input, as does the split window opened from the Adjustments page; a line already saved on a category hidden from input keeps it, its field empty until you choose another one. The category filter of the “Link transfers” window of the Balance sheet takes typing too, with “Any category” first. An open category list is no longer cut by the edge of a window or of the Transactions table, in the split window as on the last rows of the table, and it opens upward when it does not fit below but fits above (#429).
|
- Adjustments: the category of an adjustment line now takes typing, like the category cell of the Transactions page: type a few letters to filter the list, which shows the hierarchy and the names of the standard categories in your language. It offers the same categories as the Transactions page, active and allowed for input, as does the split window opened from the Adjustments page; a line already saved on a category hidden from input keeps it, its field empty until you choose another one. The category filter of the “Link transfers” window of the Balance sheet takes typing too, with “Any category” first. An open category list is no longer cut by the edge of a window or of the Transactions table, in the split window as on the last rows of the table, and it opens upward when it does not fit below but fits above (#429).
|
||||||
- Transactions: on a profile without any transaction, the “No transactions yet” card now shows as soon as the app knows the profile is empty, instead of the filters, the totals and “Loading...” until the first page of the list comes back (#384).
|
- Transactions: on a profile without any transaction, the “No transactions yet” card now shows as soon as the app knows the profile is empty, instead of the filters, the totals and “Loading...” until the first page of the list comes back (#384).
|
||||||
- Help texts: the help of the Reports page now names the reports by their cards, “Trends” and “Category Analysis”, instead of “Monthly Trends” and “Category Over Time”, tabs that no longer exist. The Dashboard section of the user guide now names the eight getting-started steps and says how they get checked: from your data, or with “Got it” (or, for the reports, a click on the outlined Trends card) for the visit steps (#446).
|
- Help texts: the help of the Reports page now names the reports by their cards, “Trends” and “Category Analysis”, instead of “Monthly Trends” and “Category Over Time”, tabs that no longer exist. The Dashboard section of the user guide now names the eight getting-started steps and says how they get checked: from your data, or with “Got it” (or, for the reports, a click on the outlined Trends card) for the visit steps (#446).
|
||||||
|
- User guide: the BMO procedure of “Export a CSV from your bank” is now confirmed on a real account (2026-10-22). The button is named “Télécharger” on the French site, without the former “or Export”, and the three points that could not be checked (the Mastercard history, loans that cannot be exported, the columns of deposit accounts) are marked as not verified. The note now says that generic detection reads BMO exports, deposit accounts and Mastercard alike, keeping the transaction date rather than the posting date for the Mastercard, and that a file whose first twenty rows hold more inflows than outflows comes out reversed in the preview until “Flip the signs” (#371).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,15 +203,15 @@ Les cartes de crédit n'offrent qu'environ trois mois d'historique.
|
||||||
|
|
||||||
#### BMO
|
#### BMO
|
||||||
|
|
||||||
*Procédure reconstituée d'après une description générale, à confirmer sur un compte réel ; format de fichier non encore reconnu*
|
*Procédure confirmée sur un compte réel le 2026-10-22 ; fichier lu par la détection générique (format BMO pas encore reconnu par son nom)*
|
||||||
|
|
||||||
1. Connectez-vous aux Services bancaires en ligne BMO sur bmo.com (le site, pas l'application)
|
1. Connectez-vous aux Services bancaires en ligne BMO sur bmo.com (le site, pas l'application)
|
||||||
2. Dans le sommaire, cliquez sur le compte voulu (chèques, épargne ou Mastercard)
|
2. Dans le sommaire, cliquez sur le compte voulu (chèques, épargne ou Mastercard)
|
||||||
3. Au-dessus de la liste des transactions, cliquez sur « Télécharger » (ou « Exporter »)
|
3. Au-dessus de la liste des transactions, cliquez sur « Télécharger »
|
||||||
4. Choisissez le format CSV — les autres options visent QuickBooks, Quicken, Simply Accounting ou Microsoft Money
|
4. Choisissez le format CSV — les autres options visent QuickBooks, Quicken, Simply Accounting ou Microsoft Money
|
||||||
5. Choisissez la période, puis téléchargez le fichier
|
5. Choisissez la période, puis téléchargez le fichier
|
||||||
|
|
||||||
L'historique téléchargeable est limité à **123 jours** au maximum, et à environ **trois mois plus les transactions non facturées** pour une Mastercard : exportez chaque mois. Les prêts, hypothèques et marges de crédit ne s'exportent pas (relevés PDF seulement, conservés 7 ans). Les colonnes diffèrent entre les comptes de dépôt et la carte de crédit. BMO n'a pas encore de format reconnu par l'application : la détection générique lit la plupart des exports à montants signés ; si l'aperçu signale des entrées et des sorties inversées, utilisez « Inverser les signes ». Si le fichier n'est pas lu, envoyez-nous **uniquement la ligne d'en-tête et une ou deux lignes aux valeurs fictives** via Paramètres → Système → Envoyer un feedback. **Ne collez jamais un numéro de compte, un solde ni une transaction réelle** : la rétroaction est un message texte envoyé à un serveur, c'est la seule exception au fonctionnement local de l'application.
|
L'historique téléchargeable est limité à **123 jours** au maximum : exportez chaque mois. Non vérifié : une Mastercard n'offrirait qu'environ **trois mois plus les transactions non facturées** ; les prêts, hypothèques et marges de crédit ne s'exporteraient pas (relevés PDF seulement, conservés 7 ans) ; les colonnes différeraient entre les comptes de dépôt et la carte de crédit. BMO n'est pas encore reconnu par son nom, mais la détection générique lit ses exports, des comptes de dépôt comme de la Mastercard : pour la Mastercard, elle retient la date de la transaction, pas celle de l'inscription au relevé. À la première configuration d'une source, le sens des montants est deviné d'après la majorité des premières lignes du fichier (les vingt premières) : si elles comptent plus d'entrées que de sorties (un compte épargne qui reçoit surtout des dépôts, un relevé Mastercard composé surtout de paiements et de remboursements), le fichier sort inversé. Le récapitulatif de l'aperçu le montre ; « Inverser les signes » corrige alors l'import, et la correction est enregistrée avec la source. Si le fichier n'est pas lu, envoyez-nous **uniquement la ligne d'en-tête et une ou deux lignes aux valeurs fictives** via Paramètres → Système → Envoyer un feedback. **Ne collez jamais un numéro de compte, un solde ni une transaction réelle** : la rétroaction est un message texte envoyé à un serveur, c'est la seule exception au fonctionnement local de l'application.
|
||||||
|
|
||||||
### Astuces
|
### Astuces
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1121,15 +1121,15 @@
|
||||||
{
|
{
|
||||||
"id": "import-bmo",
|
"id": "import-bmo",
|
||||||
"title": "BMO",
|
"title": "BMO",
|
||||||
"status": "Procedure reconstructed from a general description, to be confirmed on a real account; file format not recognised yet",
|
"status": "Procedure confirmed on a real account on 2026-10-22, on the French site; file read by generic detection (BMO format not recognised by name yet)",
|
||||||
"steps": [
|
"steps": [
|
||||||
"Sign in to BMO Online Banking at bmo.com (the website, not the app)",
|
"Sign in to BMO Online Banking at bmo.com (the website, not the app)",
|
||||||
"In the summary, click the account you want (chequing, savings or Mastercard)",
|
"In the summary, click the account you want (chequing, savings or Mastercard)",
|
||||||
"Above the transaction list, click “Download” (or “Export”)",
|
"Above the transaction list, click the download button, labelled “Télécharger” on the French site",
|
||||||
"Choose the CSV format — the other options target QuickBooks, Quicken, Simply Accounting or Microsoft Money",
|
"Choose the CSV format — the other options target QuickBooks, Quicken, Simply Accounting or Microsoft Money",
|
||||||
"Pick the period, then download the file"
|
"Pick the period, then download the file"
|
||||||
],
|
],
|
||||||
"note": "The downloadable history is capped at 123 days, and at about three months plus unbilled transactions for a Mastercard: export every month. Loans, mortgages and lines of credit cannot be exported (PDF statements only, kept for 7 years). The columns differ between deposit accounts and the credit card. BMO has no format recognised by the app yet: generic detection reads most exports with signed amounts; if the preview reports swapped inflows and outflows, use “Flip the signs”. If the file is not read, send us only the header line and one or two lines with made-up values via Settings → System → Send feedback. Never paste an account number, a balance or a real transaction: feedback is a text message sent to a server, the only exception to the app working locally."
|
"note": "The downloadable history is capped at 123 days: export every month. Not verified: a Mastercard would only offer about three months plus unbilled transactions; loans, mortgages and lines of credit would not be exportable (PDF statements only, kept for 7 years); the columns would differ between deposit accounts and the credit card. BMO is not recognised by name yet, but generic detection reads its exports, deposit accounts and Mastercard alike: for the Mastercard, it keeps the transaction date (“Date de la transaction” on the French site), not the posting date (“Date de l'inscription au relevé”). When a source is first configured, the direction of the amounts is guessed from the majority of the first rows of the file (the first twenty): if they hold more inflows than outflows (a savings account that mostly receives deposits, a Mastercard statement made up mostly of payments and refunds), the file comes out reversed. The preview recap shows it; “Flip the signs” then corrects the import, and the correction is saved with the source. If the file is not read, send us only the header line and one or two lines with made-up values via Settings → System → Send feedback. Never paste an account number, a balance or a real transaction: feedback is a text message sent to a server, the only exception to the app working locally."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tips": [
|
"tips": [
|
||||||
|
|
|
||||||
|
|
@ -1121,15 +1121,15 @@
|
||||||
{
|
{
|
||||||
"id": "import-bmo",
|
"id": "import-bmo",
|
||||||
"title": "BMO",
|
"title": "BMO",
|
||||||
"status": "Procédure reconstituée d'après une description générale, à confirmer sur un compte réel ; format de fichier non encore reconnu",
|
"status": "Procédure confirmée sur un compte réel le 2026-10-22 ; fichier lu par la détection générique (format BMO pas encore reconnu par son nom)",
|
||||||
"steps": [
|
"steps": [
|
||||||
"Connectez-vous aux Services bancaires en ligne BMO sur bmo.com (le site, pas l'application)",
|
"Connectez-vous aux Services bancaires en ligne BMO sur bmo.com (le site, pas l'application)",
|
||||||
"Dans le sommaire, cliquez sur le compte voulu (chèques, épargne ou Mastercard)",
|
"Dans le sommaire, cliquez sur le compte voulu (chèques, épargne ou Mastercard)",
|
||||||
"Au-dessus de la liste des transactions, cliquez sur « Télécharger » (ou « Exporter »)",
|
"Au-dessus de la liste des transactions, cliquez sur « Télécharger »",
|
||||||
"Choisissez le format CSV — les autres options visent QuickBooks, Quicken, Simply Accounting ou Microsoft Money",
|
"Choisissez le format CSV — les autres options visent QuickBooks, Quicken, Simply Accounting ou Microsoft Money",
|
||||||
"Choisissez la période, puis téléchargez le fichier"
|
"Choisissez la période, puis téléchargez le fichier"
|
||||||
],
|
],
|
||||||
"note": "L'historique téléchargeable est limité à 123 jours au maximum, et à environ trois mois plus les transactions non facturées pour une Mastercard : exportez chaque mois. Les prêts, hypothèques et marges de crédit ne s'exportent pas (relevés PDF seulement, conservés 7 ans). Les colonnes diffèrent entre les comptes de dépôt et la carte de crédit. BMO n'a pas encore de format reconnu par l'application : la détection générique lit la plupart des exports à montants signés ; si l'aperçu signale des entrées et des sorties inversées, utilisez « Inverser les signes ». Si le fichier n'est pas lu, envoyez-nous uniquement la ligne d'en-tête et une ou deux lignes aux valeurs fictives via Paramètres → Système → Envoyer un feedback. Ne collez jamais un numéro de compte, un solde ni une transaction réelle : la rétroaction est un message texte envoyé à un serveur, c'est la seule exception au fonctionnement local de l'application."
|
"note": "L'historique téléchargeable est limité à 123 jours au maximum : exportez chaque mois. Non vérifié : une Mastercard n'offrirait qu'environ trois mois plus les transactions non facturées ; les prêts, hypothèques et marges de crédit ne s'exporteraient pas (relevés PDF seulement, conservés 7 ans) ; les colonnes différeraient entre les comptes de dépôt et la carte de crédit. BMO n'est pas encore reconnu par son nom, mais la détection générique lit ses exports, des comptes de dépôt comme de la Mastercard : pour la Mastercard, elle retient la date de la transaction, pas celle de l'inscription au relevé. À la première configuration d'une source, le sens des montants est deviné d'après la majorité des premières lignes du fichier (les vingt premières) : si elles comptent plus d'entrées que de sorties (un compte épargne qui reçoit surtout des dépôts, un relevé Mastercard composé surtout de paiements et de remboursements), le fichier sort inversé. Le récapitulatif de l'aperçu le montre ; « Inverser les signes » corrige alors l'import, et la correction est enregistrée avec la source. Si le fichier n'est pas lu, envoyez-nous uniquement la ligne d'en-tête et une ou deux lignes aux valeurs fictives via Paramètres → Système → Envoyer un feedback. Ne collez jamais un numéro de compte, un solde ni une transaction réelle : la rétroaction est un message texte envoyé à un serveur, c'est la seule exception au fonctionnement local de l'application."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tips": [
|
"tips": [
|
||||||
|
|
|
||||||
|
|
@ -190,20 +190,29 @@ function mapCorpusRow(
|
||||||
/** The shape `autoDetectConfig` returns: a format minus the encoding. */
|
/** The shape `autoDetectConfig` returns: a format minus the encoding. */
|
||||||
type DetectedConfig = NonNullable<ReturnType<typeof autoDetectConfig>>;
|
type DetectedConfig = NonNullable<ReturnType<typeof autoDetectConfig>>;
|
||||||
|
|
||||||
|
/** `parseContentEndToEnd` on a corpus fixture. */
|
||||||
|
function parseFixtureEndToEnd(
|
||||||
|
name: CsvFixtureName,
|
||||||
|
configure?: (config: DetectedConfig) => DetectedConfig
|
||||||
|
) {
|
||||||
|
return parseContentEndToEnd(readCsvFixture(name), name, configure);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full pipeline: raw file text -> signed amounts, as the wizard runs it.
|
* Full pipeline: raw file text -> signed amounts, as the wizard runs it.
|
||||||
*
|
*
|
||||||
* `configure` rewrites the detected configuration before anything is read, so a
|
* `configure` rewrites the detected configuration before anything is read, so a
|
||||||
* correction the user makes in the preview — the sign flip (#329) — can be
|
* correction the user makes in the preview — the sign flip (#329) — can be
|
||||||
* replayed over the whole file exactly as the wizard replays it.
|
* replayed over the whole file exactly as the wizard replays it. `label` only
|
||||||
|
* names the file in a failure.
|
||||||
*/
|
*/
|
||||||
function parseFixtureEndToEnd(
|
function parseContentEndToEnd(
|
||||||
name: CsvFixtureName,
|
rawContent: string,
|
||||||
|
label: string,
|
||||||
configure?: (config: DetectedConfig) => DetectedConfig
|
configure?: (config: DetectedConfig) => DetectedConfig
|
||||||
) {
|
) {
|
||||||
const rawContent = readCsvFixture(name);
|
|
||||||
const detected = autoDetectConfig(rawContent);
|
const detected = autoDetectConfig(rawContent);
|
||||||
if (!detected) throw new Error(`autoDetectConfig returned null for ${name}`);
|
if (!detected) throw new Error(`autoDetectConfig returned null for ${label}`);
|
||||||
const cfg = configure ? configure(detected) : detected;
|
const cfg = configure ? configure(detected) : detected;
|
||||||
const format = { ...cfg, encoding: "utf-8" };
|
const format = { ...cfg, encoding: "utf-8" };
|
||||||
|
|
||||||
|
|
@ -239,7 +248,11 @@ function recapOf(
|
||||||
name: CsvFixtureName,
|
name: CsvFixtureName,
|
||||||
configure?: (config: DetectedConfig) => DetectedConfig
|
configure?: (config: DetectedConfig) => DetectedConfig
|
||||||
) {
|
) {
|
||||||
const { rows } = parseFixtureEndToEnd(name, configure);
|
return recapOfRows(parseFixtureEndToEnd(name, configure).rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The preview recap of rows mapped by `parseContentEndToEnd`. */
|
||||||
|
function recapOfRows(rows: ReturnType<typeof parseContentEndToEnd>["rows"]) {
|
||||||
return summarizeParsedRows(
|
return summarizeParsedRows(
|
||||||
rows.map((r, rowIndex) =>
|
rows.map((r, rowIndex) =>
|
||||||
"error" in r
|
"error" in r
|
||||||
|
|
@ -921,6 +934,179 @@ describe("autoDetectConfig — description column read from the labels (#327)",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Issue #371 — the BMO Mastercard export, read by the generic dictionary
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// The user guide says generic detection reads BMO exports and keeps the
|
||||||
|
// transaction date, not the posting date, for the Mastercard; Max confirmed it
|
||||||
|
// on real exports on 2026-10-22. BMO has no bank signature yet (#488), so these
|
||||||
|
// cases pin the claim on the real header row of the Mastercard export, labels
|
||||||
|
// only. Every row value below is invented, the date format included.
|
||||||
|
|
||||||
|
const BMO_MASTERCARD_HEADER =
|
||||||
|
"Article no,Carte no,Date de la transaction,Date de l'inscription au relevé,Montant de la transaction,Description";
|
||||||
|
|
||||||
|
/** One invented row: transaction date, posting date, amount as written, merchant. */
|
||||||
|
type BmoMastercardRow = readonly [string, string, string, string];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Mastercard export laid out like BMO's. Two invented card numbers alternate,
|
||||||
|
* so the card column is a numeric candidate that must never be read as the
|
||||||
|
* amount.
|
||||||
|
*/
|
||||||
|
function bmoMastercard(rows: readonly BmoMastercardRow[]): string {
|
||||||
|
return withHeader(
|
||||||
|
BMO_MASTERCARD_HEADER,
|
||||||
|
rows.map(([date, posted, amount, merchant], i) => {
|
||||||
|
const card = i % 2 === 0 ? "1111" : "2222";
|
||||||
|
return `${i + 1},${card},${date},${posted},${amount},${merchant}`;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Purchases written as positive amounts, the card payment written negative. */
|
||||||
|
const BMO_PURCHASES_POSITIVE: readonly BmoMastercardRow[] = [
|
||||||
|
["2026-10-01", "2026-10-02", "45.67", "EPICERIE FICTIVE"],
|
||||||
|
["2026-10-03", "2026-10-06", "12.50", "CAFE FICTIF"],
|
||||||
|
["2026-10-05", "2026-10-07", "-200.00", "PAIEMENT FICTIF"],
|
||||||
|
["2026-10-08", "2026-10-09", "89.99", "PHARMACIE FICTIVE"],
|
||||||
|
["2026-10-12", "2026-10-13", "23.10", "LIBRAIRIE FICTIVE"],
|
||||||
|
];
|
||||||
|
|
||||||
|
/** The same statement, every sign written the other way round. */
|
||||||
|
const BMO_PURCHASES_NEGATIVE: readonly BmoMastercardRow[] =
|
||||||
|
BMO_PURCHASES_POSITIVE.map(
|
||||||
|
([date, posted, amount, merchant]): BmoMastercardRow => [
|
||||||
|
date,
|
||||||
|
posted,
|
||||||
|
amount.startsWith("-") ? amount.slice(1) : `-${amount}`,
|
||||||
|
merchant,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
/** What reaches the database either way: purchases out, the payment in. */
|
||||||
|
const BMO_SIGNED_AMOUNTS = [-45.67, -12.5, 200, -89.99, -23.1];
|
||||||
|
|
||||||
|
function signedAmounts(rows: ReturnType<typeof parseContentEndToEnd>["rows"]) {
|
||||||
|
return rows.map((r) => ("error" in r ? r.error : r.amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("detectImportFormat — BMO Mastercard header, no bank signature yet (#371)", () => {
|
||||||
|
it("maps the transaction date, the amount and the description, never the posting date nor the card column", () => {
|
||||||
|
const content = bmoMastercard(BMO_PURCHASES_POSITIVE);
|
||||||
|
const outcome = detectImportFormat(content);
|
||||||
|
if (outcome.status !== "ok") {
|
||||||
|
throw new Error(`bmo-mastercard: detection returned ${outcome.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read by the generic dictionary; the expectation becomes "bmo" with #488.
|
||||||
|
expect(outcome.bank).toBeNull();
|
||||||
|
expect(outcome.config.hasHeader).toBe(true);
|
||||||
|
expect(outcome.config.skipLines).toBe(0);
|
||||||
|
expect(outcome.config.amountMode).toBe("single");
|
||||||
|
expect(outcome.config.columnMapping).toEqual({
|
||||||
|
date: 2,
|
||||||
|
amount: 4,
|
||||||
|
description: 5,
|
||||||
|
});
|
||||||
|
expect(outcome.score.totalRows).toBe(5);
|
||||||
|
expect(outcome.score.readRows).toBe(outcome.score.totalRows);
|
||||||
|
|
||||||
|
const { rows } = parseContentEndToEnd(content, "bmo-mastercard");
|
||||||
|
// The transaction date reaches the row, never the posting date.
|
||||||
|
expect(rows.map((r) => ("error" in r ? r.error : r.date))).toEqual(
|
||||||
|
BMO_PURCHASES_POSITIVE.map(([date]) => date)
|
||||||
|
);
|
||||||
|
expect(rows.map((r) => ("error" in r ? r.error : r.description))).toEqual(
|
||||||
|
BMO_PURCHASES_POSITIVE.map(([, , , merchant]) => merchant)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reads purchases as outflows and the payment as an inflow, whichever way the export signs them", () => {
|
||||||
|
expect(
|
||||||
|
autoDetectConfig(bmoMastercard(BMO_PURCHASES_POSITIVE))!.signConvention
|
||||||
|
).toBe("positive_expense");
|
||||||
|
expect(
|
||||||
|
autoDetectConfig(bmoMastercard(BMO_PURCHASES_NEGATIVE))!.signConvention
|
||||||
|
).toBe("negative_expense");
|
||||||
|
|
||||||
|
for (const statement of [BMO_PURCHASES_POSITIVE, BMO_PURCHASES_NEGATIVE]) {
|
||||||
|
const { rows } = parseContentEndToEnd(
|
||||||
|
bmoMastercard(statement),
|
||||||
|
"bmo-mastercard"
|
||||||
|
);
|
||||||
|
expect(signedAmounts(rows)).toEqual(BMO_SIGNED_AMOUNTS);
|
||||||
|
const recap = recapOfRows(rows);
|
||||||
|
expect(recap.outflowCount).toBe(4);
|
||||||
|
expect(recap.inflowCount).toBe(1);
|
||||||
|
expect(recap.errorCount).toBe(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reads a statement with more payments than purchases backwards, as the guide warns, until the flip", () => {
|
||||||
|
// `detectSingleAmount` guesses the convention from the majority of rows:
|
||||||
|
// three payments and refunds against one purchase tip it the wrong way.
|
||||||
|
const content = bmoMastercard([
|
||||||
|
["2026-10-01", "2026-10-02", "-200.00", "PAIEMENT FICTIF"],
|
||||||
|
["2026-10-03", "2026-10-06", "-15.00", "REMBOURSEMENT FICTIF"],
|
||||||
|
["2026-10-05", "2026-10-07", "-50.00", "SECOND PAIEMENT FICTIF"],
|
||||||
|
["2026-10-08", "2026-10-09", "45.67", "EPICERIE FICTIVE"],
|
||||||
|
]);
|
||||||
|
expect(autoDetectConfig(content)!.signConvention).toBe("negative_expense");
|
||||||
|
|
||||||
|
const backwards = parseContentEndToEnd(content, "bmo-mostly-payments");
|
||||||
|
expect(signedAmounts(backwards.rows)).toEqual([-200, -15, -50, 45.67]);
|
||||||
|
expect(recapOfRows(backwards.rows).inflowCount).toBe(1);
|
||||||
|
|
||||||
|
const repaired = parseContentEndToEnd(
|
||||||
|
content,
|
||||||
|
"bmo-mostly-payments",
|
||||||
|
flipped
|
||||||
|
);
|
||||||
|
expect(signedAmounts(repaired.rows)).toEqual([200, 15, 50, -45.67]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("guesses the sign from the first twenty rows only, as the guide says", () => {
|
||||||
|
// The same 25 rows, 14 purchases and 11 payments, in two orders. Detection
|
||||||
|
// samples the first twenty data rows (`sampleRows`), so the order alone
|
||||||
|
// decides: payments first, eleven of those twenty are inflows and the file
|
||||||
|
// reads backwards although the whole of it holds more outflows.
|
||||||
|
const row = (i: number, amount: string, merchant: string): BmoMastercardRow => [
|
||||||
|
`2026-09-${String(i + 1).padStart(2, "0")}`,
|
||||||
|
`2026-09-${String(i + 2).padStart(2, "0")}`,
|
||||||
|
amount,
|
||||||
|
merchant,
|
||||||
|
];
|
||||||
|
const payments = Array.from({ length: 11 }, (_, i) =>
|
||||||
|
row(i, `-${100 + i}.00`, `PAIEMENT FICTIF ${i + 1}`)
|
||||||
|
);
|
||||||
|
const purchases = Array.from({ length: 14 }, (_, i) =>
|
||||||
|
row(11 + i, `${10 + i}.25`, `ACHAT FICTIF ${i + 1}`)
|
||||||
|
);
|
||||||
|
|
||||||
|
const paymentsFirst = bmoMastercard([...payments, ...purchases]);
|
||||||
|
expect(autoDetectConfig(paymentsFirst)!.signConvention).toBe(
|
||||||
|
"negative_expense"
|
||||||
|
);
|
||||||
|
const backwards = recapOfRows(
|
||||||
|
parseContentEndToEnd(paymentsFirst, "bmo-payments-first").rows
|
||||||
|
);
|
||||||
|
expect(backwards.inflowCount).toBe(14);
|
||||||
|
expect(backwards.outflowCount).toBe(11);
|
||||||
|
|
||||||
|
const purchasesFirst = bmoMastercard([...purchases, ...payments]);
|
||||||
|
expect(autoDetectConfig(purchasesFirst)!.signConvention).toBe(
|
||||||
|
"positive_expense"
|
||||||
|
);
|
||||||
|
const forwards = recapOfRows(
|
||||||
|
parseContentEndToEnd(purchasesFirst, "bmo-purchases-first").rows
|
||||||
|
);
|
||||||
|
expect(forwards.outflowCount).toBe(14);
|
||||||
|
expect(forwards.inflowCount).toBe(11);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("autoDetectConfig — degenerate input (#326)", () => {
|
describe("autoDetectConfig — degenerate input (#326)", () => {
|
||||||
it("returns null on content with fewer than two non-empty lines", () => {
|
it("returns null on content with fewer than two non-empty lines", () => {
|
||||||
expect(autoDetectConfig("")).toBeNull();
|
expect(autoDetectConfig("")).toBeNull();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue