Added Sepa Mandats stuff
This commit is contained in:
@@ -16,28 +16,38 @@ define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$i = 0;
|
||||
foreach(AddressModel::search(["customer_number" => true, "billing_type" => "sepa"]) as $address) {
|
||||
if($address->sepa_date) continue;
|
||||
|
||||
//foreach(AddressModel::search(["customer_number" => true, "billing_type" => "sepa"]) as $address) {
|
||||
foreach(AddressModel::search(["fibu_account_number" => true, "billing_type" => "sepa"]) as $address) {
|
||||
//if($address->sepa_date) continue;
|
||||
$bill = IvtBillModel::getFirst(["cid" => $address->customer_number]);
|
||||
if(!$bill) continue;
|
||||
|
||||
|
||||
if(!trim($bill->IBAN) || !trim($bill->BIC)) continue;
|
||||
|
||||
|
||||
if(!$bill->date_outgoing) {
|
||||
echo "date outgoing fehlt im ivt: ".$address->customer_number."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$out_date = new DateTime($bill->date_outgoing);
|
||||
$sepa_date = $out_date->getTimestamp();
|
||||
echo "$sepa_date - ".$bill->date_outgoing."\n";
|
||||
echo "sepa date: $sepa_date - ".$bill->date_outgoing."\n";
|
||||
|
||||
if(!$sepa_date){
|
||||
echo "Konnte Datum nicht umwandeln\n";
|
||||
}
|
||||
|
||||
$address->sepa_date = $sepa_date;
|
||||
|
||||
$last_bill = IvtBillModel::getLast(["cid" => $address->customer_number]);
|
||||
if(!$last_bill) continue;
|
||||
$last_date = new DateTime($last_bill->date_outgoing);
|
||||
$last_invoice_date = $last_date->getTimestamp();
|
||||
echo "last invoice date: $last_invoice_date ".$last_bill->date_outgoing."\n";
|
||||
|
||||
if(!$address->sepa_date) {
|
||||
$address->sepa_date = $sepa_date;
|
||||
}
|
||||
|
||||
$address->last_invoice_date = $last_invoice_date;
|
||||
$address->save();
|
||||
$i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user