updated Address filter
This commit is contained in:
151
scripts/fibu-check/compare-addresses-from-fibu.php
Normal file
151
scripts/fibu-check/compare-addresses-from-fibu.php
Normal file
@@ -0,0 +1,151 @@
|
||||
#!/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 = "Kontaktliste.csv";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$l = 0;
|
||||
while($csv = fgetcsv($input)) {
|
||||
$l++;
|
||||
if($l == 1) continue;
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//var_dump($csv);exit;
|
||||
|
||||
$fibu_account_number = trim($csv[1]);
|
||||
$fibu_supplier_number = trim($csv[3]);
|
||||
|
||||
$lastname = trim($csv[4]);
|
||||
$firstname = trim($csv[5]);
|
||||
$company = trim($csv[6]);
|
||||
|
||||
$street = trim($csv[7]);
|
||||
$zip = trim($csv[8]);
|
||||
$city = trim($csv[9]);
|
||||
$country = trim($csv[10]);
|
||||
|
||||
$uid = strtoupper(trim($csv[11]));
|
||||
$email = trim($csv[12]);
|
||||
|
||||
$iban = strtoupper(trim($csv[13]));
|
||||
$bic = strtoupper(trim($csv[14]));
|
||||
|
||||
|
||||
if(!$fibu_account_number && !$fibu_supplier_number) {
|
||||
echo "invalid line: ".implode(", ", $csv)."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$address = false;
|
||||
$supplier = false;
|
||||
|
||||
if($fibu_account_number) {
|
||||
$address = AddressModel::getFirst(["fibu_account_number" => $fibu_account_number]);
|
||||
if(!$address) {
|
||||
echo "Kunde $fibu_account_number ($company $firstname $lastname) missing in thetool\n";
|
||||
}
|
||||
if(!$address->fibu_primary_account) {
|
||||
$primary = AddressModel::getFirst(["fibu_account_number" => $fibu_account_number, "fibu_primary_account" => 1]);
|
||||
if($primary) $address = $primary;
|
||||
}
|
||||
}
|
||||
|
||||
if($fibu_supplier_number) {
|
||||
$supplier = AddressModel::getFirst(["fibu_supplier_number" => $fibu_supplier_number]);
|
||||
if(!$supplier) {
|
||||
echo "Lieferant $fibu_supplier_number ($company $firstname $lastname) missing in thetool\n";
|
||||
|
||||
$supplier = AddressModel::create([
|
||||
"fibu_supplier_number" => $fibu_supplier_number,
|
||||
"company" => $company,
|
||||
"lastname" => $lastname,
|
||||
"firstname" => $firstname,
|
||||
"street" => $street,
|
||||
"zip" => $zip,
|
||||
"city" => $city,
|
||||
"country" => $country,
|
||||
"uid" => $uid,
|
||||
"email" => $email,
|
||||
"phone" => "",
|
||||
"fax" => "",
|
||||
"mobile" => "",
|
||||
"create_by" => 1,
|
||||
"edit_by" => 1
|
||||
]);
|
||||
if(!$supplier->save()) {
|
||||
die("Error saving supplier $fibu_supplier_number\n");
|
||||
}
|
||||
//var_dump($supplier);exit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($supplier) $address = $supplier;
|
||||
if(!$address) continue;
|
||||
|
||||
// check UID
|
||||
if($uid && $address->uid != $uid) {
|
||||
echo "UID weicht ab: ".$address->uid." vs. $uid ($fibu_account_number $fibu_supplier_number)\n";
|
||||
$address->uid = $uid;
|
||||
if($fibu_supplier_number != 330189) {
|
||||
$address->save();
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
// check bankdata
|
||||
|
||||
$a_iban = strtoupper(trim($address->bank_account_iban));
|
||||
$a_bic = strtoupper(trim($address->bank_account_bic));
|
||||
|
||||
if($supplier) {
|
||||
if(!$iban || !$bic) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$a_iban && !$a_bic) {
|
||||
echo "Bankdaten im tool fehlen\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$ibans = explode("\n", $iban);
|
||||
$bics = explode("\n", $bic);
|
||||
|
||||
if($ibans) {
|
||||
foreach($ibans as $c => $ib) {
|
||||
if(!array_key_exists($c, $bics)) continue;
|
||||
if($ib == $a_iban && $bics[$c] == $a_bic) {
|
||||
echo "Bankdaten in array gefunden\n";
|
||||
continue 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(($iban && $bic) && ($iban != $a_iban || $bic != $a_bic)) {
|
||||
echo "Bankdaten weichen ab (account: $fibu_account_number, supplier: $fibu_supplier_number) thetool iban/bic: $a_iban/$a_bic vs. $iban/$bic\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
74
scripts/fibu-check/compare-bankdata.php
Normal file
74
scripts/fibu-check/compare-bankdata.php
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/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 = "bankdaten-liste.csv";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$l = 0;
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
$l++;
|
||||
if($l == 1) continue;
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//var_dump($csv);exit;
|
||||
|
||||
$fibu_supplier_number = trim($csv[0]);
|
||||
$iban = trim($csv[1]);
|
||||
|
||||
$supplier = AddressModel::getFirst(["fibu_supplier_number" => $fibu_supplier_number]);
|
||||
if(!$supplier) {
|
||||
echo "Supplier not found $fibu_supplier_number\n";
|
||||
}
|
||||
|
||||
echo $supplier->getCompanyOrName()."\n";
|
||||
|
||||
$result = IbanValidator::validate($iban);
|
||||
if(is_array($result) && $result) {
|
||||
var_dump($result);
|
||||
|
||||
if(!$result["iban_correct"]) {
|
||||
echo "IBAN incorrect: $iban\n";
|
||||
continue;
|
||||
}
|
||||
if($result["iban_sus"] && $result["iban_sus"] != "www") {
|
||||
echo "IBAN suspicious: $iban\n";
|
||||
}
|
||||
|
||||
if(is_array($result["bic"]) && count($result["bic"])) {
|
||||
$bic = array_shift($result["bic"]);
|
||||
|
||||
if($supplier->bank_account_iban != $iban || $supplier->bank_account_bic != $bic) {
|
||||
$supplier->bank_account_iban = $iban;
|
||||
$supplier->bank_account_bic = $bic;
|
||||
$supplier->save();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
echo "Bic nicht gefunden: $iban\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/fibu-check/files/.~lock.Kontaktliste.csv#
Normal file
1
scripts/fibu-check/files/.~lock.Kontaktliste.csv#
Normal file
@@ -0,0 +1 @@
|
||||
,fronk,fronk-nb,23.01.2024 21:03,file:///home/fronk/.config/libreoffice/4;
|
||||
6269
scripts/fibu-check/files/Kontaktliste.csv
Normal file
6269
scripts/fibu-check/files/Kontaktliste.csv
Normal file
File diff suppressed because it is too large
Load Diff
36
scripts/fibu-check/files/bankdaten-liste.csv
Normal file
36
scripts/fibu-check/files/bankdaten-liste.csv
Normal file
@@ -0,0 +1,36 @@
|
||||
Worxx Fibukonto Lieferant;IBAN
|
||||
330083;AT153846000010360287
|
||||
330025;AT126000000007501818
|
||||
330139;AT253800000000018036
|
||||
330197;AT422081507000000500
|
||||
330012;AT682081500041151259
|
||||
330028;AT173807100000001917
|
||||
330022;DE46100400000592222400
|
||||
330051;AT503620000000258707
|
||||
330091;AT963400000000026864
|
||||
330042;CZ2803000000000206315868
|
||||
330085;AT033800000000836239
|
||||
330086;AT653800000000050005
|
||||
330029;AT141500000711137802
|
||||
330211;
|
||||
330071;AT911100002883352300
|
||||
330011;AT331200010002969961
|
||||
330102;AT451100002883040400
|
||||
330075;AT023818700000047100
|
||||
330077;AT453818700000024307
|
||||
330004;AT391200050660059006
|
||||
330027;AT373837400000000042
|
||||
330176;AT692081527300008888
|
||||
330062;AT883805600000072785
|
||||
330260;AT313807500005505037
|
||||
330064;AT191200052496481505
|
||||
330038;DE08741400480351857800
|
||||
330237;AT055600021253030655
|
||||
330271;AT173800000005190996
|
||||
330100;AT402081500001852698
|
||||
330063;AT724501000004101051
|
||||
330110;
|
||||
330060;AT263818700000196048
|
||||
330296;
|
||||
330268;AT871952000200553030
|
||||
330093;AT704232030054360002
|
||||
|
Reference in New Issue
Block a user