HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/Excel/Types/Row/ExpenseRow.php
<?php


namespace App\Komma\Excel\Types\Row;

use App\Komma\Expenses\Expense;
use App\Komma\Subprojects\Subproject;
use App\Komma\Users\User;
use Carbon\Carbon;

class ExpenseRow extends AbstractTypeRow
{

    public string $project;
    public string $subProject;
    public string $type;
    public float $price;
    public float $amount;
    public string $unit;
    public string $description;
    public string $internDescription;
    public Carbon $date;
    public User $user;
    public bool $billable;
    public bool $billed;

    public function __construct(Subproject $subProject, Expense $expense)
    {
        $this->extractAttributesFromSubProject($subProject);
        $this->extractAttributesFromExpense($expense);
    }

    /**
     * Map the direct values of the Subproject
     *
     * @param  Subproject  $subproject
     */
    private function extractAttributesFromSubProject(Subproject $subproject)
    {
        $this->project = $subproject->Project->name;
        $this->subProject = $subproject->name;
    }

    /**
     * Map the direct values of the Expense
     *
     * @param  Expense $expense
     */
    private function extractAttributesFromExpense(Expense $expense)
    {
        $this->type = $expense->ExpenseType->name;
        $this->price = floatval($expense->costs);
        $this->amount = floatval($expense->value);
        $this->unit = $expense->ExpenseType->ExpenseUnit->name;
        $this->description = $expense->description;
        $this->internDescription = $expense->intern_description ?? '';
        $this->date = $expense->date;
        $this->user = $expense->User;
        $this->billed = !empty($expense->billed_at);
        $this->billable = $expense->billable;
    }

    /**
     * Check if row has any styling rules
     *
     * @return bool
     */
    function hasStyling(): bool
    {
        return false;
    }
}