small changes to invoice & removed debugging
This commit is contained in:
@@ -94,48 +94,43 @@ class BillingController extends mfBaseController {
|
||||
protected function importContractsAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$today = new DateTime("now");
|
||||
$today->setTime(0,0,0);
|
||||
|
||||
//$tomorrow = new DateTime("tomorrow");
|
||||
//$tomorrow->setTime(0,0,0);
|
||||
|
||||
$i = 0;
|
||||
$v = 0;
|
||||
|
||||
//$yearly_not_before = new DateTime("2023-06-01");
|
||||
$today = new DateTime("now");
|
||||
$today->setTime(0,0,0);
|
||||
|
||||
$now_year = date("Y");
|
||||
$now_month = date("m");
|
||||
$now_day = date("d");
|
||||
|
||||
//$now_year = 2024;
|
||||
//$now_month = 6;
|
||||
//$now_day = 3; // XXX for debugging only, must be removed
|
||||
|
||||
// XXX only for 1st Billing after IVT Import
|
||||
//$yearly_not_before = new DateTime("$now_year-$now_month-01");
|
||||
$yearly_not_before = new DateTime("$now_year-06-01");
|
||||
$yearly_not_before = new DateTime("$now_year-$now_month-01");
|
||||
|
||||
$del = 0;
|
||||
// first delete all non-invoiced billing records
|
||||
/*foreach(BillingModel::search(["invoice_id" => null]) as $bill) {
|
||||
foreach(BillingModel::search(["invoice_id" => null]) as $bill) {
|
||||
$bill->delete();
|
||||
$del++;
|
||||
}*/
|
||||
}
|
||||
|
||||
$this->log->notice(__METHOD__.": $del Billing records deleted");
|
||||
//$stop = false;
|
||||
foreach(ContractModel::search(["owner_id" => 783, "finish_date<" => mktime(0,1,0,$now_month, $now_day, $now_year), "cancel_date" => null]) as $contract) {
|
||||
//while(!$stop) {
|
||||
//$stop = true;
|
||||
//$contract = new Contract(1475);
|
||||
|
||||
//var_dump($contract);exit;
|
||||
$contract_search = [
|
||||
"finish_date<" => mktime(2,0,0,$now_month, $now_day, $now_year),
|
||||
"cancel_date_null_or_gte" => mktime(0,0,0,$now_month, 1, $now_year)
|
||||
];
|
||||
|
||||
foreach(ContractModel::search($contract_search) as $contract) {
|
||||
$bill_month = $now_month;
|
||||
$bill_year = $now_year;
|
||||
//$bill_day = $now_day;
|
||||
$bill_date = new DateTime("$bill_year-$bill_month-01");
|
||||
//echo $bill_date->format("Y-m-d H:i:s")."<br>";
|
||||
|
||||
$monthly_bill_period_to = clone($bill_date);
|
||||
$monthly_bill_period_to->modify("last day of this month");
|
||||
|
||||
@@ -165,6 +160,7 @@ class BillingController extends mfBaseController {
|
||||
$cancel_date = false;
|
||||
if($contract->cancel_date) {
|
||||
$cancel_date = new DateTime("@".$contract->cancel_date);
|
||||
$cancel_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||
$cancel_date->setTime(0,0,0);
|
||||
if($cancel_date->format("Y") != $now_year || $cancel_date->format("m") != $now_month) {
|
||||
$cancel_date = false;
|
||||
@@ -301,9 +297,7 @@ class BillingController extends mfBaseController {
|
||||
$eday = $end_date->format("d");
|
||||
|
||||
if ($contract->price && ($sday > 1 || $cancel_date)) {
|
||||
// aliquoter preis
|
||||
$days = ($eday - $sday) + 1;
|
||||
|
||||
// Aliquoten Preis errechnen
|
||||
$first_of_period = clone $start_date;
|
||||
$first_of_period->modify("first day of this month");
|
||||
|
||||
@@ -379,7 +373,7 @@ class BillingController extends mfBaseController {
|
||||
$data["billing_period"] = $contract->billing_period;
|
||||
|
||||
$matchcode = $contract->matchcode;
|
||||
// if voice product and matchcode consists oh phonenumbers only, remove matchcode
|
||||
// if voice product and matchcode consists of phonenumbers only, remove matchcode
|
||||
if(array_key_exists("needs_number", $contract->product->attributes) && $contract->product->attributes["needs_number"] == 1 && preg_match('/^[0-9, ]+$]/', $matchcode)) {
|
||||
$matchcode = "";
|
||||
}
|
||||
@@ -416,8 +410,6 @@ class BillingController extends mfBaseController {
|
||||
/*
|
||||
* Create Voice Billing, if contract has voicenumbers
|
||||
*/
|
||||
|
||||
|
||||
$voicenumbers = VoicenumberModel::search(["contract_id" => $contract->id]);
|
||||
|
||||
if(count($voicenumbers)) {
|
||||
|
||||
Reference in New Issue
Block a user