WIP Contract 2024-06-13

This commit is contained in:
Frank Schubert
2024-06-20 17:59:51 +02:00
parent 6e2e4f1962
commit 92724ca6b5
12 changed files with 549 additions and 89 deletions

View File

@@ -13,10 +13,13 @@ require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
define("INTERNAL_USER_ID", $me->id);
$finish_date_from = new DateTime("2024-05-31 22:00:00");
$finish_date_to = new DateTime("2024-06-01 23:59:59");
$cms = 0;
$cmss = 0;
$cys = 0;
foreach(ContractModel::getAll() as $contract) {
foreach(ContractModel::search(["finish_date>" => $finish_date_from->getTimestamp(), "finish_date<" => $finish_date_to->getTimestamp()]) as $contract) {
if($contract->billing_period == 1 && $contract->price > 0.00000) {
$cms += $contract->price;
}
@@ -27,9 +30,9 @@ foreach(ContractModel::getAll() as $contract) {
}
$First = new DateTime("2024-05-13 00:00:00");
$First = new DateTime("2024-05-31 22:00:00");
//$First = new DateTime("2024-06-09 00:00:00");
$Last = new DateTime("2024-06-12 23:59:59");
$Last = new DateTime("2024-06-01 06:00:00");
foreach(ContractModel::search(["billing_period" => 12]) as $contract) {
$fdate = new DateTime("@".$contract->finish_date);
@@ -38,7 +41,7 @@ foreach(ContractModel::search(["billing_period" => 12]) as $contract) {
$d = $fdate->format("d");
//if(($m == 5 && $d >= 11) || ($m == 6 && $d <= 10)) {
if($contract->finish_date >= $First->getTimestamp() && $contract->finish_date <= $Last->getTimestamp()) {
if($contract->finish_date >= $First->getTimestamp() && $contract->finish_date <= $Last->getTimestamp()) {
$cys += $contract->price;
}
}
@@ -53,11 +56,10 @@ echo "Contract Total Sum: $cts\n";
echo "======================================\n";
$ims = 0;
$iys = 0;
foreach(IvtCustomerProductModel::getAll() as $ivt_contract) {
foreach(IvtCustomerProductModel::search(["lastdate" => '2024-06-10']) as $ivt_contract) {
$product = $ivt_contract->product;
if($product->interval == 0) {
$ims += $product->price;
@@ -77,7 +79,7 @@ echo "======================================\n";
$ibs = 0;
foreach(IvtBillModel::search(['date_outgoing>' => "2024-06-01"]) as $ivt_bill) {
foreach(IvtBillModel::search(['date_outgoing' => "2024-06-10"]) as $ivt_bill) {
$positions = IvtBillPositionProductModel::search(["bid" => $ivt_bill->id]);
foreach($positions as $position) {
$ibs += $position->price;
@@ -89,4 +91,55 @@ echo "Ivt Bills Total Sum: $ibs\n";
echo "======================================\n";
$cid = $ibs - $cts;
echo "Diff thetool <-> ivt Bills: $cid\n";
echo "Diff thetool <-> ivt Bills: ".round($cid, 4)."\n";
$gsm = 0;
$gsy = 0;
foreach(ContractModel::search(["price<" => 0, "finish_date>" => $finish_date_from->getTimestamp(), "finish_date<" => $finish_date_to->getTimestamp()]) as $contract) {
if($contract->billing_period == 1) {
$gsm += $contract->price;
} elseif($contract->billing_period == 12) {
$gsy += $contract->price;
}
}
$gst = $gsm + $gsy;
echo "\n\n";
echo "Contract Credit monthly: $gsm\n";
echo "Contract Credit yearly: $gsy\n";
echo "--------------------------------------\n";
echo "Contract Credit Total: $gst\n";
echo "======================================\n";
$icm = 0;
foreach(IvtCustomerCreditingModel::search(['lastdate' => '2024-06-10']) as $ivt_credit) {
$product = $ivt_credit->crediting_product;
$icm += $product->price_excl;
}
$icm *= -1;
echo "IVT Credit Total: $icm\n";
echo "======================================\n";
$icbs = 0;
foreach(IvtCreditingModel::search(["date_outgoing" => "2024-06-10"]) as $ivt_credit) {
foreach(IvtCreditingPositionModel::search(["head_id" => $ivt_credit->id]) as $position) {
$icbs += $position->price_excl;
}
}
$icbs *= -1;
$cred_diff = $icbs - ($gsm + $gsy);
echo "IVT Credit Bill Total: $icbs\n";
echo "======================================\n";
echo "\n";
echo "Credit Diff thetool <-> ivt: ".round($cred_diff, 4)."\n";
echo "======================================\n";