#!/usr/bin/php id); $finish_date_from = new DateTime("2024-05-31 22:00:00"); $finish_date_to = new DateTime("2024-06-01 02:00:00"); $finish_date = new DateTime("2024-06-01 00:00:00"); $cms = 0; $cmss = 0; $cys = 0; foreach(ContractModel::search(["finish_date" => $finish_date->getTimestamp()]) as $contract) { if($contract->billing_period == 1 && $contract->price > 0.00000) { $cms += $contract->price; } if($contract->price_setup && $contract->price_setup > 0.00000) { $cmss += $contract->price_setup; } } $First = new DateTime("2023-05-31 22:00:00"); //$First = new DateTime("2024-06-09 00:00:00"); $Last = new DateTime("2024-06-01 00:00:00"); foreach(ContractModel::search(["billing_period" => 12]) as $contract) { $fdate = new DateTime("@".$contract->finish_date); $y = $fdate->format("Y"); $m = $fdate->format("m"); $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 == $Last->getTimestamp()) { $cys += $contract->price; } } $cts = $cms + $cys + $cmss; echo "Contract Monthly Sum: $cms\n"; echo "Contract Setup Sum: $cmss\n"; echo "Contract Yearly Sum: $cys\n"; echo "--------------------------------------\n"; echo "Contract Total Sum: $cts\n"; echo "======================================\n"; $ims = 0; $iys = 0; foreach(IvtCustomerProductModel::search(["lastdate" => '2024-06-10']) as $ivt_contract) { $product = $ivt_contract->product; if($product->interval == 0) { $ims += $product->price; } elseif($product->interval == 1 && $ivt_contract->lastdate == "2024-06-10") { $iys += $product->price; } } $its = $ims + $iys; echo "\n"; echo "Ivt product_customer Monthly Sum: $ims\n"; echo "Ivt product_customer Yearly Sum: $iys\n"; echo "--------------------------------------\n"; echo "Ivt product_customer Total Sum: $its\n"; echo "======================================\n"; $ibs = 0; 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; } } //echo "\n"; echo "Ivt Bills Total Sum: $ibs\n"; echo "======================================\n"; $cid = $ibs - $cts; echo "Diff thetool <-> ivt Bills: ".round($cid, 4)."\n"; $gsm = 0; $gsy = 0; foreach(ContractModel::search(["price<" => 0, "finish_date" => $finish_date->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";