Utilisateur·ice·s de Kresus

Import fichier OFX

Bonjour,
Merci et Bravo pour votre application.

Je voulais utiliser kresus à la place de linxo que j’utilise depuis quelques temps, et j’avais en tete de pouvoir importer les transactions de mes comptes dans kresus avec un fichier OFX puisque c’est disponible depuis quelques versions.
Et je viens de me heurter à un soucis :

[2022-01-14T14:29:07.112] [INFO] controllers/all - Parsing OFX file...
[2022-01-14T14:29:08.550] [ERROR] helpers - when importing data: Cannot read property 'ACCTID' of undefined
[2022-01-14T14:29:08.554] [INFO] helpers - TypeError: Cannot read property 'ACCTID' of undefined
    at Object.ofxToKresus (/home/user/app/node_modules/kresus/build/server/controllers/ofx.js:129:45)
    at importOFX_ (/home/user/app/node_modules/kresus/build/server/controllers/all.js:605:40)
    at Layer.handle [as handle_request] (/home/user/app/node_modules/kresus/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/user/app/node_modules/kresus/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/user/app/node_modules/kresus/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/user/app/node_modules/kresus/node_modules/express/lib/router/layer.js:95:5)
    at /home/user/app/node_modules/kresus/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/user/app/node_modules/kresus/node_modules/express/lib/router/index.js:335:12)
    at next (/home/user/app/node_modules/kresus/node_modules/express/lib/router/index.js:275:10)
    at app.use (/home/user/app/node_modules/kresus/build/server/index.js:90:9)
[2022-01-14T14:29:08.556] [ERROR] HTTP - POST /api/all/import/ofx - 500 (1503 ms)
[2022-01-14T14:40:09.618] [INFO] providers/woob - Calling woob: command version...
[2022-01-14T14:40:10.178] [INFO] providers/woob - exited with code 0.
[2022-01-14T14:40:10.178] [INFO] providers/woob - OK: woob exited normally with non-empty JSON content.
[2022-01-14T14:40:10.181] [INFO] HTTP - GET /api/instance/woob - 304 (563 ms)

En clair linxo de mets pas le champ ACCTID dans le fichier OFX lorsque l’on exporte depuis leur interface, probablement parce qu’on doit le faire sur chaque compte…

Pour vous aider dans le debug/dev voici un exemple de fichier que l’on peut avoir depuis linxo (il a été anonymisé)

<?xml version="1.0" encoding="utf-8"?>
<?OFX OFXHEADER="200" VERSION="202" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>
<OFX>
    <SIGNONMSGSRSV1>
        <SONRS>
            <STATUS>
                <CODE>0</CODE>
                <SEVERITY>INFO</SEVERITY>
            </STATUS>
            <DTSERVER>20220114144820.619</DTSERVER>
            <LANGUAGE>FRA</LANGUAGE>
        </SONRS>
    </SIGNONMSGSRSV1>
    <BANKMSGSRSV1>
        <STMTTRNRS>
            <TRNUID>ba309960-f35b-47e1-b7f8-0f113141fd4b</TRNUID>
            <STATUS>
                <CODE>0</CODE>
                <SEVERITY>INFO</SEVERITY>
            </STATUS>
            <STMTRS>
                <CURDEF>EUR</CURDEF>
                <BANKTRANLIST>
                    <DTSTART>20160428000000.000</DTSTART>
                    <DTEND>20210721000000.000</DTEND>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20210721000000.000</DTPOSTED>
                        <TRNAMT>-4533.57</TRNAMT>
                        <FITID>2293252777</FITID>
                        <NAME>Dolores sequi aspernatur</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20210429000000.000</DTPOSTED>
                        <TRNAMT>2963.53</TRNAMT>
                        <FITID>2286782428</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20200528000000.000</DTPOSTED>
                        <TRNAMT>-392.44</TRNAMT>
                        <FITID>1878910876</FITID>
                        <NAME>Eos repellat ea velit vitae occaecati</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20200429000000.000</DTPOSTED>
                        <TRNAMT>3926.03</TRNAMT>
                        <FITID>1877893969</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20190430000000.000</DTPOSTED>
                        <TRNAMT>367.15</TRNAMT>
                        <FITID>1842548482</FITID>
                        <NAME>Early Release</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20190426000000.000</DTPOSTED>
                        <TRNAMT>4256.47</TRNAMT>
                        <FITID>1825668481</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20180426000000.000</DTPOSTED>
                        <TRNAMT>3288.4</TRNAMT>
                        <FITID>1812068480</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20180126000000.000</DTPOSTED>
                        <TRNAMT>-14022.92</TRNAMT>
                        <FITID>18420548479</FITID>
                        <NAME>Dolores sequi aspernatur</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20170427000000.000</DTPOSTED>
                        <TRNAMT>2607.4</TRNAMT>
                        <FITID>1840528478</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20170427000000.000</DTPOSTED>
                        <TRNAMT>-930.83</TRNAMT>
                        <FITID>1840258477</FITID>
                        <NAME> Sed explicabo est qui.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20170316000000.000</DTPOSTED>
                        <TRNAMT>60.92</TRNAMT>
                        <FITID>1847858476</FITID>
                        <NAME>Animi similique et nisi ea asperiores dolore autem dolores.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20170220000000.000</DTPOSTED>
                        <TRNAMT>12517.04</TRNAMT>
                        <FITID>1842625475</FITID>
                        <NAME>Versement Par Cheque</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20160428000000.000</DTPOSTED>
                        <TRNAMT>-100.84</TRNAMT>
                        <FITID>1842145474</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20160428000000.000</DTPOSTED>
                        <TRNAMT>608.48</TRNAMT>
                        <FITID>1842968473</FITID>
                        <NAME> Sed explicabo est qui.</NAME>
                    </STMTTRN>
                </BANKTRANLIST>
            </STMTRS>
        </STMTTRNRS>
    </BANKMSGSRSV1>
