/**
  * @test
  */
 public function actual_gp()
 {
     $currentMonthDespatch = DespatchLogEntry::currentMonth()->get();
     $gpCalculator = new GpIndicatorsCalculator();
     $this->assertInstanceOf(GpIndicatorsCalculator::class, $gpCalculator, "GP Calculator Object");
     $globalTarget = GlobalVariable::first()->monthly_gp_target;
     $gpTarget = $gpCalculator->target();
     $actualGpCalc = 0;
     $actualTurnOverCalc = 0;
     foreach ($currentMonthDespatch as $entry) {
         $this->assertInstanceOf(DespatchLogEntry::class, $entry);
         $actualGpCalc += $entry->gp_contribution;
         $this->assertInternalType('float', $entry->gp_contribution);
         $actualTurnOverCalc += $entry->selling_price * $entry->net_weight;
         $this->assertInternalType('float', $entry->selling_price);
     }
     $this->assertEquals(round($actualGpCalc), $gpCalculator->monthActualGp(), "Current Month Actual");
     $this->assertEquals(round($actualTurnOverCalc), $gpCalculator->monthActualTurnOver(), "Current Month Actual Turn Over");
     $this->assertEquals(round($actualGpCalc / $gpTarget * 100), round($gpCalculator->monthActualPercentage()), "Current Month Actual Percentage");
     $this->assertEquals(round($actualGpCalc / $globalTarget * 100), round($gpCalculator->monthProductionAchievedPercentage()), "Current Month Production Target Percentage");
 }
Beispiel #2
0
 /**
  * Get the the job's expected gross profit contribution percentage
  *
  * @return string
  */
 public function getActualGpContributionPercentageAttribute()
 {
     $globalVariables = GlobalVariable::first();
     return $this->actual_gp_contribution / $globalVariables->monthly_gp_target * 100;
 }
Beispiel #3
0
 /**
  * Get the the job costing spec's grams per meter based on dry gsm
  *
  * @return int
  */
 public function getPressSetupThroughputLostAttribute()
 {
     $globalVariable = GlobalVariable::first();
     return $this->press_setup_minutes * $globalVariable->overhead_per_minute;
 }
 /**
  * GpIndicatorsCalculator constructor.
  */
 public function __construct($date = null)
 {
     $this->date = is_a($date, 'Carbon\\Carbon') ? $date : Carbon::now();
     $this->gpTarget = GlobalVariable::first()->monthly_gp_target;
 }
 /**
  * @test
  */
 public function press_setup_calculation()
 {
     $globalVariable = GlobalVariable::first();
     $jobCosting = JobCosting::find(36);
     $this->assertInstanceOf(JobCosting::class, $jobCosting, "JobCosting Model");
     $colourSpec = $jobCosting->colourSpec;
     $this->assertInstanceOf(ColourSpec::class, $colourSpec, "ColourSpec Model");
     $pressSetupMinutes = $colourSpec->colour_setup_per_colour * $colourSpec->colour_number_colours;
     $this->assertInternalType('int', $pressSetupMinutes);
     $pressSetupThroughputLost = $pressSetupMinutes * $globalVariable->overhead_per_minute;
     $this->assertInternalType('float', $pressSetupThroughputLost);
     $this->assertEquals($pressSetupMinutes, $jobCosting->press_setup_minutes, "Press Setup Minutes");
     $this->assertEquals($pressSetupThroughputLost, $jobCosting->press_setup_throughput_lost, "Press Setup Throughput Lost");
 }
Beispiel #6
0
 /**
  * @test
  */
 public function department_should_return_global_constraint_department()
 {
     $constraint = new Constraint();
     $this->global = \App\Models\GlobalVariable::first();
     $this->assertEquals($this->global->constraint->name, $constraint->department->name, 'Constraint Department');
 }
Beispiel #7
0
 /**
  * Constraint constructor.
  */
 function __construct()
 {
     $this->data['department'] = GlobalVariable::first()->constraint;
 }