diff --git a/scripts/contract/check-bankdata-with-ivt.php b/scripts/contract/check-bankdata-with-ivt.php new file mode 100644 index 000000000..b8b2154a7 --- /dev/null +++ b/scripts/contract/check-bankdata-with-ivt.php @@ -0,0 +1,73 @@ +#!/usr/bin/php +price < 0) continue; + $contract_id = $contract->id; + $customer_number = $contract->owner->customer_number; + $owner_id = $contract->owner_id; + $billingaddress_id = $contract->billingaddress_id; + + if($billingaddress_id == $owner_id) { + $address = new Address($owner_id); + } else { + $address = new Address($billingaddress_id); + } + + $ivt_customer = new IvtCustomer($customer_number); + if(!$ivt_customer) { + var_dump($contract); + die("Ivt Kunde nicht gefunden: $customer_number\n"); + } + + + + $ivt_bill_type = ($ivt_customer->payment == 1) ? "invoice" : "sepa"; + $ivt_delivery = ($ivt_customer->paper_invoice == 1) ? "paper" : "email"; + $ivt_iban = strtoupper(trim(str_replace(" ","", $ivt_customer->IBAN))); + $ivt_bic = strtoupper(trim(str_replace(" ","", $ivt_customer->BIC))); + + $tool_iban = strtoupper(trim(str_replace(" ","", $address->bank_account_iban))); + $tool_bic = strtoupper(trim(str_replace(" ","", $address->bank_account_bic))); + + $error = false; + + + if($address->billing_type != $ivt_bill_type) { + $error = true; + echo "Customer $customer_number contract_id $contract_id [ivt type: $ivt_bill_type | tool: ".$address->billing_type."\n"; + } + if($address->billing_delivery != $ivt_delivery) { + $error = true; + echo "Customer $customer_number contract_id $contract_id [ivt delivery: $ivt_delivery | tool: ".($address->billing_delivery ? $address->billing_delivery : "paper")."\n"; + } + + if($address->billing_type == "sepa" || $ivt_bill_type == "sepa") { + if ($ivt_iban != $tool_iban) { + $error = true; + echo "Customer $customer_number contract_id $contract_id [ivt iban: $ivt_iban | tool: $tool_iban\n"; + } + if ($ivt_bic != $tool_bic) { + $error = true; + echo "Customer $customer_number contract_id $contract_id [ivt iban: $ivt_bic | tool: $tool_bic\n"; + } + } + + /*if($error) { + var_dump($ivt_customer);exit; + }*/ + + +} \ No newline at end of file