Fixed sepa import scripts
This commit is contained in:
@@ -17,7 +17,6 @@ foreach(ContractModel::searchActive([]) as $contract) {
|
|||||||
$owner = $contract->owner;
|
$owner = $contract->owner;
|
||||||
$billingaddress = $contract->billingaddress;
|
$billingaddress = $contract->billingaddress;
|
||||||
|
|
||||||
if($billingaddress->last_invcice_date) continue;
|
|
||||||
if($billingaddress->billing_type != "sepa") continue;
|
if($billingaddress->billing_type != "sepa") continue;
|
||||||
if(!$billingaddress->fibu_account_number) continue;
|
if(!$billingaddress->fibu_account_number) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ define("INTERNAL_USER_USERNAME", $me->username);
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
//foreach(AddressModel::search(["customer_number" => true, "billing_type" => "sepa"]) as $address) {
|
//foreach(AddressModel::search(["customer_number" => true, "billing_type" => "sepa"]) as $address) {
|
||||||
foreach(AddressModel::search(["fibu_account_number" => true, "billing_type" => "sepa"]) as $address) {
|
foreach(AddressModel::search(["fibu_account_number" => true, "billing_type" => "sepa"]) as $address) {
|
||||||
//if($address->sepa_date) continue;
|
if($address->sepa_date && $address->last_invoice_date) continue;
|
||||||
$bill = IvtBillModel::getFirst(["cid" => $address->customer_number]);
|
|
||||||
|
$bill = IvtBillModel::getFirst(["cid" => $address->customer_number, "iban" => true, "bic" => true]);
|
||||||
if(!$bill) continue;
|
if(!$bill) continue;
|
||||||
|
|
||||||
if(!trim($bill->IBAN) || !trim($bill->BIC)) continue;
|
if(!trim($bill->IBAN) || !trim($bill->BIC)) continue;
|
||||||
|
|
||||||
if(!$bill->date_outgoing) {
|
if(!$bill->date_outgoing) {
|
||||||
echo "date outgoing fehlt im ivt: ".$address->customer_number."\n";
|
echo "date outgoing fehlt im ivt: ".$address->customer_number."\n";
|
||||||
continue;
|
continue;
|
||||||
@@ -37,18 +37,21 @@ foreach(AddressModel::search(["fibu_account_number" => true, "billing_type" => "
|
|||||||
echo "Konnte Datum nicht umwandeln\n";
|
echo "Konnte Datum nicht umwandeln\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_bill = IvtBillModel::getLast(["cid" => $address->customer_number]);
|
$last_bill = IvtBillModel::getLast(["cid" => $address->customer_number, "iban" => true, "bic" => true]);
|
||||||
if(!$last_bill) continue;
|
if(!$last_bill) continue;
|
||||||
$last_date = new DateTime($last_bill->date_outgoing);
|
$last_date = new DateTime($last_bill->date_outgoing);
|
||||||
$last_invoice_date = $last_date->getTimestamp();
|
$last_invoice_date = $last_date->getTimestamp();
|
||||||
echo "last invoice date: $last_invoice_date ".$last_bill->date_outgoing."\n";
|
//echo "last invoice date: $last_invoice_date ".$last_bill->date_outgoing."\n";
|
||||||
|
|
||||||
if(!$address->sepa_date) {
|
if(!$address->sepa_date) {
|
||||||
$address->sepa_date = $sepa_date;
|
$address->sepa_date = $sepa_date;
|
||||||
|
$address->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$address->last_invoice_date = $last_invoice_date;
|
if(!$address->last_invoice_date) {
|
||||||
$address->save();
|
$address->last_invoice_date = $last_invoice_date;
|
||||||
|
$address->save();
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user