Add ability to update billable rate of existing time entries

This commit is contained in:
Constantin Graf
2024-06-14 16:46:39 +02:00
committed by Gregor Vostrak
parent 7c26cee1ea
commit 2184b3c835
22 changed files with 1001 additions and 25 deletions

View File

@@ -23,6 +23,7 @@ class MemberFactory extends Factory
public function definition(): array
{
return [
'billable_rate' => null,
'role' => Role::Employee,
'organization_id' => Organization::factory(),
'user_id' => User::factory(),
@@ -68,6 +69,20 @@ class MemberFactory extends Factory
});
}
public function billableRate(?int $billableRate): self
{
return $this->state(fn (array $attributes) => [
'billable_rate' => $billableRate,
]);
}
public function withBillableRate(): self
{
return $this->state(fn (array $attributes) => [
'billable_rate' => $this->faker->numberBetween(50, 1000) * 100,
]);
}
public function attachToOrganization(Organization $organization, array $pivot = []): static
{
return $this->afterCreating(function (User $user) use ($organization, $pivot) {

View File

@@ -23,12 +23,26 @@ class OrganizationFactory extends Factory
return [
'name' => $this->faker->unique()->company(),
'currency' => $this->faker->currencyCode(),
'billable_rate' => $this->faker->numberBetween(50, 1000) * 100,
'billable_rate' => null,
'user_id' => User::factory(),
'personal_team' => true,
];
}
public function billableRate(?int $billableRate): self
{
return $this->state(fn (array $attributes) => [
'billable_rate' => $billableRate,
]);
}
public function withBillableRate(): self
{
return $this->state(fn (array $attributes) => [
'billable_rate' => $this->faker->numberBetween(50, 1000) * 100,
]);
}
public function withOwner(?User $owner = null): self
{
return $this->state(fn (array $attributes) => [

View File

@@ -40,9 +40,29 @@ class TimeEntryFactory extends Factory
'task_id' => null,
'project_id' => null,
'organization_id' => Organization::factory(),
'billable_rate' => null,
];
}
public function notBillable(): self
{
return $this->state(function (array $attributes): array {
return [
'billable' => false,
];
});
}
public function billableRate(int $billableRate): self
{
return $this->state(function (array $attributes) use ($billableRate): array {
return [
'billable' => true,
'billable_rate' => $billableRate,
];
});
}
public function withTask(Organization $organization): self
{
return $this->state(function (array $attributes) use (&$organization): array {