Finished Contract Cancel

This commit is contained in:
Frank Schubert
2024-07-11 14:07:29 +02:00
parent 87f3708fe8
commit 3b35bd561e
3 changed files with 33 additions and 5 deletions

View File

@@ -135,6 +135,33 @@ class ContractController extends mfBaseController
$this->redirect("Contract");
}
if($contract->finish_date) {
$today = new DateTime();
$tomorrow = clone($today);
$tomorrow->modify("+1 day");
$finish_date = new DateTime("@".$contract->finish_date);
$finish_date->setTimezone(new DateTimeZone("Europe/Vienna"));
$period_end_date = clone($finish_date);
$period_end_date->modify("+".$contract->contract_term." months");
while($period_end_date->format("Y-m-d") <= $today->format("Y-m-d")) {
$period_end_date = $finish_date->modify("+".$contract->billing_period." months");
}
$period_end_date->modify("-1 day");
$next_billing_period = clone($finish_date);
$next_billing_period->modify("+".$contract->billing_period." months");
while($next_billing_period->format("Y-m-d") <= $today->format("Y-m-d")) {
$next_billing_period->modify("+".$contract->billing_period." months");
}
$next_billing_period->modify("-1 day");
$this->layout()->set("tomorrow", $tomorrow);
$this->layout()->set("term_end_date", $period_end_date);
$this->layout()->set("period_end_date", $next_billing_period);
}
$this->layout()->set("contract", $contract);
}