</OFX>

Bonjour @kurt !

On pourrait imaginer générer un id s’il n’y en a aucun mais avant ça, si tu ajoutes toi-même champ avec la valeur que tu veux, est-ce que l’import fonctionne ?

non ca ne suffit pas.
Je suis allé voir la norme et il manque bcpde chose dans la réponse de linxo (me semble t’il)

J’ai l’impression qu’il manque tout le <BANKACCTFROM> + <AVAILBAL>

Et je confirme car
voici le fichier modifié et dont l’import fonctionne, j’y ai ajouté les deux champs ci dessus :

<?xml version="1.0" encoding="utf-8"?>
<?OFX OFXHEADER="200" VERSION="202" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>
<OFX>
    <SIGNONMSGSRSV1>
        <SONRS>
            <STATUS>
                <CODE>0</CODE>
                <SEVERITY>INFO</SEVERITY>
            </STATUS>
            <DTSERVER>20220114144820.619</DTSERVER>
            <LANGUAGE>FRA</LANGUAGE>
        </SONRS>
    </SIGNONMSGSRSV1>
    <BANKMSGSRSV1>
        <STMTTRNRS>
            <TRNUID>ba309960-f35b-47e1-b7f8-0f113141fd4b</TRNUID>
            <STATUS>
                <CODE>0</CODE>
                <SEVERITY>INFO</SEVERITY>
            </STATUS>
            <STMTRS>
                <BANKACCTFROM>
                    <BANKID>credit de ouf</BANKID>
                    <ACCTID>65464654</ACCTID>
                </BANKACCTFROM>
                <CURDEF>EUR</CURDEF>
                <BANKTRANLIST>
                    <DTSTART>20160428000000.000</DTSTART>
                    <DTEND>20210721000000.000</DTEND>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20210721000000.000</DTPOSTED>
                        <TRNAMT>-4533.57</TRNAMT>
                        <FITID>2293252777</FITID>
                        <NAME>Dolores sequi aspernatur</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20210429000000.000</DTPOSTED>
                        <TRNAMT>2963.53</TRNAMT>
                        <FITID>2286782428</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20200528000000.000</DTPOSTED>
                        <TRNAMT>-392.44</TRNAMT>
                        <FITID>1878910876</FITID>
                        <NAME>Eos repellat ea velit vitae occaecati</NAME>
                    </STMTTRN>
                    <STMTTRN>
                        <TRNTYPE>XFER</TRNTYPE>
                        <DTPOSTED>20200429000000.000</DTPOSTED>
                        <TRNAMT>3926.03</TRNAMT>
                        <FITID>1877893969</FITID>
                        <NAME>Aut enim rerum tempora officiis.</NAME>
                    </STMTTRN>
                    
                </BANKTRANLIST>

                <AVAILBAL>
                    <BALAMT>684654</BALAMT>
                    <DTASOF>1</DTASOF>
                </AVAILBAL>                
            </STMTRS>
        </STMTTRNRS>
    </BANKMSGSRSV1>
</OFX>