Bockwurst2 / ynab_csv

convert ksk or comdirect csv to ynab
0 stars 0 forks source link

KSK CSV Export: Standard Dateiname? #1

Open torbengb opened 6 years ago

torbengb commented 6 years ago

Hallo Bockwurst! Ich hoffe du siehst diese Frage, denn sonst kann ich dich nicht erreichen. Ich bin dabei, die vielen YNAB Konvertoren zusammenzufassen: bank2ynab
-- Welche Bank genau ist mit "KSK" gemeint? Ist das allgemein "Kreissparkasse" oder eine bestimmte davon? -- Was ist der standardmäßige Dateiname von den CSV Exports?

Liebe Grüße, Ben

Bockwurst2 commented 6 years ago

Hi die Skripte sollte ich mal raus nehmen. Die sind nie Fertig geworden. Habs der einfachheit halber mit: https://github.com/mschindler83/fints-hbci-php gelöst. Das kann die Buchungen via HBCI abholen. Kann dir bei Gelegenheit und bedarf ein Skript schicken mit dem die Buchungen als YNAB fähige CSV ausgegeben werden.

torbengb commented 6 years ago

Ja bitte! Die Skripte oder noch besser eine echte (anonymisierte) input Datei wäre spitze, mit einem originalen Namen. Danke! LG Ben

On Sat, 3 Feb 2018, 11:07 Bockwurst2, notifications@github.com wrote:

Hi die Skripte sollte ich mal raus nehmen. Die sind nie Fertig geworden. Habs der einfachheit halber mit: https://github.com/mschindler83/fints-hbci-php gelöst. Das kann die Buchungen via HBCI abholen. Kann dir bei Gelegenheit und bedarf ein Skript schicken mit dem die Buchungen als YNAB fähige CSV ausgegeben werden.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Bockwurst2/ynab_csv/issues/1#issuecomment-362795361, or mute the thread https://github.com/notifications/unsubscribe-auth/AAxeXpB3Iwn0uipgdThyDpMCWJ2GfhI6ks5tRC_ygaJpZM4RqSx2 .

Bockwurst2 commented 6 years ago

Nicht schön aber tuts <?php

/ Nutzt https://github.com/mschindler83/fints-hbci-php und wandelt die Ausgaben in eine CSV um die in YNAB 4 eingelesen werden kann Übergabe parameter ist das Datum / require '../vendor/autoload.php';

use Fhp\FinTs; use Fhp\Model\StatementOfAccount\Statement; use Fhp\Model\StatementOfAccount\Transaction;

define('FHP_BANK_URL', 'https://banking-rp1.s-fints-pt-rp.de/fints30'); # HBCI / FinTS Url can be found here: https://www.hbci-zka.de/institute/institut_auswahl.htm (use the PIN/TAN URL) define('FHP_BANK_PORT', 443); # HBCI / FinTS Port can be found here: https://www.hbci-zka.de/institute/institut_auswahl.htm define('FHP_BANK_CODE', ''); # Your bank code / Bankleitzahl define('FHP_ONLINE_BANKING_USERNAME', ''); # Your online banking username / alias define('FHP_ONLINE_BANKING_PIN', ''); # Your online banking PIN (NOT! the pin of your bank card!)

$fints = new FinTs( FHP_BANK_URL, FHP_BANK_PORT, FHP_BANK_CODE, FHP_ONLINE_BANKING_USERNAME, FHP_ONLINE_BANKING_PIN );

$accounts = $fints->getSEPAAccounts();

$oneAccount = $accounts[0];

if(isset($argv[1])){ $from = new \DateTime($argv[1]); }else{ $from = new \DateTime('2017-01-20'); }

$to = new \DateTime(); $soa = $fints->getStatementOfAccount($oneAccount, $from, $to);

$list; $header=array("Date" ,"Payee" ,"Category" ,"Memo" ,"Outflow" ,"Inflow"); $list[]=$header;

foreach ($soa->getStatements() as $statement) { foreach ($statement->getTransactions() as $transaction) { unset($row); $ynab_date = $transaction->getValutaDate()->format('d/m/Y'); $row[] = $ynab_date; $row[] = $transaction->getName(); $row[] = ''; $row[] = $transaction->getBookingText().';'.$transaction->getDescription1();

    if ($transaction->getCreditDebit() == Transaction::CD_CREDIT)
    {       
        $row[] = '';
        $row[] = $transaction->getAmount();
    }else{
        $row[] = $transaction->getAmount();
        $row[] = '';
    }

    $list[]=$row;   

}

}

echo "Found " . count($soa->getStatements()) . ' statements.' . PHP_EOL;

$fp = fopen('/path_tosave/kontoauszug'.FHP_ONLINE_BANKINGUSERNAME. ''.date("Y.m.d").'.csv', 'w');

foreach ($list as $fields) { fputcsv($fp, $fields); }

fclose($fp);`