Exemplo n.º 1
0
 /**
  * Store a new job costing design
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(Request $request)
 {
     $this->authorize('edit_job_costings');
     $this->validate($request, ['jc_customer_id_fk' => 'required|exists:customer,customer_id', 'jc_design_name' => 'required|unique:job_costing', 'jc_reference' => 'string|max:255']);
     $jobcosting = JobCosting::create($request->all());
     flash()->success('Job Costing Saved', 'New job costing design has been added.');
     return redirect()->away('http://mis2.mtech.local/jobcostings/' . $jobcosting->job_costing_id);
 }
Exemplo n.º 2
0
 /**
  * Overwrite the parent boot method
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     JobCosting::creating(function ($jobCosting) {
         $jobCosting->jc_user_added_id_fk = \Auth::user()->id;
         $jobCosting->jc_user_modified_id_fk = \Auth::user()->id;
     });
     JobCosting::updating(function ($jobCosting) {
         $jobCosting->jc_user_modified_id_fk = \Auth::user()->id;
     });
 }
 /**
  * @test
  */
 public function expected_meters_kg_works()
 {
     $jobCosting = JobCosting::find(4524);
     $this->assertInstanceOf(JobCosting::class, $jobCosting, "JobCosting Model");
     $calculator = new ExpectedWasteCalculator($jobCosting);
     $expectedMeters = $calculator->expectedPressWasteMeters(1000);
     $expectedKg = $calculator->expectedPressWasteKg(1000);
     $manualMeters = $jobCosting->colourSpec->colour_first_roll_waste_m + 1000 / $jobCosting->grams_per_meter * $jobCosting->colourSpec->colour_waste_per_1000_m;
     $manualKg = $manualMeters * $jobCosting->grams_per_meter / 1000;
     $this->assertEquals($manualMeters, $expectedMeters, "Expected Meters");
     $this->assertEquals($manualKg, $expectedKg, "Expected Kgs");
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $jobCosting = JobCosting::find($this->get('job_cards_jc_id_fk'));
     $lowestMoq = $jobCosting ? $jobCosting->lowest_moq : 0;
     return ['job_cards_jc_id_fk' => 'required|exists:job_costing,job_costing_id', 'job_cards_order_no' => 'string', 'job_cards_order_qty' => 'required|numeric|min:' . $lowestMoq, 'job_cards_job_status_id_fk' => 'required|exists:job_status,job_status_id', 'job_cards_cust_req_date' => 'date', 'job_cards_orig_oc_date' => 'date', 'job_cards_notes' => 'string|max:255', 'job_cards_delivery_notes' => 'string|max:255', 'job_cards_customer_notes' => 'string|max:255', 'job_cards_no_waste' => 'required|boolean'];
 }
Exemplo n.º 5
0
 /**
  * Create new job view
  */
 public function create()
 {
     $this->authorize('edit_buffer');
     return view('production.buffer.create')->with(['designs' => JobCosting::listIDAndDesignGroupedByCustomer(), 'status_list' => JobStatus::all()->pluck('job_status_description', 'job_status_id')]);
 }
Exemplo n.º 6
0
 /**
  * @test
  */
 public function core_weight()
 {
     $jobCosting = JobCosting::find(4524);
     $this->assertInstanceOf(JobCosting::class, $jobCosting, "JobCosting Model");
     $coreWeight = $jobCosting->core_weight;
     $trim_waste_cost_check = ($jobCosting->core->core_in_diameter_mm + $jobCosting->core->core_thickness_mm) * $jobCosting->core->core_thickness_mm * 2.45 * ($jobCosting->jc_slit_width_mm - 2) / 1000000;
     $this->assertEquals($trim_waste_cost_check, $coreWeight, "Core Weight");
     $this->assertInternalType('float', $coreWeight, "Weight is FLoat");
 }