mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-17 12:42:15 +01:00
Added billable flag to projects
This commit is contained in:
committed by
Constantin Graf
parent
20f9b344f6
commit
86555664c5
@@ -85,6 +85,7 @@ class ProjectController extends Controller
|
||||
$project = new Project();
|
||||
$project->name = $request->input('name');
|
||||
$project->color = $request->input('color');
|
||||
$project->is_billable = (bool) $request->input('is_billable');
|
||||
$project->billable_rate = $request->input('billable_rate');
|
||||
$project->client_id = $request->input('client_id');
|
||||
$project->organization()->associate($organization);
|
||||
@@ -105,6 +106,7 @@ class ProjectController extends Controller
|
||||
$this->checkPermission($organization, 'projects:update', $project);
|
||||
$project->name = $request->input('name');
|
||||
$project->color = $request->input('color');
|
||||
$project->is_billable = (bool) $request->input('is_billable');
|
||||
$project->billable_rate = $request->input('billable_rate');
|
||||
$project->client_id = $request->input('client_id');
|
||||
$project->save();
|
||||
|
||||
@@ -38,6 +38,10 @@ class ProjectStoreRequest extends FormRequest
|
||||
'max:255',
|
||||
new ColorRule(),
|
||||
],
|
||||
'is_billable' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'billable_rate' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
|
||||
@@ -37,6 +37,10 @@ class ProjectUpdateRequest extends FormRequest
|
||||
'max:255',
|
||||
new ColorRule(),
|
||||
],
|
||||
'is_billable' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'billable_rate' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
|
||||
@@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
* @property string $organization_id
|
||||
* @property string $client_id
|
||||
* @property int|null $billable_rate
|
||||
* @property bool $is_billable
|
||||
* @property-read Organization $organization
|
||||
* @property-read Client|null $client
|
||||
* @property-read Collection<int, Task> $tasks
|
||||
@@ -43,6 +44,15 @@ class Project extends Model
|
||||
'color' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Set default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
'is_billable' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Organization, Project>
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,7 @@ class ClockifyProjectsImporter extends DefaultImporter
|
||||
], [
|
||||
'client_id' => $clientId,
|
||||
'color' => $this->colorService->getRandomColor(),
|
||||
'is_billable' => $record['Billability'] === 'Yes',
|
||||
'billable_rate' => $billableRateKey !== null && $record[$billableRateKey] !== '' ? (int) (((float) $record[$billableRateKey]) * 100) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ abstract class DefaultImporter implements ImporterContract
|
||||
'required',
|
||||
'max:255',
|
||||
],
|
||||
'is_billable' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'billable_rate' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
|
||||
@@ -121,6 +121,7 @@ class TogglDataImporter extends DefaultImporter
|
||||
], [
|
||||
'client_id' => $clientId,
|
||||
'color' => $project->color,
|
||||
'is_billable' => $project->rate !== null,
|
||||
'billable_rate' => $project->rate !== null ? (int) ($project->rate * 100) : null,
|
||||
], (string) $project->id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user