InvoiceFile WIP 2024-07-09
This commit is contained in:
79
scripts/fibu-check/test-bmd-export-sepa-data.php
Normal file
79
scripts/fibu-check/test-bmd-export-sepa-data.php
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
$folder = __DIR__."/files/";
|
||||
$csvname = "tt-rech-export-bmd-2024-07-09_19-42-04.csv";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$i = 0;
|
||||
$l = 0;
|
||||
while($csv = fgetcsv($input, false, ";")) {
|
||||
$l++;
|
||||
if($l == 1) continue;
|
||||
|
||||
if(!trim($csv[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fibu_account_number = trim($csv[1]);
|
||||
$text = trim($csv[11]);
|
||||
$iban = strtoupper(trim($csv[13]));
|
||||
$bic = strtoupper(trim($csv[14]));
|
||||
|
||||
if(!$iban || !$bic) continue;
|
||||
|
||||
$customer_number = false;
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/\[(\d+)\]/', $text, $m)) {
|
||||
if(count($m)) {
|
||||
$customer_number = $m[1];
|
||||
}
|
||||
}
|
||||
|
||||
if(!$customer_number) {
|
||||
die("Konnte Kundennummer nicht extrahieren\n");
|
||||
}
|
||||
|
||||
/*if(in_array($customer_number, [3171])) {
|
||||
continue;
|
||||
}
|
||||
echo "$customer_number\n";
|
||||
*/
|
||||
$ivt_customer = new IvtCustomer($customer_number);
|
||||
if(!$ivt_customer->id) {
|
||||
die("Kunde $customer_number nicht im ivt gefunden\n");
|
||||
}
|
||||
|
||||
|
||||
$ivt_iban = strtoupper(str_replace(" ","", $ivt_customer->IBAN));
|
||||
$ivt_bic = strtoupper(str_replace(" ","", $ivt_customer->BIC));
|
||||
|
||||
if($ivt_iban != $iban) {
|
||||
echo "$customer_number | iban: $iban <> $ivt_iban\n";
|
||||
}
|
||||
if($ivt_bic != $bic) {
|
||||
echo "$customer_number | bic: $bic <> $ivt_bic\n";
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "\n$i Zeilen verarbeitet\n";
|
||||
117
scripts/fibu-check/test-bmd-sepafile-sepa-data.php
Normal file
117
scripts/fibu-check/test-bmd-sepafile-sepa-data.php
Normal file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
$folder = __DIR__."/files/";
|
||||
$csvname = "NTCS_Bankeinzug DT.xml";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = file_get_contents($filename);
|
||||
|
||||
$i = 0;
|
||||
$l = 0;
|
||||
|
||||
$in_tx = false;
|
||||
$rechnum = false;
|
||||
$iban = false;
|
||||
$bic = false;
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach(explode("\n", $input) as $line) {
|
||||
$line = trim($line);
|
||||
|
||||
if(preg_match('@</DrctDbtTxInf>@i', $line, $m)) {
|
||||
$in_tx = false;
|
||||
$rechnum = false;
|
||||
$iban = false;
|
||||
$bic = false;
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$m = [];
|
||||
if(preg_match('@<DrctDbtTxInf>@i', $line, $m)) {
|
||||
$in_tx = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if($in_tx) {
|
||||
$m = [];
|
||||
if(preg_match('@<EndToEndId>([a-z0-9-]+)</EndToEndId>@i', $line, $m)) {
|
||||
$rechnum = $m[1];
|
||||
}
|
||||
|
||||
if(preg_match('@<BIC>([a-z0-9-]+)</BIC>@i', $line, $m)) {
|
||||
$bic = $m[1];
|
||||
}
|
||||
|
||||
if(preg_match('@<IBAN>([a-z0-9-]+)</IBAN>@i', $line, $m)) {
|
||||
$iban = $m[1];
|
||||
}
|
||||
|
||||
if($rechnum && $bic && $iban) {
|
||||
|
||||
if(!array_key_exists($rechnum, $data)) {
|
||||
$data[$rechnum] = [
|
||||
"iban" => $iban,
|
||||
"bic" => $bic
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
echo "$i input datensätze\n";
|
||||
exit;
|
||||
|
||||
$i = 0;
|
||||
foreach($data as $r => $d) {
|
||||
//echo "$r ".$d["iban"]." ".$d["bic"]."\n";
|
||||
|
||||
$m = [];
|
||||
if(!preg_match('/(RN2024-.+)/', $r, $m)) {
|
||||
die("error");
|
||||
}
|
||||
|
||||
$rechnum = $m[1];
|
||||
$sepa_iban = strtoupper(str_replace(" ","", $d["iban"]));
|
||||
$sepa_bic = strtoupper(str_replace(" ","", $d["bic"]));
|
||||
|
||||
$invoice = InvoiceModel::getFirst(["invoice_number" => $rechnum]);
|
||||
if(!$invoice) {
|
||||
die("$rechnum not found\n");
|
||||
}
|
||||
|
||||
$address = new Address($invoice->billingaddress_id);
|
||||
if(!$address) {
|
||||
die("not billingaddress\n");
|
||||
}
|
||||
$tiban = strtoupper(str_replace(" ","", $address->bank_account_iban));
|
||||
$tbic = strtoupper(str_replace(" ","", $address->bank_account_bic));
|
||||
|
||||
if($sepa_iban != $tiban) {
|
||||
echo "$rechnum | tool iban: $tiban <> $sepa_iban\n";
|
||||
}
|
||||
if($sepa_bic != $tbic) {
|
||||
echo "$rechnum | tool bic: $tbic <> $sepa_bic\n";
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
echo "$i sepa daten verglichen\n";
|
||||
Reference in New Issue
Block a user