add billable rate restriction for free organizations

This commit is contained in:
Gregor Vostrak
2026-10-13 14:59:12 +02:00
committed by Constantin Graf
parent deb0c26e32
commit 5a9c8a8bf7
55 changed files with 1207 additions and 103 deletions

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import UpgradeLockedBadge from '@/packages/ui/src/UpgradeLockedBadge.vue';
import { canUseBillableRates } from '@/utils/billing';
import MainContainer from '@/packages/ui/src/MainContainer.vue';
import AppLayout from '@/Layouts/AppLayout.vue';
import { FolderIcon, PlusIcon } from '@heroicons/vue/20/solid';
@@ -80,6 +82,9 @@ const shownTasks = computed(() => {
return task.project_id === projectId && task.is_done;
});
});
// Note: The page sits above the app layout that provides the lock, so it can not inject it
const billableRatesLocked = computed(() => !canUseBillableRates());
</script>
<template>
@@ -117,11 +122,17 @@ const shownTasks = computed(() => {
</li>
</ol>
<div class="px-4 space-x-1">
<Badge v-if="project?.billable_rate">
<UpgradeLockedBadge v-if="billableRatesLocked"
>Billable Rates</UpgradeLockedBadge
>
<Badge v-else-if="project?.billable_rate">
{{ billableRateFormatted }}
/ h
</Badge>
<Badge v-if="project?.is_billable && !project?.billable_rate">
<Badge
v-if="
project?.is_billable && !project?.billable_rate && !billableRatesLocked
">
Default Rate
</Badge>
<Badge v-if="!project?.is_billable"> Non-Billable </Badge>

View File

@@ -10,10 +10,12 @@ import { storeToRefs } from 'pinia';
import OrganizationBillableRateModal from '@/Components/Common/Organization/OrganizationBillableRateModal.vue';
import { getOrganizationCurrencyString } from '@/utils/money';
import { Checkbox } from '@/packages/ui/src';
import { useBillableRatesLock } from '@/packages/ui/src/utils/useBillableRatesLock';
const store = useOrganizationStore();
const { fetchOrganization, updateOrganization } = store;
const { organization } = storeToRefs(store);
const { locked: billableRatesLocked, requestUpgrade } = useBillableRatesLock();
const saving = ref(false);
const organizationBody = ref<UpdateOrganizationBody>({
name: '',
@@ -75,9 +77,8 @@ function checkForConfirmationModal() {
<Checkbox
v-if="organization"
id="organizationShowBillableRatesToEmployees"
v-model:checked="
organizationBody.employees_can_see_billable_rates
"></Checkbox>
v-model:checked="organizationBody.employees_can_see_billable_rates"
:disabled="billableRatesLocked"></Checkbox>
<FieldLabel for="organizationShowBillableRatesToEmployees"
>Show Billable Rates to Employees</FieldLabel
>
@@ -85,7 +86,10 @@ function checkForConfirmationModal() {
</div>
</template>
<template #actions>
<PrimaryButton @click="checkForConfirmationModal">Save</PrimaryButton>
<PrimaryButton v-if="billableRatesLocked" @click="requestUpgrade"
>Upgrade</PrimaryButton
>
<PrimaryButton v-else @click="checkForConfirmationModal">Save</PrimaryButton>
</template>
</FormSection>
</template>