add: more tests
This commit is contained in:
parent
ce7f620984
commit
fcd76cf130
11 changed files with 232 additions and 15 deletions
|
@ -34,10 +34,9 @@ class CsvAgentCost
|
|||
|
||||
function calculate_agents_cost(array $array, array $agents_time, float $minute_cost)
|
||||
{
|
||||
$minute_cost = utils::round_up_to_two_decimals($minute_cost);
|
||||
foreach ($agents_time as $name => $agent_time) {
|
||||
//Identify agents involved in the issue
|
||||
$agent_cost = utils::round_up_to_two_decimals($agent_time / 60 * $minute_cost);
|
||||
$agent_cost = utils::round_up_to_two_decimals($agent_time * $minute_cost / 60);
|
||||
$array[$name] = gmdate('H:i:s', $agent_time);
|
||||
$array[$name . ' costo'] = $agent_cost;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@ namespace App\Http\Controllers\CsvController\CsvCostCalc;
|
|||
|
||||
class CsvCostCalc
|
||||
{
|
||||
/**
|
||||
* @var CsvMinuteCostCalc|(CsvMinuteCostCalc&object&\PHPUnit\Framework\MockObject\MockObject)|(CsvMinuteCostCalc&\PHPUnit\Framework\MockObject\MockObject)|(object&\PHPUnit\Framework\MockObject\MockObject)|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->internal_percentage_to_deduct = getenv('PRICE_INTERNAL_PERCENTAGE_TO_DEDUCT');
|
||||
|
|
|
@ -28,7 +28,7 @@ class CsvMinuteCostCalc
|
|||
|
||||
private function calculate_minute_cost(int $hourly_cost)
|
||||
{
|
||||
return utils::round_up_to_two_decimals($hourly_cost / 60);
|
||||
return $hourly_cost / 60;
|
||||
}
|
||||
|
||||
private function extract_string_from_label($label)
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CsvController\CsvCostCalc;
|
||||
use function Utils\round_up_to_two_decimals;
|
||||
use App\Utils\utils;
|
||||
|
||||
class CsvTotalCostCalc
|
||||
{
|
||||
private $CsvMinuteCostCalc;
|
||||
public function __construct()
|
||||
{
|
||||
$this->CsvMinuteCostCalc = new CsvMinuteCostCalc();
|
||||
|
@ -15,7 +14,7 @@ class CsvTotalCostCalc
|
|||
function total_time_cost(array $array, int $total_time)
|
||||
{
|
||||
$minute_cost = $this->CsvMinuteCostCalc->select_correct_cost($array['Request By'], $array['Priority']);
|
||||
$total_cost = round_up_to_two_decimals($total_time / 60 * $minute_cost);
|
||||
$total_cost = utils::round_up_to_two_decimals($total_time * ($minute_cost / 60));
|
||||
$array['Tempo totale'] = gmdate('H:i:s', $total_time);
|
||||
$array['Costo totale'] = $total_cost;
|
||||
return $array;
|
||||
|
|
|
@ -15,7 +15,7 @@ class CsvDataHandling
|
|||
$this->csv_cost_calc = new CsvCostCalc();
|
||||
}
|
||||
|
||||
private function handle_agent_issue($agents_issue_time, $time)
|
||||
function handle_agent_issue($agents_issue_time, $time)
|
||||
{
|
||||
$time_agent = $time['user_name'];
|
||||
!array_key_exists($time_agent, $agents_issue_time) && $agents_issue_time[$time_agent] = 0;
|
||||
|
@ -23,7 +23,7 @@ class CsvDataHandling
|
|||
return $agents_issue_time;
|
||||
}
|
||||
|
||||
private function get_issue_total_time(array $issue_time)
|
||||
function get_issue_total_time(array $issue_time)
|
||||
{
|
||||
$total_issue_time = 0;
|
||||
$agents_issue_time = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue