Files
thetool/scripts/contract/test.php
2024-06-11 18:14:41 +02:00

93 lines
2.5 KiB
PHP

#!/usr/bin/php
<?php
require("../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
define("INTERNAL_USER_ID", $me->id);
$cms = 0;
$cmss = 0;
$cys = 0;
foreach(ContractModel::getAll() 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("2024-05-13 00:00:00");
//$First = new DateTime("2024-06-09 00:00:00");
$Last = new DateTime("2024-06-12 23:59:59");
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()) {
$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::getAll() 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-01"]) 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: $cid\n";